// File: /workspace/github_c_makefile_star2_O2/crcx[P]retroforth/vm/nga-c/retro.c
// Function: main
int main(int argc, char **argv) {
  int i;
  int modes[16];
  NgaState *vm = calloc(sizeof(NgaState), sizeof(char));
  verbose = 0;

  register_signal_handlers();

  initialize(vm);               /* Initialize Nga & image    */
  register_devices(vm);
  vm->sys_argc = argc;           /* Point the global argc and */
  vm->sys_argv = argv;           /* argv to the actual ones   */

  strlcpy(vm->scripting_sources[0], "<none>", 8192);


  /* Check arguments. If no flags were passed, load & run the
     file specified and exit. */
  if (argc >= 2 && argv[1][0] != '-') {
    update_rx(vm);
    include_file(vm, argv[1], 0);
    if (ACTIVE.sp >= 1)  dump_stack(vm);
    exit(0);
  }

  /* Clear startup modes       */
  for (i = 0; i < 16; i++)
    modes[i] = 0;

  if (argc <= 1) modes[FLAG_INTERACTIVE] = 1;

  update_rx(vm);

  /* Process Arguments */
  for (i = 1; i < argc; i++) {
    if ARG("-h") {
      help(argv[0]);
      exit(0);
    } else if ARG("-v") {
      verbose = 1;
    } else if ARG("-i") {
      modes[FLAG_INTERACTIVE] = 1;
      vm->interactive = -1;
    } else if ARG("-f") {
      include_file(vm, argv[i + 1], 0);
      i++;
    } else if ARG("-p") {
      include_plain_file(vm, argv[i + 1], 0);
      i++;
    } else if ARG("-u") {
      i++;
      load_image(vm, argv[i]);
      update_rx(vm);
    } else if ARG("-r") {
      i++;
      load_image(vm, argv[i]);
      modes[FLAG_INTERACTIVE] = 1;
      update_rx(vm);
    } else if ARG("-t") {
      include_file(vm, argv[i + 1], 1);
      i++;
    } else if (ARG("--code-start") || ARG("-cs")) {
      i++;
      strlcpy(vm->code_start, argv[i], 256);
    } else if (ARG("--code-end") || ARG("-ce")) {
      i++;
      strlcpy(vm->code_end, argv[i], 256);
    }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movq %rsi, %r14
movl %edi, %ebp
pushq $0x1
popq %rsi
movl $0x288ff0, %edi         # imm = 0x288FF0
callq 0x3220
movq %rax, %r15
movq %rax, %rbx
andl $0x0, 0x54a16(%rip)     # 0x5c290
callq 0x77f4
movq %r15, %rdi
callq 0x73ca
movq %r15, %rdi
callq 0x761f
movl %ebp, 0x207ad0(%r15)
movq %r14, 0x207ac8(%r15)
movl $0x6e6f6e3c, 0x207ad4(%r15) # imm = 0x6E6F6E3C
movl $0x3e656e, 0x207ad7(%r15) # imm = 0x3E656E
cmpl $0x1, %ebp
movq %rbx, 0x8(%rsp)
jle 0x78ca
movq 0x8(%r14), %rax
cmpb $0x2d, (%rax)
jne 0x7bd6
xorl %eax, %eax
cmpq $0x10, %rax
je 0x78dc
andl $0x0, 0x30(%rsp,%rax,4)
incq %rax
jmp 0x78cc
pushq $0x1
popq %rax
cmpl $0x2, %ebp
jl 0x78e8
movl 0x34(%rsp), %eax
movl %eax, 0x14(%rsp)
movq %rbx, %rdi
callq 0x7c10
leaq 0x288dec(%r15), %rax
movq %rax, 0x18(%rsp)
leaq 0x288cec(%r15), %rax
movq %rax, 0x20(%rsp)
leaq 0x288bec(%r15), %rax
movq %rax, 0x28(%rsp)
addq $0x288aec, %r15         # imm = 0x288AEC
pushq $0x1
popq %r12
cmpl %ebp, %r12d
jge 0x7b78
movslq %r12d, %rbx
movq (%r14,%rbx,8), %r13
cmpb $0x2d, (%r13)
jne 0x79ce
cmpb $0x68, 0x1(%r13)
jne 0x7950
cmpb $0x0, 0x2(%r13)
je 0x7bc7
cmpb $0x76, 0x1(%r13)
jne 0x7962
cmpb $0x0, 0x2(%r13)
je 0x7ab8
cmpb $0x69, 0x1(%r13)
jne 0x7974
cmpb $0x0, 0x2(%r13)
je 0x7ac4
cmpb $0x66, 0x1(%r13)
jne 0x7986
cmpb $0x0, 0x2(%r13)
je 0x7ad5
cmpb $0x70, 0x1(%r13)
jne 0x7998
cmpb $0x0, 0x2(%r13)
je 0x7b08
cmpb $0x75, 0x1(%r13)
jne 0x79aa
cmpb $0x0, 0x2(%r13)
je 0x7b1c
cmpb $0x72, 0x1(%r13)
jne 0x79bc
cmpb $0x0, 0x2(%r13)
je 0x7b3b
cmpb $0x74, 0x1(%r13)
jne 0x79ce
cmpb $0x0, 0x2(%r13)
je 0x7b61
movq %r13, %rdi
leaq 0x1889(%rip), %rsi      # 0x9261
callq 0x3240
testl %eax, %eax
je 0x7a92
movq %r13, %rdi
leaq 0x187f(%rip), %rsi      # 0x926e
callq 0x3240
testl %eax, %eax
je 0x7a92
movq %r13, %rdi
leaq 0x186c(%rip), %rsi      # 0x9272
callq 0x3240
testl %eax, %eax
je 0x7aa4
movq %r13, %rdi
leaq 0x1860(%rip), %rsi      # 0x927d
callq 0x3240
testl %eax, %eax
je 0x7aa4
movq %r13, %rdi
leaq 0x1851(%rip), %rsi      # 0x9281
callq 0x3240
testl %eax, %eax
je 0x7ae9
movq %r13, %rdi
leaq 0x1847(%rip), %rsi      # 0x928e
callq 0x3240
testl %eax, %eax
je 0x7ae9
movq %r13, %rdi
leaq 0x1834(%rip), %rsi      # 0x9292
callq 0x3240
testl %eax, %eax
je 0x7a7e
movq %r13, %rdi
leaq 0x182c(%rip), %rsi      # 0x929d
callq 0x3240
testl %eax, %eax
jne 0x7b00
incl %r12d
movq 0x8(%r14,%rbx,8), %rsi
movl $0x100, %edx            # imm = 0x100
movq 0x18(%rsp), %rdi
jmp 0x7afb
incl %r12d
movq 0x8(%r14,%rbx,8), %rsi
movl $0x100, %edx            # imm = 0x100
movq %r15, %rdi
jmp 0x7afb
incl %r12d
movq 0x8(%r14,%rbx,8), %rsi
movl $0x100, %edx            # imm = 0x100
movq 0x28(%rsp), %rdi
jmp 0x7afb
movl $0x1, 0x547ce(%rip)     # 0x5c290
jmp 0x7b00
movq 0x8(%rsp), %rax
orl $-0x1, 0x288adc(%rax)
jmp 0x7b58
incl %r12d
movq 0x8(%r14,%rbx,8), %rsi
movq 0x8(%rsp), %rdi
xorl %edx, %edx
jmp 0x7b71
incl %r12d
movq 0x8(%r14,%rbx,8), %rsi
movl $0x100, %edx            # imm = 0x100
movq 0x20(%rsp), %rdi
callq 0x3c71
incl %r12d
jmp 0x7923
incl %r12d
movq 0x8(%r14,%rbx,8), %rsi
movq 0x8(%rsp), %rdi
callq 0x69e9
jmp 0x7b00
incl %r12d
movq 0x8(%r14,%rbx,8), %rsi
movq 0x8(%rsp), %rbx
movq %rbx, %rdi
callq 0x7c2e
movq %rbx, %rdi
callq 0x7c10
jmp 0x7b00
incl %r12d
movq 0x8(%r14,%rbx,8), %rsi
movq 0x8(%rsp), %rbx
movq %rbx, %rdi
callq 0x7c2e
movq %rbx, %rdi
callq 0x7c10
pushq $0x1
popq %rax
movl %eax, 0x14(%rsp)
jmp 0x7b00
incl %r12d
movq 0x8(%r14,%rbx,8), %rsi
movq 0x8(%rsp), %rdi
pushq $0x1
popq %rdx
callq 0x66ba
jmp 0x7b00
cmpl $0x1, 0x14(%rsp)
movq 0x8(%rsp), %rbx
jne 0x7b8e
movq %rbx, %rdi
xorl %esi, %esi
callq 0x390d
movslq 0x2043a4(%rbx), %rax
imulq $0x874, %rax, %rax      # imm = 0x874
cmpl $0x0, 0x200004(%rbx,%rax)
jle 0x7bae
movq %rbx, %rdi
callq 0x7144
movq %rbx, %rdi
callq 0x3040
xorl %eax, %eax
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq (%r14), %rdi
callq 0x752c
xorl %edi, %edi
callq 0x33b0
movq %rbx, %rdi
callq 0x7c10
movq 0x8(%r14), %rsi
movq %rbx, %rdi
xorl %edx, %edx
callq 0x66ba
movslq 0x2043a4(%rbx), %rax
imulq $0x874, %rax, %rax      # imm = 0x874
cmpl $0x0, 0x200004(%rbx,%rax)
jle 0x7bcf
movq 0x8(%rsp), %rdi
callq 0x7144
jmp 0x7bcf