// File: /workspace/github_c_makefile_star2_O2/RodionGork[P]tinyscheme/scheme.c
// Function: main
int main(int argc, char **argv) {
  scheme sc;
  FILE *fin = NULL;
  char *file_name = InitFile;
  char *executable_name = argv[0];
  int retcode;
  int isfile = 1;

  initFromEnv();
  if (argc == 1) {
    printf("%s", get_version());
  }
  if (argc == 2 && str_eq(argv[1], "-?")) {
    printf("Usage: tinyscheme -?\n");
    printf("or:    tinyscheme [<file1> <file2> ...]\n");
    printf("followed by\n");
    printf("          -1 <file> [<arg1> <arg2> ...]\n");
    printf("          -c <Scheme commands> [<arg1> <arg2> ...]\n");
    printf("assuming that the executable is named tinyscheme.\n");
    printf("Use - as filename for stdin.\n");
    return 1;
  }
  if (!scheme_init(&sc)) {
    fprintf(stderr, "Could not initialize!\n");
    return 2;
  }
  scheme_set_input_port_file(&sc, stdin);
  scheme_set_output_port_file(&sc, stdout);
#if USE_DL
  scheme_define(&sc, sc.global_env, mk_symbol(&sc, "load-extension"),
      mk_foreign_func(&sc, scm_load_ext));
#endif
  argv++;
  if (access(file_name, 0) != 0) {
    char *p = getenv("TINYSCHEMEINIT");
    if (p != 0) {
      file_name = p;
    } else {
      strcpy(sc.strbuff, executable_name);
      p = strrchr(sc.strbuff, '/');
      if (p != 0) {
        strcpy(p + 1, file_name);
        file_name = sc.strbuff;
      }
    }
  }
  evalcnt = 0;
  do {
    if (str_eq(file_name, "-1") || str_eq(file_name, "-c")) {
      pointer args = sc.NIL;
      isfile = file_name[1] == '1';
      file_name = *argv++;
      if (isfile) {
        fin = open_file(file_name);
      }
      for (; *argv; argv++) {
        pointer value = mk_string(&sc, *argv);
        args = cons(&sc, value, args);
      }
      args = reverse_in_place(&sc, sc.NIL, args);
      scheme_define(&sc, sc.global_env, mk_symbol(&sc, "*args*"), args);

    } else {
      fin = open_file(file_name);
    }
    if (isfile && fin == 0) {
      fprintf(stderr, "Could not open file %s\n", file_name);
    } else {
      if (isfile) {
        scheme_load_named_file(&sc, fin, file_name);
      } else {
        scheme_load_string(&sc, file_name);
      }
      if (!isfile || fin != stdin) {
        if (sc.retcode != 0) {
          fprintf(stderr, "Errors encountered reading %s\n", file_name);
        }
        if (isfile) {
          fclose(fin);
        }
      }
    }
    file_name = *argv++;
  } while (file_name != 0);
  if (argc == 1) {
    scheme_load_named_file(&sc, stdin, "-");
  }
  retcode = sc.retcode;
  scheme_deinit(&sc);

  return retcode;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xf08, %rsp            # imm = 0xF08
movq %rsi, %r14
movl %edi, %ebp
movq (%rsi), %r12
callq 0x5d41
cmpl $0x1, %ebp
jne 0x5dc8
leaq 0x6eed(%rip), %rdi      # 0xcca5
leaq 0x678b(%rip), %rsi      # 0xc54a
xorl %eax, %eax
callq 0x40d0
jmp 0x5de6
cmpl $0x2, %ebp
jne 0x5de6
movq 0x8(%r14), %rax
cmpb $0x2d, (%rax)
jne 0x5de6
cmpb $0x3f, 0x1(%rax)
jne 0x5de6
cmpb $0x0, 0x2(%rax)
je 0x609b
leaq 0x10(%rsp), %rdi
callq 0x4d73
testl %eax, %eax
je 0x607b
movq 0xc1d1(%rip), %rax      # 0x11fd0
movq (%rax), %rsi
leaq 0x10(%rsp), %rbx
movq %rbx, %rdi
callq 0x5374
movq 0xc1b2(%rip), %rax      # 0x11fc8
movq (%rax), %rsi
movq %rbx, %rdi
callq 0x5434
leaq 0x6756(%rip), %rbx      # 0xc57e
movq %rbx, %rdi
xorl %esi, %esi
callq 0x4230
testl %eax, %eax
movl %ebp, 0xc(%rsp)
je 0x5e92
leaq 0x675d(%rip), %rdi      # 0xc59e
callq 0x4040
movq %rax, %r13
testq %rax, %rax
jne 0x5e95
movq 0xeb0(%rsp), %rdi
movq %r12, %rsi
callq 0x4050
movq 0xeb0(%rsp), %rdi
pushq $0x2f
popq %rsi
callq 0x4100
movq %rbx, %r13
testq %rax, %rax
je 0x5e95
movabsq $0x6d63732e74696e69, %rcx # imm = 0x6D63732E74696E69
movq %rcx, 0x1(%rax)
movb $0x0, 0x9(%rax)
movq 0xeb0(%rsp), %r13
jmp 0x5e95
movq %rbx, %r13
andq $0x0, 0xc32b(%rip)      # 0x121c8
pushq $0x1
popq %rbp
leaq 0x10(%rsp), %r12
movq $0x0, (%rsp)
movq 0xc11c(%rip), %rbx      # 0x11fd0
leaq 0x8(%r14), %r15
cmpb $0x2d, (%r13)
jne 0x5edb
cmpb $0x31, 0x1(%r13)
jne 0x5ecd
cmpb $0x0, 0x2(%r13)
je 0x5f47
cmpb $0x63, 0x1(%r13)
jne 0x5edb
cmpb $0x0, 0x2(%r13)
je 0x5f47
movq %r13, %rdi
callq 0x5d13
movq %rax, (%rsp)
movq %r15, %r14
testl %ebp, %ebp
je 0x5ef9
cmpq $0x0, (%rsp)
je 0x5fff
movq %r12, %rdi
testl %ebp, %ebp
je 0x5f16
movq (%rsp), %r15
movq %r15, %rsi
movq %r13, %rdx
callq 0x5771
cmpq (%rbx), %r15
jne 0x5f1e
jmp 0x5f36
movq %r13, %rsi
callq 0x5adf
cmpl $0x0, 0x20(%rsp)
jne 0x601f
testl %ebp, %ebp
je 0x5f36
movq (%rsp), %rdi
callq 0x40b0
movq (%r14), %r13
testq %r13, %r13
jne 0x5eb4
jmp 0x603f
movq 0xa0(%rsp), %rbx
xorl %ebp, %ebp
cmpb $0x31, 0x1(%r13)
sete %al
movq (%r15), %r13
jne 0x5f70
movq %r13, %rdi
movl %eax, %r15d
callq 0x5d13
movq %rax, (%rsp)
movl %r15d, %eax
movb %al, %bpl
addq $0x10, %r14
movq %r14, %r15
movq (%r15), %rsi
testq %rsi, %rsi
je 0x5fa3
movq %r12, %rdi
callq 0x46f1
movq %r12, %rdi
movq %rax, %rsi
movq %rbx, %rdx
xorl %ecx, %ecx
callq 0x45e8
movq %rax, %rbx
addq $0x8, %r15
jmp 0x5f7a
movq 0xa0(%rsp), %rax
movq %rax, %r14
cmpq %rax, %rbx
je 0x5fcb
movq 0x10(%rbx), %rcx
movq %r14, 0x10(%rbx)
movq 0xa0(%rsp), %rax
movq %rbx, %r14
movq %rcx, %rbx
jmp 0x5fae
movq 0x110(%rsp), %rbx
movq %r12, %rdi
leaq 0x65d0(%rip), %rsi      # 0xc5ad
callq 0x484c
movq %r12, %rdi
movq %rbx, %rsi
movq %rax, %rdx
movq %r14, %rcx
callq 0x5b93
movq 0xbfd6(%rip), %rbx      # 0x11fd0
jmp 0x5ee7
movq 0xbff2(%rip), %rax      # 0x11ff8
movq (%rax), %rdi
leaq 0x65a4(%rip), %rsi      # 0xc5b4
movq %r13, %rdx
xorl %eax, %eax
callq 0x41b0
jmp 0x5f36
movq 0xbfd2(%rip), %rax      # 0x11ff8
movq (%rax), %rdi
leaq 0x659c(%rip), %rsi      # 0xc5cc
movq %r13, %rdx
xorl %eax, %eax
callq 0x41b0
jmp 0x5f29
cmpl $0x1, 0xc(%rsp)
jne 0x605a
movq (%rbx), %rsi
leaq 0x6511(%rip), %rdx      # 0xc561
leaq 0x10(%rsp), %rdi
callq 0x5771
leaq 0x10(%rsp), %rdi
movl 0x10(%rdi), %ebx
callq 0x5466
movl %ebx, %eax
addq $0xf08, %rsp            # imm = 0xF08
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0xbf76(%rip), %rax      # 0x11ff8
movq (%rax), %rcx
leaq 0x64fb(%rip), %rdi      # 0xc587
pushq $0x16
popq %rsi
pushq $0x1
popq %rdx
callq 0x42a0
pushq $0x2
jmp 0x60f1
leaq 0x72a4(%rip), %rdi      # 0xd346
callq 0x4070
leaq 0x72ad(%rip), %rdi      # 0xd35b
callq 0x4070
leaq 0x72c9(%rip), %rdi      # 0xd383
callq 0x4070
leaq 0x72c9(%rip), %rdi      # 0xd38f
callq 0x4070
leaq 0x72e5(%rip), %rdi      # 0xd3b7
callq 0x4070
leaq 0x730c(%rip), %rdi      # 0xd3ea
callq 0x4070
leaq 0x7332(%rip), %rdi      # 0xd41c
callq 0x4070
pushq $0x1
popq %rbx
jmp 0x6067