// File: /workspace/github_c_makefile_star2_O0/markdryan[P]subtilis/arch/arm32/arm_sub_section.c
// Function: subtilis_arm_subsections_calculate
void subtilis_arm_subsections_calculate(subtilis_arm_subsections_t *sss,
					subtilis_arm_section_t *arm_s,
					subtilis_error_t *err)
{
	size_t ptr;
	subtilis_arm_ss_t *ss;
	subtilis_arm_op_t *op;
	subtilis_arm_op_t *next;
	size_t count;
	size_t label;
	size_t ss_ptr;

	if (arm_s->first_op == arm_s->last_op) {
		subtilis_error_set_assertion_failed(err);
		return;
	}

	ptr = arm_s->first_op;
	ss_ptr = prv_add_new_sub_section(sss, arm_s, ptr, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;
	ss = &sss->sub_sections[ss_ptr];

	count = 0;
	while (ptr != SIZE_MAX) {
		op = &arm_s->op_pool->ops[ptr];
		if (op->type == SUBTILIS_ARM_OP_LABEL) {
			prv_finalize_sub_section(ss, arm_s, op->prev, count,
						 err);
			if (err->type != SUBTILIS_ERROR_OK)
				return;
			count = 0;
			ss_ptr = prv_add_new_sub_section(sss, arm_s, ptr, err);
			if (err->type != SUBTILIS_ERROR_OK)
				return;
			ss = &sss->sub_sections[ss_ptr];
			label = op->op.label;
			if (label >= arm_s->label_counter) {
				subtilis_error_set_assertion_failed(err);
				return;
			}
			prv_sss_link_map_insert(sss, ss_ptr, label, err);
			if (err->type != SUBTILIS_ERROR_OK)
				return;
		} else if ((op->type == SUBTILIS_ARM_OP_INSTR) &&
			   (op->op.instr.type == SUBTILIS_ARM_INSTR_B) &&
			   (!op->op.instr.operands.br.link) &&
			   (op->op.instr.operands.br.ccode !=
			    SUBTILIS_ARM_CCODE_NV)) {
			prv_add_link(ss, arm_s, ptr,
				     op->op.instr.operands.br.target.label,
				     err);
			if (err->type != SUBTILIS_ERROR_OK)
				return;
			if (op->next != SIZE_MAX) {
				next = &arm_s->op_pool->ops[op->next];
				if (next->type != SUBTILIS_ARM_OP_LABEL) {
					subtilis_arm_section_insert_label(
					    arm_s, arm_s->label_counter, next,
					    err);
					if (err->type != SUBTILIS_ERROR_OK)
						return;

					/*
					 * Inserting or adding an instruction
					 * could invalidate our pointer.  Let's
					 * refresh it.
					 */

					op = &arm_s->op_pool->ops[ptr];
				}
			}
		}

		count++;
		if (ptr == arm_s->last_op)
			break;

		ptr = op->next;
	}

	if (count > 0) {
		prv_finalize_sub_section(ss, arm_s, arm_s->last_op, count, err);
		if (err->type != SUBTILIS_ERROR_OK)
			return;
	}

	/*
	 * We need to update the outputs for the first subsection if
	 * it has any arguments.
	 */

	prv_add_args(&sss->sub_sections[0], arm_s, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	prv_compute_must_save(sss, err);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rax
movq -0x10(%rbp), %rcx
cmpq 0x28(%rcx), %rax
jne 0x89275
movq -0x18(%rbp), %rdi
movl $0xf, %esi
leaq 0x24661(%rip), %rdx     # 0xad8c7
movl $0x16f, %ecx            # imm = 0x16F
callq 0x158e0
jmp 0x89525
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x20(%rbp)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x20(%rbp), %rdx
movq -0x18(%rbp), %rcx
callq 0x89530
movq %rax, -0x50(%rbp)
movq -0x18(%rbp), %rax
cmpl $0x0, (%rax)
je 0x892a8
jmp 0x89525
movq -0x8(%rbp), %rax
movq (%rax), %rax
imulq $0x130, -0x50(%rbp), %rcx # imm = 0x130
addq %rcx, %rax
movq %rax, -0x28(%rbp)
movq $0x0, -0x40(%rbp)
cmpq $-0x1, -0x20(%rbp)
je 0x894c8
movq -0x10(%rbp), %rax
movq 0x38(%rax), %rax
movq (%rax), %rax
imulq $0x68, -0x20(%rbp), %rcx
addq %rcx, %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
cmpl $0x1, (%rax)
jne 0x893c6
movq -0x28(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x30(%rbp), %rax
movq 0x60(%rax), %rdx
movq -0x40(%rbp), %rcx
movq -0x18(%rbp), %r8
callq 0x89660
movq -0x18(%rbp), %rax
cmpl $0x0, (%rax)
je 0x89320
jmp 0x89525
movq $0x0, -0x40(%rbp)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x20(%rbp), %rdx
movq -0x18(%rbp), %rcx
callq 0x89530
movq %rax, -0x50(%rbp)
movq -0x18(%rbp), %rax
cmpl $0x0, (%rax)
je 0x8934f
jmp 0x89525
movq -0x8(%rbp), %rax
movq (%rax), %rax
imulq $0x130, -0x50(%rbp), %rcx # imm = 0x130
addq %rcx, %rax
movq %rax, -0x28(%rbp)
movq -0x30(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rax
movq -0x10(%rbp), %rcx
cmpq 0x10(%rcx), %rax
jb 0x8939e
movq -0x18(%rbp), %rdi
movl $0xf, %esi
leaq 0x24538(%rip), %rdx     # 0xad8c7
movl $0x188, %ecx            # imm = 0x188
callq 0x158e0
jmp 0x89525
movq -0x8(%rbp), %rdi
movq -0x50(%rbp), %rsi
movq -0x48(%rbp), %rdx
movq -0x18(%rbp), %rcx
callq 0x897d0
movq -0x18(%rbp), %rax
cmpl $0x0, (%rax)
je 0x893c1
jmp 0x89525
jmp 0x8949b
movq -0x30(%rbp), %rax
cmpl $0x0, (%rax)
jne 0x89499
movq -0x30(%rbp), %rax
cmpl $0x16, 0x8(%rax)
jne 0x89499
movq -0x30(%rbp), %rax
testb $0x1, 0x14(%rax)
jne 0x89499
movq -0x30(%rbp), %rax
cmpl $0xf, 0x10(%rax)
je 0x89499
movq -0x28(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x20(%rbp), %rdx
movq -0x30(%rbp), %rax
movq 0x20(%rax), %rcx
movq -0x18(%rbp), %r8
callq 0x898d0
movq -0x18(%rbp), %rax
cmpl $0x0, (%rax)
je 0x89428
jmp 0x89525
movq -0x30(%rbp), %rax
cmpq $-0x1, 0x58(%rax)
je 0x89497
movq -0x10(%rbp), %rax
movq 0x38(%rax), %rax
movq (%rax), %rax
movq -0x30(%rbp), %rcx
imulq $0x68, 0x58(%rcx), %rcx
addq %rcx, %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
cmpl $0x1, (%rax)
je 0x89495
movq -0x10(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rsi
movq -0x38(%rbp), %rdx
movq -0x18(%rbp), %rcx
callq 0x709a0
movq -0x18(%rbp), %rax
cmpl $0x0, (%rax)
je 0x8947e
jmp 0x89525
movq -0x10(%rbp), %rax
movq 0x38(%rax), %rax
movq (%rax), %rax
imulq $0x68, -0x20(%rbp), %rcx
addq %rcx, %rax
movq %rax, -0x30(%rbp)
jmp 0x89497
jmp 0x89499
jmp 0x8949b
movq -0x40(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x40(%rbp)
movq -0x20(%rbp), %rax
movq -0x10(%rbp), %rcx
cmpq 0x28(%rcx), %rax
jne 0x894b7
jmp 0x894c8
movq -0x30(%rbp), %rax
movq 0x58(%rax), %rax
movq %rax, -0x20(%rbp)
jmp 0x892c6
cmpq $0x0, -0x40(%rbp)
jbe 0x894f9
movq -0x28(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rdx
movq -0x40(%rbp), %rcx
movq -0x18(%rbp), %r8
callq 0x89660
movq -0x18(%rbp), %rax
cmpl $0x0, (%rax)
je 0x894f7
jmp 0x89525
jmp 0x894f9
movq -0x8(%rbp), %rax
movq (%rax), %rdi
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
callq 0x89ab0
movq -0x18(%rbp), %rax
cmpl $0x0, (%rax)
je 0x89518
jmp 0x89525
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x89bc0
addq $0x50, %rsp
popq %rbp
retq
nopl (%rax,%rax)