// File: /workspace/github_c_makefile_star2_O2/stickyPiston[P]ti-basic-compiler/src/main.c
// Function: main
int main(int argc, char *argv[]) {
  for (int i = 1; i < argc; i++) {
    if (strcmp(argv[i], "-o") == 0) {
      outputFile = argv[++i];
    } else if (strcmp(argv[i], "-i") == 0) {
      ignoreWhitespace = true;
    } else if (strcmp(argv[i], "-d") == 0) {
      disassembleMode = true;
    } else if (strcmp(argv[i], "-n") == 0) {
      strncpy(programName, argv[++i], 8);
    } else if (strcmp(argv[i], "-h") == 0 || strcmp(argv[i], "--help") == 0) {
      openHelp(argv[0]);
      return 0;
    } else if (strcmp(argv[i], "-l") == 0 || strcmp(argv[i], "--lang") == 0) {
      i++;
      if (strcmp(argv[i], "SE") == 0 || strcmp(argv[i], "se") == 0) lang = LANG_SE;
      if (strcmp(argv[i], "EN") == 0 || strcmp(argv[i], "en") == 0) lang = LANG_EN;
      if (strcmp(argv[i], "NL") == 0 || strcmp(argv[i], "nl") == 0) lang = LANG_NL;
    } else {
      if (argv[i][0] == '-') {
        printf("Unknown flag: %s\n", argv[i]);
        return 1;
      } else {
        inputFile = argv[i];
      }
    }
  }

  if (outputFile == NULL) outputFile = "out.8xp";
  if (inputFile == NULL) { openHelp(argv[0]); return 0;}
  if (*programName == 0) strcpy(programName, "PROG");

  if (disassembleMode) {
    disassemble();
  } else {
    compile();
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %rbx
movl %edi, -0x2c(%rbp)
pushq $0x1
popq %r15
cmpl -0x2c(%rbp), %r15d
jge 0xe422
movslq %r15d, %r13
movq (%rbx,%r13,8), %r12
movb (%r12), %r14b
cmpb $0x2d, %r14b
jne 0xe2e3
cmpb $0x6f, 0x1(%r12)
jne 0xe293
cmpb $0x0, 0x2(%r12)
je 0xe386
cmpb $0x69, 0x1(%r12)
jne 0xe2a7
cmpb $0x0, 0x2(%r12)
je 0xe397
cmpb $0x64, 0x1(%r12)
jne 0xe2bb
cmpb $0x0, 0x2(%r12)
je 0xe3a0
cmpb $0x6e, 0x1(%r12)
jne 0xe2cf
cmpb $0x0, 0x2(%r12)
je 0xe3a9
cmpb $0x68, 0x1(%r12)
jne 0xe2e3
cmpb $0x0, 0x2(%r12)
je 0xe472
movq %r12, %rdi
leaq 0xd17(%rip), %rsi       # 0xf004
callq 0xe0d0
testl %eax, %eax
je 0xe472
cmpb $0x2d, %r14b
jne 0xe310
cmpb $0x6c, 0x1(%r12)
jne 0xe310
cmpb $0x0, 0x2(%r12)
je 0xe33c
movq %r12, %rdi
leaq 0xcf1(%rip), %rsi       # 0xf00b
callq 0xe0d0
testl %eax, %eax
je 0xe33c
cmpb $0x2d, %r14b
je 0xe47e
movq %r12, 0xb8bc(%rip)      # 0x19bf0
incl %r15d
jmp 0xe264
incl %r15d
movq 0x8(%rbx,%r13,8), %rax
movzbl (%rax), %ecx
cmpl $0x73, %ecx
je 0xe359
cmpl $0x53, %ecx
jne 0xe371
cmpb $0x45, 0x1(%rax)
jne 0xe334
jmp 0xe35f
cmpb $0x65, 0x1(%rax)
jne 0xe334
cmpb $0x0, 0x2(%rax)
jne 0xe334
movl $0x2, 0xb879(%rip)      # 0x19be8
movb (%rax), %cl
cmpb $0x65, %cl
je 0xe3c5
movzbl %cl, %edx
cmpl $0x45, %edx
jne 0xe3e2
cmpb $0x4e, 0x1(%rax)
jne 0xe334
jmp 0xe3cf
incl %r15d
movq 0x8(%rbx,%r13,8), %rax
movq %rax, 0xb873(%rip)      # 0x19c08
jmp 0xe334
movb $0x1, 0xb872(%rip)      # 0x19c10
jmp 0xe334
movb $0x1, 0xb86a(%rip)      # 0x19c11
jmp 0xe334
incl %r15d
movq 0x8(%rbx,%r13,8), %rsi
leaq 0xb840(%rip), %rdi      # 0x19bf8
pushq $0x8
popq %rdx
callq 0xe050
jmp 0xe334
cmpb $0x6e, 0x1(%rax)
jne 0xe334
cmpb $0x0, 0x2(%rax)
jne 0xe334
andl $0x0, 0xb808(%rip)      # 0x19be8
movb (%rax), %cl
cmpb $0x6e, %cl
je 0xe3ff
movzbl %cl, %ecx
cmpl $0x4e, %ecx
jne 0xe334
cmpb $0x4c, 0x1(%rax)
jne 0xe334
jmp 0xe409
cmpb $0x6c, 0x1(%rax)
jne 0xe334
cmpb $0x0, 0x2(%rax)
jne 0xe334
movl $0x1, 0xb7cb(%rip)      # 0x19be8
jmp 0xe334
cmpq $0x0, 0xb7de(%rip)      # 0x19c08
jne 0xe43a
leaq 0xbf1(%rip), %rax       # 0xf024
movq %rax, 0xb7ce(%rip)      # 0x19c08
cmpq $0x0, 0xb7ae(%rip)      # 0x19bf0
je 0xe472
cmpb $0x0, 0xb7ad(%rip)      # 0x19bf8
jne 0xe45e
movb $0x0, 0xb7a8(%rip)      # 0x19bfc
movl $0x474f5250, 0xb79a(%rip) # imm = 0x474F5250
cmpb $0x1, 0xb7ac(%rip)      # 0x19c11
jne 0xe494
xorl %ebx, %ebx
xorl %eax, %eax
callq 0xe9cc
jmp 0xe49d
movq (%rbx), %rdi
callq 0xe4ae
xorl %ebx, %ebx
jmp 0xe49d
leaq 0xb8d(%rip), %rdi       # 0xf012
movq %r12, %rsi
xorl %eax, %eax
callq 0xe0b0
pushq $0x1
popq %rbx
jmp 0xe49d
xorl %ebx, %ebx
xorl %eax, %eax
callq 0xe5e0
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq