Question: Procedure returns an uninitiated local variables - what happens?

Look at the following Maple code and output, from Maple 2020. Can you explain the results? I know returning an uninitiated local variable is bad practice, but I cannot make sense of what happens when I do it anyway (just to understand the internals of the Maple language). Should I simply consider the results as undefined behavior?

> f:=proc()                                                                    
>     local x;                                                                 
>     return x;                                                                
> end proc:                                     

> a1 := f() + f();                                                             
                                   a1 := 2 x

> a2 := f() - f();                                                             
                                  a2 := x - x

> a1 + a2;                                                                       
                                  2 x + x - x

> a3 := f() + f() + f();                                                       
                                   a3 := 3 x

> a4 := f() + f() + f() - f();                                                 
                                 a4 := 3 x - x

Please Wait...