// File: /workspace/github_c_makefile_star2_O0/ughman[P]c2c/src/emu.c
// Function: EMU_ReadU8
uint8_t EMU_ReadU8(uint32_t address)
{
	if (address >= 0x80000000 && address <= 0x801FFFFF)
	{
normal:
		{
			uint32_t (*codehandler)(uint32_t) = EMU_codemap[(address & 0x1FFFFF) >> 2];
			if (codehandler != EMU_ExecuteUnrecognizedCode)
			{
				SDL_LogError(LOG_EMU,"Reading code as data");
			}
		}
		return EMU_ram[(address & 0x1FFFFF) >> 2] >> (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)
	{
		return EMU_scratch[(address & 0x3FF) >> 2] >> (address & 3) * 8;
	}
	else switch (address)
	{
	case 0x1F801040:
		return PAD_Read();
	case 0x1F801800:
		return CDR_GetStatus();
	case 0x1F801801:
		return CDR_ReadResponse();
	case 0x1F801802:
		return CDR_Read();
	case 0x1F801803:
		return CDR_Read3();
	default:
		SDL_LogError(LOG_EMU,"Unrecognized 8-bit read address %.8X",address);
		return PCSX_Read8(address);
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movl %edi, -0x8(%rbp)
cmpl $0x80000000, -0x8(%rbp) # imm = 0x80000000
jb 0x31a838
cmpl $0x801fffff, -0x8(%rbp) # imm = 0x801FFFFF
ja 0x31a838
jmp 0x31a7cf
movl -0x8(%rbp), %eax
andl $0x1fffff, %eax         # imm = 0x1FFFFF
shrl $0x2, %eax
movl %eax, %eax
movl %eax, %ecx
leaq 0xc1fb(%rip), %rax      # 0x3269e0
movq (%rax,%rcx,8), %rax
movq %rax, -0x10(%rbp)
leaq -0x184(%rip), %rax      # 0x31a670
cmpq %rax, -0x10(%rbp)
je 0x31a80d
movl $0x13, %edi
leaq 0x7e80(%rip), %rsi      # 0x322686
movb $0x0, %al
callq 0x10d0
movq 0x40c1cc(%rip), %rax    # 0x7269e0
movl -0x8(%rbp), %ecx
andl $0x1fffff, %ecx         # imm = 0x1FFFFF
shrl $0x2, %ecx
movl %ecx, %ecx
movl (%rax,%rcx,4), %eax
movl -0x8(%rbp), %ecx
andl $0x3, %ecx
shll $0x3, %ecx
shrl %cl, %eax
movb %al, -0x1(%rbp)
jmp 0x31a936
cmpl $0x0, -0x8(%rbp)
jb 0x31a849
cmpl $0x1fffff, -0x8(%rbp)   # imm = 0x1FFFFF
ja 0x31a849
jmp 0x31a7cf
cmpl $0xa0000000, -0x8(%rbp) # imm = 0xA0000000
jb 0x31a860
cmpl $0xa01fffff, -0x8(%rbp) # imm = 0xA01FFFFF
ja 0x31a860
jmp 0x31a7cf
cmpl $0x1f800000, -0x8(%rbp) # imm = 0x1F800000
jb 0x31a89d
cmpl $0x1f8003ff, -0x8(%rbp) # imm = 0x1F8003FF
ja 0x31a89d
movq 0x40c16f(%rip), %rax    # 0x7269e8
movl -0x8(%rbp), %ecx
andl $0x3ff, %ecx            # imm = 0x3FF
shrl $0x2, %ecx
movl %ecx, %ecx
movl (%rax,%rcx,4), %eax
movl -0x8(%rbp), %ecx
andl $0x3, %ecx
shll $0x3, %ecx
shrl %cl, %eax
movb %al, -0x1(%rbp)
jmp 0x31a936
movl -0x8(%rbp), %eax
movl %eax, -0x14(%rbp)
subl $0x1f801040, %eax       # imm = 0x1F801040
je 0x31a8dc
jmp 0x31a8ac
movl -0x14(%rbp), %eax
subl $0x1f801800, %eax       # imm = 0x1F801800
je 0x31a8e6
jmp 0x31a8b8
movl -0x14(%rbp), %eax
subl $0x1f801801, %eax       # imm = 0x1F801801
je 0x31a8f0
jmp 0x31a8c4
movl -0x14(%rbp), %eax
subl $0x1f801802, %eax       # imm = 0x1F801802
je 0x31a8fa
jmp 0x31a8d0
movl -0x14(%rbp), %eax
subl $0x1f801803, %eax       # imm = 0x1F801803
je 0x31a904
jmp 0x31a90e
callq 0x1210
movb %al, -0x1(%rbp)
jmp 0x31a936
callq 0x12b0
movb %al, -0x1(%rbp)
jmp 0x31a936
callq 0x1320
movb %al, -0x1(%rbp)
jmp 0x31a936
callq 0x1300
movb %al, -0x1(%rbp)
jmp 0x31a936
callq 0x1340
movb %al, -0x1(%rbp)
jmp 0x31a936
movl -0x8(%rbp), %edx
movl $0x13, %edi
leaq 0x7d7e(%rip), %rsi      # 0x32269b
movb $0x0, %al
callq 0x10d0
leaq 0xbfd5(%rip), %rax      # 0x326900
movq (%rax), %rax
movl -0x8(%rbp), %edi
callq *%rax
movb %al, -0x1(%rbp)
movb -0x1(%rbp), %al
addq $0x20, %rsp
popq %rbp
retq
nop