// File: /workspace/github_c_makefile_star2_O1/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 0x1570
movq %rax, 0x2a49(%rip)      # 0x40c0
testq %rax, %rax
je 0x1ad7
movw $0x0, 0x2a47(%rip)      # 0x40d0
movq $0x0, 0x2a34(%rip) # 0x40c8
xorps %xmm0, %xmm0
movups %xmm0, 0x2a36(%rip)     # 0x40d4
movups %xmm0, 0x2a3b(%rip)     # 0x40e0
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 0x1110
cmpl $0x74, %eax
je 0x16ba
cmpl $-0x1, %eax
je 0x16df
cmpl $0x6f, %eax
jne 0x1ad2
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, 0x29e2(%rip)      # 0x40e0
jmp 0x173d
subl %ebx, %ebp
cmpl $0x1, %ebp
jne 0x1b3a
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 0x1100
movq %rax, 0x29ac(%rip)      # 0x40e0
testq %rax, %rax
je 0x1b3f
leaq 0x969(%rip), %rsi       # 0x20ad
movq %r12, %rdi
callq 0x1100
movq %rax, 0x2995(%rip)      # 0x40e8
testq %rax, %rax
je 0x1ae0
movq %r12, 0x10(%rsp)
movq 0x2978(%rip), %rdi      # 0x40e0
testq %rdi, %rdi
je 0x1ae9
callq 0x10d0
testl %eax, %eax
je 0x188b
cmpl $0x1, 0x2957(%rip)      # 0x40dc
jne 0x1a57
cmpl $0x0, 0x2946(%rip)      # 0x40d8
jne 0x1a61
cmpq $0x0, 0x2948(%rip)      # 0x40e8
je 0x1b08
movq 0x2913(%rip), %rax      # 0x40c0
movq 0x10(%rax), %r14
testq %r14, %r14
movq 0x10(%rsp), %r12
je 0x1a6b
leaq 0xaed(%rip), %rdi       # 0x22b3
movq %r14, %rsi
xorl %eax, %eax
callq 0x10a0
movq %r14, %rdi
callq 0x10f0
testq %rax, %rax
je 0x1b27
movq %rax, %r15
movq 0x28d5(%rip), %rdi      # 0x40c0
callq 0x162a
testl %eax, %eax
jne 0x1818
movq %r15, %rbx
movq 0x28c2(%rip), %rdi      # 0x40c0
callq 0x15f1
movb %al, (%rbx)
movq 0x28b4(%rip), %rdi      # 0x40c0
callq 0x162a
incq %rbx
testl %eax, %eax
je 0x17f7
movq 0x28c9(%rip), %rcx      # 0x40e8
movl $0x1, %esi
movq %r15, %rdi
movq %r14, %rdx
callq 0x1140
movq %rax, %r14
movq %r15, %rdi
callq 0x1030
testq %r14, %r14
je 0x1a79
leaq 0x8af(%rip), %rdi       # 0x20f9
xorl %ebp, %ebp
movq %r12, %rsi
xorl %eax, %eax
callq 0x10a0
movq 0x2863(%rip), %rdi      # 0x40c0
callq 0x1635
movq 0x2877(%rip), %rdi      # 0x40e0
callq 0x1080
movq 0x2873(%rip), %rdi      # 0x40e8
callq 0x1080
movl %ebp, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xf(%rsp), %r14
leaq 0x76d(%rip), %r12       # 0x2004
xorl %r15d, %r15d
movl $0xff, %ebx
movq 0x283a(%rip), %rcx      # 0x40e0
movl $0x1, %esi
movl $0x1, %edx
movq %r14, %rdi
callq 0x1070
movb 0xf(%rsp), %r13b
cmpl $0x0, 0x2804(%rip)      # 0x40c8
je 0x1968
leal -0x30(%r13), %eax
cmpb $0x9, %al
ja 0x18e8
movslq 0x27fb(%rip), %rax      # 0x40d4
cmpq $0x5, %rax
jne 0x19d3
jmp 0x1a8d
leaq 0x27dd(%rip), %rdi      # 0x40cc
callq 0x1120
movl %eax, %ebp
cmpl $0x20000, %eax          # imm = 0x20000
jae 0x1a38
movq 0x27b8(%rip), %rdi      # 0x40c0
movl $0x5, %esi
callq 0x1595
movq 0x27a7(%rip), %rdi      # 0x40c0
movl %ebp, %esi
andl %ebx, %esi
callq 0x1595
movq 0x2797(%rip), %rdi      # 0x40c0
movl %ebp, %esi
shrl $0x8, %esi
andl %ebx, %esi
callq 0x1595
movl %r15d, 0x2790(%rip)     # 0x40cc
movw $0x0, 0x278b(%rip)      # 0x40d0
movl %r15d, 0x2788(%rip)     # 0x40d4
incl 0x278a(%rip)            # 0x40dc
cmpl $0x1ffff, %ebp          # imm = 0x1FFFF
ja 0x1ac6
movl $0x0, 0x2760(%rip)      # 0x40c8
movzbl %r13b, %edx
leal -0x20(%rdx), %eax
cmpl $0xf, %eax
ja 0x19ae
movslq (%r12,%rax,4), %rax
addq %r12, %rax
jmpq *%rax
movl 0x2755(%rip), %eax      # 0x40d8
testl %eax, %eax
je 0x1aa7
decl %eax
movl %eax, 0x2745(%rip)      # 0x40d8
movl 0x2743(%rip), %edx      # 0x40dc
cmpl $0x1, %edx
jle 0x1aae
decl %edx
movl %edx, 0x2732(%rip)      # 0x40dc
movb $0x6, %al
jmp 0x1a10
leal -0x9(%rdx), %eax
cmpl $0x2, %eax
jb 0x1a1f
leal -0x30(%r13), %eax
cmpb $0x9, %al
ja 0x1a94
movl $0x1, 0x26fc(%rip)      # 0x40c8
movslq 0x2701(%rip), %rax      # 0x40d4
leal 0x1(%rax), %ecx
movl %ecx, 0x26f8(%rip)      # 0x40d4
leaq 0x26dd(%rip), %rcx      # 0x40c0
movb %r13b, 0xc(%rax,%rcx)
jmp 0x1a1f
incl 0x26e8(%rip)            # 0x40d8
movb $0x3, %al
jmp 0x1a10
incl 0x26de(%rip)            # 0x40d8
movb $0x4, %al
jmp 0x1a10
incl 0x26d4(%rip)            # 0x40d8
movb $0x2, %al
jmp 0x1a10
incl 0x26ca(%rip)            # 0x40d8
movb $0x1, %al
movq 0x26a9(%rip), %rdi      # 0x40c0
movzbl %al, %esi
callq 0x1595
movq 0x26ba(%rip), %rdi      # 0x40e0
callq 0x10d0
testl %eax, %eax
je 0x189f
jmp 0x177e
movq 0x25b9(%rip), %rax      # 0x3ff8
movq (%rax), %rdi
movl %ebp, %edx
leaq 0x7df(%rip), %rsi       # 0x222a
xorl %eax, %eax
callq 0x10c0
jmp 0x1952
callq 0x12cd
jmp 0x178b
callq 0x12e9
jmp 0x1798
leaq 0x899(%rip), %rdi       # 0x230b
callq 0x1060
jmp 0x1a7e
callq 0x1305
callq 0x1321
movl $0x1, %ebp
jmp 0x1856
callq 0x1185
jmp 0x1ac6
movq 0x255d(%rip), %rax      # 0x3ff8
movq (%rax), %rdi
leaq 0x76e(%rip), %rsi       # 0x2213
jmp 0x1abf
callq 0x11a1
jmp 0x1ac6
movq 0x2543(%rip), %rax      # 0x3ff8
movq (%rax), %rdi
leaq 0x734(%rip), %rsi       # 0x21f3
xorl %eax, %eax
callq 0x10c0
leaq 0xf(%rsp), %rdi
callq 0x11bd
jmp 0x1a83
callq 0x1050
leaq 0x63a(%rip), %rsi       # 0x2118
jmp 0x1b2e
leaq 0x5c9(%rip), %rsi       # 0x20b0
jmp 0x1b46
leaq 0x647(%rip), %rdi       # 0x2137
leaq 0x658(%rip), %rsi       # 0x214f
leaq 0x65c(%rip), %rcx       # 0x215a
movl $0xea, %edx
callq 0x10b0
leaq 0x777(%rip), %rdi       # 0x2286
leaq 0x639(%rip), %rsi       # 0x214f
leaq 0x77e(%rip), %rcx       # 0x229b
movl $0x108, %edx            # imm = 0x108
callq 0x10b0
leaq 0x79e(%rip), %rsi       # 0x22cc
movl $0x47, %edi
xorl %eax, %eax
callq 0x1090
callq 0x1160
leaq 0x51f(%rip), %rsi       # 0x2065
movl $0x4a, %edi
xorl %eax, %eax
callq 0x10e0