// File: /workspace/github_c_makefile_star2_O2/sisshiki1969[P]monocc/src/monocc.c
// Function: main
int main(int argc, char **argv) {
  char *file;
  verbose = true;
  for (int i = 1; i < argc; i++) {
    if (strcmp(argv[i], "-test") == 0) {
      test_vec();
      return 0;
    } else if (strcmp(argv[i], "-string") == 0) {
      if (i + 2 > argc) {
        fprintf(stderr, "No input string.\n");
        return 1;
      }
      file = "input";
      source_text = argv[i + 1];
      output = fopen("tmp.s", "w");
      compile(file);
      return 0;
    } else if (strcmp(argv[i], "-v") == 0) {
      verbose = false;
    } else {
      file = argv[i];
      source_text = read_file(argv[i]);
      output_file_name = calloc(1, strlen(file) + 5);
      strcpy(output_file_name, file);
      char *dot = output_file_name + strlen(output_file_name) - 2;
      if (strcmp(dot, ".c") != 0) {
        fprintf(stderr, "Invalid aource file name.");
        return 1;
      }
      *(dot + 1) = 's';

      output = fopen(output_file_name, "w");
      if (!output) {
        fprintf(stderr, "Cannot open output file.\n");
        exit(1);
      }

      compile(file);
      return 0;
    }
  }

  fprintf(stderr, "Invalid arguments.\n");
  return 1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %r14
leaq 0xc1c7(%rip), %rax      # 0x11200
movb $0x1, (%rax)
movl %edi, 0x4(%rsp)
movslq %edi, %rbp
pushq $0x1
popq %r13
leaq 0x610d(%rip), %r15      # 0xb15b
leaq 0x610c(%rip), %r12      # 0xb161
cmpq %rbp, %r13
jge 0x51b0
movq (%r14,%r13,8), %rbx
movq %rbx, %rdi
movq %r15, %rsi
callq 0x10e0
testl %eax, %eax
je 0x5135
movq %rbx, %rdi
movq %r12, %rsi
callq 0x10e0
testl %eax, %eax
je 0x5140
cmpb $0x2d, (%rbx)
jne 0x50a8
cmpb $0x76, 0x1(%rbx)
jne 0x50a8
cmpb $0x0, 0x2(%rbx)
jne 0x50a8
leaq 0xc160(%rip), %rax      # 0x11200
movb $0x0, (%rax)
incq %r13
jmp 0x5055
movq %rbx, %rdi
callq 0x4b78
movq %rax, 0xc159(%rip)      # 0x11210
movq %rbx, %rdi
callq 0x1090
leaq 0x5(%rax), %rsi
pushq $0x1
popq %rdi
callq 0x10d0
movq %rax, %r14
movq %rax, 0xc16b(%rip)      # 0x11240
movq %rax, %rdi
movq %rbx, %rsi
callq 0x1060
movq %r14, %rdi
callq 0x1090
cmpb $0x2e, -0x2(%r14,%rax)
jne 0x518f
cmpb $0x63, -0x1(%r14,%rax)
jne 0x518f
cmpb $0x0, (%r14,%rax)
jne 0x518f
movb $0x73, -0x1(%r14,%rax)
leaq 0x5f96(%rip), %rsi      # 0xb0ae
movq %r14, %rdi
callq 0x1150
movq %rax, 0xc0f9(%rip)      # 0x11220
testq %rax, %rax
je 0x51da
movq %rbx, %rdi
jmp 0x5177
xorl %ebx, %ebx
xorl %eax, %eax
callq 0x353d
jmp 0x517e
leal 0x2(%r13), %eax
cmpl 0x4(%rsp), %eax
jg 0x51c5
movq 0x8(%r14,%r13,8), %rax
movq %rax, 0xc0ba(%rip)      # 0x11210
leaq 0x6024(%rip), %rdi      # 0xb181
leaq 0x5f4a(%rip), %rsi      # 0xb0ae
callq 0x1150
movq %rax, 0xc0b0(%rip)      # 0x11220
leaq 0x6004(%rip), %rdi      # 0xb17b
callq 0x4c9e
xorl %ebx, %ebx
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0xbe62(%rip), %rax      # 0x10ff8
movq (%rax), %rcx
leaq 0x5fe7(%rip), %rdi      # 0xb187
pushq $0x19
popq %rsi
pushq $0x1
popq %rdx
callq 0x1190
pushq $0x1
popq %rbx
jmp 0x517e
movq 0xbe41(%rip), %rax      # 0x10ff8
movq (%rax), %rcx
leaq 0x5ffa(%rip), %rdi      # 0xb1bb
pushq $0x13
jmp 0x51a2
movq 0xbe2c(%rip), %rax      # 0x10ff8
movq (%rax), %rcx
leaq 0x5f93(%rip), %rdi      # 0xb169
pushq $0x11
jmp 0x51a2
movq 0xbe17(%rip), %rax      # 0x10ff8
movq (%rax), %rcx
leaq 0x5fb6(%rip), %rdi      # 0xb1a1
pushq $0x19
popq %rsi
pushq $0x1
popq %rdx
callq 0x1190
pushq $0x1
popq %rdi
callq 0x1180
nop