// File: /workspace/github_c_makefile_star2_O2/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
pushq $0x58
popq %rdi
callq 0x29a78
movq %rax, %rbx
movq %r14, (%rsp)
movq %r14, (%rax)
leaq 0x53e2(%rip), %rdi      # 0x2a583
leaq 0x547e(%rip), %rsi      # 0x2a626
callq 0x2a188
movq %rax, 0x30(%rbx)
movq %rbx, %rdi
callq 0x25504
movq %rax, 0x8(%rsp)
movq %rbx, %rdi
callq 0x25504
movq %rax, %rbp
xorl %r14d, %r14d
cmpq %r14, %r12
je 0x252ce
movq (%r13,%r14,8), %r15
movl 0x8(%r15), %eax
cmpq $0xb, %rax
je 0x252c6
cmpl $0x8, %eax
jne 0x254dd
movq %r15, %rdi
callq 0x1b5e6
cmpl $0x35, %eax
jne 0x252a7
movq 0x50(%r15), %rax
movq (%rax), %rax
cmpl $0x9, 0x8(%rax)
jne 0x252a7
cmpl $0x6, 0x18(%rax)
jne 0x252a7
testq %r14, %r14
je 0x25283
movq -0x8(%r13,%r14,8), %rdi
cmpl $0x8, 0x8(%rdi)
jne 0x25283
movq (%r13,%r14,8), %rax
movq (%rax), %r15
callq 0x1b5e6
cmpl $0x3e, %eax
je 0x25283
movq -0x8(%r13,%r14,8), %rdi
callq 0x1b5e6
cmpl $0x30, %eax
je 0x25283
movq (%r13,%r14,8), %rdi
callq 0x1c153
movq %r15, %rdi
movq %rax, %rsi
callq 0x1bb86
movq %r15, %rdi
pushq $0x30
popq %rsi
movq %rax, %rdx
xorl %ecx, %ecx
xorl %eax, %eax
callq 0x1b718
movq %rbx, %rdi
movq %rbp, %rsi
movq %rax, %rdx
callq 0x25552
cmpq $0x0, 0x20(%rbp)
je 0x25295
movq %rbx, %rdi
callq 0x25504
movq %rax, %rbp
movq (%r13,%r14,8), %rsi
movq %rbx, %rdi
movq %rbp, %rdx
callq 0x25606
jmp 0x252c6
movq (%r13,%r14,8), %rdx
movq %rbx, %rdi
movq %rbp, %rsi
callq 0x25552
testl %eax, %eax
je 0x252c6
movq %rbx, %rdi
callq 0x25504
movq %rax, %rbp
incq %r14
jmp 0x251cc
movq %rbx, %rdi
callq 0x25504
movq %rax, %r12
movl 0x39f89(%rip), %ecx     # 0x5f268
leal 0x1(%rcx), %eax
movl %eax, 0x39f80(%rip)     # 0x5f268
leaq 0xef56(%rip), %rdx      # 0x34245
xorl %r13d, %r13d
leaq 0x10(%rsp), %r15
pushq $0x20
popq %rsi
movq %r15, %rdi
xorl %eax, %eax
callq 0x2a9bf
movq (%rsp), %rax
movq (%rax), %rdi
movq %r15, %rsi
callq 0x1bb86
movq %rbx, %rdi
movq %rax, %rsi
movq %r12, %rdx
callq 0x25606
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 0x29ed5
movq 0x8(%rbx), %rax
movq 0x8(%rax), %rax
movq 0x28(%rax), %rdi
movslq (%r14), %rsi
callq 0x29ed5
movq 0x8(%rbx), %rax
movq 0x20(%rbx), %rcx
movq -0x10(%rax,%rcx,8), %rax
movq 0x30(%rax), %rdi
movslq (%r12), %rsi
callq 0x29ed5
movq 0x28(%r12), %rdi
movq 0x8(%rbx), %rax
movq 0x20(%rbx), %rcx
movq -0x10(%rax,%rcx,8), %rax
movslq (%rax), %rsi
callq 0x29ed5
cmpq 0x40(%rbx), %r13
jae 0x2548b
movq 0x38(%rbx), %rax
movq 0x48(%rbx), %rcx
movq (%rcx,%r13,8), %rbp
movq (%rax,%r13,8), %rdi
callq 0x1b5e6
cmpl $0x2f, %eax
je 0x253e3
cmpl $0x3e, %eax
je 0x253cd
cmpl $0x30, %eax
jne 0x254f6
movq 0x38(%rbx), %rax
movq (%rax,%r13,8), %rax
movq 0x50(%rax), %rax
movq (%rax), %r15
jmp 0x25401
movq 0x38(%rbx), %rax
movq (%rax,%r13,8), %rax
movq 0x50(%rax), %rax
movq 0x8(%rax), %r15
movq 0x10(%rax), %r14
jmp 0x25404
movq 0x18(%rbx), %rax
movq 0x38(%rbx), %rcx
movq (%rcx,%r13,8), %rcx
movq 0x8(%rax), %rax
movq (%rax), %rsi
movq (%rcx), %rdi
callq 0x1bb86
movq %rax, %r15
xorl %r14d, %r14d
testq %r15, %r15
je 0x25446
movq 0x30(%rbx), %r12
movq %r15, %rdi
callq 0x1c153
movq %r12, %rdi
movq %rax, %rsi
callq 0x2a3e8
testq %rax, %rax
je 0x254c4
movq %rax, %r12
movq 0x30(%rbp), %rdi
movslq (%rax), %rsi
callq 0x29ed5
movq 0x28(%r12), %rdi
movslq (%rbp), %rsi
callq 0x29ed5
testq %r14, %r14
je 0x25483
movq 0x30(%rbx), %r15
movq %r14, %rdi
callq 0x1c153
movq %r15, %rdi
movq %rax, %rsi
callq 0x2a3e8
testq %rax, %rax
je 0x254c9
movq %rax, %r15
movq 0x30(%rbp), %rdi
movslq (%rax), %rsi
callq 0x29ed5
movq 0x28(%r15), %rdi
movslq (%rbp), %rsi
callq 0x29ed5
incq %r13
jmp 0x2538a
leaq 0x38d4e(%rip), %rax     # 0x5e1e0
cmpb $0x0, 0x43(%rax)
je 0x254aa
movq 0x1bb31(%rip), %rax     # 0x40fd0
movq (%rax), %rsi
movq %rbx, %rdi
callq 0x2562d
movq %rbx, %rdi
callq 0x25102
movq %rbx, %rax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r15, %rdi
jmp 0x254cc
movq %r14, %rdi
callq 0x1c153
leaq 0xed89(%rip), %rdi      # 0x34261
movq %rax, %rsi
jmp 0x254ef
leaq 0x387bc(%rip), %rcx     # 0x5dca0
movq (%rcx,%rax,8), %rsi
leaq 0xed38(%rip), %rdi      # 0x34227
xorl %eax, %eax
callq 0x1205c
leaq 0xed50(%rip), %rdi      # 0x3424d
xorl %eax, %eax
callq 0x1205c