// File: /workspace/github_c_makefile_star2_O0/ughman[P]c2c/src/emu.c
// Function: EMU_Invoke
uint32_t EMU_Invoke(uint32_t address,int argc,...)
{
	va_list args;
	uint32_t ra_saved = RA;
	uint32_t pc;
	SP -= argc * 4;
	va_start(args,argc);
	for (int i = 0;i < argc;i++)
	{
		if (i == 0)
			A0 = va_arg(args,uint32_t);
		else if (i == 1)
			A1 = va_arg(args,uint32_t);
		else if (i == 2)
			A2 = va_arg(args,uint32_t);
		else if (i == 3)
			A3 = va_arg(args,uint32_t);
		else
			EMU_Write32(SP + i * 4,va_arg(args,uint32_t));
	}
	va_end(args);
	RA = 0xDEADBEEF;
	pc = address;
	while (pc != 0xDEADBEEF)
	{
		if (pc & 3)
			SDL_LogError(LOG_EMU,"Program counter is unaligned");
		pc = EMU_codemap[(pc & 0x1FFFFF) >> 2](pc);
	}
	SP += argc * 4;
	RA = ra_saved;
	return V0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x160, %rsp            # imm = 0x160
testb %al, %al
je 0x31db08
movaps %xmm0, -0xb0(%rbp)
movaps %xmm1, -0xa0(%rbp)
movaps %xmm2, -0x90(%rbp)
movaps %xmm3, -0x80(%rbp)
movaps %xmm4, -0x70(%rbp)
movaps %xmm5, -0x60(%rbp)
movaps %xmm6, -0x50(%rbp)
movaps %xmm7, -0x40(%rbp)
movq %r9, -0xb8(%rbp)
movq %r8, -0xc0(%rbp)
movq %rcx, -0xc8(%rbp)
movq %rdx, -0xd0(%rbp)
movl %edi, -0x4(%rbp)
movl %esi, -0x8(%rbp)
movq 0x8e9f(%rip), %rax      # 0x3269d0
movl 0x7c(%rax), %eax
movl %eax, -0x24(%rbp)
movl -0x8(%rbp), %edx
shll $0x2, %edx
movq 0x8e8c(%rip), %rax      # 0x3269d0
movl 0x74(%rax), %ecx
subl %edx, %ecx
movl %ecx, 0x74(%rax)
leaq -0x20(%rbp), %rax
leaq -0xe0(%rbp), %rcx
movq %rcx, 0x10(%rax)
leaq 0x10(%rbp), %rcx
movq %rcx, 0x8(%rax)
movl $0x30, 0x4(%rax)
movl $0x10, (%rax)
movl $0x0, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
cmpl -0x8(%rbp), %eax
jge 0x31ddf5
cmpl $0x0, -0x2c(%rbp)
jne 0x31dbf9
leaq -0x20(%rbp), %rax
movq %rax, -0xf0(%rbp)
movl -0x20(%rbp), %eax
movl %eax, -0xe4(%rbp)
cmpl $0x28, %eax
ja 0x31dbc4
movq -0xf0(%rbp), %rcx
movl -0xe4(%rbp), %edx
movslq %edx, %rax
addq 0x10(%rcx), %rax
addl $0x8, %edx
movl %edx, (%rcx)
movq %rax, -0xf8(%rbp)
jmp 0x31dbe1
movq -0xf0(%rbp), %rcx
movq 0x8(%rcx), %rax
movq %rax, %rdx
addq $0x8, %rdx
movq %rdx, 0x8(%rcx)
movq %rax, -0xf8(%rbp)
movq -0xf8(%rbp), %rax
movl (%rax), %ecx
movq 0x8ddf(%rip), %rax      # 0x3269d0
movl %ecx, 0x10(%rax)
jmp 0x31dde5
cmpl $0x1, -0x2c(%rbp)
jne 0x31dc6f
leaq -0x20(%rbp), %rax
movq %rax, -0x108(%rbp)
movl -0x20(%rbp), %eax
movl %eax, -0xfc(%rbp)
cmpl $0x28, %eax
ja 0x31dc3a
movq -0x108(%rbp), %rcx
movl -0xfc(%rbp), %edx
movslq %edx, %rax
addq 0x10(%rcx), %rax
addl $0x8, %edx
movl %edx, (%rcx)
movq %rax, -0x110(%rbp)
jmp 0x31dc57
movq -0x108(%rbp), %rcx
movq 0x8(%rcx), %rax
movq %rax, %rdx
addq $0x8, %rdx
movq %rdx, 0x8(%rcx)
movq %rax, -0x110(%rbp)
movq -0x110(%rbp), %rax
movl (%rax), %ecx
movq 0x8d69(%rip), %rax      # 0x3269d0
movl %ecx, 0x14(%rax)
jmp 0x31dde3
cmpl $0x2, -0x2c(%rbp)
jne 0x31dce5
leaq -0x20(%rbp), %rax
movq %rax, -0x120(%rbp)
movl -0x20(%rbp), %eax
movl %eax, -0x114(%rbp)
cmpl $0x28, %eax
ja 0x31dcb0
movq -0x120(%rbp), %rcx
movl -0x114(%rbp), %edx
movslq %edx, %rax
addq 0x10(%rcx), %rax
addl $0x8, %edx
movl %edx, (%rcx)
movq %rax, -0x128(%rbp)
jmp 0x31dccd
movq -0x120(%rbp), %rcx
movq 0x8(%rcx), %rax
movq %rax, %rdx
addq $0x8, %rdx
movq %rdx, 0x8(%rcx)
movq %rax, -0x128(%rbp)
movq -0x128(%rbp), %rax
movl (%rax), %ecx
movq 0x8cf3(%rip), %rax      # 0x3269d0
movl %ecx, 0x18(%rax)
jmp 0x31dde1
cmpl $0x3, -0x2c(%rbp)
jne 0x31dd5b
leaq -0x20(%rbp), %rax
movq %rax, -0x138(%rbp)
movl -0x20(%rbp), %eax
movl %eax, -0x12c(%rbp)
cmpl $0x28, %eax
ja 0x31dd26
movq -0x138(%rbp), %rcx
movl -0x12c(%rbp), %edx
movslq %edx, %rax
addq 0x10(%rcx), %rax
addl $0x8, %edx
movl %edx, (%rcx)
movq %rax, -0x140(%rbp)
jmp 0x31dd43
movq -0x138(%rbp), %rcx
movq 0x8(%rcx), %rax
movq %rax, %rdx
addq $0x8, %rdx
movq %rdx, 0x8(%rcx)
movq %rax, -0x140(%rbp)
movq -0x140(%rbp), %rax
movl (%rax), %ecx
movq 0x8c7d(%rip), %rax      # 0x3269d0
movl %ecx, 0x1c(%rax)
jmp 0x31dddf
movq 0x8c6e(%rip), %rax      # 0x3269d0
movl 0x74(%rax), %eax
movl -0x2c(%rbp), %ecx
shll $0x2, %ecx
addl %ecx, %eax
movl %eax, -0x154(%rbp)
leaq -0x20(%rbp), %rax
movq %rax, -0x150(%rbp)
movl -0x20(%rbp), %eax
movl %eax, -0x144(%rbp)
cmpl $0x28, %eax
ja 0x31ddae
movq -0x150(%rbp), %rcx
movl -0x144(%rbp), %edx
movslq %edx, %rax
addq 0x10(%rcx), %rax
addl $0x8, %edx
movl %edx, (%rcx)
movq %rax, -0x160(%rbp)
jmp 0x31ddcb
movq -0x150(%rbp), %rcx
movq 0x8(%rcx), %rax
movq %rax, %rdx
addq $0x8, %rdx
movq %rdx, 0x8(%rcx)
movq %rax, -0x160(%rbp)
movl -0x154(%rbp), %edi
movq -0x160(%rbp), %rax
movl (%rax), %esi
callq 0x31d3f0
jmp 0x31dde1
jmp 0x31dde3
jmp 0x31dde5
jmp 0x31dde7
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x31db77
leaq -0x20(%rbp), %rax
movq 0x8bd0(%rip), %rax      # 0x3269d0
movl $0xdeadbeef, 0x7c(%rax) # imm = 0xDEADBEEF
movl -0x4(%rbp), %eax
movl %eax, -0x28(%rbp)
cmpl $0xdeadbeef, -0x28(%rbp) # imm = 0xDEADBEEF
je 0x31de58
movl -0x28(%rbp), %eax
andl $0x3, %eax
cmpl $0x0, %eax
je 0x31de34
movl $0x13, %edi
leaq 0x49bf(%rip), %rsi      # 0x3227ec
movb $0x0, %al
callq 0x10d0
movl -0x28(%rbp), %eax
andl $0x1fffff, %eax         # imm = 0x1FFFFF
shrl $0x2, %eax
movl %eax, %eax
movl %eax, %ecx
leaq 0x8b96(%rip), %rax      # 0x3269e0
movq (%rax,%rcx,8), %rax
movl -0x28(%rbp), %edi
callq *%rax
movl %eax, -0x28(%rbp)
jmp 0x31de0d
movl -0x8(%rbp), %ecx
movq 0x8b6e(%rip), %rax      # 0x3269d0
movl 0x74(%rax), %esi
movl %ecx, %edx
movl %esi, %ecx
leal (%rcx,%rdx,4), %ecx
movl %ecx, 0x74(%rax)
movl -0x24(%rbp), %ecx
movq 0x8b57(%rip), %rax      # 0x3269d0
movl %ecx, 0x7c(%rax)
movq 0x8b4d(%rip), %rax      # 0x3269d0
movl 0x8(%rax), %eax
addq $0x160, %rsp            # imm = 0x160
popq %rbp
retq
nop