// File: /workspace/github_c_makefile_star2_O3/oridb[P]mc/mi/cfg.c
// Function: mkcfg
Cfg *
mkcfg(Node *fn, Node **nl, size_t nn)
{
	Cfg *cfg;
	Bb *pre, *post;
	Bb *bb, *targ;
	Node *a, *b;
	static int nextret;
	char buf[32];
	size_t i;

	cfg = zalloc(sizeof(Cfg));
	cfg->fn = fn;
	cfg->lblmap = mkht(strhash, streq);
	pre = mkbb(cfg);
	bb = mkbb(cfg);
	for (i = 0; i < nn; i++) {
		switch (nl[i]->type) {
		case Nexpr:
			if (islabel(nl[i]))
				bb = addlabel(cfg, bb, nl, i, nl[i]->loc);
			else if (addnode(cfg, bb, nl[i]))
				bb = mkbb(cfg);
			break;
			break;
		case Ndecl:
			break;
		default:
			die("Invalid node type %s in mkcfg", nodestr[nl[i]->type]);
		}
	}
	post = mkbb(cfg);
	bprintf(buf, sizeof buf, ".Lret%d", nextret++);
	label(cfg, mklbl(fn->loc, buf), post);

	cfg->start = pre;
	cfg->end = post;
	bsput(pre->succ, cfg->bb[1]->id);
	bsput(cfg->bb[1]->pred, pre->id);
	bsput(cfg->bb[cfg->nbb - 2]->succ, post->id);
	bsput(post->pred, cfg->bb[cfg->nbb - 2]->id);

	for (i = 0; i < cfg->nfixjmp; i++) {
		bb = cfg->fixblk[i];
		switch (exprop(cfg->fixjmp[i])) {
		case Ojmp:
			a = cfg->fixjmp[i]->expr.args[0];
			b = NULL;
			break;
		case Ocjmp:
			a = cfg->fixjmp[i]->expr.args[1];
			b = cfg->fixjmp[i]->expr.args[2];
			break;
		case Oret:
			a = mklbl(cfg->fixjmp[i]->loc, cfg->end->lbls[0]);
			b = NULL;
			break;
		default:
			die("Bad jump fix thingy");
			break;
		}
		if (a) {
			targ = htget(cfg->lblmap, lblstr(a));
			if (!targ)
				die("No bb with label \"%s\"", lblstr(a));
			bsput(bb->succ, targ->id);
			bsput(targ->pred, bb->id);
		}
		if (b) {
			targ = htget(cfg->lblmap, lblstr(b));
			if (!targ)
				die("No bb with label \"%s\"", lblstr(b));
			bsput(bb->succ, targ->id);
			bsput(targ->pred, bb->id);
		}
	}
        if (debugopt['C'])
            dumpcfg(cfg, stdout);
	trim(cfg);
	return cfg;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rdx, %r12
movq %rsi, %r13
movq %rdi, %r14
movl $0x58, %edi
callq 0x2ce48
movq %rax, %rbx
movq %r14, (%rsp)
movq %r14, (%rax)
leaq 0x58ba(%rip), %rdi      # 0x2da93
leaq 0x595b(%rip), %rsi      # 0x2db3b
callq 0x2d678
movq %rax, 0x30(%rbx)
movq %rbx, %rdi
callq 0x2855a
movq %rax, 0x8(%rsp)
movq %rbx, %rdi
callq 0x2855a
testq %r12, %r12
je 0x28314
movq %rax, %rbp
xorl %r14d, %r14d
movq (%r13,%r14,8), %r15
movl 0x8(%r15), %eax
cmpq $0xb, %rax
je 0x28308
cmpl $0x8, %eax
jne 0x28533
movq %r15, %rdi
callq 0x1d422
cmpl $0x35, %eax
jne 0x282e9
movq 0x50(%r15), %rax
movq (%rax), %rax
cmpl $0x9, 0x8(%rax)
jne 0x282e9
cmpl $0x6, 0x18(%rax)
jne 0x282e9
testq %r14, %r14
je 0x282bd
movq -0x8(%r13,%r14,8), %rdi
cmpl $0x8, 0x8(%rdi)
jne 0x282bd
movq (%r13,%r14,8), %rax
movq (%rax), %r15
callq 0x1d422
cmpl $0x3e, %eax
je 0x282bd
movq -0x8(%r13,%r14,8), %rdi
callq 0x1d422
cmpl $0x30, %eax
je 0x282bd
movq (%r13,%r14,8), %rdi
callq 0x1e5ac
movq %r15, %rdi
movq %rax, %rsi
callq 0x1dd07
movq %r15, %rdi
movl $0x30, %esi
movq %rax, %rdx
xorl %ecx, %ecx
xorl %eax, %eax
callq 0x1d5e2
movq %rbx, %rdi
movq %rbp, %rsi
movq %rax, %rdx
callq 0x285aa
cmpq $0x0, 0x20(%rbp)
je 0x282cf
movq %rbx, %rdi
callq 0x2855a
movq %rax, %rbp
movq (%r13,%r14,8), %rdi
callq 0x1e5ac
movq %rbx, %rdi
movq %rax, %rsi
movq %rbp, %rdx
callq 0x27fca
jmp 0x28308
movq (%r13,%r14,8), %rdx
movq %rbx, %rdi
movq %rbp, %rsi
callq 0x285aa
testl %eax, %eax
je 0x28308
movq %rbx, %rdi
callq 0x2855a
movq %rax, %rbp
incq %r14
cmpq %r14, %r12
jne 0x2820d
movq %rbx, %rdi
callq 0x2855a
movq %rax, %r12
movl 0x39f43(%rip), %ecx     # 0x62268
leal 0x1(%rcx), %eax
movl %eax, 0x39f3a(%rip)     # 0x62268
leaq 0xff00(%rip), %rdx      # 0x38235
leaq 0x10(%rsp), %r15
movl $0x20, %esi
movq %r15, %rdi
xorl %eax, %eax
callq 0x2dfae
movq (%rsp), %rax
movq (%rax), %rdi
movq %r15, %rsi
callq 0x1dd07
movq %rax, %rdi
callq 0x1e5ac
movq %rbx, %rdi
movq %rax, %rsi
movq %r12, %rdx
callq 0x27fca
movq 0x8(%rsp), %r14
movq %r14, 0x10(%rbx)
movq %r12, 0x18(%rbx)
movq 0x30(%r14), %rdi
movq 0x8(%rbx), %rax
movq 0x8(%rax), %rax
movslq (%rax), %rsi
callq 0x2d369
movq 0x8(%rbx), %rax
movq 0x8(%rax), %rax
movq 0x28(%rax), %rdi
movslq (%r14), %rsi
callq 0x2d369
movq 0x8(%rbx), %rax
movq 0x20(%rbx), %rcx
movq -0x10(%rax,%rcx,8), %rax
movq 0x30(%rax), %rdi
movslq (%r12), %rsi
callq 0x2d369
movq 0x28(%r12), %rdi
movq 0x8(%rbx), %rax
movq 0x20(%rbx), %rcx
movq -0x10(%rax,%rcx,8), %rax
movslq (%rax), %rsi
callq 0x2d369
cmpq $0x0, 0x40(%rbx)
je 0x284e1
xorl %r13d, %r13d
movq 0x38(%rbx), %rax
movq 0x48(%rbx), %rcx
movq (%rcx,%r13,8), %rbp
movq (%rax,%r13,8), %rdi
callq 0x1d422
cmpl $0x2f, %eax
je 0x28434
cmpl $0x3e, %eax
je 0x2841e
cmpl $0x30, %eax
jne 0x2854c
movq 0x38(%rbx), %rax
movq (%rax,%r13,8), %rax
movq 0x50(%rax), %rax
movq (%rax), %r15
jmp 0x28452
movq 0x38(%rbx), %rax
movq (%rax,%r13,8), %rax
movq 0x50(%rax), %rax
movq 0x8(%rax), %r15
movq 0x10(%rax), %r14
jmp 0x28455
movq 0x18(%rbx), %rax
movq 0x38(%rbx), %rcx
movq (%rcx,%r13,8), %rcx
movq 0x8(%rax), %rax
movq (%rax), %rsi
movq (%rcx), %rdi
callq 0x1dd07
movq %rax, %r15
xorl %r14d, %r14d
testq %r15, %r15
je 0x28497
movq 0x30(%rbx), %r12
movq %r15, %rdi
callq 0x1e5ac
movq %r12, %rdi
movq %rax, %rsi
callq 0x2d8fa
testq %rax, %rax
je 0x2851f
movq %rax, %r12
movq 0x30(%rbp), %rdi
movslq (%rax), %rsi
callq 0x2d369
movq 0x28(%r12), %rdi
movslq (%rbp), %rsi
callq 0x2d369
testq %r14, %r14
je 0x284d4
movq 0x30(%rbx), %r15
movq %r14, %rdi
callq 0x1e5ac
movq %r15, %rdi
movq %rax, %rsi
callq 0x2d8fa
testq %rax, %rax
je 0x2851a
movq %rax, %r15
movq 0x30(%rbp), %rdi
movslq (%rax), %rsi
callq 0x2d369
movq 0x28(%r15), %rdi
movslq (%rbp), %rsi
callq 0x2d369
incq %r13
cmpq 0x40(%rbx), %r13
jb 0x283e5
leaq 0x38cf8(%rip), %rax     # 0x611e0
cmpb $0x0, 0x43(%rax)
je 0x28500
movq 0x1badb(%rip), %rax     # 0x43fd0
movq (%rax), %rsi
movq %rbx, %rdi
callq 0x28688
movq %rbx, %rdi
callq 0x2812e
movq %rbx, %rax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r14, %rdi
jmp 0x28522
movq %r15, %rdi
callq 0x1e5ac
leaq 0xfd23(%rip), %rdi      # 0x38251
movq %rax, %rsi
jmp 0x28545
leaq 0x38766(%rip), %rcx     # 0x60ca0
movq (%rcx,%rax,8), %rsi
leaq 0xfcd2(%rip), %rdi      # 0x38217
xorl %eax, %eax
callq 0x13844
leaq 0xfcea(%rip), %rdi      # 0x3823d
xorl %eax, %eax
callq 0x13844