The main result of the present paper is about the solutions of the functional equation F ( x + y 2) + f 1 (x) + f 2 (y) = G (g 1 (x) + g 2 (y)) , x , y ∈ I , derived originally, in a natural way, from the invariance problem of generalized weighted quasi-arithmetic means, where F , f 1 , f 2 , g 1 , g 2 : I → R and G : g 1 (I) + g 2 (I) → R are the unknown functions assumed to be continuously differentiable with 0 ∉ g 1 ′ (I) ∪ g 2 ′ (I) , and the set I stands for a nonempty open subinterval of R . In addition to these, we will also touch upon solutions not necessarily regular. More precisely, we are going to solve the above equation assuming first that F is affine on I and g 1 and g 2 are continuous functions strictly monotone in the same sense, and secondly that g 1 and g 2 are invertible affine functions with a common additive part. [ABSTRACT FROM AUTHOR]