// File: /workspace/github_c_makefile_star2_O2/BernardTatin[P]s7sh/s7.c
// Function: unbound_variable
static s7_pointer unbound_variable(s7_scheme *sc, s7_pointer sym)
                {
                    /* this always occurs in a context where we're trying to find anything, so I'll move a couple of those checks here */
                    if (has_let_ref_fallback(sc->envir)) /* an experiment -- see s7test (with-let *db* (+ int32_t (length str))) */
                        return(call_let_ref_fallback(sc, sc->envir, sym));
                    /* but if the thing we want to hit this fallback happens to exist at a higher level, oops... */

                    if (sym == sc->unquote_symbol)
                        eval_error(sc, "unquote (',') occurred outside quasiquote: ~S", 45, current_code(sc));

                    if (sym == sc->__func___symbol) /* __func__ is a sort of symbol macro */
                    {
                        s7_pointer env;
                        env = find_closure_let(sc, sc->envir);
                        if (is_let(env))
                        {
                            /* for C-defined things like hooks and dilambda, let_file and let_line are 0 */
                            if ((has_let_file(env)) &&
                                    (let_file(env) <= (s7_int)sc->file_names_top) && /* let_file(env) might be > int32_t */
                                    (let_line(env) > 0))
                                return(list_3(sc, funclet_function(env), sc->file_names[let_file(env)], make_integer(sc, let_line(env))));
                            return(funclet_function(env));
                        }
                        return(sc->undefined);
                    }

                    if (safe_strcmp(symbol_name(sym), "|#"))
                        return(read_error(sc, "unmatched |#"));

                    /* check *autoload*, autoload_names, then *unbound-variable-hook* */
                    if ((sc->autoload_names) ||
                            (is_hash_table(sc->autoload_table)) ||
                            (hook_has_functions(sc->unbound_variable_hook)))
                    {
                        s7_pointer result, cur_code, value, code, args, cur_env, x, z;
                        /* sc->args and sc->code are pushed on the stack by s7_call, then
                         *   restored by eval, so they are normally protected, but sc->value and current_code(sc) are
                         *   not protected (yet).  We need current_code(sc) so that the possible eventual error
                         *   call can tell where the error occurred, and we need sc->value because it might
                         *   be awaiting addition to sc->args in e.g. OP_EVAL_ARGS5, and then be clobbered
                         *   by the hook function.  (+ 1 asdf) will end up evaluating (+ asdf asdf) if sc->value
                         *   is not protected.  We also need to save/restore sc->envir in case s7_load is called.
                         */

                        args = (sc->args) ? sc->args : sc->nil;
                        code = sc->code;
                        value = sc->value;
                        cur_code = current_code(sc);
                        cur_env = sc->envir;
                        result = sc->undefined;
                        x = sc->x;
                        z = sc->z;
                        sc->temp7 = cons(sc, code, cons(sc, args, cons(sc, value, cons(sc, cur_code, cons(sc, x, cons(sc, z, sc->nil)))))); /* not s7_list (debugger checks) */

                        if (!is_pair(cur_code))
                        {
                            /* isolated typo perhaps -- no pair to hold the position info, so make one. current_code(sc) is GC-protected, so this should be safe. */
                            cur_code = cons(sc, sym, sc->nil);     /* the error will say "(sym)" which is not too misleading */
                            set_file_and_line_number(sc, cur_code);
                        }

#if (!DISABLE_AUTOLOAD)
                        /* check sc->autoload_names */
                        if ((sc->is_autoloading) &&
                                (sc->autoload_names))
                        {
                            const char *file;
                            bool loaded = false;
                            file = find_autoload_name(sc, sym, &loaded, true);
                            if ((file) && (!loaded))
                            {
                                s7_pointer e;
                                /* if we've already loaded this file, we can get the library (e) from a table [(file lib) ...]
                                 * here it was possible to get caught in a loop:
                                 *   change file, reload, unbound var seen, check autoload, it says "load file"... (where file does not get added to *libraries*)
                                 *   so the "loaded" arg tries to catch such cases
                                 */
                                e = loaded_library(sc, file);
                                if ((!e) || (!is_let(e)))
                                    e = s7_load(sc, file);           /* s7_load can return NULL */
                                result = s7_symbol_value(sc, sym); /* calls find_symbol, does not trigger unbound_variable search */
                                if ((result == sc->undefined) &&
                                        (e) && (is_let(e)))
                                {
                                    result = s7_let_ref(sc, e, sym);
                                    /* I think to be consistent we should add '(sym . result) to the global env */
                                    if (result != sc->undefined)
                                        s7_define(sc, sc->nil, sym, result);
                                }
                            }
                        }
#endif

                        if (result == sc->undefined)
                        {
#if (!DISABLE_AUTOLOAD)
                            /* check the *autoload* hash table */
                            if ((sc->is_autoloading) &&
                                    (is_hash_table(sc->autoload_table)))
                            {
                                s7_pointer val;
                                /* it was possible to get in a loop here: missing paren in x.scm, checks last symbol, sees
                                 *   autoload sym -> x.scm, loads x.scm, missing paren...
                                 */
                                val = s7_hash_table_ref(sc, sc->autoload_table, sym);
                                if (is_string(val))                /* val should be a filename. *load-path* is searched if necessary. */
                                    s7_load(sc, string_value(val));
                                else
                                {
                                    if (is_closure(val))           /* val should be a function of one argument, the current (calling) environment */
                                        s7_call(sc, val, s7_cons(sc, sc->envir, sc->nil));
                                }
                                result = s7_symbol_value(sc, sym); /* calls find_symbol, does not trigger unbound_variable search */
                            }
#endif

                            /* check *unbound-variable-hook* */
                            if ((result == sc->undefined) &&
                                    (is_procedure(sc->unbound_variable_hook)) &&
                                    (hook_has_functions(sc->unbound_variable_hook)))
                            {
                                /* (let () (set! (hook-functions *unbound-variable-hook*) (list (lambda (v) _asdf_))) _asdf_) */
                                s7_pointer old_hook;

                                old_hook = sc->unbound_variable_hook;
                                set_car(sc->z2_1, old_hook);
                                sc->unbound_variable_hook = sc->error_hook;      /* avoid the infinite loop mentioned above -- error_hook might be () or #f if we're in error-hook now */
                                result = s7_call(sc, old_hook, list_1(sc, sym)); /* not s7_apply_function */
                                sc->unbound_variable_hook = old_hook;
                            }
                        }

                        sc->value = T_Pos(value);
                        set_current_code(sc, cur_code);
                        sc->args = T_Pos(args);
                        sc->code = code;
                        sc->envir = cur_env;
                        sc->x = x;
                        sc->z = z;
                        sc->temp7 = sc->nil;

                        if ((result != sc->undefined) &&
                                (result != sc->unspecified))
                            return(result);
                    }
                    eval_error_any(sc, sc->unbound_variable_symbol, "~A: unbound variable", 20, sym);
                }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rsi, %r15
movq %rdi, %rbx
movq 0x8(%rdi), %r14
movq (%r14), %rax
movl %eax, %ecx
notl %ecx
testl $0x44000000, %ecx       # imm = 0x44000000
jne 0x7d1f5
movq %rbx, %rdi
movq %r14, %rsi
movq %r15, %rdx
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xaa3e
cmpq %r15, 0x17b8(%rbx)
je 0x7d2c2
cmpq %r15, 0x18d0(%rbx)
je 0x7d254
movq 0x8(%r15), %rax
movq 0x10(%rax), %rdi
leaq 0x663c2(%rip), %rsi     # 0xe35dc
callq 0x7772a
testb %al, %al
je 0x7d31c
leaq 0x663a4(%rip), %rsi     # 0xe35d2
movq %rbx, %rdi
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x7da56
movq (%r14), %rax
btl $0x1d, %eax
jb 0x7d262
movq 0x10(%r14), %r14
movb (%r14), %al
cmpb $0x1c, %al
je 0x7d244
movq 0x110(%rbx), %r14
movb (%r14), %al
cmpb $0x1c, %al
jne 0x7d6aa
testb $0x2, 0x6(%r14)
je 0x7d6b3
movl 0x2c(%r14), %eax
movslq 0x4a4(%rbx), %rcx
cmpq %rcx, %rax
jg 0x7d6b3
movl 0x28(%r14), %r12d
testq %r12, %r12
je 0x7d6b3
movq 0x20(%r14), %r14
movq 0x498(%rbx), %rcx
movq (%rcx,%rax,8), %r15
cmpl $0x7ff, %r12d           # imm = 0x7FF
ja 0x7d819
leaq 0x98697(%rip), %rax     # 0x115950
movq (%rax,%r12,8), %r13
jmp 0x7d853
movq 0x1918(%rbx), %r13
movq 0x820(%rbx), %rax
movslq 0x7dc(%rbx), %rcx
movq (%rax,%rcx,8), %rax
incl %ecx
andl $0x7, %ecx
movl %ecx, 0x7dc(%rbx)
leaq 0x662b7(%rip), %rcx     # 0xe35a4
movq %rcx, 0x10(%rax)
movq $0x2d, 0x8(%rax)
movq 0x28(%rbx), %rcx
movq 0x6e0(%rbx), %rdx
movq %rax, 0x8(%rdx)
movq 0x6e0(%rbx), %rax
movq 0x10(%rax), %rax
movq %rcx, 0x8(%rax)
jmp 0x7d686
cmpq $0x0, 0x2160(%rbx)
jne 0x7d34a
movq 0x2140(%rbx), %rax
cmpb $0x1b, (%rax)
je 0x7d34a
movq 0x1f0(%rbx), %rsi
movq %rbx, %rdi
callq 0x97c7
cmpb $0x1, (%rax)
jne 0x7d635
movq (%rbx), %rax
movq %rax, 0x38(%rsp)
movq 0x10(%rbx), %rax
testq %rax, %rax
movq 0x110(%rbx), %r12
cmoveq %r12, %rax
movq %rax, 0x30(%rsp)
movq 0x20(%rbx), %rax
movq %rax, 0x18(%rsp)
movq 0x28(%rbx), %rax
movq %rax, 0x10(%rsp)
movq 0x128(%rbx), %r13
movq 0x4e0(%rbx), %rax
movq %rax, 0x28(%rsp)
movq 0x4f0(%rbx), %rax
movq %rax, 0x20(%rsp)
movq 0x90(%rbx), %rax
cmpq 0x98(%rbx), %rax
ja 0x7d3b9
movq %rbx, %rdi
callq 0x9c27
movq 0x90(%rbx), %rax
leaq -0x8(%rax), %rcx
movq %rcx, 0x90(%rbx)
movq -0x8(%rax), %rbp
movq $0x200001, (%rbp)       # imm = 0x200001
movq 0x20(%rsp), %rax
movq %rax, 0x8(%rbp)
movq %r12, 0x10(%rbp)
movq 0x90(%rbx), %rax
cmpq 0x98(%rbx), %rax
ja 0x7d3fc
movq %rbx, %rdi
callq 0x9c27
movq 0x90(%rbx), %rax
leaq -0x8(%rax), %rcx
movq %rcx, 0x90(%rbx)
movq -0x8(%rax), %r12
movq $0x200001, (%r12)       # imm = 0x200001
movq 0x28(%rsp), %rax
movq %rax, 0x8(%r12)
movq %rbp, 0x10(%r12)
movq 0x90(%rbx), %rax
cmpq 0x98(%rbx), %rax
ja 0x7d441
movq %rbx, %rdi
callq 0x9c27
movq 0x90(%rbx), %rax
leaq -0x8(%rax), %rcx
movq %rcx, 0x90(%rbx)
movq -0x8(%rax), %rbp
movq $0x200001, (%rbp)       # imm = 0x200001
movq 0x10(%rsp), %rax
movq %rax, 0x8(%rbp)
movq %r12, 0x10(%rbp)
movq 0x90(%rbx), %rax
cmpq 0x98(%rbx), %rax
ja 0x7d484
movq %rbx, %rdi
callq 0x9c27
movq 0x90(%rbx), %rax
leaq -0x8(%rax), %rcx
movq %rcx, 0x90(%rbx)
movq -0x8(%rax), %r12
movq $0x200001, (%r12)       # imm = 0x200001
movq 0x18(%rsp), %rax
movq %rax, 0x8(%r12)
movq %rbp, 0x10(%r12)
movq 0x90(%rbx), %rax
cmpq 0x98(%rbx), %rax
ja 0x7d4c9
movq %rbx, %rdi
callq 0x9c27
movq 0x90(%rbx), %rax
leaq -0x8(%rax), %rcx
movq %rcx, 0x90(%rbx)
movq -0x8(%rax), %rbp
movq $0x200001, (%rbp)       # imm = 0x200001
movq 0x30(%rsp), %rax
movq %rax, 0x8(%rbp)
movq %r12, 0x10(%rbp)
movq 0x90(%rbx), %rax
cmpq 0x98(%rbx), %rax
ja 0x7d50c
movq %rbx, %rdi
callq 0x9c27
movq 0x90(%rbx), %rax
leaq -0x8(%rax), %rcx
movq %rcx, 0x90(%rbx)
movq -0x8(%rax), %rax
movq $0x200001, (%rax)       # imm = 0x200001
movq 0x38(%rsp), %rcx
movq %rcx, 0x8(%rax)
movq %rbp, 0x10(%rax)
movq %rax, 0x528(%rbx)
movq 0x10(%rsp), %rax
cmpb $0x1, (%rax)
je 0x7d591
movq 0x90(%rbx), %rax
movq 0x110(%rbx), %r12
cmpq 0x98(%rbx), %rax
ja 0x7d566
movq %rbx, %rdi
callq 0x9c27
movq 0x90(%rbx), %rax
leaq -0x8(%rax), %rcx
movq %rcx, 0x90(%rbx)
movq -0x8(%rax), %rsi
movq $0x200001, (%rsi)       # imm = 0x200001
movq %r15, 0x8(%rsi)
movq %r12, 0x10(%rsi)
movq %rbx, %rdi
movq %rsi, 0x10(%rsp)
callq 0x7da5d
cmpb $0x1, 0x249(%rbx)
jne 0x7d5ca
cmpq $0x0, 0x2160(%rbx)
je 0x7d5ca
leaq 0xf(%rsp), %rdx
movb $0x0, (%rdx)
pushq $0x1
popq %rcx
movq %rbx, %rdi
movq %r15, %rsi
callq 0x7da8d
testq %rax, %rax
je 0x7d5ca
cmpb $0x0, 0xf(%rsp)
je 0x7d7ce
movq 0x128(%rbx), %r12
cmpq %r12, %r13
je 0x7d6b9
movq 0x18(%rsp), %rax
movq %rax, 0x20(%rbx)
movq 0x10(%rsp), %rax
movq %rax, 0x28(%rbx)
movq 0x30(%rsp), %rax
movq %rax, 0x10(%rbx)
movq 0x38(%rsp), %rax
movq %rax, (%rbx)
movq %r14, 0x8(%rbx)
movq 0x28(%rsp), %rax
movq %rax, 0x4e0(%rbx)
movq 0x20(%rsp), %rax
movq %rax, 0x4f0(%rbx)
movq 0x110(%rbx), %rax
movq %rax, 0x528(%rbx)
cmpq %r12, %r13
je 0x7d635
cmpq 0x130(%rbx), %r13
jne 0x7d698
movq 0x1958(%rbx), %r13
movq 0x820(%rbx), %rax
movslq 0x7dc(%rbx), %rcx
movq (%rax,%rcx,8), %rax
incl %ecx
andl $0x7, %ecx
movl %ecx, 0x7dc(%rbx)
leaq 0x66f05(%rip), %rcx     # 0xe4565
movq %rcx, 0x10(%rax)
movq $0x14, 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 %r13, %rsi
callq 0x2cdc0
movq %r13, %rax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x128(%rbx), %r13
jmp 0x7d698
movq 0x20(%r14), %r13
jmp 0x7d698
cmpb $0x1, 0x249(%rbx)
jne 0x7d706
movq 0x2140(%rbx), %rsi
cmpb $0x1b, (%rsi)
movq %r13, %r12
jne 0x7d709
movq %rbx, %rdi
movq %r15, %rdx
callq *0x18(%rsi)
movq 0x20(%rax), %r13
movzbl (%r13), %eax
cmpl $0x28, %eax
je 0x7d96a
cmpl $0x13, %eax
jne 0x7d98b
movq 0x10(%r13), %rsi
movq %rbx, %rdi
callq 0x2a33b
jmp 0x7d98b
movq %r13, %r12
movq 0x1f0(%rbx), %rbp
movzbl (%rbp), %eax
leaq 0x9dc15(%rip), %rcx     # 0x11b330
cmpb $0x0, (%rax,%rcx)
je 0x7d7b7
movq %rbx, %rdi
movq %rbp, %rsi
callq 0x97c7
cmpb $0x1, (%rax)
jne 0x7d5da
movq 0x598(%rbx), %rax
movq %rbp, 0x8(%rax)
movq 0x208(%rbx), %rax
movq %rax, 0x1f0(%rbx)
movq 0x90(%rbx), %rax
movq 0x110(%rbx), %r12
cmpq 0x98(%rbx), %rax
ja 0x7d778
movq %rbx, %rdi
callq 0x9c27
movq 0x90(%rbx), %rax
leaq -0x8(%rax), %rcx
movq %rcx, 0x90(%rbx)
movq -0x8(%rax), %rdx
movq $0x200001, (%rdx)       # imm = 0x200001
movq %r15, 0x8(%rdx)
movq %r12, 0x10(%rdx)
movq %rbx, %rdi
movq %rbp, %rsi
callq 0x35e2b
movq %rax, %r13
movq %rbp, 0x1f0(%rbx)
movq 0x128(%rbx), %r12
jmp 0x7d5da
cmpb $0x14, %al
jne 0x7d5da
testb $0x20, 0x2(%rbp)
je 0x7d5da
jmp 0x7d725
movq %rax, %rbp
leaq 0x110(%rbx), %rax
movq %rax, 0x40(%rsp)
movq 0x1250(%rbx), %rax
movq 0x10(%rax), %r13
movq 0x10(%r13), %r13
cmpb $0x1, (%r13)
jne 0x7d8e0
movq 0x8(%r13), %r12
movq 0x8(%r12), %rax
movq 0x10(%rax), %rsi
movq %rbp, %rdi
callq 0x70b07
testb %al, %al
je 0x7d7e8
addq $0x10, %r12
jmp 0x7d8e5
movq 0x90(%rbx), %rax
cmpq 0x98(%rbx), %rax
ja 0x7d838
movq %rbx, %rdi
callq 0x9c27
movq 0x90(%rbx), %rax
leaq -0x8(%rax), %rcx
movq %rcx, 0x90(%rbx)
movq -0x8(%rax), %r13
movq $0xb, (%r13)
movq %r12, 0x8(%r13)
movq 0x90(%rbx), %rax
movq 0x110(%rbx), %r12
cmpq 0x98(%rbx), %rax
ja 0x7d879
movq %rbx, %rdi
callq 0x9c27
movq 0x90(%rbx), %rax
leaq -0x8(%rax), %rcx
movq %rcx, 0x90(%rbx)
movq -0x8(%rax), %rax
movl $0x200001, %ecx         # imm = 0x200001
movq %rcx, (%rax)
movq %r13, 0x8(%rax)
movq %r12, 0x10(%rax)
movq 0x90(%rbx), %rdx
leaq -0x8(%rdx), %rsi
movq %rsi, 0x90(%rbx)
movq -0x8(%rdx), %rdx
movq %rcx, (%rdx)
movq %r15, 0x8(%rdx)
movq %rax, 0x10(%rdx)
movq 0x90(%rbx), %rax
leaq -0x8(%rax), %rsi
movq %rsi, 0x90(%rbx)
movq -0x8(%rax), %r13
movq %rcx, (%r13)
movq %r14, 0x8(%r13)
movq %rdx, 0x10(%r13)
jmp 0x7d698
movq 0x40(%rsp), %r12
movq (%r12), %r12
testq %r12, %r12
je 0x7d8f5
cmpb $0x1c, (%r12)
je 0x7d903
movq %rbx, %rdi
movq %rbp, %rsi
callq 0x2a33b
movq %rax, %r12
movq %rbx, %rdi
movq %r15, %rsi
callq 0x94b4
movq %rax, %r13
cmpq 0x128(%rbx), %rax
jne 0x7d5ca
testq %r12, %r12
je 0x7d5ca
cmpb $0x1c, (%r12)
jne 0x7d5ca
movq %rbx, %rdi
movq %r12, %rsi
movq %r15, %rdx
callq 0xa842
movq %rax, %r13
cmpq 0x128(%rbx), %rax
je 0x7d5ca
movq 0x110(%rbx), %rsi
movq %rbx, %rdi
movq %r15, %rdx
movq %r13, %rcx
callq 0xb123
jmp 0x7d5ca
movq 0x8(%rbx), %rsi
movq 0x110(%rbx), %rdx
movq %rbx, %rdi
callq 0x2c1a0
movq %rbx, %rdi
movq %r13, %rsi
movq %rax, %rdx
callq 0x35e2b
movq %rbx, %rdi
movq %r15, %rsi
callq 0x94b4
movq %rax, %r13
movq 0x128(%rbx), %r12
cmpq %r12, %rax
jne 0x7d5da
jmp 0x7d709