// File: /workspace/github_c_makefile_star2_O2/lucvoo[P]sparse-dev/flowgraph.c
// Function: domtree_build
void domtree_build(struct entrypoint *ep)
{
	struct basic_block *entry = ep->entry->bb;
	struct basic_block **doms;
	struct basic_block *bb;
	unsigned int size;
	int max_level = 0;
	int changed;

	// First calculate the (reverse) postorder.
	// This will give use us:
	//	- the links to do a reverse postorder traversal
	//	- the order number for each block
	size = cfg_postorder(ep);

	// initialize the dominators array
	doms = calloc(size, sizeof(*doms));
	assert(entry->postorder_nr == size-1);
	doms[size-1] = entry;

	do {
		struct basic_block *b;

		changed = 0;
		FOR_EACH_PTR(ep->bbs, b) {
			struct basic_block *p;
			int bnr = b->postorder_nr;
			struct basic_block *new_idom = NULL;

			if (b == entry)
				continue;	// ignore entry node

			FOR_EACH_PTR(b->parents, p) {
				unsigned int pnr = p->postorder_nr;
				if (!doms[pnr])
					continue;
				if (!new_idom) {
					new_idom = p;
					continue;
				}

				new_idom = intersect_dom(doms, p, new_idom);
			} END_FOR_EACH_PTR(p);

			assert(new_idom);
			if (doms[bnr] != new_idom) {
				doms[bnr] = new_idom;
				changed = 1;
			}
		} END_FOR_EACH_PTR(b);
	} while (changed);

	FOR_EACH_PTR(ep->bbs, bb) {
		free_ptr_list(&bb->doms);
	} END_FOR_EACH_PTR(bb);

	// set the idom links
	FOR_EACH_PTR(ep->bbs, bb) {
		struct basic_block *idom = doms[bb->postorder_nr];

		if (bb == entry)
			continue;	// ignore entry node

		bb->idom = idom;
		add_bb(&idom->doms, bb);
	} END_FOR_EACH_PTR(bb);
	entry->idom = NULL;

	// set the dominance levels
	FOR_EACH_PTR(ep->bbs, bb) {
		struct basic_block *idom = bb->idom;
		int level = idom ? idom->dom_level + 1 : 0;

		bb->dom_level = level;
		if (max_level < level)
			max_level = level;
	} END_FOR_EACH_PTR(bb);
	ep->dom_levels = max_level + 1;

	free(doms);
	if (dbg_domtree)
		debug_domtree(ep);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdi, %rbx
movq 0x28(%rdi), %rax
movq 0x8(%rax), %r15
callq 0x35fb4
movl %eax, %ebp
movl %eax, %edi
pushq $0x8
popq %rsi
callq 0xe1b0
movq %rax, %r14
movl 0x58(%r15), %eax
decl %ebp
cmpl %ebp, %eax
jne 0x364bd
movq %r15, (%r14,%rax,8)
movq %rbx, (%rsp)
movq 0x18(%rbx), %rbx
testq %rbx, %rbx
je 0x36373
movq $0x0, 0x8(%rsp)
movq %rbx, %rdx
movq %rbx, 0x10(%rsp)
movzwl (%rdx), %esi
movsbl %sil, %eax
testw %ax, %ax
movl $0x0, %ecx
cmovgl %eax, %ecx
movzwl %cx, %edi
xorl %r8d, %r8d
cmpq %rdi, %r8
je 0x362b3
movq 0x18(%rdx,%r8,8), %rax
cmpw $0x100, %si             # imm = 0x100
jb 0x361f9
testq %rax, %rax
je 0x362ab
cmpq %r15, %rax
je 0x362ab
movq 0x18(%rax), %r10
testq %r10, %r10
je 0x3649e
movslq 0x58(%rax), %r9
movq %r10, %r11
xorl %eax, %eax
movzwl (%r11), %ebp
movsbl %bpl, %ecx
testw %cx, %cx
movl $0x0, %ebx
cmovgl %ecx, %ebx
movzwl %bx, %r13d
xorl %r12d, %r12d
cmpq %r13, %r12
je 0x36287
movq 0x18(%r11,%r12,8), %rbx
cmpw $0x100, %bp             # imm = 0x100
jb 0x36248
testq %rbx, %rbx
je 0x36282
movl 0x58(%rbx), %ecx
cmpq $0x0, (%r14,%rcx,8)
je 0x36282
testq %rax, %rax
je 0x3627f
movl 0x58(%rax), %eax
cmpl %eax, %ecx
jne 0x3626a
jmp 0x3627f
movslq %ecx, %rcx
movq (%r14,%rcx,8), %rbx
movl 0x58(%rbx), %ecx
cmpl %eax, %ecx
jl 0x36260
jmp 0x36279
cltq
movq (%r14,%rax,8), %rax
movl 0x58(%rax), %eax
cmpl %ecx, %eax
jl 0x36270
jmp 0x3625a
movq %rbx, %rax
incq %r12
jmp 0x36232
movq 0x10(%r11), %r11
cmpq %r10, %r11
jne 0x36218
testq %rax, %rax
je 0x3649e
cmpq %rax, (%r14,%r9,8)
je 0x362ab
movq %rax, (%r14,%r9,8)
pushq $0x1
popq %rax
movq %rax, 0x8(%rsp)
incq %r8
jmp 0x361db
movq 0x10(%rdx), %rdx
movq 0x10(%rsp), %rbx
cmpq %rbx, %rdx
jne 0x361c3
movq %rbx, %rdx
cmpl $0x0, 0x8(%rsp)
movl $0x0, %eax
movq %rax, 0x8(%rsp)
jne 0x361c3
xorl %r12d, %r12d
movl (%rbx), %eax
movsbq %al, %rcx
cmpq %rcx, %r12
jge 0x36309
movq 0x18(%rbx,%r12,8), %rdi
cmpw $0x100, %ax             # imm = 0x100
jb 0x362fb
testq %rdi, %rdi
je 0x36304
addq $0x40, %rdi
callq 0x1ff30
incq %r12
jmp 0x362e0
movq 0x10(%rbx), %rbx
cmpq 0x10(%rsp), %rbx
jne 0x362dd
movq (%rsp), %rax
movq 0x18(%rax), %rbx
testq %rbx, %rbx
je 0x36373
movq %rbx, %r12
xorl %r13d, %r13d
movl (%r12), %eax
movsbq %al, %rcx
cmpq %rcx, %r13
jge 0x36369
movq 0x18(%r12,%r13,8), %rsi
cmpw $0x100, %ax             # imm = 0x100
setae %al
testq %rsi, %rsi
sete %cl
testb %cl, %al
jne 0x36364
cmpq %r15, %rsi
je 0x36364
movslq 0x58(%rsi), %rax
movq (%r14,%rax,8), %rdi
movq %rdi, 0x30(%rsi)
addq $0x40, %rdi
callq 0x1fae9
incq %r13
jmp 0x36327
movq 0x10(%r12), %r12
cmpq %rbx, %r12
jne 0x36324
andq $0x0, 0x30(%r15)
movq (%rsp), %r12
movq 0x18(%r12), %rcx
testq %rcx, %rcx
je 0x363dd
xorl %eax, %eax
movq %rcx, %rdx
xorl %esi, %esi
movl (%rdx), %r8d
movsbq %r8b, %rdi
cmpq %rdi, %rsi
jge 0x363d0
movq 0x18(%rdx,%rsi,8), %rdi
cmpw $0x100, %r8w            # imm = 0x100
jb 0x363ab
testq %rdi, %rdi
je 0x363cb
movq 0x30(%rdi), %r8
testq %r8, %r8
je 0x363bd
movl 0x3c(%r8), %r8d
incl %r8d
jmp 0x363c0
xorl %r8d, %r8d
movl %r8d, 0x3c(%rdi)
cmpl %r8d, %eax
cmovlel %r8d, %eax
incq %rsi
jmp 0x3638d
movq 0x10(%rdx), %rdx
cmpq %rcx, %rdx
jne 0x3638b
incl %eax
jmp 0x363e0
pushq $0x1
popq %rax
movl %eax, 0x30(%r12)
movq %r14, %rdi
callq 0xe030
leaq 0x2a9b8(%rip), %rax     # 0x60dac
cmpl $0x0, (%rax)
je 0x3648f
movq (%r12), %rax
movq 0x18(%rax), %rdi
callq 0x2936d
leaq 0xe0c5(%rip), %rdi      # 0x444d6
movq %rax, %rsi
xorl %eax, %eax
callq 0xe0f0
movq 0x18(%r12), %rbx
testq %rbx, %rbx
je 0x3648f
leaq 0xe0b7(%rip), %r14      # 0x444e3
movq %rbx, %r13
xorl %ebp, %ebp
movl (%r13), %eax
movsbq %al, %rcx
cmpq %rcx, %rbp
jge 0x36486
movq 0x18(%r13,%rbp,8), %r15
cmpw $0x100, %ax             # imm = 0x100
jb 0x3644e
testq %r15, %r15
je 0x36481
movq 0x28(%r12), %rax
cmpq 0x8(%rax), %r15
je 0x36481
movq %r15, %rdi
callq 0x11a05
movq %rax, %r12
movq 0x30(%r15), %rdi
callq 0x11a05
movq %r14, %rdi
movq %r12, %rsi
movq (%rsp), %r12
movq %rax, %rdx
xorl %eax, %eax
callq 0xe0f0
incq %rbp
jmp 0x36431
movq 0x10(%r13), %r13
cmpq %rbx, %r13
jne 0x3642f
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xe004(%rip), %rdi      # 0x444a9
leaq 0xdfc9(%rip), %rsi      # 0x44475
leaq 0xdfce(%rip), %rcx      # 0x44481
movl $0xa1, %edx
callq 0xe120
leaq 0xdf93(%rip), %rdi      # 0x44457
leaq 0xdfaa(%rip), %rsi      # 0x44475
leaq 0xdfaf(%rip), %rcx      # 0x44481
movl $0x86, %edx
callq 0xe120