// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x90, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movq -0x8(%rbp), %rax
cmpq $0x2, 0x128(%rax)
jb 0x8991c
movq -0x28(%rbp), %rdi
movl $0xf, %esi
leaq 0x23fba(%rip), %rdx     # 0xad8c7
movl $0x6b, %ecx
callq 0x158e0
jmp 0x89a9e
movq -0x10(%rbp), %rax
movq 0x38(%rax), %rax
movq (%rax), %rax
imulq $0x68, -0x18(%rbp), %rcx
addq %rcx, %rax
movq %rax, -0x88(%rbp)
movq -0x10(%rbp), %rdi
leaq -0x78(%rbp), %rsi
leaq -0x80(%rbp), %rdx
callq 0x700a0
leaq -0x70(%rbp), %rdi
callq 0x76fb0
movq -0x8(%rbp), %rax
addq $0x48, %rax
movq -0x8(%rbp), %rdx
movq 0x128(%rdx), %rcx
movq %rcx, %rsi
addq $0x1, %rsi
movq %rsi, 0x128(%rdx)
imulq $0x70, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rdi
callq 0x88790
movq -0x38(%rbp), %rdi
addq $0x18, %rdi
callq 0x88790
movq -0x38(%rbp), %rdi
addq $0x30, %rdi
callq 0x88790
movq -0x38(%rbp), %rdi
addq $0x48, %rdi
callq 0x88790
movq -0x8(%rbp), %rax
cmpq $0x1, 0x128(%rax)
jne 0x89a2f
movq -0x10(%rbp), %rax
movq 0x38(%rax), %rax
movq (%rax), %rax
movq -0x8(%rbp), %rcx
imulq $0x68, 0x8(%rcx), %rcx
addq %rcx, %rax
movq %rax, -0x40(%rbp)
movq -0x10(%rbp), %rdi
movq -0x40(%rbp), %rsi
movq -0x88(%rbp), %rdx
movq -0x78(%rbp), %rcx
movq -0x80(%rbp), %r8
movq -0x28(%rbp), %rax
leaq -0x70(%rbp), %r9
movq %rax, (%rsp)
callq 0x79620
movq -0x28(%rbp), %rax
cmpl $0x0, (%rax)
je 0x89a0b
jmp 0x89a95
movq -0x38(%rbp), %rdi
leaq -0x70(%rbp), %rsi
callq 0x88fc0
movq -0x38(%rbp), %rdi
addq $0x18, %rdi
leaq -0x70(%rbp), %rsi
addq $0x18, %rsi
callq 0x88fc0
jmp 0x89a7d
movq -0x8(%rbp), %rax
addq $0x48, %rax
movq %rax, -0x30(%rbp)
movq -0x38(%rbp), %rdi
movq -0x30(%rbp), %rsi
movq -0x28(%rbp), %rdx
callq 0x88cd0
movq -0x28(%rbp), %rax
cmpl $0x0, (%rax)
je 0x89a57
jmp 0x89a95
movq -0x38(%rbp), %rdi
addq $0x18, %rdi
movq -0x30(%rbp), %rsi
addq $0x18, %rsi
movq -0x28(%rbp), %rdx
callq 0x88cd0
movq -0x28(%rbp), %rax
cmpl $0x0, (%rax)
je 0x89a7b
jmp 0x89a95
jmp 0x89a7d
movq -0x20(%rbp), %rcx
movq -0x38(%rbp), %rax
movq %rcx, 0x60(%rax)
movq -0x18(%rbp), %rcx
movq -0x38(%rbp), %rax
movq %rcx, 0x68(%rax)
leaq -0x70(%rbp), %rdi
callq 0x76fe0
addq $0x90, %rsp
popq %rbp
retq
nopw (%rax,%rax)