+ int sarg_ofs = 1; // stack offset to args, in DWORDs
+ int saved_regs = 0;
+ int c_is_stdcall;
+ int argc_repush;
+ int stack_args;
+ int ret64;
+ int i;
+
+ argc_repush = pp->argc;
+ stack_args = pp->argc_stack;
+ if (pp->is_vararg) {
+ argc_repush = ARRAY_SIZE(pp->arg); // hopefully enough?
+ stack_args = argc_repush - pp->argc_reg;
+ }
+
+ ret64 = strstr(pp->ret_type.name, "int64") != NULL;
+
+ fprintf(f, "# %s",
+ pp->is_fastcall ? "__fastcall" :
+ (pp->is_stdcall ? "__stdcall" : "__cdecl"));
+ if (ret64)
+ fprintf(f, " ret64");
+ fprintf(f, "\n.global %s\n", sym);
+ fprintf(f, "%s:\n", sym);
+
+ if ((pp->argc_reg == 0 || pp->is_fastcall)
+ && !IS(pp->name, "storm_491")) // wants edx save :(
+ {
+ fprintf(f, "\tjmp %s%s",
+ pp->is_fastcall ? "@" : "_", sym);
+ if (pp->is_stdcall)
+ fprintf(f, "@%d", pp->argc * 4);
+ fprintf(f, "\n\n");
+ return;
+ }
+
+ c_is_stdcall = (pp->argc_reg == 0 && pp->is_stdcall);
+
+ // at least sc sub_47B150 needs edx to be preserved
+ // int64 returns use edx:eax - no edx save
+ // we use ecx also as scratch
+ fprintf(f, "\tpushl %%ecx\n");
+ saved_regs++;
+ sarg_ofs++;
+ if (!ret64) {
+ fprintf(f, "\tpushl %%edx\n");
+ saved_regs++;
+ sarg_ofs++;
+ }