// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x460, %rsp            # imm = 0x460
movq %rdi, -0x8(%rbp)
movq $0x0, -0x450(%rbp)
cmpq $0x66, -0x450(%rbp)
jae 0x8a76
movq -0x450(%rbp), %rax
movl %eax, %edi
callq 0xffc0
movq -0x450(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x450(%rbp)
jmp 0x8a4a
movq $0x0, -0x30(%rbp)
movq $0x0, -0x440(%rbp)
movq $0x0, -0x28(%rbp)
movq $0x0, -0x448(%rbp)
leaq 0x27d2d(%rip), %rdi     # 0x307d0
leaq 0x27df6(%rip), %rsi     # 0x308a0
callq 0x48fe0
movq %rax, -0x10(%rbp)
movq -0x10(%rbp), %rdi
callq 0x7870
leaq 0x742d5(%rip), %rax     # 0x7cd98
movq 0x90(%rax), %rdi
movq -0x10(%rbp), %rsi
callq 0x74e0
leaq 0x742be(%rip), %rax     # 0x7cd98
movq 0x90(%rax), %rdi
callq 0x32db0
movq $0x0, -0x450(%rbp)
movq -0x450(%rbp), %rax
leaq 0x74299(%rip), %rcx     # 0x7cd98
cmpq 0x48(%rcx), %rax
jae 0x8bc0
leaq 0x74288(%rip), %rax     # 0x7cd98
movq 0x40(%rax), %rax
movq -0x450(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
movl 0x8(%rax), %eax
movl %eax, -0x454(%rbp)
subl $0x7, %eax
je 0x8b51
jmp 0x8b37
movl -0x454(%rbp), %eax
subl $0xb, %eax
je 0x8b53
jmp 0x8b44
movl -0x454(%rbp), %eax
subl $0xd, %eax
jne 0x8b85
jmp 0x8b51
jmp 0x8ba7
movq -0x20(%rbp), %rdi
callq 0x40f30
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rdi
movq -0x10(%rbp), %rsi
leaq -0x30(%rbp), %rdx
leaq -0x440(%rbp), %rcx
leaq -0x28(%rbp), %r8
leaq -0x448(%rbp), %r9
callq 0x16ca0
jmp 0x8ba7
movq -0x20(%rbp), %rax
movl 0x8(%rax), %eax
movl %eax, %ecx
leaq 0x73c2b(%rip), %rax     # 0x7c7c0
movq (%rax,%rcx,8), %rsi
leaq 0x42895(%rip), %rdi     # 0x4b435
movb $0x0, %al
callq 0x1df20
jmp 0x8ba9
movq -0x450(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x450(%rbp)
jmp 0x8af1
callq 0x32e20
leaq -0x430(%rbp), %rdi
movl $0x400, %esi            # imm = 0x400
callq 0x6190
cmpq $0x0, %rax
jne 0x8bf9
callq 0x6060
movl (%rax), %edi
callq 0x6340
movq %rax, %rsi
leaq 0x4285b(%rip), %rdi     # 0x4b44d
movb $0x0, %al
callq 0x1df20
movq $0x0, -0x450(%rbp)
movq -0x450(%rbp), %rax
leaq 0x74186(%rip), %rcx     # 0x7cd98
cmpq (%rcx), %rax
jae 0x8c73
leaq 0x7417a(%rip), %rax     # 0x7cd98
movq 0x8(%rax), %rax
movq -0x450(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x438(%rbp)
movq -0x8(%rbp), %rdi
movq -0x450(%rbp), %rdx
addq $0x1, %rdx
leaq -0x430(%rbp), %rcx
movq -0x438(%rbp), %r8
leaq 0x4280c(%rip), %rsi     # 0x4b464
movb $0x0, %al
callq 0x6230
movq -0x450(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x450(%rbp)
jmp 0x8c04
leaq 0x40d96(%rip), %rdi     # 0x49a10
leaq 0x40ddf(%rip), %rsi     # 0x49a60
callq 0x48fe0
movq %rax, -0x18(%rbp)
movq -0x8(%rbp), %rdi
leaq 0x427e2(%rip), %rsi     # 0x4b477
movb $0x0, %al
callq 0x6230
movq $0x0, -0x450(%rbp)
movq -0x450(%rbp), %rax
cmpq -0x448(%rbp), %rax
jae 0x8ceb
movq -0x8(%rbp), %rdi
movq -0x28(%rbp), %rax
movq -0x450(%rbp), %rcx
movq (%rax,%rcx,8), %rsi
movq -0x10(%rbp), %rdx
movq -0x18(%rbp), %rcx
callq 0x86c0
movq -0x450(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x450(%rbp)
jmp 0x8ca7
movq -0x8(%rbp), %rdi
leaq 0x44ec0(%rip), %rsi     # 0x4dbb6
movb $0x0, %al
callq 0x6230
movq -0x8(%rbp), %rdi
leaq 0x42776(%rip), %rsi     # 0x4b47e
movb $0x0, %al
callq 0x6230
movq $0x0, -0x450(%rbp)
movq -0x450(%rbp), %rax
cmpq -0x440(%rbp), %rax
jae 0x8d5e
movq -0x8(%rbp), %rdi
movq -0x30(%rbp), %rax
movq -0x450(%rbp), %rcx
movq (%rax,%rcx,8), %rsi
movq -0x10(%rbp), %rdx
movq -0x18(%rbp), %rcx
callq 0x8db0
movq -0x450(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x450(%rbp)
jmp 0x8d1a
movq -0x8(%rbp), %rdi
callq 0x8f20
movq -0x8(%rbp), %rdi
leaq 0x44e44(%rip), %rsi     # 0x4dbb6
movb $0x0, %al
callq 0x6230
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x84d0
movq -0x8(%rbp), %rdi
leaq 0x44e25(%rip), %rsi     # 0x4dbb6
movb $0x0, %al
callq 0x6230
movq -0x8(%rbp), %rdi
callq 0x60f0
addq $0x460, %rsp            # imm = 0x460
popq %rbp
retq
nopw (%rax,%rax)