// File: /workspace/github_c_makefile_star2_O0/mikecat[P]x86_interpreter/dynamic_memory.c
// Function: dmemory_read
void dmemory_read(void* dest, uint32_t addr, uint32_t size) {
	if (size > 0 && size - 1 > UINT32_MAX - addr) size = UINT32_MAX - addr + 1;
	uint8_t* destu8 = (uint8_t*)dest;
	int fidx_s, sidx_s, fidx_e, sidx_e;
	if (!get_idxs(&fidx_s, &sidx_s, &fidx_e, &sidx_e, addr, size)) return;
	uint32_t read_offset = addr % ALLOCATE_UNIT_SIZE;
	uint32_t read_size = ALLOCATE_UNIT_SIZE - read_offset;
	int i, j;
	for (i = fidx_s; i <= fidx_e; i++) {
		int jmin = (i == fidx_s ? sidx_s : 0);
		int jmax = (i == fidx_e ? sidx_e : SECOND_TABLE_SIZE - 1);
		for (j = jmin; j <= jmax; j++) {
			if (read_size > size) read_size = size;
			if (aut_table[i] != NULL && (*aut_table[i])[j] != NULL) {
				memcpy(destu8, *(*aut_table[i])[j] + read_offset, read_size);
			}
			destu8 += read_size;
			size -= read_size;
			read_offset = 0;
			read_size = ALLOCATE_UNIT_SIZE;
		}
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movl %edx, -0x10(%rbp)
cmpl $0x0, -0x10(%rbp)
jbe 0x78c8
movl -0x10(%rbp), %eax
subl $0x1, %eax
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
subl -0xc(%rbp), %ecx
cmpl %ecx, %eax
jbe 0x78c8
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
subl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x18(%rbp)
movl -0xc(%rbp), %r8d
movl -0x10(%rbp), %r9d
leaq -0x1c(%rbp), %rdi
leaq -0x20(%rbp), %rsi
leaq -0x24(%rbp), %rdx
leaq -0x28(%rbp), %rcx
callq 0x7a20
cmpl $0x0, %eax
jne 0x78f7
jmp 0x7a1a
movl -0xc(%rbp), %eax
andl $0xfff, %eax            # imm = 0xFFF
movl %eax, -0x2c(%rbp)
movl $0x1000, %eax           # imm = 0x1000
subl -0x2c(%rbp), %eax
movl %eax, -0x30(%rbp)
movl -0x1c(%rbp), %eax
movl %eax, -0x34(%rbp)
movl -0x34(%rbp), %eax
cmpl -0x24(%rbp), %eax
jg 0x7a1a
movl -0x34(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jne 0x792f
movl -0x20(%rbp), %eax
movl %eax, -0x44(%rbp)
jmp 0x7936
xorl %eax, %eax
movl %eax, -0x44(%rbp)
jmp 0x7936
movl -0x44(%rbp), %eax
movl %eax, -0x3c(%rbp)
movl -0x34(%rbp), %eax
cmpl -0x24(%rbp), %eax
jne 0x794c
movl -0x28(%rbp), %eax
movl %eax, -0x48(%rbp)
jmp 0x7956
movl $0x3ff, %eax            # imm = 0x3FF
movl %eax, -0x48(%rbp)
jmp 0x7956
movl -0x48(%rbp), %eax
movl %eax, -0x40(%rbp)
movl -0x3c(%rbp), %eax
movl %eax, -0x38(%rbp)
movl -0x38(%rbp), %eax
cmpl -0x40(%rbp), %eax
jg 0x7a0a
movl -0x30(%rbp), %eax
cmpl -0x10(%rbp), %eax
jbe 0x797c
movl -0x10(%rbp), %eax
movl %eax, -0x30(%rbp)
movslq -0x34(%rbp), %rcx
leaq 0xd8a9(%rip), %rax      # 0x15230
cmpq $0x0, (%rax,%rcx,8)
je 0x79d3
movslq -0x34(%rbp), %rcx
leaq 0xd897(%rip), %rax      # 0x15230
movq (%rax,%rcx,8), %rax
movslq -0x38(%rbp), %rcx
cmpq $0x0, (%rax,%rcx,8)
je 0x79d3
movq -0x18(%rbp), %rdi
movslq -0x34(%rbp), %rcx
leaq 0xd879(%rip), %rax      # 0x15230
movq (%rax,%rcx,8), %rax
movslq -0x38(%rbp), %rcx
movq (%rax,%rcx,8), %rsi
movl -0x2c(%rbp), %eax
addq %rax, %rsi
movl -0x30(%rbp), %eax
movl %eax, %edx
callq 0x10e0
movl -0x30(%rbp), %ecx
movq -0x18(%rbp), %rax
movl %ecx, %ecx
addq %rcx, %rax
movq %rax, -0x18(%rbp)
movl -0x30(%rbp), %ecx
movl -0x10(%rbp), %eax
subl %ecx, %eax
movl %eax, -0x10(%rbp)
movl $0x0, -0x2c(%rbp)
movl $0x1000, -0x30(%rbp)    # imm = 0x1000
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
jmp 0x7962
jmp 0x7a0c
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x7913
addq $0x50, %rsp
popq %rbp
retq