// File: /workspace/github_c_makefile_star2_O0/markdryan[P]subtilis/arch/arm32/arm_heap.c
// Function: prv_get_slot
static void prv_get_slot(subtilis_arm_section_t *arm_s,
			 subtilis_arm_reg_t value, subtilis_arm_reg_t ret,
			 subtilis_arm_reg_t scratch, subtilis_error_t *err)
{
	subtilis_arm_data_instr_t *datai;
	subtilis_arm_instr_t *instr;
	int32_t i;
	int32_t masks[5] = {0, 0x2, 0xc, 0xf0, 0xff00};

	subtilis_arm_add_mov_imm(arm_s, SUBTILIS_ARM_CCODE_AL, false, ret, 0,
				 err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	subtilis_arm_add_sub_imm(arm_s, SUBTILIS_ARM_CCODE_AL, false, value,
				 value, 1, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	subtilis_arm_add_mov_imm(arm_s, SUBTILIS_ARM_CCODE_AL, false, scratch,
				 0xff000000, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	subtilis_arm_add_data_imm(arm_s, SUBTILIS_ARM_INSTR_ORR,
				  SUBTILIS_ARM_CCODE_AL, false, scratch,
				  scratch, 0xff0000, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	subtilis_arm_add_cmp(arm_s, SUBTILIS_ARM_INSTR_TST,
			     SUBTILIS_ARM_CCODE_AL, value, scratch, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	for (i = 4; i >= 0; --i) {
		instr = subtilis_arm_section_add_instr(
		    arm_s, SUBTILIS_ARM_INSTR_MOV, err);
		if (err->type != SUBTILIS_ERROR_OK)
			return;
		datai = &instr->operands.data;
		datai->ccode = SUBTILIS_ARM_CCODE_NE;
		datai->status = false;
		datai->dest = value;
		datai->op2.type = SUBTILIS_ARM_OP2_SHIFTED;
		datai->op2.op.shift.shift_reg = false;
		datai->op2.op.shift.reg = value;
		datai->op2.op.shift.type = SUBTILIS_ARM_SHIFT_LSR;
		datai->op2.op.shift.shift.integer = 1 << i;

		subtilis_arm_add_data_imm(arm_s, SUBTILIS_ARM_INSTR_ORR,
					  SUBTILIS_ARM_CCODE_NE, false, ret,
					  ret, 1 << i, err);
		if (err->type != SUBTILIS_ERROR_OK)
			return;

		if (i == 0)
			break;

		subtilis_arm_add_cmp_imm(arm_s, SUBTILIS_ARM_INSTR_TST,
					 SUBTILIS_ARM_CCODE_AL, value, masks[i],
					 err);
		if (err->type != SUBTILIS_ERROR_OK)
			return;
	}

	subtilis_arm_add_sub_imm(arm_s, SUBTILIS_ARM_CCODE_AL, false, ret, ret,
				 subtilis_arm_heap_min_slot_shift - 1, err);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movq 0x1f32d(%rip), %rax     # 0xadad0
movq %rax, -0x50(%rbp)
movq 0x1f32a(%rip), %rax     # 0xadad8
movq %rax, -0x48(%rbp)
movl 0x1f328(%rip), %eax     # 0xadae0
movl %eax, -0x40(%rbp)
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %r9
movq -0x28(%rbp), %rax
movl $0xd, %esi
movl $0xf, %edx
movl $0xe, %ecx
xorl %r8d, %r8d
movl $0x0, (%rsp)
movq %rax, 0x8(%rsp)
callq 0x71b10
movq -0x28(%rbp), %rax
cmpl $0x0, (%rax)
je 0x8e7f8
jmp 0x8ea3f
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %r9
movq -0x10(%rbp), %r10
movq -0x28(%rbp), %rax
movl $0x2, %esi
movl $0x4, %edx
movl $0xe, %ecx
xorl %r8d, %r8d
movq %r10, (%rsp)
movl $0x1, 0x8(%rsp)
movq %rax, 0x10(%rsp)
callq 0x71640
movq -0x28(%rbp), %rax
cmpl $0x0, (%rax)
je 0x8e83e
jmp 0x8ea3f
movq -0x8(%rbp), %rdi
movq -0x20(%rbp), %r9
movq -0x28(%rbp), %rax
movl $0xd, %esi
movl $0xf, %edx
movl $0xe, %ecx
xorl %r8d, %r8d
movl $0xff000000, (%rsp)     # imm = 0xFF000000
movq %rax, 0x8(%rsp)
callq 0x71b10
movq -0x28(%rbp), %rax
cmpl $0x0, (%rax)
je 0x8e87b
jmp 0x8ea3f
movq -0x8(%rbp), %rdi
movq -0x20(%rbp), %r8
movq -0x20(%rbp), %r9
movq -0x28(%rbp), %rax
movl $0xc, %esi
movl $0xe, %edx
xorl %ecx, %ecx
movl $0xff0000, (%rsp)       # imm = 0xFF0000
movq %rax, 0x8(%rsp)
callq 0x71cd0
movq -0x28(%rbp), %rax
cmpl $0x0, (%rax)
je 0x8e8b6
jmp 0x8ea3f
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rcx
movq -0x20(%rbp), %r8
movq -0x28(%rbp), %r9
movl $0x8, %esi
movl $0xe, %edx
callq 0x72710
movq -0x28(%rbp), %rax
cmpl $0x0, (%rax)
je 0x8e8e3
jmp 0x8ea3f
movl $0x4, -0x3c(%rbp)
cmpl $0x0, -0x3c(%rbp)
jl 0x8ea07
movq -0x8(%rbp), %rdi
movq -0x28(%rbp), %rdx
movl $0xd, %esi
callq 0x70b50
movq %rax, -0x38(%rbp)
movq -0x28(%rbp), %rax
cmpl $0x0, (%rax)
je 0x8e918
jmp 0x8ea3f
movq -0x38(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
movl $0x1, (%rax)
movq -0x30(%rbp), %rax
movb $0x0, 0x4(%rax)
movq -0x10(%rbp), %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x30(%rbp), %rax
movl $0x2, 0x18(%rax)
movq -0x30(%rbp), %rax
movb $0x0, 0x38(%rax)
movq -0x10(%rbp), %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x20(%rax)
movq -0x30(%rbp), %rax
movl $0x2, 0x28(%rax)
movl -0x3c(%rbp), %ecx
movl $0x1, %eax
shll %cl, %eax
movl %eax, %ecx
movq -0x30(%rbp), %rax
movl %ecx, 0x30(%rax)
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %r8
movq -0x18(%rbp), %r9
movl -0x3c(%rbp), %ecx
movl $0x1, %r10d
shll %cl, %r10d
movq -0x28(%rbp), %rax
movl $0xc, %esi
movl $0x1, %edx
xorl %ecx, %ecx
movl %r10d, (%rsp)
movq %rax, 0x8(%rsp)
callq 0x71cd0
movq -0x28(%rbp), %rax
cmpl $0x0, (%rax)
je 0x8e9c0
jmp 0x8ea3f
cmpl $0x0, -0x3c(%rbp)
jne 0x8e9c8
jmp 0x8ea07
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rcx
movslq -0x3c(%rbp), %rax
movl -0x50(%rbp,%rax,4), %r8d
movq -0x28(%rbp), %r9
movl $0x8, %esi
movl $0xe, %edx
callq 0x72620
movq -0x28(%rbp), %rax
cmpl $0x0, (%rax)
je 0x8e9f7
jmp 0x8ea3f
jmp 0x8e9f9
movl -0x3c(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x8e8ea
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %r9
movq -0x18(%rbp), %r10
movq -0x28(%rbp), %rax
movl $0x2, %esi
movl $0x4, %edx
movl $0xe, %ecx
xorl %r8d, %r8d
movq %r10, (%rsp)
movl $0x4, 0x8(%rsp)
movq %rax, 0x10(%rsp)
callq 0x71640
addq $0x70, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)