// File: /workspace/github_c_makefile_star2_O3/markdryan[P]subtilis/arch/arm32/arm_heap.c
// Function: prv_split_slot12_block
static void prv_split_slot12_block(subtilis_arm_section_t *arm_s,
				   size_t split_slot12_block_label,
				   size_t exact_slot_size_label,
				   subtilis_error_t *err)
{
	subtilis_arm_br_instr_t *br;
	subtilis_arm_instr_t *instr;
	subtilis_arm_data_instr_t *datai;
	subtilis_arm_stran_instr_t *stran;
	const subtilis_arm_reg_t heap_start = 0;
	const subtilis_arm_reg_t segment = 1;
	const subtilis_arm_reg_t ptr = 4;
	const subtilis_arm_reg_t split_block_size = 7;
	const subtilis_arm_reg_t split_slot = 8;
	const subtilis_arm_reg_t max_size_of_block = 10;

	size_t find_next_slot_label = arm_s->label_counter++;

	instr =
	    subtilis_arm_section_add_instr(arm_s, SUBTILIS_ARM_INSTR_LDR, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;
	stran = &instr->operands.stran;

	stran->ccode = SUBTILIS_ARM_CCODE_AL;
	stran->dest = ptr;
	stran->base = heap_start;
	stran->offset.type = SUBTILIS_ARM_OP2_SHIFTED;
	stran->offset.op.shift.reg = split_slot;
	stran->offset.op.shift.type = SUBTILIS_ARM_SHIFT_LSL;
	stran->offset.op.shift.shift.integer = 2;
	stran->offset.op.shift.shift_reg = false;
	stran->pre_indexed = true;
	stran->write_back = false;
	stran->subtract = false;
	stran->byte = false;

	subtilis_arm_add_stran_imm(arm_s, SUBTILIS_ARM_INSTR_STR,
				   SUBTILIS_ARM_CCODE_AL, max_size_of_block,
				   segment, 0, false, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	subtilis_arm_add_stran_imm(arm_s, SUBTILIS_ARM_INSTR_STR,
				   SUBTILIS_ARM_CCODE_AL, ptr, segment, 4,
				   false, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	instr =
	    subtilis_arm_section_add_instr(arm_s, SUBTILIS_ARM_INSTR_STR, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;
	stran = &instr->operands.stran;

	stran->ccode = SUBTILIS_ARM_CCODE_AL;
	stran->dest = segment;
	stran->base = heap_start;
	stran->offset.type = SUBTILIS_ARM_OP2_SHIFTED;
	stran->offset.op.shift.reg = split_slot;
	stran->offset.op.shift.type = SUBTILIS_ARM_SHIFT_LSL;
	stran->offset.op.shift.shift.integer = 2;
	stran->offset.op.shift.shift_reg = false;
	stran->pre_indexed = true;
	stran->write_back = false;
	stran->subtract = false;
	stran->byte = false;

	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 = segment;
	datai->op2.type = SUBTILIS_ARM_OP2_REG;
	datai->op2.op.reg = max_size_of_block;

	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 = split_block_size;
	datai->op2.type = SUBTILIS_ARM_OP2_REG;
	datai->op2.op.reg = max_size_of_block;

	subtilis_arm_section_add_label(arm_s, find_next_slot_label, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	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;

	subtilis_arm_add_cmp(arm_s, SUBTILIS_ARM_INSTR_CMP,
			     SUBTILIS_ARM_CCODE_AL, split_block_size,
			     max_size_of_block, 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;

	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_LT;
	br->link = false;
	br->target.label = find_next_slot_label;

	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_AL;
	br->link = false;
	br->target.label = split_slot12_block_label;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rcx, %r14
movq %rdx, %r13
movq %rsi, %rbx
movq %rdi, %r15
movq 0x10(%rdi), %r12
leaq 0x1(%r12), %rax
movq %rax, 0x10(%rdi)
movl $0x12, %esi
movq %rcx, %rdx
callq 0x4f6e2
cmpl $0x0, (%r14)
jne 0x61cf6
movl $0xe, 0x8(%rax)
movq $0x4, 0x10(%rax)
movq $0x0, 0x18(%rax)
movl $0x2, %ecx
movl %ecx, 0x20(%rax)
movq $0x8, 0x28(%rax)
xorl %ebp, %ebp
movl %ebp, 0x30(%rax)
movl %ecx, 0x38(%rax)
movb $0x0, 0x40(%rax)
movl $0x1, 0x48(%rax)
movl $0xa, %ecx
movl $0x1, %r8d
movq %r15, %rdi
movl $0x13, %esi
movl $0xe, %edx
xorl %r9d, %r9d
pushq %r14
pushq %rbp
callq 0x50516
addq $0x10, %rsp
cmpl %ebp, (%r14)
jne 0x61cf6
movl $0x4, %ecx
movl $0x1, %r8d
movq %r15, %rdi
movl $0x13, %esi
movl $0xe, %edx
movl $0x4, %r9d
pushq %r14
pushq $0x0
callq 0x50516
addq $0x10, %rsp
cmpl $0x0, (%r14)
jne 0x61cf6
movq %r15, %rdi
movl $0x13, %esi
movq %r14, %rdx
callq 0x4f6e2
cmpl $0x0, (%r14)
jne 0x61cf6
movl $0xe, 0x8(%rax)
movq $0x1, 0x10(%rax)
movq $0x0, 0x18(%rax)
movl $0x2, %ecx
movl %ecx, 0x20(%rax)
movq $0x8, 0x28(%rax)
movl $0x0, 0x30(%rax)
movl %ecx, 0x38(%rax)
movb $0x0, 0x40(%rax)
movl $0x1, 0x48(%rax)
movq %r15, %rdi
movl $0x4, %esi
movq %r14, %rdx
callq 0x4f6e2
cmpl $0x0, (%r14)
jne 0x61cf6
movl $0xe, 0x8(%rax)
movb $0x0, 0xc(%rax)
movl $0x1, %ecx
movq %rcx, 0x10(%rax)
movq %rcx, 0x18(%rax)
movl $0x0, 0x20(%rax)
movq $0xa, 0x28(%rax)
movq %r15, %rdi
movl $0x2, %esi
movq %r14, %rdx
callq 0x4f6e2
cmpl $0x0, (%r14)
jne 0x61cf6
movl $0xe, 0x8(%rax)
movb $0x0, 0xc(%rax)
movl $0x7, %ecx
movq %rcx, 0x10(%rax)
movq %rcx, 0x18(%rax)
movl $0x0, 0x20(%rax)
movq $0xa, 0x28(%rax)
movq %r15, %rdi
movq %r12, %rsi
movq %r14, %rdx
callq 0x4f530
cmpl $0x0, (%r14)
jne 0x61cf6
subq $0x8, %rsp
movl $0x8, %r9d
movq %r15, %rdi
movl $0x2, %esi
movl $0x4, %edx
movl $0xe, %ecx
xorl %r8d, %r8d
pushq %r14
pushq $0x1
pushq $0x8
callq 0x4fd3f
addq $0x20, %rsp
cmpl $0x0, (%r14)
jne 0x61cf6
movq %r15, %rdi
movl $0xd, %esi
movq %r14, %rdx
callq 0x4f6e2
cmpl $0x0, (%r14)
jne 0x61cf6
movl $0xe, 0x8(%rax)
xorl %ecx, %ecx
movb %cl, 0xc(%rax)
movl $0xa, %edx
movq %rdx, 0x10(%rax)
movl $0x2, %esi
movl %esi, 0x20(%rax)
movb %cl, 0x40(%rax)
movq %rdx, 0x28(%rax)
movl %esi, 0x30(%rax)
movl $0x1, 0x38(%rax)
movl $0x7, %ecx
movl $0xa, %r8d
movq %r15, %rdi
movl $0xa, %esi
movl $0xe, %edx
movq %r14, %r9
callq 0x5099c
cmpl $0x0, (%r14)
jne 0x61cf6
movq %r15, %rdi
movl $0x16, %esi
movq %r14, %rdx
callq 0x4f6e2
cmpl $0x0, (%r14)
jne 0x61cf6
movl $0x0, 0x8(%rax)
movb $0x0, 0xc(%rax)
movq %r13, 0x18(%rax)
movq %r15, %rdi
movl $0x16, %esi
movq %r14, %rdx
callq 0x4f6e2
cmpl $0x0, (%r14)
jne 0x61cf6
movl $0xb, 0x8(%rax)
movb $0x0, 0xc(%rax)
movq %r12, 0x18(%rax)
movq %r15, %rdi
movl $0x16, %esi
movq %r14, %rdx
callq 0x4f6e2
cmpl $0x0, (%r14)
jne 0x61cf6
movl $0xe, 0x8(%rax)
movb $0x0, 0xc(%rax)
movq %rbx, 0x18(%rax)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq