// File: /workspace/github_c_makefile_star2_O2/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 0x35b40
leaq 0x2b3f8(%rip), %r12     # 0x60d74
movq %r15, %r13
xorl %ebp, %ebp
movsbq (%r13), %rax
cmpq %rax, %rbp
jge 0x35b33
movq 0x18(%r13,%rbp,8), %rbx
testq %rbx, %rbx
je 0x35b2b
movq 0x28(%rbx), %rax
testq %rax, %rax
je 0x35a5e
movq %rax, %rcx
movzwl (%rcx), %edx
movsbl %dl, %esi
testw %si, %si
movl $0x0, %edi
cmovgl %esi, %edi
movzwl %di, %edi
xorl %r8d, %r8d
cmpq %r8, %rdi
je 0x359f7
movq 0x18(%rcx,%r8,8), %rsi
cmpw $0x100, %dx             # imm = 0x100
jb 0x359da
testq %rsi, %rsi
je 0x359f2
cmpq $0x0, 0x8(%rsi)
je 0x359f2
movl (%rsi), %r9d
andl $0x7f, %r9d
leal -0x4b(%r9), %r10d
cmpl $0x2, %r10d
jae 0x35a02
incq %r8
jmp 0x359c4
movq 0x10(%rcx), %rcx
cmpq %rax, %rcx
jne 0x359ad
jmp 0x35a5e
leal -0x3(%r9), %eax
cmpl $0x1, %eax
ja 0x35a5e
movq 0x38(%rsi), %r14
cmpl $0x4, %r9d
jne 0x35a2a
movq 0x30(%rsi), %rax
cmpl $0x6, 0x4(%rax)
jne 0x35a5e
cmpq $0x0, 0x18(%rax)
jne 0x35a2a
movq 0x40(%rsi), %r14
movq 0x18(%rbx), %rdi
callq 0x1f919
testq %rax, %rax
je 0x35a4c
movq %rax, %rdi
movq %rbx, %rsi
movq %r14, %rdx
callq 0x35e7e
testl %eax, %eax
jne 0x35a2a
jmp 0x35a5e
testq %r14, %r14
je 0x35a5e
movq %rbx, %rdi
callq 0x34e6e
jmp 0x35b2b
movq 0x18(%rbx), %rax
testq %rax, %rax
je 0x35b2b
xorl %edi, %edi
movq %rax, %rcx
movzwl (%rcx), %edx
movsbl %dl, %esi
testw %si, %si
movl $0x0, %r8d
cmovgl %esi, %r8d
movzwl %r8w, %esi
xorl %r8d, %r8d
cmpq %r8, %rsi
je 0x35ab4
movq 0x18(%rcx,%r8,8), %r9
cmpw $0x100, %dx             # imm = 0x100
jb 0x35aa0
testq %r9, %r9
je 0x35aaf
testq %rdi, %rdi
je 0x35aac
cmpq %r9, %rdi
je 0x35aaf
jmp 0x35b2b
movq %r9, %rdi
incq %r8
jmp 0x35a8a
movq 0x10(%rcx), %rcx
cmpq %rax, %rcx
jne 0x35a70
testq %rdi, %rdi
je 0x35b2b
cmpq %rbx, %rdi
je 0x35b2b
movq 0x20(%rdi), %rax
testq %rax, %rax
je 0x35b1f
movq %rax, %rcx
movzwl (%rcx), %edx
movsbl %dl, %esi
testw %si, %si
movl $0x0, %r8d
cmovgl %esi, %r8d
movzwl %r8w, %esi
xorl %r8d, %r8d
cmpq %r8, %rsi
je 0x35b16
cmpw $0x100, %dx             # imm = 0x100
setae %r10b
movq 0x18(%rcx,%r8,8), %r9
testq %r9, %r9
sete %r11b
incq %r8
testb %r11b, %r10b
jne 0x35aed
cmpq %rbx, %r9
je 0x35aed
jmp 0x35b2b
movq 0x10(%rcx), %rcx
cmpq %rax, %rcx
jne 0x35ad3
movq %rbx, %rsi
callq 0x3568c
orl %eax, (%r12)
incq %rbp
jmp 0x35981
movq 0x10(%r13), %r13
cmpq %r15, %r13
jne 0x3597f
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq