// File: /workspace/github_c_makefile_star2_O1/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 $0x28, %rsp
movq %rsi, %r14
movl %edi, %ebp
movl $0x288ff0, %edi         # imm = 0x288FF0
movl $0x1, %esi
callq 0x3230
movq %rax, %rbx
movl $0x0, 0x557b5(%rip)     # 0x5e2a0
callq 0x8a57
movq %rbx, %rdi
callq 0x852a
movq %rbx, %rdi
callq 0x8800
movl %ebp, 0x207ad0(%rbx)
movq %r14, 0x207ac8(%rbx)
movl $0x6e6f6e3c, 0x207ad4(%rbx) # imm = 0x6E6F6E3C
movl $0x3e656e, 0x207ad7(%rbx) # imm = 0x3E656E
cmpl $0x2, %ebp
jl 0x8b33
movq 0x8(%r14), %rax
cmpb $0x2d, (%rax)
jne 0x8f6e
movl $0x0, 0x4(%rsp)
cmpl $0x2, %ebp
setl %r15b
movl 0x8(%rbx), %eax
movl 0x14(%rbx), %ecx
movl %eax, 0x2045b0(%rbx)
movl %ecx, 0x2045b4(%rbx)
movl 0x28(%rbx), %esi
testl %esi, %esi
je 0x8b63
movq %rbx, %rdi
callq 0x3a2d
cmpl $0x2, %ebp
jl 0x8f17
movl 0x4(%rsp), %eax
movb %r15b, %al
movl %eax, 0x4(%rsp)
leaq 0x288dec(%rbx), %rax
movq %rax, 0x8(%rsp)
leaq 0x288cec(%rbx), %rax
movq %rax, 0x10(%rsp)
leaq 0x288bec(%rbx), %rax
movq %rax, 0x18(%rsp)
movq %rbx, %rax
addq $0x288aec, %rax         # imm = 0x288AEC
movq %rax, 0x20(%rsp)
movl $0x1, %r15d
movslq %r15d, %r12
movq (%r14,%r12,8), %r13
movq %r13, %rdi
leaq 0x29d5(%rip), %rsi      # 0xb595
callq 0x3250
testl %eax, %eax
je 0x8f5f
movq %r13, %rdi
leaq 0x2bb6(%rip), %rsi      # 0xb78d
callq 0x3250
testl %eax, %eax
je 0x8d5e
movq %r13, %rdi
leaq 0x29c7(%rip), %rsi      # 0xb5b5
callq 0x3250
testl %eax, %eax
je 0x8d6d
movq %r13, %rdi
leaq 0x2642(%rip), %rsi      # 0xb247
callq 0x3250
testl %eax, %eax
je 0x8d84
movq %r13, %rdi
leaq 0x262e(%rip), %rsi      # 0xb24a
callq 0x3250
testl %eax, %eax
je 0x8d9d
movq %r13, %rdi
leaq 0x261a(%rip), %rsi      # 0xb24d
callq 0x3250
testl %eax, %eax
je 0x8db4
movq %r13, %rdi
leaq 0x2606(%rip), %rsi      # 0xb250
callq 0x3250
testl %eax, %eax
je 0x8ddd
movq %r13, %rdi
leaq 0x25f2(%rip), %rsi      # 0xb253
callq 0x3250
testl %eax, %eax
je 0x8e59
movq %r13, %rdi
leaq 0x25de(%rip), %rsi      # 0xb256
callq 0x3250
testl %eax, %eax
je 0x8e21
movq %r13, %rdi
leaq 0x25d4(%rip), %rsi      # 0xb263
callq 0x3250
testl %eax, %eax
je 0x8e21
movq %r13, %rdi
leaq 0x25c1(%rip), %rsi      # 0xb267
callq 0x3250
testl %eax, %eax
je 0x8e77
movq %r13, %rdi
leaq 0x25b5(%rip), %rsi      # 0xb272
callq 0x3250
testl %eax, %eax
je 0x8e77
movq %r13, %rdi
leaq 0x25a2(%rip), %rsi      # 0xb276
callq 0x3250
testl %eax, %eax
je 0x8eb3
movq %r13, %rdi
leaq 0x2598(%rip), %rsi      # 0xb283
callq 0x3250
testl %eax, %eax
je 0x8eb3
movq %r13, %rdi
leaq 0x2585(%rip), %rsi      # 0xb287
callq 0x3250
testl %eax, %eax
je 0x8d22
movq %r13, %rdi
leaq 0x257d(%rip), %rsi      # 0xb292
callq 0x3250
testl %eax, %eax
jne 0x8f02
leal 0x1(%r12), %r15d
movq 0x8(%r14,%r12,8), %rdx
xorl %ecx, %ecx
movq %rcx, %rax
cmpq $0xff, %rcx
je 0x8eef
movb (%rdx,%rax), %sil
movq 0x8(%rsp), %rcx
movb %sil, (%rcx,%rax)
leaq 0x1(%rax), %rcx
testb %sil, %sil
jne 0x8d2e
addq 0x8(%rsp), %rcx
jmp 0x8ef7
movl $0x1, 0x55538(%rip)     # 0x5e2a0
jmp 0x8f02
movl $0xffffffff, 0x288adc(%rbx) # imm = 0xFFFFFFFF
movl $0x1, 0x4(%rsp)
jmp 0x8f02
leal 0x1(%r12), %r15d
movq 0x8(%r14,%r12,8), %rsi
movq %rbx, %rdi
xorl %edx, %edx
callq 0x764e
jmp 0x8f02
leal 0x1(%r12), %r15d
movq 0x8(%r14,%r12,8), %rsi
movq %rbx, %rdi
callq 0x7a54
jmp 0x8f02
leal 0x1(%r12), %r15d
movq 0x8(%r14,%r12,8), %rsi
movq %rbx, %rdi
callq 0x8fdd
movl 0x8(%rbx), %eax
movl 0x14(%rbx), %ecx
movl %eax, 0x2045b0(%rbx)
movl %ecx, 0x2045b4(%rbx)
movl 0x28(%rbx), %esi
jmp 0x8e0c
leal 0x1(%r12), %r15d
movq 0x8(%r14,%r12,8), %rsi
movq %rbx, %rdi
callq 0x8fdd
movl 0x8(%rbx), %eax
movl 0x14(%rbx), %ecx
movl %eax, 0x2045b0(%rbx)
movl %ecx, 0x2045b4(%rbx)
movl 0x28(%rbx), %esi
movl $0x1, 0x4(%rsp)
testl %esi, %esi
je 0x8f02
movq %rbx, %rdi
callq 0x3a2d
jmp 0x8f02
leal 0x1(%r12), %r15d
movq 0x8(%r14,%r12,8), %rdx
xorl %ecx, %ecx
movq %rcx, %rax
cmpq $0xff, %rcx
je 0x8e70
movb (%rdx,%rax), %sil
movq 0x20(%rsp), %rcx
movb %sil, (%rcx,%rax)
leaq 0x1(%rax), %rcx
testb %sil, %sil
jne 0x8e2d
addq 0x20(%rsp), %rcx
jmp 0x8ef7
leal 0x1(%r12), %r15d
movq 0x8(%r14,%r12,8), %rsi
movq %rbx, %rdi
movl $0x1, %edx
jmp 0x8d93
movq 0x20(%rsp), %rcx
jmp 0x8ef4
leal 0x1(%r12), %r15d
movq 0x8(%r14,%r12,8), %rdx
xorl %ecx, %ecx
movq %rcx, %rax
cmpq $0xff, %rcx
je 0x8eac
movb (%rdx,%rax), %sil
movq 0x18(%rsp), %rcx
movb %sil, (%rcx,%rax)
leaq 0x1(%rax), %rcx
testb %sil, %sil
jne 0x8e83
addq 0x18(%rsp), %rcx
jmp 0x8ef7
movq 0x18(%rsp), %rcx
jmp 0x8ef4
leal 0x1(%r12), %r15d
movq 0x8(%r14,%r12,8), %rdx
xorl %ecx, %ecx
movq %rcx, %rax
cmpq $0xff, %rcx
je 0x8ee8
movb (%rdx,%rax), %sil
movq 0x10(%rsp), %rcx
movb %sil, (%rcx,%rax)
leaq 0x1(%rax), %rcx
testb %sil, %sil
jne 0x8ebf
addq 0x10(%rsp), %rcx
jmp 0x8ef7
movq 0x10(%rsp), %rcx
jmp 0x8ef4
movq 0x8(%rsp), %rcx
addq %rax, %rcx
cmpq $0xff, %rax
jne 0x8f02
movb $0x0, (%rcx)
incl %r15d
cmpl %ebp, %r15d
jl 0x8baf
cmpl $0x1, 0x4(%rsp)
sete %r15b
testb %r15b, %r15b
je 0x8f26
movq %rbx, %rdi
xorl %esi, %esi
callq 0x3a2d
movslq 0x2043a4(%rbx), %rax
imulq $0x874, %rax, %rax      # imm = 0x874
cmpl $0x0, 0x200004(%rbx,%rax)
jle 0x8f46
movq %rbx, %rdi
callq 0x8268
movq %rbx, %rdi
callq 0x3040
xorl %eax, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq (%r14), %rdi
callq 0x870d
xorl %edi, %edi
callq 0x33d0
movl 0x8(%rbx), %eax
movl 0x14(%rbx), %ecx
movl %eax, 0x2045b0(%rbx)
movl %ecx, 0x2045b4(%rbx)
movl 0x28(%rbx), %esi
testl %esi, %esi
je 0x8f8f
movq %rbx, %rdi
callq 0x3a2d
movq 0x8(%r14), %rsi
movq %rbx, %rdi
xorl %edx, %edx
callq 0x764e
movslq 0x2043a4(%rbx), %rax
imulq $0x874, %rax, %rax      # imm = 0x874
cmpl $0x0, 0x200004(%rbx,%rax)
jle 0x8f67
movq %rbx, %rdi
callq 0x8268
jmp 0x8f67