// File: /workspace/github_c_makefile_star2_O0/markdryan[P]subtilis/arch/arm32/arm_heap.c
// Function: prv_slot12_alloc
static void prv_slot12_alloc(subtilis_arm_section_t *arm_s, size_t good_label,
			     size_t bad_label, size_t exact_slot_size_label,
			     subtilis_error_t *err)
{
	subtilis_arm_br_instr_t *br;
	subtilis_arm_instr_t *instr;
	const subtilis_arm_reg_t ret_val = 0;
	subtilis_arm_data_instr_t *datai;
	const subtilis_arm_reg_t heap_start = 0;
	const subtilis_arm_reg_t segment = 1;
	const subtilis_arm_reg_t first_entry = 3;
	const subtilis_arm_reg_t next_ptr = 4;
	const subtilis_arm_reg_t block_size = 5;
	const subtilis_arm_reg_t scratch2 = 6;
	const subtilis_arm_reg_t split_block_size = 7;
	const subtilis_arm_reg_t split_slot = 8;
	const subtilis_arm_reg_t scratch3 = 9;
	const subtilis_arm_reg_t scratch = 10;
	const subtilis_arm_reg_t max_size_of_block = 10;

	subtilis_arm_add_stran_imm(arm_s, SUBTILIS_ARM_INSTR_LDR,
				   SUBTILIS_ARM_CCODE_AL, next_ptr, first_entry,
				   4, false, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	subtilis_arm_add_stran_imm(arm_s, SUBTILIS_ARM_INSTR_LDR,
				   SUBTILIS_ARM_CCODE_AL, scratch2, first_entry,
				   0, false, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	instr =
	    subtilis_arm_section_add_instr(arm_s, SUBTILIS_ARM_INSTR_SUB, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;
	datai = &instr->operands.data;
	datai->ccode = SUBTILIS_ARM_CCODE_AL;
	datai->status = false;
	datai->dest = split_block_size;
	datai->op1 = scratch2;
	datai->op2.type = SUBTILIS_ARM_OP2_REG;
	datai->op2.op.reg = block_size;

	subtilis_arm_add_stran_imm(arm_s, SUBTILIS_ARM_INSTR_STR,
				   SUBTILIS_ARM_CCODE_AL, next_ptr, heap_start,
				   subtilis_arm_heap_max_slot * sizeof(int32_t),
				   false, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	subtilis_arm_add_cmp_imm(arm_s, SUBTILIS_ARM_INSTR_CMP,
				 SUBTILIS_ARM_CCODE_AL, split_block_size, 0,
				 err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	subtilis_arm_add_add_imm(arm_s, SUBTILIS_ARM_CCODE_EQ, false, ret_val,
				 first_entry, 8, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	instr =
	    subtilis_arm_section_add_instr(arm_s, SUBTILIS_ARM_INSTR_B, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	br = &instr->operands.br;
	br->ccode = SUBTILIS_ARM_CCODE_EQ;
	br->link = false;
	br->target.label = good_label;

	subtilis_arm_add_mov_reg(arm_s, SUBTILIS_ARM_CCODE_AL, false, scratch,
				 split_block_size, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	instr =
	    subtilis_arm_section_add_instr(arm_s, SUBTILIS_ARM_INSTR_ADD, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;
	datai = &instr->operands.data;
	datai->ccode = SUBTILIS_ARM_CCODE_AL;
	datai->status = false;
	datai->dest = segment;
	datai->op1 = first_entry;
	datai->op2.type = SUBTILIS_ARM_OP2_REG;
	datai->op2.op.reg = block_size;

	prv_get_slot(arm_s, scratch, split_slot, scratch3, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	subtilis_arm_add_cmp_imm(arm_s, SUBTILIS_ARM_INSTR_CMP,
				 SUBTILIS_ARM_CCODE_AL, split_slot,
				 subtilis_arm_heap_max_slot, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	subtilis_arm_add_mov_imm(arm_s, SUBTILIS_ARM_CCODE_GT, false,
				 split_slot, subtilis_arm_heap_max_slot, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	instr =
	    subtilis_arm_section_add_instr(arm_s, SUBTILIS_ARM_INSTR_B, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	br = &instr->operands.br;
	br->ccode = SUBTILIS_ARM_CCODE_GE;
	br->link = false;
	br->target.label = exact_slot_size_label;

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

	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_AL;
	datai->status = false;
	datai->dest = scratch;
	datai->op2.type = SUBTILIS_ARM_OP2_SHIFTED;
	datai->op2.op.shift.shift_reg = true;
	datai->op2.op.shift.reg = scratch3;
	datai->op2.op.shift.type = SUBTILIS_ARM_SHIFT_LSL;
	datai->op2.op.shift.shift.reg = split_slot;

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

	instr =
	    subtilis_arm_section_add_instr(arm_s, SUBTILIS_ARM_INSTR_B, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	br = &instr->operands.br;
	br->ccode = SUBTILIS_ARM_CCODE_EQ;
	br->link = false;
	br->target.label = exact_slot_size_label;

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

	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_AL;
	datai->status = false;
	datai->dest = max_size_of_block;
	datai->op2.type = SUBTILIS_ARM_OP2_SHIFTED;
	datai->op2.op.shift.shift_reg = false;
	datai->op2.op.shift.reg = max_size_of_block;
	datai->op2.op.shift.type = SUBTILIS_ARM_SHIFT_LSR;
	datai->op2.op.shift.shift.integer = 1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xc0, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movq $0x0, -0x40(%rbp)
movq $0x0, -0x50(%rbp)
movq $0x1, -0x58(%rbp)
movq $0x3, -0x60(%rbp)
movq $0x4, -0x68(%rbp)
movq $0x5, -0x70(%rbp)
movq $0x6, -0x78(%rbp)
movq $0x7, -0x80(%rbp)
movq $0x8, -0x88(%rbp)
movq $0x9, -0x90(%rbp)
movq $0xa, -0x98(%rbp)
movq $0xa, -0xa0(%rbp)
movq -0x8(%rbp), %rdi
movq -0x28(%rbp), %rax
movl $0x12, %esi
movl $0xe, %edx
movl $0x4, %ecx
movl $0x3, %r8d
movl $0x4, %r9d
xorl %r10d, %r10d
movl $0x0, (%rsp)
movq %rax, 0x8(%rsp)
callq 0x72030
movq -0x28(%rbp), %rax
cmpl $0x0, (%rax)
je 0x8eb20
jmp 0x8f06a
movq -0x8(%rbp), %rdi
movq -0x28(%rbp), %rax
movl $0x12, %esi
movl $0xe, %edx
movl $0x6, %ecx
movl $0x3, %r8d
xorl %r9d, %r9d
movl $0x0, (%rsp)
movq %rax, 0x8(%rsp)
callq 0x72030
movq -0x28(%rbp), %rax
cmpl $0x0, (%rax)
je 0x8eb5f
jmp 0x8f06a
movq -0x8(%rbp), %rdi
movq -0x28(%rbp), %rdx
movl $0x2, %esi
callq 0x70b50
movq %rax, -0x38(%rbp)
movq -0x28(%rbp), %rax
cmpl $0x0, (%rax)
je 0x8eb83
jmp 0x8f06a
movq -0x38(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rax
movl $0xe, (%rax)
movq -0x48(%rbp), %rax
movb $0x0, 0x4(%rax)
movq -0x48(%rbp), %rax
movq $0x7, 0x8(%rax)
movq -0x48(%rbp), %rax
movq $0x6, 0x10(%rax)
movq -0x48(%rbp), %rax
movl $0x0, 0x18(%rax)
movq -0x48(%rbp), %rax
movq $0x5, 0x20(%rax)
movq -0x8(%rbp), %rdi
movq -0x28(%rbp), %rax
movl $0x13, %esi
movl $0xe, %edx
movl $0x4, %ecx
xorl %r8d, %r8d
movl $0x30, %r9d
xorl %r10d, %r10d
movl $0x0, (%rsp)
movq %rax, 0x8(%rsp)
callq 0x72030
movq -0x28(%rbp), %rax
cmpl $0x0, (%rax)
je 0x8ec12
jmp 0x8f06a
movq -0x8(%rbp), %rdi
movq -0x28(%rbp), %r9
movl $0xa, %esi
movl $0xe, %edx
movl $0x7, %ecx
xorl %r8d, %r8d
callq 0x72620
movq -0x28(%rbp), %rax
cmpl $0x0, (%rax)
je 0x8ec3f
jmp 0x8f06a
movq -0x8(%rbp), %rdi
movq -0x28(%rbp), %rax
movl $0x4, %esi
movl $0x2, %edx
xorl %r8d, %r8d
xorl %ecx, %ecx
movl %ecx, %r9d
movl %r8d, %ecx
movq $0x3, (%rsp)
movl $0x8, 0x8(%rsp)
movq %rax, 0x10(%rsp)
callq 0x71640
movq -0x28(%rbp), %rax
cmpl $0x0, (%rax)
je 0x8ec84
jmp 0x8f06a
movq -0x8(%rbp), %rdi
movq -0x28(%rbp), %rdx
movl $0x16, %esi
callq 0x70b50
movq %rax, -0x38(%rbp)
movq -0x28(%rbp), %rax
cmpl $0x0, (%rax)
je 0x8eca8
jmp 0x8f06a
movq -0x38(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
movl $0x0, (%rax)
movq -0x30(%rbp), %rax
movb $0x0, 0x4(%rax)
movq -0x10(%rbp), %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x8(%rbp), %rdi
movq -0x28(%rbp), %rax
movl $0xd, %esi
movl $0xe, %edx
xorl %ecx, %ecx
movl $0xa, %r8d
movl $0x7, %r9d
movq %rax, (%rsp)
callq 0x71fa0
movq -0x28(%rbp), %rax
cmpl $0x0, (%rax)
je 0x8ed09
jmp 0x8f06a
movq -0x8(%rbp), %rdi
movq -0x28(%rbp), %rdx
movl $0x4, %esi
callq 0x70b50
movq %rax, -0x38(%rbp)
movq -0x28(%rbp), %rax
cmpl $0x0, (%rax)
je 0x8ed2d
jmp 0x8f06a
movq -0x38(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rax
movl $0xe, (%rax)
movq -0x48(%rbp), %rax
movb $0x0, 0x4(%rax)
movq -0x48(%rbp), %rax
movq $0x1, 0x8(%rax)
movq -0x48(%rbp), %rax
movq $0x3, 0x10(%rax)
movq -0x48(%rbp), %rax
movl $0x0, 0x18(%rax)
movq -0x48(%rbp), %rax
movq $0x5, 0x20(%rax)
movq -0x8(%rbp), %rdi
movq -0x28(%rbp), %r8
movl $0xa, %esi
movl $0x8, %edx
movl $0x9, %ecx
callq 0x8e780
movq -0x28(%rbp), %rax
cmpl $0x0, (%rax)
je 0x8eda4
jmp 0x8f06a
movq -0x8(%rbp), %rdi
movq -0x28(%rbp), %r9
movl $0xa, %esi
movl $0xe, %edx
movl $0x8, %ecx
movl $0xc, %r8d
callq 0x72620
movq -0x28(%rbp), %rax
cmpl $0x0, (%rax)
je 0x8edd4
jmp 0x8f06a
movq -0x8(%rbp), %rdi
movq -0x28(%rbp), %rax
movl $0xd, %esi
movl $0xf, %edx
movl $0xc, %ecx
xorl %r8d, %r8d
movl $0x8, %r9d
movl $0xc, (%rsp)
movq %rax, 0x8(%rsp)
callq 0x71b10
movq -0x28(%rbp), %rax
cmpl $0x0, (%rax)
je 0x8ee13
jmp 0x8f06a
movq -0x8(%rbp), %rdi
movq -0x28(%rbp), %rdx
movl $0x16, %esi
callq 0x70b50
movq %rax, -0x38(%rbp)
movq -0x28(%rbp), %rax
cmpl $0x0, (%rax)
je 0x8ee37
jmp 0x8f06a
movq -0x38(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
movl $0xa, (%rax)
movq -0x30(%rbp), %rax
movb $0x0, 0x4(%rax)
movq -0x20(%rbp), %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x8(%rbp), %rdi
movq -0x28(%rbp), %rax
movl $0xd, %esi
movl $0xf, %edx
movl $0xe, %ecx
xorl %r8d, %r8d
movl $0x9, %r9d
movl $0x20, (%rsp)
movq %rax, 0x8(%rsp)
callq 0x71b10
movq -0x28(%rbp), %rax
cmpl $0x0, (%rax)
je 0x8eea0
jmp 0x8f06a
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 0x8eec4
jmp 0x8f06a
movq -0x38(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rax
movl $0xe, (%rax)
movq -0x48(%rbp), %rax
movb $0x0, 0x4(%rax)
movq -0x48(%rbp), %rax
movq $0xa, 0x8(%rax)
movq -0x48(%rbp), %rax
movl $0x2, 0x18(%rax)
movq -0x48(%rbp), %rax
movb $0x1, 0x38(%rax)
movq -0x48(%rbp), %rax
movq $0x9, 0x20(%rax)
movq -0x48(%rbp), %rax
movl $0x0, 0x28(%rax)
movq -0x48(%rbp), %rax
movq $0x8, 0x30(%rax)
movq -0x8(%rbp), %rdi
movq -0x28(%rbp), %r9
movl $0xa, %esi
movl $0xe, %edx
movl $0xa, %ecx
movl $0x7, %r8d
callq 0x72710
movq -0x28(%rbp), %rax
cmpl $0x0, (%rax)
je 0x8ef54
jmp 0x8f06a
movq -0x8(%rbp), %rdi
movq -0x28(%rbp), %rdx
movl $0x16, %esi
callq 0x70b50
movq %rax, -0x38(%rbp)
movq -0x28(%rbp), %rax
cmpl $0x0, (%rax)
je 0x8ef78
jmp 0x8f06a
movq -0x38(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
movl $0x0, (%rax)
movq -0x30(%rbp), %rax
movb $0x0, 0x4(%rax)
movq -0x20(%rbp), %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x8(%rbp), %rdi
movq -0x28(%rbp), %rax
movl $0x2, %esi
movl $0x4, %edx
movl $0xe, %ecx
xorl %r8d, %r8d
movl $0x8, %r9d
movq $0x8, (%rsp)
movl $0x1, 0x8(%rsp)
movq %rax, 0x10(%rsp)
callq 0x71640
movq -0x28(%rbp), %rax
cmpl $0x0, (%rax)
je 0x8efea
jmp 0x8f06a
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 0x8f00b
jmp 0x8f06a
movq -0x38(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rax
movl $0xe, (%rax)
movq -0x48(%rbp), %rax
movb $0x0, 0x4(%rax)
movq -0x48(%rbp), %rax
movq $0xa, 0x8(%rax)
movq -0x48(%rbp), %rax
movl $0x2, 0x18(%rax)
movq -0x48(%rbp), %rax
movb $0x0, 0x38(%rax)
movq -0x48(%rbp), %rax
movq $0xa, 0x20(%rax)
movq -0x48(%rbp), %rax
movl $0x2, 0x28(%rax)
movq -0x48(%rbp), %rax
movl $0x1, 0x30(%rax)
addq $0xc0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)