// File: /workspace/github_c_makefile_star2_O3/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 0x3cad4
movl %eax, %ebp
movl %eax, %edi
movl $0x8, %esi
callq 0xe1b0
movq %rax, %r14
movl 0x58(%r15), %eax
decl %ebp
cmpl %ebp, %eax
jne 0x3d03f
movq %r15, (%r14,%rax,8)
movq %rbx, (%rsp)
movq 0x18(%rbx), %rbx
testq %rbx, %rbx
je 0x3ced6
movq $0x0, 0x8(%rsp)
movq %rbx, %rcx
movq %rbx, 0x10(%rsp)
movzwl (%rcx), %eax
movsbl %al, %edx
testw %dx, %dx
jle 0x3cdf8
movzwl %dx, %edx
movzwl %ax, %esi
xorl %edi, %edi
movq 0x18(%rcx,%rdi,8), %rax
cmpl $0x100, %esi            # imm = 0x100
jb 0x3cd32
testq %rax, %rax
je 0x3cdec
cmpq %r15, %rax
je 0x3cdec
movq 0x18(%rax), %r9
testq %r9, %r9
je 0x3d020
movslq 0x58(%rax), %r8
movq %r9, %r10
xorl %r11d, %r11d
movzwl (%r10), %eax
movsbl %al, %ebx
testw %bx, %bx
jle 0x3cdc6
movzwl %bx, %r13d
movzwl %ax, %ebp
xorl %ebx, %ebx
movq %r11, %rax
movq 0x18(%r10,%rbx,8), %r11
cmpl $0x100, %ebp            # imm = 0x100
jb 0x3cd7c
testq %r11, %r11
je 0x3cdb8
movl 0x58(%r11), %r12d
cmpq $0x0, (%r14,%r12,8)
je 0x3cdb8
testq %rax, %rax
je 0x3cdbb
movl 0x58(%rax), %eax
cmpl %eax, %r12d
jne 0x3cda1
jmp 0x3cdbb
movslq %r12d, %r11
movq (%r14,%r11,8), %r11
movl 0x58(%r11), %r12d
cmpl %eax, %r12d
jl 0x3cd96
jmp 0x3cdb1
cltq
movq (%r14,%rax,8), %rax
movl 0x58(%rax), %eax
cmpl %r12d, %eax
jl 0x3cda8
jmp 0x3cd8f
movq %rax, %r11
incq %rbx
movq %r11, %rax
cmpq %r13, %rbx
jne 0x3cd6a
movq 0x10(%r10), %r10
cmpq %r9, %r10
jne 0x3cd52
testq %r11, %r11
je 0x3d020
cmpq %r11, (%r14,%r8,8)
je 0x3cdec
movq %r11, (%r14,%r8,8)
movl $0x1, %eax
movq %rax, 0x8(%rsp)
incq %rdi
cmpq %rdx, %rdi
jne 0x3cd1c
movq 0x10(%rcx), %rcx
movq 0x10(%rsp), %rbx
cmpq %rbx, %rcx
jne 0x3cd05
movq %rbx, %rcx
cmpl $0x0, 0x8(%rsp)
movl $0x0, %eax
movq %rax, 0x8(%rsp)
jne 0x3cd05
movzwl (%rbx), %eax
testb %al, %al
jle 0x3ce5c
xorl %r12d, %r12d
movq 0x18(%rbx,%r12,8), %rdi
movzwl %ax, %ecx
cmpl $0x100, %ecx            # imm = 0x100
jb 0x3ce41
testq %rdi, %rdi
je 0x3ce4d
addq $0x40, %rdi
callq 0x22c4e
movzwl (%rbx), %eax
incq %r12
movzwl %ax, %ecx
movsbq %cl, %rcx
cmpq %rcx, %r12
jl 0x3ce2c
movq 0x10(%rbx), %rbx
cmpq 0x10(%rsp), %rbx
jne 0x3ce22
movq (%rsp), %rax
movq 0x18(%rax), %rbx
testq %rbx, %rbx
je 0x3ced6
movq %rbx, %r12
movzwl (%r12), %eax
testb %al, %al
jle 0x3cecc
xorl %r13d, %r13d
movq 0x18(%r12,%r13,8), %rsi
movzwl %ax, %ecx
cmpl $0x100, %ecx            # imm = 0x100
setae %cl
testq %rsi, %rsi
sete %dl
testb %dl, %cl
jne 0x3cebd
cmpq %r15, %rsi
je 0x3cebd
movslq 0x58(%rsi), %rax
movq (%r14,%rax,8), %rdi
movq %rdi, 0x30(%rsi)
addq $0x40, %rdi
callq 0x227b4
movzwl (%r12), %eax
incq %r13
movzwl %ax, %ecx
movsbq %cl, %rcx
cmpq %rcx, %r13
jl 0x3ce83
movq 0x10(%r12), %r12
cmpq %rbx, %r12
jne 0x3ce77
movq $0x0, 0x30(%r15)
movq (%rsp), %r12
movq 0x18(%r12), %rcx
testq %rcx, %rcx
je 0x3cf4d
xorl %eax, %eax
movq %rcx, %rdx
movzwl (%rdx), %edi
testb %dil, %dil
jle 0x3cf40
xorl %esi, %esi
movq 0x18(%rdx,%rsi,8), %r8
movzwl %di, %r9d
cmpl $0x100, %r9d            # imm = 0x100
jb 0x3cf12
testq %r8, %r8
je 0x3cf30
movq 0x30(%r8), %rdi
testq %rdi, %rdi
je 0x3cf22
movl 0x3c(%rdi), %edi
incl %edi
jmp 0x3cf24
xorl %edi, %edi
movl %edi, 0x3c(%r8)
cmpl %edi, %eax
cmovlel %edi, %eax
movzwl (%rdx), %edi
incq %rsi
movzwl %di, %r8d
movsbq %r8b, %r8
cmpq %r8, %rsi
jl 0x3cefb
movq 0x10(%rdx), %rdx
cmpq %rcx, %rdx
jne 0x3cef1
incl %eax
jmp 0x3cf52
movl $0x1, %eax
movl %eax, 0x30(%r12)
movq %r14, %rdi
callq 0xe030
leaq 0x29e46(%rip), %rax     # 0x66dac
cmpl $0x0, (%rax)
je 0x3d011
movq (%r12), %rax
movq 0x18(%rax), %rdi
callq 0x2de35
leaq 0xe303(%rip), %rdi      # 0x4b286
movq %rax, %rsi
xorl %eax, %eax
callq 0xe0f0
movq 0x18(%r12), %rbx
testq %rbx, %rbx
je 0x3d011
leaq 0xe2f5(%rip), %r14      # 0x4b293
movq %rbx, %r13
movzwl (%r13), %eax
testb %al, %al
jle 0x3d008
xorl %ebp, %ebp
movq 0x18(%r13,%rbp,8), %r15
movzwl %ax, %ecx
cmpl $0x100, %ecx            # imm = 0x100
jb 0x3cfc1
testq %r15, %r15
je 0x3cff9
movq 0x28(%r12), %rcx
cmpq 0x8(%rcx), %r15
je 0x3cff9
movq %r15, %rdi
callq 0x122b5
movq %rax, %r12
movq 0x30(%r15), %rdi
callq 0x122b5
movq %r14, %rdi
movq %r12, %rsi
movq (%rsp), %r12
movq %rax, %rdx
xorl %eax, %eax
callq 0xe0f0
movzwl (%r13), %eax
incq %rbp
movzwl %ax, %ecx
movsbq %cl, %rcx
cmpq %rcx, %rbp
jl 0x3cfac
movq 0x10(%r13), %r13
cmpq %rbx, %r13
jne 0x3cfa1
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xe232(%rip), %rdi      # 0x4b259
leaq 0xe1f7(%rip), %rsi      # 0x4b225
leaq 0xe1fc(%rip), %rcx      # 0x4b231
movl $0xa1, %edx
callq 0xe120
leaq 0xe1c1(%rip), %rdi      # 0x4b207
leaq 0xe1d8(%rip), %rsi      # 0x4b225
leaq 0xe1dd(%rip), %rcx      # 0x4b231
movl $0x86, %edx
callq 0xe120