// File: /workspace/github_c_makefile_star2_O0/ughman[P]c2c/src/emu.c
// Function: EMU_ReadU32
uint32_t EMU_ReadU32(uint32_t address)
{
	if (address & 3)
		SDL_LogError(LOG_EMU,"Unaligned word load");
	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];
	}
	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];
	}
	else switch (address)
	{
	case 0x1F801014:
		// Unused waitstate configuration
		return PCSX_Read16(address);
	case 0x1F801074:
		return IRQ_GetMask();
	case 0x1F8010A8:
		return DMA_GetMode(DMA_GPU);
	case 0x1F8010B8:
		return DMA_GetMode(DMA_CDR);
	case 0x1F8010F0:
		return DMA_GetControlRegister();
	case 0x1F8010F4:
		return DMA_GetInterruptRegister();
	case 0x1F801110:
		return RCNT_GetValue(RCNT_HBLANK);
	case 0x1F801810:
		return GPU_Read();
	case 0x1F801814:
		return GPU_GetStatus();
	default:
		SDL_LogError(LOG_EMU,"Unrecognized 32-bit read address %.8X",address);
		return PCSX_Read32(address);
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movl %edi, -0x8(%rbp)
movl -0x8(%rbp), %eax
andl $0x3, %eax
cmpl $0x0, %eax
je 0x31bbc9
movl $0x13, %edi
leaq 0x6b3c(%rip), %rsi      # 0x3226fe
movb $0x0, %al
callq 0x10d0
cmpl $0x80000000, -0x8(%rbp) # imm = 0x80000000
jb 0x31bc3b
cmpl $0x801fffff, -0x8(%rbp) # imm = 0x801FFFFF
ja 0x31bc3b
jmp 0x31bbdd
movl -0x8(%rbp), %eax
andl $0x1fffff, %eax         # imm = 0x1FFFFF
shrl $0x2, %eax
movl %eax, %eax
movl %eax, %ecx
leaq 0xaded(%rip), %rax      # 0x3269e0
movq (%rax,%rcx,8), %rax
movq %rax, -0x10(%rbp)
leaq -0x1592(%rip), %rax     # 0x31a670
cmpq %rax, -0x10(%rbp)
je 0x31bc1b
movl $0x13, %edi
leaq 0x6a72(%rip), %rsi      # 0x322686
movb $0x0, %al
callq 0x10d0
movq 0x40adbe(%rip), %rax    # 0x7269e0
movl -0x8(%rbp), %ecx
andl $0x1fffff, %ecx         # imm = 0x1FFFFF
shrl $0x2, %ecx
movl %ecx, %ecx
movl (%rax,%rcx,4), %eax
movl %eax, -0x4(%rbp)
jmp 0x31bdb1
cmpl $0x0, -0x8(%rbp)
jb 0x31bc4c
cmpl $0x1fffff, -0x8(%rbp)   # imm = 0x1FFFFF
ja 0x31bc4c
jmp 0x31bbdd
cmpl $0xa0000000, -0x8(%rbp) # imm = 0xA0000000
jb 0x31bc63
cmpl $0xa01fffff, -0x8(%rbp) # imm = 0xA01FFFFF
ja 0x31bc63
jmp 0x31bbdd
cmpl $0x1f800000, -0x8(%rbp) # imm = 0x1F800000
jb 0x31bc95
cmpl $0x1f8003ff, -0x8(%rbp) # imm = 0x1F8003FF
ja 0x31bc95
movq 0x40ad6c(%rip), %rax    # 0x7269e8
movl -0x8(%rbp), %ecx
andl $0x3ff, %ecx            # imm = 0x3FF
shrl $0x2, %ecx
movl %ecx, %ecx
movl (%rax,%rcx,4), %eax
movl %eax, -0x4(%rbp)
jmp 0x31bdb1
movl -0x8(%rbp), %eax
movl %eax, -0x14(%rbp)
subl $0x1f801014, %eax       # imm = 0x1F801014
je 0x31bd07
jmp 0x31bca4
movl -0x14(%rbp), %eax
subl $0x1f801074, %eax       # imm = 0x1F801074
je 0x31bd21
jmp 0x31bcb0
movl -0x14(%rbp), %eax
subl $0x1f8010a8, %eax       # imm = 0x1F8010A8
je 0x31bd31
jmp 0x31bcbc
movl -0x14(%rbp), %eax
subl $0x1f8010b8, %eax       # imm = 0x1F8010B8
je 0x31bd40
jmp 0x31bcc8
movl -0x14(%rbp), %eax
subl $0x1f8010f0, %eax       # imm = 0x1F8010F0
je 0x31bd4f
jmp 0x31bcd4
movl -0x14(%rbp), %eax
subl $0x1f8010f4, %eax       # imm = 0x1F8010F4
je 0x31bd59
jmp 0x31bce0
movl -0x14(%rbp), %eax
subl $0x1f801110, %eax       # imm = 0x1F801110
je 0x31bd63
jmp 0x31bcec
movl -0x14(%rbp), %eax
subl $0x1f801810, %eax       # imm = 0x1F801810
je 0x31bd75
jmp 0x31bcf8
movl -0x14(%rbp), %eax
subl $0x1f801814, %eax       # imm = 0x1F801814
je 0x31bd7f
jmp 0x31bd89
leaq 0xabfa(%rip), %rax      # 0x326908
movq (%rax), %rax
movl -0x8(%rbp), %edi
callq *%rax
movzwl %ax, %eax
movl %eax, -0x4(%rbp)
jmp 0x31bdb1
callq 0x319090
movzwl %ax, %eax
movl %eax, -0x4(%rbp)
jmp 0x31bdb1
movl $0x2, %edi
callq 0x319290
movl %eax, -0x4(%rbp)
jmp 0x31bdb1
movl $0x3, %edi
callq 0x319290
movl %eax, -0x4(%rbp)
jmp 0x31bdb1
callq 0x3192f0
movl %eax, -0x4(%rbp)
jmp 0x31bdb1
callq 0x319340
movl %eax, -0x4(%rbp)
jmp 0x31bdb1
movl $0x1, %edi
callq 0x319180
movzwl %ax, %eax
movl %eax, -0x4(%rbp)
jmp 0x31bdb1
callq 0x3190e0
movl %eax, -0x4(%rbp)
jmp 0x31bdb1
callq 0x319160
movl %eax, -0x4(%rbp)
jmp 0x31bdb1
movl -0x8(%rbp), %edx
movl $0x13, %edi
leaq 0x697a(%rip), %rsi      # 0x322712
movb $0x0, %al
callq 0x10d0
leaq 0xab6a(%rip), %rax      # 0x326910
movq (%rax), %rax
movl -0x8(%rbp), %edi
callq *%rax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x20, %rsp
popq %rbp
retq
nopw (%rax,%rax)