// File: /workspace/github_c_makefile_star2_O0/janet-lang[P]janet/src/boot/boot.c
// Function: main
int main(int argc, const char **argv) {

    /* Init janet */
    janet_init();

    /* Run tests */
    array_test();
    buffer_test();
    number_test();
    system_test();
    table_test();

    /* C tests passed */

    /* Set up VM */
    int status;
    JanetTable *env;

    env = janet_core_env(NULL);

    /* Create args tuple */
    JanetArray *args = janet_array(argc);
    for (int i = 0; i < argc; i++)
        janet_array_push(args, janet_cstringv(argv[i]));
    janet_def(env, "boot/args", janet_wrap_array(args), "Command line arguments.");

    /* Add in options from janetconf.h so boot.janet can configure the image as needed. */
    JanetTable *opts = janet_table(0);
#ifdef JANET_NO_DOCSTRINGS
    janet_table_put(opts, janet_ckeywordv("no-docstrings"), janet_wrap_true());
#endif
#ifdef JANET_NO_SOURCEMAPS
    janet_table_put(opts, janet_ckeywordv("no-sourcemaps"), janet_wrap_true());
#endif
    janet_def(env, "boot/config", janet_wrap_table(opts), "Boot options");

    /* Run bootstrap script to generate core image */
    const char *boot_filename;
#ifdef JANET_NO_SOURCEMAPS
    boot_filename = NULL;
#else
    boot_filename = "boot.janet";
#endif

    int chdir_status = chdir(argv[1]);
    if (chdir_status) {
        fprintf(stderr, "Could not change to directory %s\n", argv[1]);
        exit(1);
    }

    FILE *boot_file = fopen("src/boot/boot.janet", "rb");
    if (NULL == boot_file) {
        fprintf(stderr, "Could not open src/boot/boot.janet\n");
        exit(1);
    }

    /* Slurp file into buffer */
    fseek(boot_file, 0, SEEK_END);
    size_t boot_size = ftell(boot_file);
    fseek(boot_file, 0, SEEK_SET);
    unsigned char *boot_buffer = janet_malloc(boot_size);
    if (NULL == boot_buffer) {
        fprintf(stderr, "Failed to allocate boot buffer\n");
        exit(1);
    }
    if (!fread(boot_buffer, 1, boot_size, boot_file)) {
        fprintf(stderr, "Failed to read into boot buffer\n");
        exit(1);
    }
    fclose(boot_file);

    status = janet_dobytes(env, boot_buffer, (int32_t) boot_size, boot_filename, NULL);
    janet_free(boot_buffer);

    /* Deinitialize vm */
    janet_deinit();

    return status;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x90, %rsp
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
callq 0x7a790
movb $0x0, %al
callq 0x7ba90
movb $0x0, %al
callq 0x7c250
movb $0x0, %al
callq 0x7c450
movb $0x0, %al
callq 0x7c5e0
movb $0x0, %al
callq 0x7cda0
xorl %eax, %eax
movl %eax, %edi
callq 0x26c10
movq %rax, -0x20(%rbp)
movl -0x8(%rbp), %edi
callq 0x13180
movq %rax, -0x28(%rbp)
movl $0x0, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
cmpl -0x8(%rbp), %eax
jge 0x7c050
movq -0x28(%rbp), %rax
movq %rax, -0x80(%rbp)
movq -0x10(%rbp), %rax
movslq -0x2c(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x64a70
movq %rax, %rdi
movabsq $-0x6000000000000, %rsi # imm = 0xFFFA000000000000
callq 0x7b550
movq -0x80(%rbp), %rdi
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rsi
callq 0x13510
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x7c001
movq -0x20(%rbp), %rax
movq %rax, -0x90(%rbp)
movq -0x28(%rbp), %rdi
movabsq $-0x4800000000000, %rsi # imm = 0xFFFB800000000000
callq 0x7b610
movq -0x90(%rbp), %rdi
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rdx
leaq 0x1d31a(%rip), %rsi     # 0x9939e
leaq 0x1d31d(%rip), %rcx     # 0x993a8
callq 0x6b670
xorl %edi, %edi
callq 0x692f0
movq %rax, -0x48(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0x88(%rbp)
movq -0x48(%rbp), %rdi
movabsq $-0x3800000000000, %rsi # imm = 0xFFFC800000000000
callq 0x7b610
movq -0x88(%rbp), %rdi
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rdx
leaq 0x1d2f1(%rip), %rsi     # 0x993c0
leaq 0x1d2f6(%rip), %rcx     # 0x993cc
callq 0x6b670
leaq 0x1d322(%rip), %rax     # 0x99404
movq %rax, -0x58(%rbp)
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x12320
movl %eax, -0x5c(%rbp)
cmpl $0x0, -0x5c(%rbp)
je 0x7c126
movq 0x33eed(%rip), %rax     # 0xafff0
movq (%rax), %rdi
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdx
leaq 0x1d2c4(%rip), %rsi     # 0x993d9
movb $0x0, %al
callq 0x125f0
movl $0x1, %edi
callq 0x12a70
leaq 0x1d2ce(%rip), %rdi     # 0x993fb
leaq 0x1d2db(%rip), %rsi     # 0x9940f
callq 0x12980
movq %rax, -0x68(%rbp)
xorl %eax, %eax
cmpq -0x68(%rbp), %rax
jne 0x7c167
movq 0x33ea4(%rip), %rax     # 0xafff0
movq (%rax), %rdi
leaq 0x1d2bc(%rip), %rsi     # 0x99412
movb $0x0, %al
callq 0x125f0
movl $0x1, %edi
callq 0x12a70
movq -0x68(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
movl $0x2, %edx
callq 0x12820
movq -0x68(%rbp), %rdi
callq 0x12610
movq %rax, -0x70(%rbp)
movq -0x68(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
xorl %edx, %edx
callq 0x12820
movq -0x70(%rbp), %rdi
callq 0x12770
movq %rax, -0x78(%rbp)
xorl %eax, %eax
cmpq -0x78(%rbp), %rax
jne 0x7c1cc
movq 0x33e3f(%rip), %rax     # 0xafff0
movq (%rax), %rdi
leaq 0x1d27b(%rip), %rsi     # 0x99436
movb $0x0, %al
callq 0x125f0
movl $0x1, %edi
callq 0x12a70
movq -0x78(%rbp), %rdi
movq -0x70(%rbp), %rdx
movq -0x68(%rbp), %rcx
movl $0x1, %esi
callq 0x121d0
cmpq $0x0, %rax
jne 0x7c20a
movq 0x33e01(%rip), %rax     # 0xafff0
movq (%rax), %rdi
leaq 0x1d25d(%rip), %rsi     # 0x99456
movb $0x0, %al
callq 0x125f0
movl $0x1, %edi
callq 0x12a70
movq -0x68(%rbp), %rdi
callq 0x122b0
movq -0x20(%rbp), %rdi
movq -0x78(%rbp), %rsi
movq -0x70(%rbp), %rax
movl %eax, %edx
movq -0x58(%rbp), %rcx
xorl %eax, %eax
movl %eax, %r8d
callq 0x5e2a0
movl %eax, -0x14(%rbp)
movq -0x78(%rbp), %rdi
callq 0x120b0
callq 0x7ab60
movl -0x14(%rbp), %eax
addq $0x90, %rsp
popq %rbp
retq
nopl (%rax)