// File: /workspace/github_c_makefile_star2_O3/lucvoo[P]sparse-dev/flow.c
// Function: pack_basic_blocks
void pack_basic_blocks(struct entrypoint *ep)
{
	struct basic_block *bb;

	/* See if we can merge a bb into another one.. */
	FOR_EACH_PTR(ep->bbs, bb) {
		struct instruction *first;
		struct basic_block *parent, *child, *last;

		if (!bb_reachable(bb))
			continue;

		/*
		 * Just a branch?
		 */
		FOR_EACH_PTR(bb->insns, first) {
			if (!first->bb)
				continue;
			switch (first->opcode) {
			case OP_NOP:
			case OP_INLINED_CALL:
				continue;
			case OP_CBR:
			case OP_BR: {
				struct basic_block *replace;
				replace = rewrite_branch_bb(bb, first);
				if (replace) {
					kill_bb(bb);
					goto no_merge;
				}
			}
			/* fallthrough */
			default:
				goto out;
			}
		} END_FOR_EACH_PTR(first);

out:
		/*
		 * See if we only have one parent..
		 */
		last = NULL;
		FOR_EACH_PTR(bb->parents, parent) {
			if (last) {
				if (last != parent)
					goto no_merge;
				continue;
			}
			last = parent;
		} END_FOR_EACH_PTR(parent);

		parent = last;
		if (!parent || parent == bb)
			continue;

		/*
		 * Goodie. See if the parent can merge..
		 */
		FOR_EACH_PTR(parent->children, child) {
			if (child != bb)
				goto no_merge;
		} END_FOR_EACH_PTR(child);

		repeat_phase |= merge_bb(parent, bb);

	no_merge:
		/* nothing to do */;
	} END_FOR_EACH_PTR(bb);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq 0x18(%rdi), %r15
testq %r15, %r15
je 0x3c62b
leaq 0x2a906(%rip), %r12     # 0x66d74
movq %r15, %r13
cmpb $0x0, (%r13)
jle 0x3c61e
xorl %ebp, %ebp
movq 0x18(%r13,%rbp,8), %rbx
testq %rbx, %rbx
je 0x3c60d
movq 0x28(%rbx), %rax
testq %rax, %rax
je 0x3c54b
movq %rax, %rcx
movzwl (%rcx), %edx
movsbl %dl, %esi
testw %si, %si
jle 0x3c4e4
movzwl %si, %edi
xorl %r8d, %r8d
movzwl %dx, %r9d
movq 0x18(%rcx,%r8,8), %rsi
cmpl $0x100, %r9d            # imm = 0x100
jb 0x3c4c4
testq %rsi, %rsi
je 0x3c4dc
cmpq $0x0, 0x8(%rsi)
je 0x3c4dc
movl (%rsi), %r9d
andl $0x7f, %r9d
leal -0x4b(%r9), %r10d
cmpl $0x2, %r10d
jae 0x3c4ef
incq %r8
cmpq %r8, %rdi
jne 0x3c4ad
movq 0x10(%rcx), %rcx
cmpq %rax, %rcx
jne 0x3c49c
jmp 0x3c54b
leal -0x3(%r9), %eax
cmpl $0x1, %eax
ja 0x3c54b
movq 0x38(%rsi), %r14
cmpl $0x4, %r9d
jne 0x3c517
movq 0x30(%rsi), %rax
cmpl $0x6, 0x4(%rax)
jne 0x3c54b
cmpq $0x0, 0x18(%rax)
jne 0x3c517
movq 0x40(%rsi), %r14
movq 0x18(%rbx), %rdi
callq 0x225b0
testq %rax, %rax
je 0x3c539
movq %rax, %rdi
movq %rbx, %rsi
movq %r14, %rdx
callq 0x3c98d
testl %eax, %eax
jne 0x3c517
jmp 0x3c54b
testq %r14, %r14
je 0x3c54b
movq %rbx, %rdi
callq 0x3b83b
jmp 0x3c60d
movq 0x18(%rbx), %rax
testq %rax, %rax
je 0x3c60d
xorl %edi, %edi
movq %rax, %rcx
movzwl (%rcx), %esi
movsbl %sil, %edx
testw %dx, %dx
jle 0x3c59b
movzwl %dx, %edx
movzwl %si, %esi
xorl %r8d, %r8d
movq 0x18(%rcx,%r8,8), %r9
cmpl $0x100, %esi            # imm = 0x100
jb 0x3c584
testq %r9, %r9
je 0x3c593
testq %rdi, %rdi
je 0x3c590
cmpq %r9, %rdi
je 0x3c593
jmp 0x3c60d
movq %r9, %rdi
incq %r8
cmpq %r8, %rdx
jne 0x3c572
movq 0x10(%rcx), %rcx
cmpq %rax, %rcx
jne 0x3c55d
testq %rdi, %rdi
je 0x3c60d
cmpq %rbx, %rdi
je 0x3c60d
movq 0x20(%rdi), %rax
testq %rax, %rax
je 0x3c601
movq %rax, %rcx
movzwl (%rcx), %edx
movsbl %dl, %esi
testw %si, %si
jle 0x3c5f8
movzwl %si, %esi
xorl %r8d, %r8d
movzwl %dx, %r9d
cmpl $0x100, %r9d            # imm = 0x100
setae %r10b
movq 0x18(%rcx,%r8,8), %r9
testq %r9, %r9
sete %r11b
testb %r11b, %r10b
jne 0x3c5f0
cmpq %rbx, %r9
jne 0x3c60d
incq %r8
cmpq %r8, %rsi
jne 0x3c5cb
movq 0x10(%rcx), %rcx
cmpq %rax, %rcx
jne 0x3c5ba
movq %rbx, %rsi
callq 0x3c142
orl %eax, (%r12)
incq %rbp
movsbq (%r13), %rax
cmpq %rax, %rbp
jl 0x3c47e
movq 0x10(%r13), %r13
cmpq %r15, %r13
jne 0x3c471
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq