// File: /workspace/github_c_makefile_star2_O3/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
pushq %rax
movq %rsi, %r14
movl %edi, %ebp
movl $0x288ff0, %edi         # imm = 0x288FF0
movl $0x1, %esi
callq 0x3230
movq %rax, %rbx
movl $0x0, 0x549a3(%rip)     # 0x5d2a0
callq 0x886c
movq %rbx, %rdi
callq 0x83f8
movq %rbx, %rdi
callq 0x8697
movl %ebp, 0x207ad0(%rbx)
movq %r14, 0x207ac8(%rbx)
movl $0x6e6f6e3c, 0x207ad4(%rbx) # imm = 0x6E6F6E3C
movl $0x3e656e, 0x207ad7(%rbx) # imm = 0x3E656E
movl $0x1, %r15d
cmpl $0x2, %ebp
jl 0x894e
movq 0x8(%r14), %rsi
xorl %r15d, %r15d
cmpb $0x2d, (%rsi)
jne 0x8ce7
movl 0x8(%rbx), %eax
movl 0x14(%rbx), %ecx
movl %eax, 0x2045b0(%rbx)
movl %ecx, 0x2045b4(%rbx)
movl 0x28(%rbx), %esi
testl %esi, %esi
je 0x896f
movq %rbx, %rdi
callq 0x3a33
movl %r15d, 0x4(%rsp)
cmpl $0x2, %ebp
jl 0x8c8e
movl $0x1, %r12d
movslq %r12d, %r15
movq (%r14,%r15,8), %r13
cmpb $0x2d, (%r13)
jne 0x8a25
cmpb $0x68, 0x1(%r13)
jne 0x89a7
cmpb $0x0, 0x2(%r13)
je 0x8cd8
cmpb $0x76, 0x1(%r13)
jne 0x89b9
cmpb $0x0, 0x2(%r13)
je 0x8b68
cmpb $0x69, 0x1(%r13)
jne 0x89cb
cmpb $0x0, 0x2(%r13)
je 0x8b77
cmpb $0x66, 0x1(%r13)
jne 0x89dd
cmpb $0x0, 0x2(%r13)
je 0x8b9b
cmpb $0x70, 0x1(%r13)
jne 0x89ef
cmpb $0x0, 0x2(%r13)
je 0x8bdc
cmpb $0x75, 0x1(%r13)
jne 0x8a01
cmpb $0x0, 0x2(%r13)
je 0x8bf2
cmpb $0x72, 0x1(%r13)
jne 0x8a13
cmpb $0x0, 0x2(%r13)
je 0x8c1a
cmpb $0x74, 0x1(%r13)
jne 0x8a25
cmpb $0x0, 0x2(%r13)
je 0x8c60
movq %r13, %rdi
leaq 0x1832(%rip), %rsi      # 0xa261
callq 0x3250
testl %eax, %eax
je 0x8b07
movq %r13, %rdi
leaq 0x1828(%rip), %rsi      # 0xa26e
callq 0x3250
testl %eax, %eax
je 0x8b07
movq %r13, %rdi
leaq 0x1815(%rip), %rsi      # 0xa272
callq 0x3250
testl %eax, %eax
je 0x8b3e
movq %r13, %rdi
leaq 0x1809(%rip), %rsi      # 0xa27d
callq 0x3250
testl %eax, %eax
je 0x8b3e
movq %r13, %rdi
leaq 0x17f6(%rip), %rsi      # 0xa281
callq 0x3250
testl %eax, %eax
je 0x8bae
movq %r13, %rdi
leaq 0x17ec(%rip), %rsi      # 0xa28e
callq 0x3250
testl %eax, %eax
je 0x8bae
movq %r13, %rdi
leaq 0x17d9(%rip), %rsi      # 0xa292
callq 0x3250
testl %eax, %eax
je 0x8ad9
movq %r13, %rdi
leaq 0x17d1(%rip), %rsi      # 0xa29d
callq 0x3250
testl %eax, %eax
jne 0x8c76
leal 0x1(%r15), %r12d
movq 0x8(%r14,%r15,8), %rax
xorl %ecx, %ecx
cmpq $0xff, %rcx
je 0x8c84
movb (%rax,%rcx), %dl
movb %dl, 0x288dec(%rbx,%rcx)
incq %rcx
testb %dl, %dl
jne 0x8ae4
jmp 0x8c76
leal 0x1(%r15), %r12d
movq 0x8(%r14,%r15,8), %rax
xorl %ecx, %ecx
cmpq $0xff, %rcx
je 0x8b31
movb (%rax,%rcx), %dl
movb %dl, 0x288aec(%rbx,%rcx)
incq %rcx
testb %dl, %dl
jne 0x8b12
jmp 0x8c76
movb $0x0, 0x288aec(%rbx,%rcx)
jmp 0x8c76
leal 0x1(%r15), %r12d
movq 0x8(%r14,%r15,8), %rax
xorl %ecx, %ecx
cmpq $0xff, %rcx
je 0x8b8e
movb (%rax,%rcx), %dl
movb %dl, 0x288bec(%rbx,%rcx)
incq %rcx
testb %dl, %dl
jne 0x8b49
jmp 0x8c76
movl $0x1, 0x5472e(%rip)     # 0x5d2a0
jmp 0x8c76
movl $0xffffffff, 0x288adc(%rbx) # imm = 0xFFFFFFFF
movl $0x1, 0x4(%rsp)
jmp 0x8c76
movb $0x0, 0x288bec(%rbx,%rcx)
jmp 0x8c76
leal 0x1(%r15), %r12d
movq 0x8(%r14,%r15,8), %rsi
movq %rbx, %rdi
xorl %edx, %edx
jmp 0x8c71
leal 0x1(%r15), %r12d
movq 0x8(%r14,%r15,8), %rax
xorl %ecx, %ecx
cmpq $0xff, %rcx
je 0x8c56
movb (%rax,%rcx), %dl
movb %dl, 0x288cec(%rbx,%rcx)
incq %rcx
testb %dl, %dl
jne 0x8bb9
jmp 0x8c76
leal 0x1(%r15), %r12d
movq 0x8(%r14,%r15,8), %rsi
movq %rbx, %rdi
callq 0x7910
jmp 0x8c76
leal 0x1(%r15), %r12d
movq 0x8(%r14,%r15,8), %rsi
movq %rbx, %rdi
callq 0x8d58
movl 0x8(%rbx), %eax
movl 0x14(%rbx), %ecx
movl %eax, 0x2045b0(%rbx)
movl %ecx, 0x2045b4(%rbx)
movl 0x28(%rbx), %esi
jmp 0x8c48
leal 0x1(%r15), %r12d
movq 0x8(%r14,%r15,8), %rsi
movq %rbx, %rdi
callq 0x8d58
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 0x8c76
movq %rbx, %rdi
callq 0x3a33
jmp 0x8c76
movb $0x0, 0x288cec(%rbx,%rcx)
jmp 0x8c76
leal 0x1(%r15), %r12d
movq 0x8(%r14,%r15,8), %rsi
movq %rbx, %rdi
movl $0x1, %edx
callq 0x7503
incl %r12d
cmpl %ebp, %r12d
jl 0x8983
jmp 0x8c8e
movb $0x0, 0x288dec(%rbx,%rcx)
jmp 0x8c76
cmpl $0x1, 0x4(%rsp)
jne 0x8c9f
movq %rbx, %rdi
xorl %esi, %esi
callq 0x3a33
movslq 0x2043a4(%rbx), %rax
imulq $0x874, %rax, %rax      # imm = 0x874
cmpl $0x0, 0x200004(%rbx,%rax)
jle 0x8cbf
movq %rbx, %rdi
callq 0x8136
movq %rbx, %rdi
callq 0x3040
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq (%r14), %rdi
callq 0x85a4
xorl %edi, %edi
callq 0x33d0
movl 0x8(%rbx), %eax
movl 0x14(%rbx), %ecx
movl %eax, 0x2045b0(%rbx)
movl %ecx, 0x2045b4(%rbx)
movl 0x28(%rbx), %eax
testl %eax, %eax
je 0x8d0e
movq %rbx, %rdi
movl %eax, %esi
callq 0x3a33
movq 0x8(%r14), %rsi
movq %rbx, %rdi
xorl %edx, %edx
callq 0x7503
movslq 0x2043a4(%rbx), %rax
imulq $0x874, %rax, %rax      # imm = 0x874
cmpl $0x0, 0x200004(%rbx,%rax)
jle 0x8ce0
movq %rbx, %rdi
callq 0x8136
jmp 0x8ce0