// File: /workspace/github_c_makefile_star2_O0/mikecat[P]x86_interpreter/dynamic_memory.c
// Function: dmemory_write
void dmemory_write(void* src, uint32_t addr, uint32_t size) {
	if (size > 0 && size - 1 > UINT32_MAX - addr) size = UINT32_MAX - addr + 1;
	uint8_t* srcu8 = (uint8_t*)src;
	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 write_offset = addr % ALLOCATE_UNIT_SIZE;
	uint32_t write_size = ALLOCATE_UNIT_SIZE - write_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 (write_size > size) write_size = size;
			if (aut_table[i] != NULL && (*aut_table[i])[j] != NULL) {
				memcpy(*(*aut_table[i])[j] + write_offset, srcu8, write_size);
			}
			srcu8 += write_size;
			size -= write_size;
			write_offset = 0;
			write_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 0x7b08
movl -0x10(%rbp), %eax
subl $0x1, %eax
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
subl -0xc(%rbp), %ecx
cmpl %ecx, %eax
jbe 0x7b08
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 0x7b37
jmp 0x7c5a
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 0x7c5a
movl -0x34(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jne 0x7b6f
movl -0x20(%rbp), %eax
movl %eax, -0x44(%rbp)
jmp 0x7b76
xorl %eax, %eax
movl %eax, -0x44(%rbp)
jmp 0x7b76
movl -0x44(%rbp), %eax
movl %eax, -0x3c(%rbp)
movl -0x34(%rbp), %eax
cmpl -0x24(%rbp), %eax
jne 0x7b8c
movl -0x28(%rbp), %eax
movl %eax, -0x48(%rbp)
jmp 0x7b96
movl $0x3ff, %eax            # imm = 0x3FF
movl %eax, -0x48(%rbp)
jmp 0x7b96
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 0x7c4a
movl -0x30(%rbp), %eax
cmpl -0x10(%rbp), %eax
jbe 0x7bbc
movl -0x10(%rbp), %eax
movl %eax, -0x30(%rbp)
movslq -0x34(%rbp), %rcx
leaq 0xd669(%rip), %rax      # 0x15230
cmpq $0x0, (%rax,%rcx,8)
je 0x7c13
movslq -0x34(%rbp), %rcx
leaq 0xd657(%rip), %rax      # 0x15230
movq (%rax,%rcx,8), %rax
movslq -0x38(%rbp), %rcx
cmpq $0x0, (%rax,%rcx,8)
je 0x7c13
movslq -0x34(%rbp), %rcx
leaq 0xd63d(%rip), %rax      # 0x15230
movq (%rax,%rcx,8), %rax
movslq -0x38(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
movl -0x2c(%rbp), %eax
addq %rax, %rdi
movq -0x18(%rbp), %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 0x7ba2
jmp 0x7c4c
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x7b53
addq $0x50, %rsp
popq %rbp
retq