// File: /workspace/github_c_makefile_star2_O3/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, %rbx
movq 0x20(%rsi), %r12
cmpq 0x28(%rsi), %r12
jne 0x5e0ca
leaq 0x188bd(%rip), %rdx     # 0x76967
movq %rbx, %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 0x145a4
movq %rsi, %r15
movq %rdi, 0x18(%rsp)
movq %r12, %rsi
movq %rbx, %rdx
callq 0x5e5cd
movq %rbx, 0x10(%rsp)
cmpl $0x0, (%rbx)
je 0x5e0f6
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
cmpq $-0x1, %r12
je 0x5e339
imulq $0x130, %rax, %r14      # imm = 0x130
movq 0x18(%rsp), %rax
addq (%rax), %r14
xorl %r13d, %r13d
movq 0x38(%r15), %rax
movq (%rax), %rbp
imulq $0x68, %r12, %rcx
leaq (%rcx,%rbp), %rbx
movl (%rbp,%rcx), %eax
testl %eax, %eax
je 0x5e1ae
cmpl $0x1, %eax
jne 0x5e2f9
movq %rcx, 0x20(%rsp)
movq 0x60(%rbx), %rdx
movq %r14, %rdi
movq %r15, %rsi
movq %r13, %rcx
movq 0x10(%rsp), %r13
movq %r13, %r8
callq 0x5e692
cmpl $0x0, (%r13)
jne 0x5e0e7
movq 0x18(%rsp), %rdi
movq %r12, %rsi
movq 0x10(%rsp), %r14
movq %r14, %rdx
callq 0x5e5cd
cmpl $0x0, (%r14)
jne 0x5e0e7
movq 0x8(%rbx), %rbx
cmpq 0x10(%r15), %rbx
jae 0x5e5b2
movq %rax, %r13
imulq $0x130, %rax, %r14      # imm = 0x130
movq 0x18(%rsp), %rcx
addq (%rcx), %r14
cmpq %rbx, 0x20(%rcx)
jbe 0x5e24e
movq 0x28(%rcx), %rax
jmp 0x5e2b0
cmpl $0x16, 0x8(%rbx)
jne 0x5e2f9
cmpb $0x0, 0x14(%rbx)
jne 0x5e2f9
cmpl $0xf, 0x10(%rbx)
je 0x5e2f9
movq %rcx, 0x20(%rsp)
movq 0x20(%rbx), %rcx
movq %r14, %rdi
movq %r15, %rsi
movq %r12, %rdx
movq %r14, 0x28(%rsp)
movq 0x10(%rsp), %r14
movq %r14, %r8
callq 0x5e794
cmpl $0x0, (%r14)
movq 0x28(%rsp), %r14
jne 0x5e0e7
movq 0x58(%rbx), %rax
cmpq $-0x1, %rax
je 0x5e2f4
movq 0x38(%r15), %rcx
movq (%rcx), %rdx
imulq $0x68, %rax, %rax
cmpl $0x1, (%rdx,%rax)
je 0x5e2f4
addq %rax, %rdx
movq 0x10(%r15), %rsi
movq %r15, %rdi
movq 0x10(%rsp), %rbx
movq %rbx, %rcx
callq 0x4f5f6
cmpl $0x0, (%rbx)
jne 0x5e0e7
movq 0x38(%r15), %rax
movq (%rax), %rbp
jmp 0x5e2f4
movq %r14, 0x28(%rsp)
movq 0x28(%rcx), %rdi
leaq 0x80(,%rbx,8), %rsi
movq %rcx, %r14
callq 0x12210
testq %rax, %rax
je 0x5e2c3
leaq 0x10(%rbx), %rsi
movq 0x20(%r14), %rcx
movq %rsi, %rdx
subq %rcx, %rdx
jbe 0x5e29e
leaq (%rax,%rcx,8), %rdi
shlq $0x3, %rdx
movq %rsi, 0x30(%rsp)
movl $0xff, %esi
movq %rax, %r14
callq 0x12140
movq 0x30(%rsp), %rsi
movq %r14, %rax
movq 0x18(%rsp), %rcx
movq %rax, 0x28(%rcx)
movq %rsi, 0x20(%rcx)
movq 0x28(%rsp), %r14
movq %r13, (%rax,%rbx,8)
cmpq %rbx, 0x18(%rcx)
ja 0x5e2e3
incq %rbx
movq %rbx, 0x18(%rcx)
jmp 0x5e2e3
movq 0x10(%rsp), %rdi
movl $0x1, %esi
leaq 0x18693(%rip), %rdx     # 0x76967
movl $0x52, %ecx
callq 0x145a4
movq 0x28(%rsp), %r14
movq 0x10(%rsp), %rax
cmpl $0x0, (%rax)
jne 0x5e0e7
xorl %r13d, %r13d
movq 0x20(%rsp), %rcx
incq %r13
cmpq 0x28(%r15), %r12
je 0x5e311
movq 0x58(%rbp,%rcx), %r12
cmpq $-0x1, %r12
jne 0x5e112
testq %r13, %r13
je 0x5e339
movq 0x28(%r15), %rdx
movq %r14, %rdi
movq %r15, %rsi
movq %r13, %rcx
movq 0x10(%rsp), %rbx
movq %rbx, %r8
callq 0x5e692
cmpl $0x0, (%rbx)
jne 0x5e0e7
movq 0x18(%rsp), %rax
movq (%rax), %r14
cmpq $0x0, 0x128(%r14)
je 0x5e406
leaq 0x48(%r14), %rcx
movq 0xa0(%r15), %rax
xorl %ebp, %ebp
movq %rcx, 0x20(%rsp)
imulq $0x70, %rbp, %r12
addq %rcx, %r12
cmpq $0x0, 0x158(%rax)
je 0x5e3a6
xorl %ebx, %ebx
leaq 0x10(%rbx), %rsi
movq %r12, %rdi
movq 0x10(%rsp), %r13
movq %r13, %rdx
callq 0x5db68
cmpl $0x0, (%r13)
jne 0x5e0e7
incq %rbx
movq 0xa0(%r15), %rax
cmpq 0x158(%rax), %rbx
jb 0x5e374
cmpq $0x0, 0x160(%rax)
je 0x5e3f1
addq $0x18, %r12
xorl %ebx, %ebx
movq 0xc0(%r15), %rax
movq (%rax), %rsi
addq %rbx, %rsi
movq %r12, %rdi
movq 0x10(%rsp), %r13
movq %r13, %rdx
callq 0x5db68
cmpl $0x0, (%r13)
jne 0x5e0e7
incq %rbx
movq 0xa0(%r15), %rax
cmpq 0x160(%rax), %rbx
jb 0x5e3b6
incq %rbp
cmpq 0x128(%r14), %rbp
movq 0x20(%rsp), %rcx
jb 0x5e361
movq 0x18(%rsp), %rax
movq 0x8(%rax), %rax
testq %rax, %rax
je 0x5e0e7
movq 0x18(%rsp), %rcx
leaq 0x30(%rcx), %rdx
movq %rdx, 0x28(%rsp)
addq $0x48, %rcx
movq %rcx, 0x38(%rsp)
movl $0x78, %ecx
movq %rcx, 0x20(%rsp)
xorl %ebp, %ebp
leaq 0x40(%rsp), %r13
movq 0x18(%rsp), %rcx
movq (%rcx), %r12
imulq $0x130, %rbp, %r14      # imm = 0x130
movq 0x128(%r12,%r14), %rcx
testq %rcx, %rcx
je 0x5e598
addq %r12, %r14
addq 0x20(%rsp), %r12
xorl %r15d, %r15d
cmpq %r15, %rcx
jbe 0x5e516
movq %r13, %rdi
callq 0x5db38
movq 0x30(%r12), %rsi
movq 0x18(%rsp), %rax
cmpq 0x18(%rax), %rsi
movq 0x10(%rsp), %rbx
jae 0x5e536
movq %r13, %rdi
movq %rbx, %rdx
callq 0x5db68
cmpl $0x0, (%rbx)
jne 0x5e54f
movq 0x18(%rsp), %rdi
movq 0x28(%rdi), %rax
movq 0x30(%r12), %rcx
movq (%rax,%rcx,8), %rax
cmpq $-0x1, %rax
je 0x5e579
leaq -0x30(%r12), %rdx
imulq $0x130, %rax, %rsi      # imm = 0x130
addq (%rdi), %rsi
leaq 0x18(%r12), %r8
movq %rbx, (%rsp)
movq %r12, %rcx
movq %r8, 0x30(%rsp)
movq %r13, %r9
callq 0x5eb08
movq 0x28(%rsp), %rdi
movq %r12, %rsi
movq %rbx, %rdx
callq 0x5dd9f
cmpl $0x0, (%rbx)
jne 0x5e54f
movq 0x38(%rsp), %rdi
movq 0x30(%rsp), %rsi
movq %rbx, %rdx
callq 0x5dd9f
jmp 0x5e54f
movq 0x10(%rsp), %rbx
movq %rbx, %rdi
movl $0xf, %esi
leaq 0x1843d(%rip), %rdx     # 0x76967
movl $0x12c, %ecx            # imm = 0x12C
callq 0x145a4
jmp 0x5e557
movq %rbx, %rdi
movl $0xf, %esi
leaq 0x18422(%rip), %rdx     # 0x76967
movl $0x134, %ecx            # imm = 0x134
callq 0x145a4
movq %r13, %rdi
callq 0x5df52
cmpl $0x0, (%rbx)
jne 0x5e0e7
incq %r15
movq 0x128(%r14), %rcx
addq $0x70, %r12
cmpq %rcx, %r15
jb 0x5e46b
jmp 0x5e58f
movq %rbx, %rdi
movl $0xf, %esi
leaq 0x183df(%rip), %rdx     # 0x76967
movl $0x13d, %ecx            # imm = 0x13D
jmp 0x5e54a
movq 0x18(%rsp), %rax
movq 0x8(%rax), %rax
incq %rbp
addq $0x130, 0x20(%rsp)      # imm = 0x130
cmpq %rax, %rbp
jb 0x5e440
jmp 0x5e0e7
leaq 0x183ae(%rip), %rdx     # 0x76967
movq 0x10(%rsp), %rdi
movl $0xf, %esi
movl $0x188, %ecx            # imm = 0x188
jmp 0x5e0b7