// File: /workspace/github_c_makefile_star2_O2/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 0x1384
movq %rax, 0x2c59(%rip)      # 0x40c8
testq %rax, %rax
je 0x19fb
andw $0x0, 0x2c58(%rip)      # 0x40d8
andq $0x0, 0x2c48(%rip)      # 0x40d0
xorps %xmm0, %xmm0
movups %xmm0, 0x2c4a(%rip)     # 0x40dc
movups %xmm0, 0x2c4f(%rip)     # 0x40e8
leaq 0xba4(%rip), %r12       # 0x2044
leaq 0xba6(%rip), %r15       # 0x204d
movq 0x2b2a(%rip), %rbx      # 0x3fd8
movl %ebp, %edi
movq %r14, %rsi
movq %r15, %rdx
callq 0x1120
cmpl $0x74, %eax
je 0x14ae
cmpl $-0x1, %eax
je 0x14d3
cmpl $0x6f, %eax
jne 0x19f6
movq (%rbx), %r12
jmp 0x14ae
movq 0x2af6(%rip), %rax      # 0x3fd0
movslq (%rax), %rbx
cmpl %ebx, %ebp
jne 0x14f4
movq 0x2ae0(%rip), %rax      # 0x3fc8
movq (%rax), %rax
movq %rax, 0x2bf6(%rip)      # 0x40e8
jmp 0x1531
subl %ebx, %ebp
cmpl $0x1, %ebp
jne 0x1a5c
movq (%r14,%rbx,8), %rsi
leaq 0xb47(%rip), %rdi       # 0x2051
xorl %eax, %eax
callq 0x10a0
movq (%r14,%rbx,8), %rdi
leaq 0xb46(%rip), %rsi       # 0x2062
callq 0x1110
movq %rax, 0x2bc0(%rip)      # 0x40e8
testq %rax, %rax
je 0x1a80
leaq 0xb75(%rip), %rsi       # 0x20ad
movq %r12, %rdi
callq 0x1110
movq %rax, 0x2ba9(%rip)      # 0x40f0
testq %rax, %rax
je 0x1a04
movq %r12, 0x10(%rsp)
movq 0x2b8c(%rip), %rdi      # 0x40e8
testq %rdi, %rdi
je 0x1a0d
leaq 0xf(%rsp), %r14
pushq $0x1
popq %r15
leaq 0xa8f(%rip), %rbx       # 0x2004
movl $0xff, %r12d
callq 0x10e0
testl %eax, %eax
jne 0x16fc
movq 0x2b59(%rip), %rcx      # 0x40e8
movq %r14, %rdi
movq %r15, %rsi
movq %r15, %rdx
callq 0x1070
movb 0xf(%rsp), %bpl
cmpl $0x0, 0x2b27(%rip)      # 0x40d0
je 0x163a
leal -0x30(%rbp), %eax
cmpb $0x9, %al
ja 0x15cc
movslq 0x2b1f(%rip), %rax      # 0x40dc
cmpq $0x5, %rax
jne 0x16a4
jmp 0x18a3
leaq 0x2b01(%rip), %rdi      # 0x40d4
callq 0x1130
movl %eax, %r13d
cmpl $0x20000, %eax          # imm = 0x20000
jae 0x1886
movq 0x2adb(%rip), %rdi      # 0x40c8
pushq $0x5
popq %rsi
callq 0x139c
movq 0x2acc(%rip), %rdi      # 0x40c8
movl %r13d, %esi
andl %r12d, %esi
callq 0x139c
movq 0x2aba(%rip), %rdi      # 0x40c8
shrl $0x8, %r13d
andl %r12d, %r13d
movl %r13d, %esi
callq 0x139c
andw $0x0, 0x2ab3(%rip)      # 0x40d8
andl $0x0, 0x2ab0(%rip)      # 0x40dc
incl 0x2ab2(%rip)            # 0x40e4
andq $0x0, 0x2a96(%rip)      # 0x40d0
movzbl %bpl, %edx
leal -0x20(%rdx), %eax
cmpl $0xf, %eax
ja 0x1680
movslq (%rbx,%rax,4), %rax
addq %rbx, %rax
jmpq *%rax
movl 0x2a8b(%rip), %eax      # 0x40e0
testl %eax, %eax
je 0x18d4
decl %eax
movl %eax, 0x2a7b(%rip)      # 0x40e0
movl 0x2a79(%rip), %edx      # 0x40e4
cmpl $0x1, %edx
jle 0x18e9
decl %edx
movl %edx, 0x2a68(%rip)      # 0x40e4
movb $0x6, %al
jmp 0x16e1
leal -0x9(%rdx), %eax
cmpl $0x2, %eax
jb 0x16f0
leal -0x30(%rbp), %eax
cmpb $0x9, %al
ja 0x18c1
movl $0x1, 0x2a33(%rip)      # 0x40d0
movslq 0x2a38(%rip), %rax      # 0x40dc
leal 0x1(%rax), %ecx
movl %ecx, 0x2a2f(%rip)      # 0x40dc
leaq 0x2a14(%rip), %rcx      # 0x40c8
movb %bpl, 0xc(%rax,%rcx)
jmp 0x16f0
incl 0x2a1f(%rip)            # 0x40e0
movb $0x3, %al
jmp 0x16e1
incl 0x2a15(%rip)            # 0x40e0
movb $0x4, %al
jmp 0x16e1
incl 0x2a0b(%rip)            # 0x40e0
movb $0x2, %al
jmp 0x16e1
incl 0x2a01(%rip)            # 0x40e0
movb $0x1, %al
movq 0x29e0(%rip), %rdi      # 0x40c8
movzbl %al, %esi
callq 0x139c
movq 0x29f1(%rip), %rdi      # 0x40e8
jmp 0x157b
cmpl $0x1, 0x29e1(%rip)      # 0x40e4
jne 0x17f9
cmpl $0x0, 0x29d0(%rip)      # 0x40e0
movq 0x10(%rsp), %r12
jne 0x181a
cmpq $0x0, 0x29cd(%rip)      # 0x40f0
je 0x1a2c
movq 0x2998(%rip), %rax      # 0x40c8
movq 0x10(%rax), %r14
testq %r14, %r14
je 0x183b
leaq 0xb6f(%rip), %rdi       # 0x22b3
movq %r14, %rsi
xorl %eax, %eax
callq 0x10a0
movq %r14, %rdi
callq 0x1100
testq %rax, %rax
je 0x1a4b
movq %rax, %r15
movq %rax, %rbx
movq 0x295c(%rip), %rdi      # 0x40c8
callq 0x1426
testl %eax, %eax
jne 0x1788
movq 0x294c(%rip), %rdi      # 0x40c8
callq 0x13f0
movb %al, (%rbx)
incq %rbx
jmp 0x1765
movq 0x2961(%rip), %rcx      # 0x40f0
pushq $0x1
popq %rsi
movq %r15, %rdi
movq %r14, %rdx
callq 0x1150
movq %rax, %r14
movq %r15, %rdi
callq 0x1030
testq %r14, %r14
je 0x1849
leaq 0x941(%rip), %rdi       # 0x20f9
xorl %ebp, %ebp
movq %r12, %rsi
xorl %eax, %eax
callq 0x10a0
movq 0x28fd(%rip), %rdi      # 0x40c8
callq 0x1431
movq 0x2911(%rip), %rdi      # 0x40e8
callq 0x1080
movq 0x290d(%rip), %rdi      # 0x40f0
callq 0x1080
movl %ebp, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x27f8(%rip), %rax      # 0x3ff8
movq (%rax), %rcx
leaq 0x960(%rip), %rdi       # 0x216a
pushq $0x29
popq %rsi
pushq $0x1
popq %rdx
callq 0x1150
jmp 0x1709
movq 0x27d7(%rip), %rax      # 0x3ff8
movq (%rax), %rcx
leaq 0x969(%rip), %rdi       # 0x2194
pushq $0x26
popq %rsi
pushq $0x1
popq %rdx
callq 0x1150
jmp 0x171b
leaq 0xac9(%rip), %rdi       # 0x230b
callq 0x1060
jmp 0x1865
movq 0x27a8(%rip), %rax      # 0x3ff8
movq (%rax), %rcx
leaq 0xa8f(%rip), %rdi       # 0x22e9
pushq $0x21
popq %rsi
pushq $0x1
popq %rdx
callq 0x1150
movq 0x278c(%rip), %rax      # 0x3ff8
movq (%rax), %rcx
leaq 0x86b(%rip), %rdi       # 0x20e1
pushq $0x17
popq %rsi
pushq $0x1
popq %rdx
callq 0x1150
jmp 0x19ee
movq 0x276b(%rip), %rax      # 0x3ff8
movq (%rax), %rdi
movl %r13d, %edx
leaq 0x990(%rip), %rsi       # 0x222a
xorl %eax, %eax
callq 0x10d0
jmp 0x1901
movq 0x274e(%rip), %rax      # 0x3ff8
movq (%rax), %rcx
leaq 0x907(%rip), %rdi       # 0x21bb
pushq $0x1a
popq %rsi
pushq $0x1
popq %rdx
callq 0x1150
jmp 0x1901
movq 0x2730(%rip), %rax      # 0x3ff8
movq (%rax), %rdi
leaq 0x941(%rip), %rsi       # 0x2213
jmp 0x18fa
movq 0x271d(%rip), %rax      # 0x3ff8
movq (%rax), %rcx
leaq 0x8f1(%rip), %rdi       # 0x21d6
pushq $0x1c
jmp 0x18b6
movq 0x2708(%rip), %rax      # 0x3ff8
movq (%rax), %rdi
leaq 0x8f9(%rip), %rsi       # 0x21f3
xorl %eax, %eax
callq 0x10d0
movq 0x26f0(%rip), %rax      # 0x3ff8
movq (%rax), %rcx
leaq 0x7ba(%rip), %rdi       # 0x20cc
pushq $0x14
popq %rsi
pushq $0x1
popq %rdx
callq 0x1150
movl 0x27ad(%rip), %esi      # 0x40d0
leaq 0x917(%rip), %rdi       # 0x2241
xorl %eax, %eax
callq 0x10a0
movl 0x27a5(%rip), %esi      # 0x40dc
leaq 0x90f(%rip), %rdi       # 0x224d
xorl %eax, %eax
callq 0x10a0
leaq 0x90f(%rip), %r14       # 0x225b
xorl %ebx, %ebx
cmpq $0x6, %rbx
je 0x196f
leaq 0x276d(%rip), %rax      # 0x40c8
movzbl 0xc(%rbx,%rax), %esi
movq %r14, %rdi
xorl %eax, %eax
callq 0x10a0
incq %rbx
jmp 0x194e
pushq $0xa
popq %rdi
callq 0x1040
movl 0x2767(%rip), %esi      # 0x40e4
movl 0x275d(%rip), %edx      # 0x40e0
leaq 0x8d7(%rip), %rdi       # 0x2261
xorl %eax, %eax
callq 0x10a0
leaq 0x8e2(%rip), %rdi       # 0x227a
pushq $0x8
popq %rbp
leaq 0x8b9(%rip), %rbx       # 0x225b
leaq 0x8da(%rip), %r14       # 0x2283
xorl %eax, %eax
callq 0x10a0
movl %ebp, %r15d
movq 0x270e(%rip), %rdi      # 0x40c8
callq 0x1426
testl %eax, %eax
jne 0x19e6
movq 0x26fe(%rip), %rdi      # 0x40c8
callq 0x13f0
movzbl %al, %esi
movq %rbx, %rdi
xorl %eax, %eax
callq 0x10a0
decl %r15d
jne 0x19b3
movq %r14, %rdi
jmp 0x19a9
pushq $0xa
popq %rdi
callq 0x1040
pushq $0x1
popq %rbp
jmp 0x17c4
callq 0x1050
leaq 0x716(%rip), %rsi       # 0x2118
jmp 0x1a52
leaq 0x6a5(%rip), %rsi       # 0x20b0
jmp 0x1a87
leaq 0x723(%rip), %rdi       # 0x2137
leaq 0x734(%rip), %rsi       # 0x214f
leaq 0x738(%rip), %rcx       # 0x215a
movl $0xea, %edx
callq 0x10b0
leaq 0x853(%rip), %rdi       # 0x2286
leaq 0x715(%rip), %rsi       # 0x214f
leaq 0x85a(%rip), %rcx       # 0x229b
movl $0x108, %edx            # imm = 0x108
callq 0x10b0
leaq 0x87a(%rip), %rsi       # 0x22cc
pushq $0x47
popq %rdi
xorl %eax, %eax
callq 0x1090
movq 0x2595(%rip), %rax      # 0x3ff8
movq (%rax), %rcx
leaq 0x614(%rip), %rdi       # 0x2081
pushq $0x2b
popq %rsi
pushq $0x1
popq %rdx
callq 0x1150
pushq $0x40
popq %rdi
callq 0x1140
leaq 0x5de(%rip), %rsi       # 0x2065
pushq $0x4a
popq %rdi
xorl %eax, %eax
callq 0x10f0