// File: /workspace/github_c_makefile_star2_O3/BernardTatin[P]s7sh/s7.c
// Function: g_load
static s7_pointer g_load(s7_scheme *sc, s7_pointer args)
    {
#define H_load "(load file (env (rootlet))) loads the scheme file 'file'. The 'env' argument \
        defaults to the rootlet.  To load into the current environment instead, pass (curlet)."
#define Q_load s7_make_signature(sc, 3, sc->values_symbol, sc->is_string_symbol, sc->is_let_symbol)

        FILE *fp = NULL;
        s7_pointer name;
        const char *fname;

        name = car(args);
        if (!is_string(name))
            return(method_or_bust(sc, name, sc->load_symbol, args, T_STRING, 1));

        if (is_pair(cdr(args)))
        {
            s7_pointer e;
            e = cadr(args);
            if (!is_let(e))
                return(wrong_type_argument_with_type(sc, sc->load_symbol, 2, e, a_let_string));
            if (e == sc->s7_let)
                return(s7_error(sc, sc->wrong_type_arg_symbol, set_elist_2(sc, wrap_string(sc, "can't load ~S into *s7*", 23), name)));
            if (e == sc->rootlet)
                sc->envir = sc->nil;
            else sc->envir = e;
        }
        else sc->envir = sc->nil;

        fname = string_value(name);
        if ((!fname) || (!(*fname)))                 /* fopen("", "r") returns a file pointer?? */
            return(s7_error(sc, sc->out_of_range_symbol, set_elist_2(sc, wrap_string(sc, "load's first argument, ~S, should be a filename", 47), name)));

        if (is_directory(fname))
            return(s7_error(sc, sc->wrong_type_arg_symbol, set_elist_2(sc, wrap_string(sc, "load argument, ~S, is a directory", 33), name)));

#if WITH_C_LOADER
        if (load_shared_object(sc, fname, (is_null(sc->envir)) ? sc->rootlet : sc->envir))
            return(sc->F);
#endif

        fp = fopen(fname, "r");
#if WITH_GCC
        if (!fp) fp = expand_cwd(sc, fname);
#endif
        if (fp)
        {
            if (hook_has_functions(sc->load_hook))
                s7_apply_function(sc, sc->load_hook, list_1(sc, sc->temp6 = s7_make_string(sc, fname)));
        }
        else
        {
            fp = open_file_with_load_path(sc, fname);
            if (!fp) return(file_error(sc, "load", "can't open", fname));
        }
        read_scheme_file(sc, fp, fname);

        push_stack_op_let(sc, OP_LOAD_CLOSE_AND_POP_IF_EOF);  /* was pushing args and code, but I don't think they're used later */
        push_stack_op_let(sc, OP_READ_INTERNAL);

        return(sc->unspecified);
    }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x98, %rsp
movq %rsi, %rcx
movq %rdi, %rbx
movq 0x8(%rsi), %r15
cmpb $0x13, (%r15)
jne 0x7c7b1
movq 0x10(%rcx), %rax
cmpb $0x1, (%rax)
jne 0x7c72d
movq 0x8(%rax), %rcx
cmpb $0x1c, (%rcx)
jne 0x7c858
cmpq 0x2150(%rbx), %rcx
je 0x7c8bd
cmpq 0x150(%rbx), %rcx
jne 0x7c734
movq 0x110(%rbx), %rcx
movq %rcx, 0x8(%rbx)
movq 0x10(%r15), %r14
testq %r14, %r14
je 0x7c7e0
cmpb $0x0, (%r14)
je 0x7c7e0
leaq 0x8(%rsp), %rsi
movq %r14, %rdi
callq 0x83d0
testl %eax, %eax
js 0x7c891
movl $0xf000, %eax           # imm = 0xF000
andl 0x20(%rsp), %eax
cmpl $0x4000, %eax           # imm = 0x4000
jne 0x7c891
movq 0x1940(%rbx), %r14
movq 0x820(%rbx), %rax
movslq 0x7dc(%rbx), %rcx
movq (%rax,%rcx,8), %rax
incl %ecx
andl $0x7, %ecx
movl %ecx, 0x7dc(%rbx)
leaq 0x9f5ec(%rip), %rcx     # 0x11bd8f
movq %rcx, 0x10(%rax)
movq $0x21, 0x8(%rax)
jmp 0x7c817
movq 0x1288(%rbx), %rdx
movq %rbx, %rdi
movq %r15, %rsi
movl $0x13, %r8d
movl $0x1, %r9d
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xe42d
movq 0x1948(%rbx), %r14
movq 0x820(%rbx), %rax
movslq 0x7dc(%rbx), %rcx
movq (%rax,%rcx,8), %rax
incl %ecx
andl $0x7, %ecx
movl %ecx, 0x7dc(%rbx)
leaq 0x9f554(%rip), %rcx     # 0x11bd5f
movq %rcx, 0x10(%rax)
movq $0x2f, 0x8(%rax)
movq 0x6e0(%rbx), %rcx
movq %rax, 0x8(%rcx)
movq 0x6e0(%rbx), %rax
movq 0x10(%rax), %rax
movq %r15, 0x8(%rax)
movq 0x6e0(%rbx), %rdx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x38dfa
movq %r14, %rax
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x1288(%rbx), %rax
movq 0x8(%rax), %rsi
movq 0xca0f6(%rip), %rdx     # 0x146960
movq 0x140(%rbx), %r8
movq 0xce0e0(%rip), %r9      # 0x14a958
movq %rbx, %rdi
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xa4e4
movq 0x8(%rbx), %rdx
cmpq 0x110(%rbx), %rdx
jne 0x7c8a5
movq 0x150(%rbx), %rdx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x35519
testb %al, %al
je 0x7c8f9
movq 0x120(%rbx), %r14
jmp 0x7c843
movq 0x1940(%rbx), %r14
movq 0x820(%rbx), %rax
movslq 0x7dc(%rbx), %rcx
movq (%rax,%rcx,8), %rax
incl %ecx
andl $0x7, %ecx
movl %ecx, 0x7dc(%rbx)
leaq 0x9f45f(%rip), %rcx     # 0x11bd47
movq %rcx, 0x10(%rax)
movq $0x17, 0x8(%rax)
jmp 0x7c817
leaq 0x9dc47(%rip), %rsi     # 0x11a547
movq %r14, %rdi
callq 0x85b0
testq %rax, %rax
jne 0x7c921
movq %rbx, %rdi
movq %r14, %rsi
callq 0x3575e
testq %rax, %rax
je 0x7c9ff
movq %rax, %r15
movq 0x1e8(%rbx), %r12
movq 0x18e0(%rbx), %rsi
movq 0x18(%r12), %rdx
movq %rbx, %rdi
callq 0xbe9a
cmpb $0x1, (%rax)
jne 0x7c9a8
movq %rbx, %rdi
movq %r14, %rsi
callq 0xe9af
movq %rax, %r13
movq %rax, 0x520(%rbx)
movq 0x90(%rbx), %rax
movq 0x110(%rbx), %rbp
cmpq 0x98(%rbx), %rax
ja 0x7c97f
movq %rbx, %rdi
callq 0xa550
movq 0x90(%rbx), %rax
leaq -0x8(%rax), %rcx
movq %rcx, 0x90(%rbx)
movq -0x8(%rax), %rdx
movq $0x200001, (%rdx)       # imm = 0x200001
movq %r13, 0x8(%rdx)
movq %rbp, 0x10(%rdx)
movq %rbx, %rdi
movq %r12, %rsi
callq 0xaee6
movq %rbx, %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0x3597b
movq 0x8(%rbx), %rax
movq 0x50(%rbx), %rcx
movq %rax, 0x8(%rcx)
movq 0x50(%rbx), %rax
movq $0x1de, 0x18(%rax)      # imm = 0x1DE
movq 0x8(%rbx), %rax
movq 0x50(%rbx), %rcx
leaq 0x20(%rcx), %rdx
movq %rdx, 0x50(%rbx)
movq %rax, 0x28(%rcx)
movq 0x50(%rbx), %rax
movq $0x190, 0x18(%rax)      # imm = 0x190
addq $0x20, 0x50(%rbx)
movq 0x130(%rbx), %r14
jmp 0x7c843
movq %rbx, %rdi
movq %r14, %rsi
callq 0x35862
movq %rax, %r15
testq %rax, %rax
jne 0x7c9a8
leaq 0x967fa(%rip), %rsi     # 0x113213
leaq 0x9f391(%rip), %rdx     # 0x11bdb1
movq %rbx, %rdi
movq %r14, %rcx
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xf406