// File: /workspace/github_c_makefile_star2_O1/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, %r14
xorl %ebx, %ebx
movl %edi, -0x2c(%rbp)
cmpl $0x2, %edi
setge %r12b
jl 0xe4d0
movl $0x1, %r13d
movslq %r13d, %r15
movq (%r14,%r15,8), %rbx
movq %rbx, %rdi
leaq 0xcee(%rip), %rsi       # 0xf004
callq 0xe0d0
testl %eax, %eax
je 0xe3d1
movq %rbx, %rdi
leaq 0xcda(%rip), %rsi       # 0xf007
callq 0xe0d0
testl %eax, %eax
je 0xe3e5
movq %rbx, %rdi
leaq 0xcc6(%rip), %rsi       # 0xf00a
callq 0xe0d0
testl %eax, %eax
je 0xe3f1
movq %rbx, %rdi
leaq 0xcb2(%rip), %rsi       # 0xf00d
callq 0xe0d0
testl %eax, %eax
je 0xe3fd
movq %rbx, %rdi
leaq 0xc9e(%rip), %rsi       # 0xf010
callq 0xe0d0
testl %eax, %eax
je 0xe4c6
movq %rbx, %rdi
leaq 0xc8a(%rip), %rsi       # 0xf013
callq 0xe0d0
testl %eax, %eax
je 0xe4c6
movq %rbx, %rdi
leaq 0xc7a(%rip), %rsi       # 0xf01a
callq 0xe0d0
testl %eax, %eax
je 0xe41b
movq %rbx, %rdi
leaq 0xc6a(%rip), %rsi       # 0xf01d
callq 0xe0d0
testl %eax, %eax
je 0xe41b
cmpb $0x2d, (%rbx)
je 0xe548
movq %rbx, 0xb824(%rip)      # 0x19bf0
jmp 0xe4b3
incl %r13d
movq 0x8(%r14,%r15,8), %rax
movq %rax, 0xb828(%rip)      # 0x19c08
jmp 0xe4b3
movb $0x1, 0xb824(%rip)      # 0x19c10
jmp 0xe4b3
movb $0x1, 0xb819(%rip)      # 0x19c11
jmp 0xe4b3
incl %r13d
movq 0x8(%r14,%r15,8), %rsi
movl $0x8, %edx
leaq 0xb7e7(%rip), %rdi      # 0x19bf8
callq 0xe050
jmp 0xe4b3
movq 0x8(%r14,%r15,8), %rbx
movq %rbx, %rdi
leaq 0xbfa(%rip), %rsi       # 0xf024
callq 0xe0d0
testl %eax, %eax
je 0xe446
movq %rbx, %rdi
leaq 0xda2(%rip), %rsi       # 0xf1df
callq 0xe0d0
testl %eax, %eax
jne 0xe450
movl $0x2, 0xb798(%rip)      # 0x19be8
movq %rbx, %rdi
leaq 0x1c82(%rip), %rsi      # 0x100dc
callq 0xe0d0
testl %eax, %eax
je 0xe476
movq %rbx, %rdi
leaq 0xe9f(%rip), %rsi       # 0xf30c
callq 0xe0d0
testl %eax, %eax
jne 0xe480
movl $0x0, 0xb768(%rip)      # 0x19be8
incl %r13d
movq %rbx, %rdi
leaq 0xb9a(%rip), %rsi       # 0xf027
callq 0xe0d0
testl %eax, %eax
je 0xe4a9
movq %rbx, %rdi
leaq 0xb8a(%rip), %rsi       # 0xf02a
callq 0xe0d0
testl %eax, %eax
jne 0xe4b3
movl $0x1, 0xb735(%rip)      # 0x19be8
incl %r13d
cmpl -0x2c(%rbp), %r13d
setl %r12b
jl 0xe305
jmp 0xe4ce
movq (%r14), %rdi
callq 0xe563
xorl %ebx, %ebx
testb $0x1, %r12b
jne 0xe537
cmpq $0x0, 0xb72a(%rip)      # 0x19c08
jne 0xe4ee
leaq 0xb58(%rip), %rax       # 0xf03f
movq %rax, 0xb71a(%rip)      # 0x19c08
cmpq $0x0, 0xb6fa(%rip)      # 0x19bf0
je 0xe524
cmpb $0x0, 0xb6f9(%rip)      # 0x19bf8
jne 0xe512
movb $0x0, 0xb6f4(%rip)      # 0x19bfc
movl $0x474f5250, 0xb6e6(%rip) # imm = 0x474F5250
cmpb $0x1, 0xb6f8(%rip)      # 0x19c11
jne 0xe530
xorl %eax, %eax
callq 0xeac3
jmp 0xe537
movq (%r14), %rdi
callq 0xe563
xorl %ebx, %ebx
jmp 0xe537
xorl %eax, %eax
callq 0xe67d
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xade(%rip), %rdi       # 0xf02d
movq %rbx, %rsi
xorl %eax, %eax
callq 0xe0b0
movl $0x1, %ebx
jmp 0xe4d0