// File: /workspace/github_c_makefile_star2_O3/kisom[P]kam/compiler.c
// Function: main
int
main(int argc, char *argv[])
{
	int	 opt, trace, status = EXIT_SUCCESS;
	char	*prog_file = DEFAULT_BIN;

	init_compiler();

	while (-1 != (opt = getopt(argc, argv, "o:t"))) {
		switch(opt) {
		case 'o':
			prog_file = optarg;
			break;
		case 't':
			trace = 1;
			break;
		default:
			/* not reached */
			abort();
		}
	}
	argc -= optind;
	argv += optind;

	if (0 == argc) {
		compiler.source = stdin;
	} else if (1 == argc) {
		printf("Source file: %s\n", argv[0]);
		compiler.source = fopen(argv[0], "rb");
		if (NULL == compiler.source) {
			err(EX_IOERR, "failed to open source file.");
		}
	} else {
		fprintf(stderr, "Compiling multiple files is not supported.\n");
		exit(EX_USAGE);
	}
	compiler.out = fopen(prog_file, "wb");
	if (NULL == compiler.out) {
		err(EX_IOERR, "failed to open output file.");
	}
	if (-1 == parse()) {
		fprintf(stderr, "Compilation failed.\n");
		backtrace(trace);
		status = EXIT_FAILURE;
		goto exit;
	} else if (-1 == write_program()) {
		fprintf(stderr, "Writing binary failed.\n");
		status = EXIT_FAILURE;
		goto exit;
	}
	printf("Wrote compiled program to %s.\n", prog_file);

exit:
	destroy_compiler();
	return status;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rsi, %r14
movl %edi, %ebp
callq 0x1578
movq %rax, 0x2a51(%rip)      # 0x40c8
testq %rax, %rax
je 0x1ab7
movw $0x0, 0x2a4f(%rip)      # 0x40d8
movq $0x0, 0x2a3c(%rip) # 0x40d0
xorps %xmm0, %xmm0
movups %xmm0, 0x2a3e(%rip)     # 0x40dc
movups %xmm0, 0x2a43(%rip)     # 0x40e8
leaq 0x998(%rip), %r12       # 0x2044
leaq 0x99a(%rip), %r15       # 0x204d
movq 0x291e(%rip), %rbx      # 0x3fd8
movl %ebp, %edi
movq %r14, %rsi
movq %r15, %rdx
callq 0x1120
cmpl $0x74, %eax
je 0x16ba
cmpl $-0x1, %eax
je 0x16df
cmpl $0x6f, %eax
jne 0x1ab2
movq (%rbx), %r12
jmp 0x16ba
movq 0x28ea(%rip), %rax      # 0x3fd0
movslq (%rax), %rbx
cmpl %ebx, %ebp
jne 0x1700
movq 0x28d4(%rip), %rax      # 0x3fc8
movq (%rax), %rax
movq %rax, 0x29ea(%rip)      # 0x40e8
jmp 0x173d
subl %ebx, %ebp
cmpl $0x1, %ebp
jne 0x1b1a
movq (%r14,%rbx,8), %rsi
leaq 0x93b(%rip), %rdi       # 0x2051
xorl %eax, %eax
callq 0x10a0
movq (%r14,%rbx,8), %rdi
leaq 0x93a(%rip), %rsi       # 0x2062
callq 0x1110
movq %rax, 0x29b4(%rip)      # 0x40e8
testq %rax, %rax
je 0x1b1f
leaq 0x969(%rip), %rsi       # 0x20ad
movq %r12, %rdi
callq 0x1110
movq %rax, 0x299d(%rip)      # 0x40f0
testq %rax, %rax
je 0x1ac0
movq %r12, 0x10(%rsp)
movq 0x2980(%rip), %rdi      # 0x40e8
testq %rdi, %rdi
je 0x1ac9
callq 0x10e0
testl %eax, %eax
jne 0x1915
leaq 0xf(%rsp), %r14
leaq 0x293e(%rip), %r12      # 0x40c8
leaq 0x873(%rip), %r13       # 0x2004
movl $0xff, %ebx
movq 0x294b(%rip), %rcx      # 0x40e8
movl $0x1, %esi
movl $0x1, %edx
movq %r14, %rdi
callq 0x1070
movb 0xf(%rsp), %r15b
cmpl $0x0, 0x2915(%rip)      # 0x40d0
je 0x1850
leal -0x30(%r15), %eax
cmpb $0x9, %al
ja 0x17df
movslq 0x290c(%rip), %rax      # 0x40dc
cmpq $0x5, %rax
jne 0x18bc
jmp 0x1a51
leaq 0x28ee(%rip), %rdi      # 0x40d4
callq 0x1130
movl %eax, %ebp
cmpl $0x20000, %eax          # imm = 0x20000
jae 0x1a58
movq 0x28c9(%rip), %rdi      # 0x40c8
movl $0x5, %esi
callq 0x1594
movq 0x28b8(%rip), %rdi      # 0x40c8
movl %ebp, %esi
andl %ebx, %esi
callq 0x1594
movq 0x28a8(%rip), %rdi      # 0x40c8
shrl $0x8, %ebp
andl %ebx, %ebp
movl %ebp, %esi
callq 0x1594
movw $0x0, 0x28a3(%rip)      # 0x40d8
movl $0x0, 0x289d(%rip)      # 0x40dc
incl 0x289f(%rip)            # 0x40e4
movq $0x0, 0x2880(%rip) # 0x40d0
movzbl %r15b, %edx
leal -0x20(%rdx), %eax
cmpl $0xf, %eax
ja 0x1897
movslq (%r13,%rax,4), %rax
addq %r13, %rax
jmpq *%rax
movl 0x2874(%rip), %eax      # 0x40e0
testl %eax, %eax
je 0x1a87
decl %eax
movl %eax, 0x2864(%rip)      # 0x40e0
movl 0x2862(%rip), %edx      # 0x40e4
cmpl $0x1, %edx
jle 0x1a8e
decl %edx
movl %edx, 0x2851(%rip)      # 0x40e4
movb $0x6, %al
jmp 0x18f2
leal -0x9(%rdx), %eax
cmpl $0x2, %eax
jb 0x1901
leal -0x30(%r15), %eax
cmpb $0x9, %al
ja 0x1a74
movl $0x1, 0x281b(%rip)      # 0x40d0
movslq 0x2820(%rip), %rax      # 0x40dc
leal 0x1(%rax), %ecx
movl %ecx, 0x2817(%rip)      # 0x40dc
movb %r15b, 0xc(%rax,%r12)
jmp 0x1901
incl 0x280e(%rip)            # 0x40e0
movb $0x3, %al
jmp 0x18f2
incl 0x2804(%rip)            # 0x40e0
movb $0x4, %al
jmp 0x18f2
incl 0x27fa(%rip)            # 0x40e0
movb $0x2, %al
jmp 0x18f2
incl 0x27f0(%rip)            # 0x40e0
movb $0x1, %al
movq 0x27cf(%rip), %rdi      # 0x40c8
movzbl %al, %esi
callq 0x1594
movq 0x27e0(%rip), %rdi      # 0x40e8
callq 0x10e0
testl %eax, %eax
je 0x1796
cmpl $0x1, 0x27c8(%rip)      # 0x40e4
jne 0x1a1e
cmpl $0x0, 0x27b7(%rip)      # 0x40e0
jne 0x1a28
cmpq $0x0, 0x27b9(%rip)      # 0x40f0
je 0x1ae8
movq 0x2784(%rip), %rax      # 0x40c8
movq 0x10(%rax), %r14
testq %r14, %r14
movq 0x10(%rsp), %r12
je 0x1a32
leaq 0x956(%rip), %rdi       # 0x22b3
movq %r14, %rsi
xorl %eax, %eax
callq 0x10a0
movq %r14, %rdi
callq 0x1100
testq %rax, %rax
je 0x1b07
movq %rax, %r15
movq 0x2746(%rip), %rdi      # 0x40c8
callq 0x1629
testl %eax, %eax
jne 0x19af
movq %r15, %rbx
movq 0x2733(%rip), %rdi      # 0x40c8
callq 0x15f0
movb %al, (%rbx)
movq 0x2725(%rip), %rdi      # 0x40c8
callq 0x1629
incq %rbx
testl %eax, %eax
je 0x198e
movq 0x273a(%rip), %rcx      # 0x40f0
movl $0x1, %esi
movq %r15, %rdi
movq %r14, %rdx
callq 0x1150
movq %rax, %r14
movq %r15, %rdi
callq 0x1030
testq %r14, %r14
je 0x1a40
leaq 0x71c(%rip), %rdi       # 0x20f9
xorl %ebp, %ebp
movq %r12, %rsi
xorl %eax, %eax
callq 0x10a0
movq 0x26d8(%rip), %rdi      # 0x40c8
callq 0x1634
movq 0x26ec(%rip), %rdi      # 0x40e8
callq 0x1080
movq 0x26e8(%rip), %rdi      # 0x40f0
callq 0x1080
movl %ebp, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x12dd
jmp 0x1922
callq 0x12f9
jmp 0x192f
leaq 0x8d2(%rip), %rdi       # 0x230b
callq 0x1060
jmp 0x1a45
callq 0x1315
callq 0x1331
movl $0x1, %ebp
jmp 0x19e9
callq 0x1195
jmp 0x1aa6
movq 0x2599(%rip), %rax      # 0x3ff8
movq (%rax), %rdi
movl %ebp, %edx
leaq 0x7bf(%rip), %rsi       # 0x222a
xorl %eax, %eax
callq 0x10d0
jmp 0x1aa6
movq 0x257d(%rip), %rax      # 0x3ff8
movq (%rax), %rdi
leaq 0x78e(%rip), %rsi       # 0x2213
jmp 0x1a9f
callq 0x11b1
jmp 0x1aa6
movq 0x2563(%rip), %rax      # 0x3ff8
movq (%rax), %rdi
leaq 0x754(%rip), %rsi       # 0x21f3
xorl %eax, %eax
callq 0x10d0
leaq 0xf(%rsp), %rdi
callq 0x11cd
jmp 0x1a4a
callq 0x1050
leaq 0x65a(%rip), %rsi       # 0x2118
jmp 0x1b0e
leaq 0x5e9(%rip), %rsi       # 0x20b0
jmp 0x1b26
leaq 0x667(%rip), %rdi       # 0x2137
leaq 0x678(%rip), %rsi       # 0x214f
leaq 0x67c(%rip), %rcx       # 0x215a
movl $0xea, %edx
callq 0x10b0
leaq 0x797(%rip), %rdi       # 0x2286
leaq 0x659(%rip), %rsi       # 0x214f
leaq 0x79e(%rip), %rcx       # 0x229b
movl $0x108, %edx            # imm = 0x108
callq 0x10b0
leaq 0x7be(%rip), %rsi       # 0x22cc
movl $0x47, %edi
xorl %eax, %eax
callq 0x1090
callq 0x1170
leaq 0x53f(%rip), %rsi       # 0x2065
movl $0x4a, %edi
xorl %eax, %eax
callq 0x10f0