// File: /workspace/github_c_makefile_star2_O3/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 $0xf18, %rsp            # imm = 0xF18
movq %rsi, %r14
movl %edi, %ebp
movq (%rsi), %r15
callq 0x5f98
cmpl $0x1, %ebp
jne 0x6021
leaq 0x7cc4(%rip), %rdi      # 0xdcd5
leaq 0x7562(%rip), %rsi      # 0xd57a
xorl %eax, %eax
callq 0x40d0
jmp 0x603f
cmpl $0x2, %ebp
jne 0x603f
movq 0x8(%r14), %rax
cmpb $0x2d, (%rax)
jne 0x603f
cmpb $0x3f, 0x1(%rax)
jne 0x603f
cmpb $0x0, 0x2(%rax)
je 0x634e
movq 0xcf9a(%rip), %rsi      # 0x12fe0
movq 0xcf63(%rip), %rdx      # 0x12fb0
leaq 0x20(%rsp), %rdi
callq 0x4f0f
testl %eax, %eax
je 0x6342
movq 0xcf6a(%rip), %rax      # 0x12fd0
movq (%rax), %rsi
leaq 0x20(%rsp), %rbx
movq %rbx, %rdi
movl $0x10, %edx
callq 0x5525
movq %rax, 0x170(%rbx)
movq 0xcf3f(%rip), %rax      # 0x12fc8
movq (%rax), %rsi
movq %rbx, %rdi
movl $0x20, %edx
callq 0x5525
movq %rax, 0x178(%rbx)
leaq 0x7507(%rip), %rbx      # 0xd5ae
movq %rbx, %rdi
xorl %esi, %esi
callq 0x4230
testl %eax, %eax
movl %ebp, 0x1c(%rsp)
je 0x6113
leaq 0x750e(%rip), %rdi      # 0xd5ce
callq 0x4040
movq %rax, %r13
testq %rax, %rax
jne 0x6116
movq 0xec0(%rsp), %rdi
movq %r15, %rsi
callq 0x4050
movq 0xec0(%rsp), %rdi
movl $0x2f, %esi
callq 0x4100
movq %rbx, %r13
testq %rax, %rax
je 0x6116
movabsq $0x6d63732e74696e69, %rcx # imm = 0x6D63732E74696E69
movq %rcx, 0x1(%rax)
movb $0x0, 0x9(%rax)
movq 0xec0(%rsp), %r13
jmp 0x6116
movq %rbx, %r13
movq $0x0, 0xd0a7(%rip) # 0x131c8
movl $0x1, %r15d
leaq 0x20(%rsp), %r12
movq $0x0, 0x10(%rsp)
movq 0xce94(%rip), %rbx      # 0x12fd0
leaq 0x8(%r14), %rbp
cmpb $0x2d, (%r13)
jne 0x6167
cmpb $0x31, 0x1(%r13)
jne 0x6159
cmpb $0x0, 0x2(%r13)
je 0x61da
cmpb $0x63, 0x1(%r13)
jne 0x6167
cmpb $0x0, 0x2(%r13)
je 0x61da
movq %r13, %rdi
callq 0x5f6a
movq %rax, 0x10(%rsp)
movq %rbp, %r14
testl %r15d, %r15d
je 0x6188
cmpq $0x0, 0x10(%rsp)
je 0x62c6
movq %r12, %rdi
testl %r15d, %r15d
je 0x61a7
movq 0x10(%rsp), %rbp
movq %rbp, %rsi
movq %r13, %rdx
callq 0x5966
cmpq (%rbx), %rbp
jne 0x61af
jmp 0x61c9
movq %r13, %rsi
callq 0x5cbb
cmpl $0x0, 0x30(%rsp)
jne 0x62e6
testl %r15d, %r15d
je 0x61c9
movq 0x10(%rsp), %rdi
callq 0x40b0
movq (%r14), %r13
testq %r13, %r13
jne 0x613c
jmp 0x6306
movq 0xb0(%rsp), %rbx
cmpb $0x31, 0x1(%r13)
sete 0xf(%rsp)
movq (%rbp), %r13
jne 0x61ff
movq %r13, %rdi
callq 0x5f6a
movq %rax, 0x10(%rsp)
movq 0x10(%r14), %r15
addq $0x10, %r14
testq %r15, %r15
je 0x6255
movq %r14, %rbp
movq %r15, %rdi
callq 0x40c0
movq %r12, %rdi
movq %r15, %rsi
movl %eax, %edx
callq 0x47a7
movq %rax, %r14
movq %r12, %rdi
movq %rax, %rsi
movq %rbx, %rdx
callq 0x4689
movl $0x5, (%rax)
movq %r14, 0x8(%rax)
movq %rbx, 0x10(%rax)
movq 0x8(%rbp), %r15
addq $0x8, %rbp
movq %rax, %rbx
testq %r15, %r15
jne 0x620f
jmp 0x625b
movq %rbx, %rax
movq %r14, %rbp
movq 0xb0(%rsp), %rcx
cmpq %rax, %rcx
je 0x6285
xorl %r15d, %r15d
movq %rax, %rbx
movq 0x10(%rax), %rax
movq %rcx, 0x10(%rbx)
movq %rbx, %rcx
cmpq 0xb0(%rsp), %rax
jne 0x626b
jmp 0x628b
movq %rcx, %rbx
xorl %r15d, %r15d
movb 0xf(%rsp), %al
movb %al, %r15b
movq 0x120(%rsp), %r14
movq %r12, %rdi
leaq 0x7339(%rip), %rsi      # 0xd5dd
callq 0x4909
movq %r12, %rdi
movq %r14, %rsi
movq %rax, %rdx
movq %rbx, %rcx
callq 0x5d97
movq 0xcd0f(%rip), %rbx      # 0x12fd0
jmp 0x6174
movq 0xcd2b(%rip), %rax      # 0x12ff8
movq (%rax), %rdi
leaq 0x730d(%rip), %rsi      # 0xd5e4
movq %r13, %rdx
xorl %eax, %eax
callq 0x41b0
jmp 0x61c9
movq 0xcd0b(%rip), %rax      # 0x12ff8
movq (%rax), %rdi
leaq 0x7305(%rip), %rsi      # 0xd5fc
movq %r13, %rdx
xorl %eax, %eax
callq 0x41b0
jmp 0x61ba
cmpl $0x1, 0x1c(%rsp)
jne 0x6321
movq (%rbx), %rsi
leaq 0x727a(%rip), %rdx      # 0xd591
leaq 0x20(%rsp), %rdi
callq 0x5966
leaq 0x20(%rsp), %rdi
movl 0x10(%rdi), %ebx
callq 0x5637
movl %ebx, %eax
addq $0xf18, %rsp            # imm = 0xF18
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x4375
movl $0x2, %ebx
jmp 0x632e
leaq 0x8021(%rip), %rdi      # 0xe376
callq 0x4070
leaq 0x802a(%rip), %rdi      # 0xe38b
callq 0x4070
leaq 0x8046(%rip), %rdi      # 0xe3b3
callq 0x4070
leaq 0x8046(%rip), %rdi      # 0xe3bf
callq 0x4070
leaq 0x8062(%rip), %rdi      # 0xe3e7
callq 0x4070
leaq 0x8089(%rip), %rdi      # 0xe41a
callq 0x4070
leaq 0x80af(%rip), %rdi      # 0xe44c
callq 0x4070
movl $0x1, %ebx
jmp 0x632e