// File: /workspace/github_c_makefile_star2_O1/oridb[P]mc/6/gengas.c
// Function: gengas
void
gengas(FILE *fd)
{
	Htab *globls, *strtab;
	Node *n, **blob;
	Func **fn;
	char dir[1024], *path;
	size_t nfn, nblob;
	size_t i;

	/* ensure that all physical registers have a loc created before any
	 * other locs, so that locmap[Physreg] maps to the Loc for the physreg
	 * in question */
	for (i = 0; i < Nreg; i++)
		locphysreg(i);

	fn = NULL;
	nfn = 0;
	blob = NULL;
	nblob = 0;
	globls = mkht(varhash, vareq);
	initconsts(globls);

	/* We need to define all global variables before use */
	fillglobls(file.globls, globls);

	pushstab(file.globls);
	for (i = 0; i < file.nstmts; i++) {
		n = file.stmts[i];
		switch (n->type) {
		case Nuse: /* nothing to do */
		case Nimpl:
			break;
		case Ndecl:
			n = flattenfn(n);
			simpglobl(n, globls, &fn, &nfn, &blob, &nblob);
			break;
		default:
			die("Bad node %s in toplevel", nodestr[n->type]);
			break;
		}
	}
	popstab();

	if (!getcwd(dir, sizeof dir))
		die("could not get cwd: %s\n", strerror(errno));
	for (i = 0; i < file.nfiles; i++) {
		path = file.files[i];
		fprintf(fd, ".file %zd \"%s/%s\"\n", i + 1, dir, path);
	}

	strtab = mkht(strlithash, strliteq);
	fprintf(fd, ".data\n");
	for (i = 0; i < nblob; i++)
		genblob(fd, blob[i], globls, strtab);
	fprintf(fd, "\n");

	fprintf(fd, ".text\n");
	for (i = 0; i < nfn; i++)
		genfunc(fd, fn[i], globls, strtab);
	gentypes(fd);
	fprintf(fd, "\n");

	genstrings(fd, strtab);
	fprintf(fd, "\n");

	fclose(fd);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xd08, %rsp            # imm = 0xD08
movq %rdi, %rbx
xorl %r14d, %r14d
movl %r14d, %edi
callq 0xaa70
incq %r14
cmpq $0x66, %r14
jne 0x63fd
xorl %r15d, %r15d
movq %r15, 0x20(%rsp)
movq %r15, 0x10(%rsp)
movq %r15, 0x28(%rsp)
movq %r15, 0x8(%rsp)
leaq 0x18472(%rip), %rdi     # 0x1e89e
leaq 0x184da(%rip), %rsi     # 0x1e90d
callq 0x2db1c
movq %rax, %r14
movq %rax, %rdi
callq 0x56df
leaq 0x5ae2e(%rip), %rbp     # 0x61278
movq 0x90(%rbp), %rdi
movq %r14, %rsi
callq 0x54b0
movq 0x90(%rbp), %rdi
callq 0x20070
cmpq %r15, 0x48(%rbp)
je 0x64c0
xorl %r12d, %r12d
leaq 0x28(%rsp), %r13
leaq 0x8(%rsp), %r15
movq 0x40(%rbp), %rax
movq (%rax,%r12,8), %rdi
movl 0x8(%rdi), %eax
cmpq $0x7, %rax
je 0x64b7
cmpl $0xd, %eax
je 0x64b7
cmpl $0xb, %eax
jne 0x67dd
callq 0x28db8
movq %rax, %rdi
movq %r14, %rsi
leaq 0x20(%rsp), %rdx
leaq 0x10(%rsp), %rcx
movq %r13, %r8
movq %r15, %r9
callq 0xf21a
incq %r12
cmpq 0x48(%rbp), %r12
jb 0x6478
callq 0x200b6
leaq 0x500(%rsp), %rdi
movl $0x400, %esi            # imm = 0x400
callq 0x41b0
testq %rax, %rax
je 0x67f6
cmpq $0x0, (%rbp)
je 0x651d
leaq 0x2921a(%rip), %r15     # 0x2f708
leaq 0x500(%rsp), %r12
xorl %r13d, %r13d
movq 0x8(%rbp), %rax
movq (%rax,%r13,8), %r8
incq %r13
movq %rbx, %rdi
movq %r15, %rsi
movq %r13, %rdx
movq %r12, %rcx
xorl %eax, %eax
callq 0x4240
cmpq (%rbp), %r13
jb 0x64f9
leaq 0x27ae7(%rip), %rdi     # 0x2e00b
leaq 0x27af7(%rip), %rsi     # 0x2e022
callq 0x2db1c
movq %rax, %r12
leaq 0x291e1(%rip), %rdi     # 0x2f71b
movl $0x6, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x4330
cmpq $0x0, 0x8(%rsp)
je 0x6578
xorl %r15d, %r15d
movq 0x28(%rsp), %rax
movq (%rax,%r15,8), %rsi
movq %rbx, %rdi
movq %r14, %rdx
movq %r12, %rcx
callq 0x6038
incq %r15
cmpq 0x8(%rsp), %r15
jb 0x6557
movq %r12, 0x18(%rsp)
movl $0xa, %edi
movq %rbx, %rsi
callq 0x41f0
leaq 0x29191(%rip), %rdi     # 0x2f722
movl $0x6, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x4330
cmpq $0x0, 0x10(%rsp)
je 0x66c2
xorl %r15d, %r15d
leaq 0x30(%rsp), %r12
leaq 0x900(%rsp), %r13
movq 0x20(%rsp), %rax
movq (%rax,%r15,8), %rbp
movl $0x4d0, %edx            # imm = 0x4D0
movq %r12, %rdi
xorl %esi, %esi
callq 0x41a0
callq 0xaa02
movl $0x400, %esi            # imm = 0x400
movq %r13, %rdi
callq 0x41b0
testq %rax, %rax
je 0x67cc
leaq 0x182a5(%rip), %rdi     # 0x1e89e
leaq 0x1830d(%rip), %rsi     # 0x1e90d
callq 0x2db1c
movq %rax, 0x78(%rsp)
movq (%rbp), %rax
movq %rax, 0x30(%rsp)
movq 0x28(%rbp), %rax
movq %rax, 0x80(%rsp)
movq 0x30(%rbp), %rax
movq %rax, 0x88(%rsp)
movq %r14, 0x90(%rsp)
movq 0x40(%rbp), %rax
movq %rax, 0x60(%rsp)
movl 0x48(%rbp), %eax
movl %eax, 0x68(%rsp)
movq 0x50(%rbp), %rax
movq %rax, 0x40(%rsp)
movq %r13, %rdi
callq 0x4340
movq %rax, 0x38(%rsp)
cmpb $0x0, 0x59(%rbp)
je 0x6671
movl $0x4, %edi
callq 0xaa0e
movq %rax, 0x98(%rsp)
movq %r12, %rdi
movq %rbp, %rsi
movq %r14, %rdx
movq 0x18(%rsp), %rcx
callq 0x9abf
leaq 0x5ab55(%rip), %rax     # 0x611e0
cmpb $0x0, 0x69(%rax)
je 0x66a6
movq 0x3d938(%rip), %rax     # 0x43fd0
movq (%rax), %rdi
movq %r12, %rsi
movq %rbp, %rdx
callq 0x6818
movq %rbx, %rdi
movq %r12, %rsi
movq %rbp, %rdx
callq 0x6818
incq %r15
cmpq 0x10(%rsp), %r15
jb 0x65bf
leaq 0x5bb1f(%rip), %r15     # 0x621e8
cmpq $0x20, (%r15)
jb 0x677e
movl $0x1f, %r13d
leaq 0x5baf8(%rip), %rbp     # 0x621d8
leaq 0x5aae1(%rip), %r14     # 0x611c8
movq (%rbp), %rax
movq (%rax,%r13,8), %rdi
cmpb $0x0, 0x95(%rdi)
je 0x6772
callq 0x22cec
cmpb $0x0, 0x96(%rax)
jne 0x6772
cmpb $0x0, 0x94(%rax)
jne 0x6772
movq %rax, %rdi
callq 0x22cec
cmpl $0x19, (%rax)
je 0x6772
cmpb $0x0, 0x96(%rax)
jne 0x6772
movb $0x1, 0x96(%rax)
movq %rax, %rdi
callq 0x12506
movq %rax, %r12
cmpb $0x0, 0x18(%rax)
je 0x6743
movb $0x1, 0x19(%r12)
cmpl $0x0, (%r14)
jne 0x675f
movq 0x10(%r12), %rdx
movq %rbx, %rdi
leaq 0x28f45(%rip), %rsi     # 0x2f69d
xorl %eax, %eax
callq 0x4240
movq %rbx, %rdi
movq %r12, %rsi
callq 0x6154
movq %r12, %rdi
callq 0x4a92
incq %r13
cmpq (%r15), %r13
jb 0x66e7
movl $0xa, %edi
movq %rbx, %rsi
callq 0x41f0
movl $0xa, %edi
movq %rbx, %rsi
callq 0x41f0
movq %rbx, %rdi
movq 0x18(%rsp), %rsi
callq 0x5ece
movl $0xa, %edi
movq %rbx, %rsi
callq 0x41f0
movq %rbx, %rdi
callq 0x4110
addq $0xd08, %rsp            # imm = 0xD08
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x29646(%rip), %rdi     # 0x2fe19
leaq 0x900(%rsp), %rsi
jmp 0x67ef
leaq 0x5a4bc(%rip), %rcx     # 0x60ca0
movq (%rcx,%rax,8), %rsi
leaq 0x28eea(%rip), %rdi     # 0x2f6d9
xorl %eax, %eax
callq 0x13a00
callq 0x4070
movl (%rax), %edi
callq 0x4350
leaq 0x28ee8(%rip), %rdi     # 0x2f6f1
movq %rax, %rsi
jmp 0x67ef