// File: /workspace/github_c_makefile_star2_O1/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 0x2d348
movq %rax, %rbx
movq %r14, (%rsp)
movq %r14, (%rax)
leaq 0x586c(%rip), %rdi      # 0x2df3c
leaq 0x5903(%rip), %rsi      # 0x2dfda
callq 0x2db1c
movq %rax, 0x30(%rbx)
movq %rbx, %rdi
callq 0x28a51
movq %rax, 0x8(%rsp)
movq %rbx, %rdi
callq 0x28a51
testq %r12, %r12
je 0x2880b
movq %rax, %rbp
xorl %r14d, %r14d
movq (%r13,%r14,8), %r15
movl 0x8(%r15), %eax
cmpq $0xb, %rax
je 0x287ff
cmpl $0x8, %eax
jne 0x28a2a
movq %r15, %rdi
callq 0x1d672
cmpl $0x35, %eax
jne 0x287e0
movq 0x50(%r15), %rax
movq (%rax), %rax
cmpl $0x9, 0x8(%rax)
jne 0x287e0
cmpl $0x6, 0x18(%rax)
jne 0x287e0
testq %r14, %r14
je 0x287b4
movq -0x8(%r13,%r14,8), %rdi
cmpl $0x8, 0x8(%rdi)
jne 0x287b4
movq (%r13,%r14,8), %rax
movq (%rax), %r15
callq 0x1d672
cmpl $0x3e, %eax
je 0x287b4
movq -0x8(%r13,%r14,8), %rdi
callq 0x1d672
cmpl $0x30, %eax
je 0x287b4
movq (%r13,%r14,8), %rdi
callq 0x1e7fc
movq %r15, %rdi
movq %rax, %rsi
callq 0x1df57
movq %r15, %rdi
movl $0x30, %esi
movq %rax, %rdx
xorl %ecx, %ecx
xorl %eax, %eax
callq 0x1d832
movq %rbx, %rdi
movq %rbp, %rsi
movq %rax, %rdx
callq 0x28aa1
cmpq $0x0, 0x20(%rbp)
je 0x287c6
movq %rbx, %rdi
callq 0x28a51
movq %rax, %rbp
movq (%r13,%r14,8), %rdi
callq 0x1e7fc
movq %rbx, %rdi
movq %rax, %rsi
movq %rbp, %rdx
callq 0x284c6
jmp 0x287ff
movq (%r13,%r14,8), %rdx
movq %rbx, %rdi
movq %rbp, %rsi
callq 0x28aa1
testl %eax, %eax
je 0x287ff
movq %rbx, %rdi
callq 0x28a51
movq %rax, %rbp
incq %r14
cmpq %r14, %r12
jne 0x28704
movq %rbx, %rdi
callq 0x28a51
movq %rax, %r12
movl 0x39a4c(%rip), %ecx     # 0x62268
leal 0x1(%rcx), %eax
movl %eax, 0x39a43(%rip)     # 0x62268
leaq 0xfa39(%rip), %rdx      # 0x38265
leaq 0x10(%rsp), %r15
movl $0x20, %esi
movq %r15, %rdi
xorl %eax, %eax
callq 0x2e42e
movq (%rsp), %rax
movq (%rax), %rdi
movq %r15, %rsi
callq 0x1df57
movq %rax, %rdi
callq 0x1e7fc
movq %rbx, %rdi
movq %rax, %rsi
movq %r12, %rdx
callq 0x284c6
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 0x2d816
movq 0x8(%rbx), %rax
movq 0x8(%rax), %rax
movq 0x28(%rax), %rdi
movslq (%r14), %rsi
callq 0x2d816
movq 0x8(%rbx), %rax
movq 0x20(%rbx), %rcx
movq -0x10(%rax,%rcx,8), %rax
movq 0x30(%rax), %rdi
movslq (%r12), %rsi
callq 0x2d816
movq 0x28(%r12), %rdi
movq 0x8(%rbx), %rax
movq 0x20(%rbx), %rcx
movq -0x10(%rax,%rcx,8), %rax
movslq (%rax), %rsi
callq 0x2d816
cmpq $0x0, 0x40(%rbx)
je 0x289d8
xorl %r13d, %r13d
movq 0x38(%rbx), %rax
movq 0x48(%rbx), %rcx
movq (%rcx,%r13,8), %rbp
movq (%rax,%r13,8), %rdi
callq 0x1d672
cmpl $0x2f, %eax
je 0x2892b
cmpl $0x3e, %eax
je 0x28915
cmpl $0x30, %eax
jne 0x28a43
movq 0x38(%rbx), %rax
movq (%rax,%r13,8), %rax
movq 0x50(%rax), %rax
movq (%rax), %r15
jmp 0x28949
movq 0x38(%rbx), %rax
movq (%rax,%r13,8), %rax
movq 0x50(%rax), %rax
movq 0x8(%rax), %r15
movq 0x10(%rax), %r14
jmp 0x2894c
movq 0x18(%rbx), %rax
movq 0x38(%rbx), %rcx
movq (%rcx,%r13,8), %rcx
movq 0x8(%rax), %rax
movq (%rax), %rsi
movq (%rcx), %rdi
callq 0x1df57
movq %rax, %r15
xorl %r14d, %r14d
testq %r15, %r15
je 0x2898e
movq 0x30(%rbx), %r12
movq %r15, %rdi
callq 0x1e7fc
movq %r12, %rdi
movq %rax, %rsi
callq 0x2dd9a
testq %rax, %rax
je 0x28a16
movq %rax, %r12
movq 0x30(%rbp), %rdi
movslq (%rax), %rsi
callq 0x2d816
movq 0x28(%r12), %rdi
movslq (%rbp), %rsi
callq 0x2d816
testq %r14, %r14
je 0x289cb
movq 0x30(%rbx), %r15
movq %r14, %rdi
callq 0x1e7fc
movq %r15, %rdi
movq %rax, %rsi
callq 0x2dd9a
testq %rax, %rax
je 0x28a11
movq %rax, %r15
movq 0x30(%rbp), %rdi
movslq (%rax), %rsi
callq 0x2d816
movq 0x28(%r15), %rdi
movslq (%rbp), %rsi
callq 0x2d816
incq %r13
cmpq 0x40(%rbx), %r13
jb 0x288dc
leaq 0x38801(%rip), %rax     # 0x611e0
cmpb $0x0, 0x43(%rax)
je 0x289f7
movq 0x1b5e4(%rip), %rax     # 0x43fd0
movq (%rax), %rsi
movq %rbx, %rdi
callq 0x28b7f
movq %rbx, %rdi
callq 0x2862a
movq %rbx, %rax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r14, %rdi
jmp 0x28a19
movq %r15, %rdi
callq 0x1e7fc
leaq 0xf85c(%rip), %rdi      # 0x38281
movq %rax, %rsi
jmp 0x28a3c
leaq 0x3826f(%rip), %rcx     # 0x60ca0
movq (%rcx,%rax,8), %rsi
leaq 0xf80b(%rip), %rdi      # 0x38247
xorl %eax, %eax
callq 0x13a00
leaq 0xf823(%rip), %rdi      # 0x3826d
xorl %eax, %eax
callq 0x13a00