// File: /workspace/github_c_makefile_star2_O0/ughman[P]c2c/src/emu.c
// Function: EMU_Write8
void EMU_Write8(uint32_t address,uint8_t value)
{
	if (address >= 0x80000000 && address <= 0x801FFFFF)
	{
normal:
		{
			uint32_t (*codehandler)(uint32_t) = EMU_codemap[(address & 0x1FFFFF) >> 2];
			if (codehandler != EMU_ExecuteUnrecognizedCode)
			{
				SDL_LogError(LOG_EMU,"Writing over code");
			}
		}
		uint32_t *word = &EMU_ram[(address & 0x1FFFFF) >> 2];
		*word &= ~(0xFF << (address & 3) * 8);
		*word |= value << (address & 3) * 8;
	}
	else if (address >= 0x0 && address <= 0x1FFFFF)
	{
		goto normal;
	}
	else if (address >= 0xA0000000 && address <= 0xA01FFFFF)
	{
		goto normal;
	}
	else if (address >= 0x1F800000 && address <= 0x1F8003FF)
	{
		uint32_t *word = &EMU_scratch[(address & 0x3FF) >> 2];
		*word &= ~(0xFF << (address & 3) * 8);
		*word |= value << (address & 3) * 8;
	}
	else switch (address)
	{
	case 0x1F801040:
		PAD_Write(value);
		break;
	case 0x1F801800:
		CDR_SetMode(value);
		break;
	case 0x1F801801:
		CDR_Write1(value);
		break;
	case 0x1F801802:
		CDR_Write2(value);
		break;
	case 0x1F801803:
		CDR_Write3(value);
		break;
	default:
		SDL_LogError(LOG_EMU,"Unrecognized 8-bit write address %.8X",address);
		PCSX_Write8(address,value);
		break;
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movb %sil, %al
movl %edi, -0x4(%rbp)
movb %al, -0x5(%rbp)
cmpl $0x80000000, -0x4(%rbp) # imm = 0x80000000
jb 0x31be86
cmpl $0x801fffff, -0x4(%rbp) # imm = 0x801FFFFF
ja 0x31be86
jmp 0x31bded
movl -0x4(%rbp), %eax
andl $0x1fffff, %eax         # imm = 0x1FFFFF
shrl $0x2, %eax
movl %eax, %eax
movl %eax, %ecx
leaq 0xabdd(%rip), %rax      # 0x3269e0
movq (%rax,%rcx,8), %rax
movq %rax, -0x10(%rbp)
leaq -0x17a2(%rip), %rax     # 0x31a670
cmpq %rax, -0x10(%rbp)
je 0x31be2b
movl $0x13, %edi
leaq 0x6914(%rip), %rsi      # 0x322738
movb $0x0, %al
callq 0x10d0
movq 0x40abae(%rip), %rax    # 0x7269e0
movl -0x4(%rbp), %ecx
andl $0x1fffff, %ecx         # imm = 0x1FFFFF
shrl $0x2, %ecx
movl %ecx, %ecx
shlq $0x2, %rcx
addq %rcx, %rax
movq %rax, -0x18(%rbp)
movl -0x4(%rbp), %ecx
andl $0x3, %ecx
shll $0x3, %ecx
movl $0xff, %eax
shll %cl, %eax
movl %eax, %ecx
xorl $-0x1, %ecx
movq -0x18(%rbp), %rax
andl (%rax), %ecx
movl %ecx, (%rax)
movzbl -0x5(%rbp), %eax
movl -0x4(%rbp), %ecx
andl $0x3, %ecx
shll $0x3, %ecx
shll %cl, %eax
movl %eax, %ecx
movq -0x18(%rbp), %rax
orl (%rax), %ecx
movl %ecx, (%rax)
jmp 0x31bfc5
cmpl $0x0, -0x4(%rbp)
jb 0x31be9a
cmpl $0x1fffff, -0x4(%rbp)   # imm = 0x1FFFFF
ja 0x31be9a
jmp 0x31bded
cmpl $0xa0000000, -0x4(%rbp) # imm = 0xA0000000
jb 0x31beb1
cmpl $0xa01fffff, -0x4(%rbp) # imm = 0xA01FFFFF
ja 0x31beb1
jmp 0x31bded
cmpl $0x1f800000, -0x4(%rbp) # imm = 0x1F800000
jb 0x31bf1e
cmpl $0x1f8003ff, -0x4(%rbp) # imm = 0x1F8003FF
ja 0x31bf1e
movq 0x40ab1e(%rip), %rax    # 0x7269e8
movl -0x4(%rbp), %ecx
andl $0x3ff, %ecx            # imm = 0x3FF
shrl $0x2, %ecx
movl %ecx, %ecx
shlq $0x2, %rcx
addq %rcx, %rax
movq %rax, -0x20(%rbp)
movl -0x4(%rbp), %ecx
andl $0x3, %ecx
shll $0x3, %ecx
movl $0xff, %eax
shll %cl, %eax
movl %eax, %ecx
xorl $-0x1, %ecx
movq -0x20(%rbp), %rax
andl (%rax), %ecx
movl %ecx, (%rax)
movzbl -0x5(%rbp), %eax
movl -0x4(%rbp), %ecx
andl $0x3, %ecx
shll $0x3, %ecx
shll %cl, %eax
movl %eax, %ecx
movq -0x20(%rbp), %rax
orl (%rax), %ecx
movl %ecx, (%rax)
jmp 0x31bfbf
movl -0x4(%rbp), %eax
movl %eax, -0x24(%rbp)
subl $0x1f801040, %eax       # imm = 0x1F801040
je 0x31bf5d
jmp 0x31bf2d
movl -0x24(%rbp), %eax
subl $0x1f801800, %eax       # imm = 0x1F801800
je 0x31bf68
jmp 0x31bf39
movl -0x24(%rbp), %eax
subl $0x1f801801, %eax       # imm = 0x1F801801
je 0x31bf73
jmp 0x31bf45
movl -0x24(%rbp), %eax
subl $0x1f801802, %eax       # imm = 0x1F801802
je 0x31bf7e
jmp 0x31bf51
movl -0x24(%rbp), %eax
subl $0x1f801803, %eax       # imm = 0x1F801803
je 0x31bf89
jmp 0x31bf94
movzbl -0x5(%rbp), %edi
callq 0x1230
jmp 0x31bfbd
movzbl -0x5(%rbp), %edi
callq 0x12d0
jmp 0x31bfbd
movzbl -0x5(%rbp), %edi
callq 0x1360
jmp 0x31bfbd
movzbl -0x5(%rbp), %edi
callq 0x1390
jmp 0x31bfbd
movzbl -0x5(%rbp), %edi
callq 0x13c0
jmp 0x31bfbd
movl -0x4(%rbp), %edx
movl $0x13, %edi
leaq 0x67a7(%rip), %rsi      # 0x32274a
movb $0x0, %al
callq 0x10d0
leaq 0xa967(%rip), %rax      # 0x326918
movq (%rax), %rax
movl -0x4(%rbp), %edi
movzbl -0x5(%rbp), %esi
callq *%rax
jmp 0x31bfbf
jmp 0x31bfc1
jmp 0x31bfc3
jmp 0x31bfc5
addq $0x30, %rsp
popq %rbp
retq
nopl (%rax,%rax)