// File: /workspace/github_c_makefile_star2_O1/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %rdx, %rax
movq 0x20(%rsi), %r12
cmpq 0x28(%rsi), %r12
jne 0x5e0c2
leaq 0x18885(%rip), %rdx     # 0x76927
movq %rax, %rdi
movl $0xf, %esi
movl $0x16f, %ecx            # imm = 0x16F
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x145f4
movq %rsi, %r15
movq %rdi, 0x18(%rsp)
movq %r12, %rsi
movq %rax, %rdx
movq %rax, 0x10(%rsp)
callq 0x5e5c4
movq 0x10(%rsp), %r8
cmpl $0x0, (%r8)
je 0x5e0f4
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
imulq $0x130, %rax, %rdi      # imm = 0x130
movq 0x18(%rsp), %rax
addq (%rax), %rdi
xorl %ebp, %ebp
cmpq $-0x1, %r12
je 0x5e302
movq 0x38(%r15), %rax
movq (%rax), %r14
imulq $0x68, %r12, %rcx
leaq (%r14,%rcx), %rbx
movl (%r14,%rcx), %eax
testl %eax, %eax
je 0x5e224
cmpl $0x1, %eax
jne 0x5e2ef
movq %rcx, 0x20(%rsp)
movq 0x60(%rbx), %rdx
movq %r15, %rsi
movq %rbp, %rcx
movq 0x10(%rsp), %r8
callq 0x5e682
movq 0x10(%rsp), %rdx
cmpl $0x0, (%rdx)
jne 0x5e0e5
movq 0x18(%rsp), %rdi
movq %r12, %rsi
callq 0x5e5c4
movq 0x10(%rsp), %r8
cmpl $0x0, (%r8)
jne 0x5e0e5
movq 0x8(%rbx), %rbx
cmpq 0x10(%r15), %rbx
jae 0x5e5ab
movq %rax, %rbp
imulq $0x130, %rax, %rdi      # imm = 0x130
movq 0x18(%rsp), %r13
addq (%r13), %rdi
cmpq %rbx, 0x20(%r13)
ja 0x5e201
movq %rdi, 0x28(%rsp)
movq 0x28(%r13), %rdi
leaq 0x80(,%rbx,8), %rsi
callq 0x12210
testq %rax, %rax
je 0x5e2b8
leaq 0x10(%rbx), %rsi
movq 0x20(%r13), %rcx
movq %rsi, %rdx
subq %rcx, %rdx
jbe 0x5e1ef
leaq (%rax,%rcx,8), %rdi
shlq $0x3, %rdx
movq %rsi, 0x30(%rsp)
movl $0xff, %esi
movq %rax, %r13
callq 0x12140
movq 0x30(%rsp), %rsi
movq %r13, %rax
movq 0x18(%rsp), %r13
movq %rax, 0x28(%r13)
movq %rsi, 0x20(%r13)
movq 0x10(%rsp), %r8
movq 0x28(%rsp), %rdi
movq 0x28(%r13), %rax
movq %rbp, (%rax,%rbx,8)
cmpq %rbx, 0x18(%r13)
ja 0x5e2de
incq %rbx
movq 0x18(%rsp), %rax
movq %rbx, 0x18(%rax)
jmp 0x5e2de
cmpl $0x16, 0x8(%rbx)
jne 0x5e2ef
cmpb $0x0, 0x14(%rbx)
jne 0x5e2ef
cmpl $0xf, 0x10(%rbx)
je 0x5e2ef
movq %rcx, 0x20(%rsp)
movq 0x20(%rbx), %rcx
movq %rdi, %r13
movq %r15, %rsi
movq %r12, %rdx
movq 0x10(%rsp), %r8
callq 0x5e784
movq 0x10(%rsp), %r8
cmpl $0x0, (%r8)
jne 0x5e0e5
movq %r13, %rdi
movq 0x58(%rbx), %rax
cmpq $-0x1, %rax
je 0x5e2ea
movq 0x38(%r15), %rcx
movq (%rcx), %rdx
imulq $0x68, %rax, %rax
cmpl $0x1, (%rdx,%rax)
je 0x5e2ea
addq %rax, %rdx
movq 0x10(%r15), %rsi
movq %r15, %rdi
movq %r8, %rcx
callq 0x4f649
movq 0x10(%rsp), %r8
cmpl $0x0, (%r8)
jne 0x5e0e5
movq %r13, %rdi
movq 0x38(%r15), %rax
movq (%rax), %r14
jmp 0x5e2ea
movq 0x10(%rsp), %rbx
movq %rbx, %rdi
movl $0x1, %esi
leaq 0x1865b(%rip), %rdx     # 0x76927
movl $0x52, %ecx
callq 0x145f4
movq %rbx, %r8
movq 0x28(%rsp), %rdi
cmpl $0x0, (%r8)
jne 0x5e0e5
xorl %ebp, %ebp
movq 0x20(%rsp), %rcx
incq %rbp
cmpq 0x28(%r15), %r12
je 0x5e302
movq 0x58(%r14,%rcx), %r12
jmp 0x5e105
testq %rbp, %rbp
je 0x5e32a
movq 0x28(%r15), %rdx
movq %r15, %rsi
movq %rbp, %rcx
movq 0x10(%rsp), %r8
callq 0x5e682
movq 0x10(%rsp), %r8
cmpl $0x0, (%r8)
jne 0x5e0e5
movq 0x18(%rsp), %rax
movq (%rax), %r14
cmpq $0x0, 0x128(%r14)
je 0x5e3ea
leaq 0x48(%r14), %r13
xorl %ebp, %ebp
imulq $0x70, %rbp, %r12
addq %r13, %r12
movq 0xa0(%r15), %rax
cmpq $0x0, 0x158(%rax)
je 0x5e38d
xorl %ebx, %ebx
leaq 0x10(%rbx), %rsi
movq %r12, %rdi
movq %r8, %rdx
callq 0x5db60
movq 0x10(%rsp), %r8
cmpl $0x0, (%r8)
jne 0x5e3ea
incq %rbx
movq 0xa0(%r15), %rax
cmpq 0x158(%rax), %rbx
jb 0x5e360
movq 0xa0(%r15), %rax
cmpq $0x0, 0x160(%rax)
je 0x5e3da
addq $0x18, %r12
xorl %ebx, %ebx
movq 0xc0(%r15), %rax
movq (%rax), %rsi
addq %rbx, %rsi
movq %r12, %rdi
movq %r8, %rdx
callq 0x5db60
movq 0x10(%rsp), %r8
cmpl $0x0, (%r8)
jne 0x5e3ea
incq %rbx
movq 0xa0(%r15), %rax
cmpq 0x160(%rax), %rbx
jb 0x5e3a4
incq %rbp
cmpq 0x128(%r14), %rbp
jb 0x5e346
cmpl $0x0, (%r8)
jne 0x5e0e5
movq 0x18(%rsp), %rax
cmpq $0x0, 0x8(%rax)
je 0x5e0e5
movq 0x18(%rsp), %rax
leaq 0x30(%rax), %rcx
movq %rcx, 0x28(%rsp)
addq $0x48, %rax
movq %rax, 0x38(%rsp)
movl $0x78, %eax
movq %rax, 0x20(%rsp)
xorl %ebp, %ebp
leaq 0x40(%rsp), %r13
movq 0x18(%rsp), %rax
movq (%rax), %r12
imulq $0x130, %rbp, %r14      # imm = 0x130
cmpq $0x0, 0x128(%r12,%r14)
je 0x5e58b
addq %r12, %r14
addq 0x20(%rsp), %r12
xorl %r15d, %r15d
cmpq %r15, 0x128(%r14)
jbe 0x5e50b
movq %r13, %rdi
callq 0x5db30
movq 0x30(%r12), %rsi
movq 0x18(%rsp), %rax
cmpq 0x18(%rax), %rsi
jae 0x5e529
movq %r13, %rdi
movq 0x10(%rsp), %rbx
movq %rbx, %rdx
callq 0x5db60
cmpl $0x0, (%rbx)
jne 0x5e544
movq 0x18(%rsp), %rdi
movq 0x28(%rdi), %rax
movq 0x30(%r12), %rcx
movq (%rax,%rcx,8), %rax
cmpq $-0x1, %rax
je 0x5e573
leaq -0x30(%r12), %rdx
imulq $0x130, %rax, %rsi      # imm = 0x130
addq (%rdi), %rsi
leaq 0x18(%r12), %r8
movq 0x10(%rsp), %rbx
movq %rbx, (%rsp)
movq %r12, %rcx
movq %r8, 0x30(%rsp)
movq %r13, %r9
callq 0x5eaf2
movq 0x28(%rsp), %rdi
movq %r12, %rsi
movq %rbx, %rdx
callq 0x5dd9c
cmpl $0x0, (%rbx)
jne 0x5e544
movq 0x38(%rsp), %rdi
movq 0x30(%rsp), %rsi
movq 0x10(%rsp), %rdx
callq 0x5dd9c
jmp 0x5e544
movq %r8, %rdi
movl $0xf, %esi
leaq 0x1840d(%rip), %rdx     # 0x76927
movl $0x12c, %ecx            # imm = 0x12C
movq %r8, %rbx
callq 0x145f4
jmp 0x5e551
movq 0x10(%rsp), %rdi
movl $0xf, %esi
leaq 0x183ed(%rip), %rdx     # 0x76927
movl $0x134, %ecx            # imm = 0x134
callq 0x145f4
movq %r13, %rdi
callq 0x5df40
movq 0x10(%rsp), %rbx
cmpl $0x0, (%rbx)
jne 0x5e0e5
movq %rbx, %r8
incq %r15
addq $0x70, %r12
cmpq 0x128(%r14), %r15
jb 0x5e455
jmp 0x5e58b
movq 0x10(%rsp), %rdi
movl $0xf, %esi
leaq 0x183a3(%rip), %rdx     # 0x76927
movl $0x13d, %ecx            # imm = 0x13D
jmp 0x5e53f
incq %rbp
addq $0x130, 0x20(%rsp)      # imm = 0x130
movq 0x18(%rsp), %rax
cmpq 0x8(%rax), %rbp
jb 0x5e42c
jmp 0x5e0e5
leaq 0x18375(%rip), %rdx     # 0x76927
movq %r8, %rdi
movl $0xf, %esi
movl $0x188, %ecx            # imm = 0x188
jmp 0x5e0af