let rec reduce_gdecl ~env decl =
  match decl with
    CTTdeclFunction(gsclass, typ, ident, argnames, body) ->
      let acc = ref [] in
      let b = CTTdeclFunction(gsclass, typ, ident, argnames, reduce_stmt ~acc body) in
      let a = List.rev (!acc) in
      acc := [];
      let additional_decls = List.map
          (fun (typ,id,init) -> CTTdeclVariable(ModuleStatic,typ,id,init)) !acc in
      List.iter
        (fun (typ,id,_) ->
          ignore
            (C_typing.add_global_binding_to_env
               ~env
               id
               ModuleStatic
               ~is_tentative:false
               (Var typ))) a;
      (additional_decls @ [b])
  | CTTdeclVariable(gsclass, typ, ident, initopt) ->
      [decl]