// File: /workspace/github_c_makefile_star2_O0/markdryan[P]subtilis/arch/arm32/arm_reg_alloc.c
// Function: prv_load_spilled_reg
static void prv_load_spilled_reg(subtilis_arm_reg_ud_t *ud,
				 subtilis_arm_op_t *current,
				 subtilis_arm_reg_class_t *regs,
				 subtilis_arm_reg_t virt,
				 subtilis_arm_reg_t phys, subtilis_error_t *err)
{
	int i;
	size_t pos;
	subtilis_arm_section_t *arm_s = ud->arm_s;
	int32_t basic_offset = regs->spilt_regs[virt];

	if (basic_offset == INT_MAX) {
		subtilis_error_set_assertion_failed(err);
		return;
	}

	if (regs->spill_top == 0) {
		subtilis_error_set_assertion_failed(err);
		return;
	}

	if (current->prev == SIZE_MAX)
		pos = arm_s->first_op;
	else
		pos = arm_s->op_pool->ops[current->prev].next;

	prv_add_spill_point(regs, SUBTILIS_SPILL_POINT_LOAD, pos, basic_offset,
			    phys, err);

	regs->phys_to_virt[phys] = virt;
	regs->spilt_regs[virt] = INT_MAX;
	i = basic_offset / regs->reg_size;
	regs->spill_stack[i] = basic_offset;
	if (i == regs->spill_top - 1) {
		regs->spill_top--;
		for (i = i - 1; i >= 0; i--) {
			if (regs->spill_stack[i] == INT_MAX)
				break;
			regs->spill_top--;
		}
	}
	regs->next[phys] = -1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movq %r9, -0x30(%rbp)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x48(%rbp)
movq -0x18(%rbp), %rax
movq 0x20(%rax), %rax
movq -0x20(%rbp), %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0x4c(%rbp)
cmpl $0x7fffffff, -0x4c(%rbp) # imm = 0x7FFFFFFF
jne 0x776b6
movq -0x30(%rbp), %rdi
movl $0xf, %esi
leaq 0x354ec(%rip), %rdx     # 0xacb93
movl $0x2c0, %ecx            # imm = 0x2C0
callq 0x158e0
jmp 0x777fa
movq -0x18(%rbp), %rax
cmpq $0x0, 0x30(%rax)
jne 0x776e0
movq -0x30(%rbp), %rdi
movl $0xf, %esi
leaq 0x354c2(%rip), %rdx     # 0xacb93
movl $0x2c5, %ecx            # imm = 0x2C5
callq 0x158e0
jmp 0x777fa
movq -0x10(%rbp), %rax
cmpq $-0x1, 0x60(%rax)
jne 0x776f9
movq -0x48(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x40(%rbp)
jmp 0x77718
movq -0x48(%rbp), %rax
movq 0x38(%rax), %rax
movq (%rax), %rax
movq -0x10(%rbp), %rcx
imulq $0x68, 0x60(%rcx), %rcx
addq %rcx, %rax
movq 0x58(%rax), %rax
movq %rax, -0x40(%rbp)
movq -0x18(%rbp), %rdi
movq -0x40(%rbp), %rdx
movl -0x4c(%rbp), %ecx
movq -0x28(%rbp), %r8
movq -0x30(%rbp), %r9
xorl %esi, %esi
callq 0x7a4d0
movq -0x20(%rbp), %rdx
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x28(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movq -0x18(%rbp), %rax
movq 0x20(%rax), %rax
movq -0x20(%rbp), %rcx
movl $0x7fffffff, (%rax,%rcx,4) # imm = 0x7FFFFFFF
movslq -0x4c(%rbp), %rax
movq -0x18(%rbp), %rcx
xorl %edx, %edx
divq 0x40(%rcx)
movl %eax, -0x34(%rbp)
movslq -0x4c(%rbp), %rdx
movq -0x18(%rbp), %rax
movq 0x28(%rax), %rax
movslq -0x34(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movslq -0x34(%rbp), %rax
movq -0x18(%rbp), %rcx
movq 0x30(%rcx), %rcx
subq $0x1, %rcx
cmpq %rcx, %rax
jne 0x777e7
movq -0x18(%rbp), %rax
movq 0x30(%rax), %rcx
addq $-0x1, %rcx
movq %rcx, 0x30(%rax)
movl -0x34(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x34(%rbp)
cmpl $0x0, -0x34(%rbp)
jl 0x777e5
movq -0x18(%rbp), %rax
movq 0x28(%rax), %rax
movslq -0x34(%rbp), %rcx
cmpq $0x7fffffff, (%rax,%rcx,8) # imm = 0x7FFFFFFF
jne 0x777ca
jmp 0x777e5
movq -0x18(%rbp), %rax
movq 0x30(%rax), %rcx
addq $-0x1, %rcx
movq %rcx, 0x30(%rax)
movl -0x34(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x777ac
jmp 0x777e7
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x28(%rbp), %rcx
movl $0xffffffff, (%rax,%rcx,4) # imm = 0xFFFFFFFF
addq $0x50, %rsp
popq %rbp
retq