// File: /workspace/github_c_makefile_star2_O1/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 $0x38, %rsp
movq %rsi, %r15
movq %rdi, %rbx
movq 0x8(%rdi), %r14
movl (%r14), %eax
notl %eax
testl $0x44000000, %eax       # imm = 0x44000000
jne 0xa2f29
movq %rbx, %rdi
movq %r14, %rsi
movq %r15, %rdx
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xc5b7
cmpq %r15, 0x17b8(%rbx)
je 0xa2ff8
cmpq %r15, 0x18d0(%rbx)
je 0xa2f89
movq 0x8(%r15), %rax
movq 0x10(%rax), %rax
leaq 0x7d5de(%rip), %rcx     # 0x12052c
testq %rax, %rax
je 0xa3052
xorl %edx, %edx
movb (%rax,%rdx), %dil
movb (%rdx,%rcx), %r8b
cmpb %r8b, %dil
sete %sil
testb %dil, %dil
je 0xa3059
incq %rdx
cmpb %r8b, %dil
je 0xa2f59
jmp 0xa3059
testb $0x20, 0x3(%r14)
jne 0xa2f96
movq 0x10(%r14), %r14
cmpb $0x1c, (%r14)
je 0xa2f7e
movq 0x110(%rbx), %r14
cmpb $0x1c, (%r14)
jne 0xa3464
testb $0x2, 0x6(%r14)
je 0xa3470
movl 0x2c(%r14), %eax
movslq 0x4a4(%rbx), %rcx
cmpq %rcx, %rax
jg 0xa3470
movl 0x28(%r14), %r12d
testq %r12, %r12
je 0xa3470
movq 0x20(%r14), %r14
movq 0x498(%rbx), %rcx
movq (%rcx,%rax,8), %r15
cmpl $0x7ff, %r12d           # imm = 0x7FF
ja 0xa3479
leaq 0xab961(%rip), %rax     # 0x14e950
movq (%rax,%r12,8), %r13
jmp 0xa34b3
movq 0x1918(%rbx), %r12
movq 0x820(%rbx), %rax
movslq 0x7dc(%rbx), %rcx
movq (%rax,%rcx,8), %rax
incl %ecx
andl $0x7, %ecx
movl %ecx, 0x7dc(%rbx)
leaq 0x7d4d1(%rip), %rcx     # 0x1204f4
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 0xa3665
cmpq %rcx, %rax
sete %sil
testb %sil, %sil
je 0xa307d
leaq 0x7d4bd(%rip), %rsi     # 0x120522
movq %rbx, %rdi
xorl %edx, %edx
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xa38d4
cmpq $0x0, 0x2160(%rbx)
jne 0xa30b6
movq 0x2140(%rbx), %rax
cmpb $0x1b, (%rax)
je 0xa30b6
movq 0x1f0(%rbx), %rax
movq 0x18e0(%rbx), %rsi
movq 0x18(%rax), %rdx
movq %rbx, %rdi
callq 0xcd2c
cmpb $0x1, (%rax)
jne 0xa3614
movq 0x10(%rbx), %rax
movq %rax, 0x10(%rsp)
testq %rax, %rax
jne 0xa30d0
movq 0x110(%rbx), %rax
movq %rax, 0x10(%rsp)
movq (%rbx), %rax
movq %rax, 0x30(%rsp)
movq 0x20(%rbx), %rax
movq %rax, 0x18(%rsp)
movq 0x28(%rbx), %rax
movq %rax, 0x8(%rsp)
movq 0x128(%rbx), %r12
movq 0x4e0(%rbx), %rax
movq %rax, 0x28(%rsp)
movq 0x4f0(%rbx), %rax
movq %rax, 0x20(%rsp)
movq 0x110(%rbx), %r13
movq 0x90(%rbx), %rax
cmpq 0x98(%rbx), %rax
ja 0xa3128
movq %rbx, %rdi
callq 0xb389
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 %r13, 0x10(%rbp)
movq 0x90(%rbx), %rax
cmpq 0x98(%rbx), %rax
ja 0xa316b
movq %rbx, %rdi
callq 0xb389
movq 0x90(%rbx), %rax
leaq -0x8(%rax), %rcx
movq %rcx, 0x90(%rbx)
movq -0x8(%rax), %r13
movq $0x200001, (%r13)       # imm = 0x200001
movq 0x28(%rsp), %rax
movq %rax, 0x8(%r13)
movq %rbp, 0x10(%r13)
movq 0x90(%rbx), %rax
cmpq 0x98(%rbx), %rax
ja 0xa31ae
movq %rbx, %rdi
callq 0xb389
movq 0x90(%rbx), %rax
leaq -0x8(%rax), %rcx
movq %rcx, 0x90(%rbx)
movq -0x8(%rax), %rbp
movq $0x200001, (%rbp)       # imm = 0x200001
movq 0x8(%rsp), %rax
movq %rax, 0x8(%rbp)
movq %r13, 0x10(%rbp)
movq 0x90(%rbx), %rax
cmpq 0x98(%rbx), %rax
ja 0xa31f1
movq %rbx, %rdi
callq 0xb389
movq 0x90(%rbx), %rax
leaq -0x8(%rax), %rcx
movq %rcx, 0x90(%rbx)
movq -0x8(%rax), %r13
movq $0x200001, (%r13)       # imm = 0x200001
movq 0x18(%rsp), %rax
movq %rax, 0x8(%r13)
movq %rbp, 0x10(%r13)
movq 0x90(%rbx), %rax
cmpq 0x98(%rbx), %rax
ja 0xa3234
movq %rbx, %rdi
callq 0xb389
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 %r13, 0x10(%rbp)
movq 0x90(%rbx), %rax
cmpq 0x98(%rbx), %rax
ja 0xa3277
movq %rbx, %rdi
callq 0xb389
movq 0x90(%rbx), %rax
leaq -0x8(%rax), %rcx
movq %rcx, 0x90(%rbx)
movq -0x8(%rax), %rax
movq $0x200001, (%rax)       # imm = 0x200001
movq 0x30(%rsp), %rcx
movq %rcx, 0x8(%rax)
movq %rbp, 0x10(%rax)
movq %rax, 0x528(%rbx)
movq 0x8(%rsp), %r13
cmpb $0x1, (%r13)
je 0xa3330
movq 0x90(%rbx), %rax
movq 0x110(%rbx), %r13
cmpq 0x98(%rbx), %rax
ja 0xa32d3
movq %rbx, %rdi
callq 0xb389
movq 0x90(%rbx), %rax
leaq -0x8(%rax), %rcx
movq %rcx, 0x90(%rbx)
movq -0x8(%rax), %rax
movq $0x200001, (%rax)       # imm = 0x200001
movq %r15, 0x8(%rax)
movq %r13, 0x10(%rax)
movq %rax, %r13
movq 0x170(%rbx), %rax
cmpq 0x1c8(%rbx), %rax
je 0xa3330
movq 0x8(%rax), %rax
movl 0x20(%rax), %eax
movl %eax, 0x2c(%r13)
movq 0x170(%rbx), %rax
movq 0x8(%rax), %rax
movl 0x24(%rax), %eax
movl %eax, 0x28(%r13)
movq $0x240001, (%r13)       # imm = 0x240001
cmpb $0x1, 0x249(%rbx)
jne 0xa33fd
cmpq $0x0, 0x2160(%rbx)
je 0xa33fd
leaq 0x7(%rsp), %rdx
movb $0x0, (%rdx)
movq %rbx, %rdi
movq %r15, %rsi
movl $0x1, %ecx
callq 0xa374f
testq %rax, %rax
je 0xa33fd
cmpb $0x0, 0x7(%rsp)
jne 0xa33fd
movq %rax, %rbp
movq %rbx, %rdi
movq %rax, %rsi
callq 0xa3883
testq %rax, %rax
je 0xa338f
cmpb $0x1c, (%rax)
je 0xa33a1
movq 0x110(%rbx), %rdx
movq %rbx, %rdi
movq %rbp, %rsi
callq 0x375c2
movq %rbx, %rdi
movq %rax, %r12
movq %r15, %rsi
callq 0xaa24
movq %r12, %rsi
movq %rax, %r12
cmpq 0x128(%rbx), %rax
sete %al
testq %rsi, %rsi
setne %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0xa33fd
cmpb $0x1c, (%rsi)
jne 0xa33fd
movq %rbx, %rdi
movq %r15, %rdx
callq 0xc3ac
movq %rax, %r12
cmpq 0x128(%rbx), %rax
je 0xa33fd
movq 0x110(%rbx), %rsi
movq %rbx, %rdi
movq %r15, %rdx
movq %r12, %rcx
callq 0xce9d
cmpq 0x128(%rbx), %r12
jne 0xa35ba
cmpb $0x1, 0x249(%rbx)
jne 0xa35ad
movq 0x2140(%rbx), %rsi
cmpb $0x1b, (%rsi)
jne 0xa35ad
movq %rbx, %rdi
movq %r15, %rdx
callq *0x18(%rsi)
movq 0x20(%rax), %r12
movzbl (%r12), %eax
cmpl $0x28, %eax
je 0xa3542
cmpl $0x13, %eax
jne 0xa359f
movq 0x10(%r12), %rsi
movq 0x110(%rbx), %rdx
movq %rbx, %rdi
callq 0x375c2
jmp 0xa359f
movq 0x128(%rbx), %r12
jmp 0xa3677
movq 0x20(%r14), %r12
jmp 0xa3677
movq 0x90(%rbx), %rax
cmpq 0x98(%rbx), %rax
ja 0xa3491
movq %rbx, %rdi
callq 0xb389
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 0xa34d2
movq %rbx, %rdi
callq 0xb389
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), %r12
movq %rcx, (%r12)
movq %r14, 0x8(%r12)
movq %rdx, 0x10(%r12)
jmp 0xa3677
movq %r13, 0x8(%rsp)
movq 0x8(%rbx), %r13
movq 0x90(%rbx), %rax
movq 0x110(%rbx), %rbp
cmpq 0x98(%rbx), %rax
ja 0xa356a
movq %rbx, %rdi
callq 0xb389
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 0x466aa
movq 0x8(%rsp), %r13
movq %rbx, %rdi
movq %r15, %rsi
callq 0xaa24
movq %rax, %r12
cmpq 0x128(%rbx), %r12
je 0xa3689
movq 0x18(%rsp), %rax
movq %rax, 0x20(%rbx)
movq %r13, 0x28(%rbx)
movq 0x10(%rsp), %rax
movq %rax, 0x10(%rbx)
movq 0x30(%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 0x128(%rbx), %r12
je 0xa3614
cmpq 0x130(%rbx), %r12
jne 0xa3677
movq 0x1958(%rbx), %r12
movq 0x820(%rbx), %rax
movslq 0x7dc(%rbx), %rcx
movq (%rax,%rcx,8), %rax
incl %ecx
andl $0x7, %ecx
movl %ecx, 0x7dc(%rbx)
leaq 0x7de76(%rip), %rcx     # 0x1214b5
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 %r12, %rsi
callq 0x3b366
movq %r12, %rax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x1f0(%rbx), %rbp
movzbl (%rbp), %eax
leaq 0xb0c95(%rip), %rcx     # 0x154330
cmpb $0x0, (%rax,%rcx)
je 0xa3738
movq 0x18e0(%rbx), %rsi
movq 0x18(%rbp), %rdx
movq %rbx, %rdi
callq 0xcd2c
cmpb $0x1, (%rax)
jne 0xa35ba
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 0xa36f9
movq %rbx, %rdi
callq 0xb389
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 0x466aa
movq %rax, %r12
movq %rbp, 0x1f0(%rbx)
jmp 0xa35ba
cmpb $0x14, %al
jne 0xa35ba
testb $0x20, 0x2(%rbp)
je 0xa35ba
jmp 0xa36a5