// File: /workspace/github_c_makefile_star2_O3/markdryan[P]subtilis/arch/arm32/arm_sub_section.c
// Function: prv_add_link
static void prv_add_link(subtilis_arm_ss_t *ss, subtilis_arm_section_t *arm_s,
			 size_t ptr, size_t label, subtilis_error_t *err)
{
	subtilis_arm_ss_link_t *first_link;
	subtilis_arm_ss_link_t *link;
	subtilis_arm_op_t *from;
	subtilis_regs_used_virt_t regs_used;
	size_t max_int_regs;
	size_t max_real_regs;
	subtilis_arm_op_t *to;

	if (ss->num_links >= 2) {
		subtilis_error_set_assertion_failed(err);
		return;
	}

	to = &arm_s->op_pool->ops[ptr];
	subtilis_arm_section_max_regs(arm_s, &max_int_regs, &max_real_regs);
	subtilis_regs_used_virt_init(&regs_used);

	link = &ss->links[ss->num_links++];
	subtilis_bitset_init(&link->int_outputs);
	subtilis_bitset_init(&link->real_outputs);
	subtilis_bitset_init(&link->int_save);
	subtilis_bitset_init(&link->real_save);

	/*
	 * If the basic block has two links, the block essentially ends with
	 * conditional branch.  This branch will be followed by a label but
	 * this label doesn't affect the inputs of outputs.  Thus the inputs
	 * and outputs for both links will be identical.  There's no need to
	 * compute them twice, particularly as this is one of the most expensive
	 * parts of the compilation.
	 */

	if (ss->num_links == 1) {
		from = &arm_s->op_pool->ops[ss->start];
		subtilis_arm_regs_used_before_from_tov(
		    arm_s, from, to, max_int_regs, max_real_regs, &regs_used,
		    err);
		if (err->type != SUBTILIS_ERROR_OK)
			goto cleanup;
		subtilis_bitset_claim(&link->int_outputs, &regs_used.int_regs);
		subtilis_bitset_claim(&link->real_outputs,
				      &regs_used.real_regs);
	} else {
		first_link = &ss->links[0];
		subtilis_bitset_or(&link->int_outputs, &first_link->int_outputs,
				   err);
		if (err->type != SUBTILIS_ERROR_OK)
			goto cleanup;
		subtilis_bitset_or(&link->real_outputs,
				   &first_link->real_outputs, err);
		if (err->type != SUBTILIS_ERROR_OK)
			goto cleanup;
	}

	link->link = label;
	link->op = ptr;

cleanup:

	subtilis_regs_used_virt_free(&regs_used);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movq %r8, %r15
cmpq $0x2, 0x128(%rdi)
jb 0x5e7d6
leaq 0x181b1(%rip), %rdx     # 0x76967
movq %r15, %rdi
movl $0xf, %esi
movl $0x6b, %ecx
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x145a4
movq %rsi, %r14
movq %rdi, %r13
movq %rcx, 0x20(%rsp)
movq %rdx, 0x18(%rsp)
movq 0x38(%rsi), %rax
movq (%rax), %rbx
leaq 0x30(%rsp), %rsi
leaq 0x28(%rsp), %rdx
movq %r14, %rdi
callq 0x4f0be
leaq 0x38(%rsp), %rdi
callq 0x52d50
movq 0x128(%r13), %rax
leaq 0x1(%rax), %rcx
movq %rcx, 0x128(%r13)
imulq $0x70, %rax, %rbp
leaq 0x48(,%rbp), %r12
addq %r13, %r12
movq %r12, %rdi
callq 0x5db38
leaq 0x60(,%rbp), %rdi
addq %r13, %rdi
movq %rdi, 0x10(%rsp)
callq 0x5db38
leaq 0x78(,%rbp), %rdi
addq %r13, %rdi
callq 0x5db38
leaq 0x90(,%rbp), %rdi
addq %r13, %rdi
callq 0x5db38
cmpq $0x1, 0x128(%r13)
jne 0x5e8cb
movq 0x18(%rsp), %rbp
imulq $0x68, %rbp, %rax
addq %rax, %rbx
movq 0x38(%r14), %rax
imulq $0x68, 0x8(%r13), %rsi
addq (%rax), %rsi
movq 0x30(%rsp), %rcx
movq 0x28(%rsp), %r8
movq %r15, (%rsp)
leaq 0x38(%rsp), %r9
movq %r14, %rdi
movq %rbx, %rdx
callq 0x5496f
cmpl $0x0, (%r15)
jne 0x5e90e
leaq 0x38(%rsp), %rsi
movq %r12, %rdi
callq 0x5df13
leaq 0x50(%rsp), %rsi
movq 0x10(%rsp), %rdi
callq 0x5df13
jmp 0x5e8ff
leaq 0x48(%r13), %rsi
movq %r12, %rdi
movq %r15, %rdx
callq 0x5dd9f
cmpl $0x0, (%r15)
movq 0x18(%rsp), %rbp
jne 0x5e90e
addq $0x60, %r13
movq 0x10(%rsp), %rdi
movq %r13, %rsi
movq %r15, %rdx
callq 0x5dd9f
cmpl $0x0, (%r15)
jne 0x5e90e
movq 0x20(%rsp), %rax
movq %rax, 0x60(%r12)
movq %rbp, 0x68(%r12)
leaq 0x38(%rsp), %rdi
callq 0x52d66
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq