I thought after the function call of gen_aux before the loop, the static call on the type for r should have make it declared. but why not?
how static really works? this is what it's explained in the books:-
static type variable;
For local declarations, declares variable with static storage class. The value of variable persists across executions of this scope and is guaranteed to be initialized before the variable is used for the first time. When the program exits from the scope, the variable keeps its value until the next time the program enters that scope. We'll see in ยง13.4/244 that the meaning of static varies with context.