// File: /workspace/github_c_makefile_star2_O3/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
movq (%r14), %rax
movl %eax, %ecx
notl %ecx
testl $0x44000000, %ecx       # imm = 0x44000000
jne 0x9c4d5
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 0xb743
cmpq %r15, 0x17b8(%rbx)
je 0x9c53e
cmpq %r15, 0x18d0(%rbx)
je 0x9c95e
movq 0x8(%r15), %rax
movq 0x10(%rax), %rax
testq %rax, %rax
je 0x9c598
xorl %ecx, %ecx
leaq 0x7b137(%rip), %rdx     # 0x11763c
movb (%rax,%rcx), %sil
movb (%rcx,%rdx), %dil
testb %sil, %sil
je 0x9c51a
incq %rcx
cmpb %dil, %sil
je 0x9c505
cmpb %dil, %sil
jne 0x9c598
leaq 0x7b10c(%rip), %rsi     # 0x117632
movq %rbx, %rdi
xorl %edx, %edx
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x9ce4d
movq 0x1918(%rbx), %rbp
movq 0x820(%rbx), %rax
movslq 0x7dc(%rbx), %rcx
movq (%rax,%rcx,8), %rax
incl %ecx
andl $0x7, %ecx
movl %ecx, 0x7dc(%rbx)
leaq 0x7b09b(%rip), %rcx     # 0x117604
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 0x9c93a
cmpq $0x0, 0x2160(%rbx)
jne 0x9c5d1
movq 0x2140(%rbx), %rax
cmpb $0x1b, (%rax)
je 0x9c5d1
movq 0x1f0(%rbx), %rax
movq 0x18e0(%rbx), %rsi
movq 0x18(%rax), %rdx
movq %rbx, %rdi
callq 0xbe9a
cmpb $0x1, (%rax)
jne 0x9c8e9
movq (%rbx), %rax
movq %rax, 0x30(%rsp)
movq 0x10(%rbx), %rax
testq %rax, %rax
movq 0x110(%rbx), %r12
cmoveq %r12, %rax
movq %rax, 0x28(%rsp)
movq 0x20(%rbx), %rax
movq %rax, 0x10(%rsp)
movq 0x28(%rbx), %rax
movq %rax, 0x8(%rsp)
movq 0x128(%rbx), %rbp
movq 0x4e0(%rbx), %rax
movq %rax, 0x20(%rsp)
movq 0x4f0(%rbx), %rax
movq %rax, 0x18(%rsp)
movq 0x90(%rbx), %rax
cmpq 0x98(%rbx), %rax
ja 0x9c640
movq %rbx, %rdi
callq 0xa550
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 %r12, 0x10(%r13)
movq 0x90(%rbx), %rax
cmpq 0x98(%rbx), %rax
ja 0x9c683
movq %rbx, %rdi
callq 0xa550
movq 0x90(%rbx), %rax
leaq -0x8(%rax), %rcx
movq %rcx, 0x90(%rbx)
movq -0x8(%rax), %r12
movq $0x200001, (%r12)       # imm = 0x200001
movq 0x20(%rsp), %rax
movq %rax, 0x8(%r12)
movq %r13, 0x10(%r12)
movq 0x90(%rbx), %rax
cmpq 0x98(%rbx), %rax
ja 0x9c6c8
movq %rbx, %rdi
callq 0xa550
movq 0x90(%rbx), %rax
leaq -0x8(%rax), %rcx
movq %rcx, 0x90(%rbx)
movq -0x8(%rax), %r13
movq $0x200001, (%r13)       # imm = 0x200001
movq 0x8(%rsp), %rax
movq %rax, 0x8(%r13)
movq %r12, 0x10(%r13)
movq 0x90(%rbx), %rax
cmpq 0x98(%rbx), %rax
ja 0x9c70b
movq %rbx, %rdi
callq 0xa550
movq 0x90(%rbx), %rax
leaq -0x8(%rax), %rcx
movq %rcx, 0x90(%rbx)
movq -0x8(%rax), %r12
movq $0x200001, (%r12)       # imm = 0x200001
movq 0x10(%rsp), %rax
movq %rax, 0x8(%r12)
movq %r13, 0x10(%r12)
movq 0x90(%rbx), %rax
cmpq 0x98(%rbx), %rax
ja 0x9c750
movq %rbx, %rdi
callq 0xa550
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 %r12, 0x10(%r13)
movq 0x90(%rbx), %rax
cmpq 0x98(%rbx), %rax
ja 0x9c793
movq %rbx, %rdi
callq 0xa550
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 %r13, 0x10(%rax)
movq %rax, 0x528(%rbx)
movq 0x8(%rsp), %r13
cmpb $0x1, (%r13)
je 0x9c843
movq 0x90(%rbx), %rax
movq 0x110(%rbx), %r12
cmpq 0x98(%rbx), %rax
ja 0x9c7ef
movq %rbx, %rdi
callq 0xa550
movq 0x90(%rbx), %rax
leaq -0x8(%rax), %rcx
movq %rcx, 0x90(%rbx)
movq -0x8(%rax), %r13
movq $0x200001, (%r13)       # imm = 0x200001
movq %r15, 0x8(%r13)
movq %r12, 0x10(%r13)
movq 0x170(%rbx), %rax
cmpq 0x1c8(%rbx), %rax
je 0x9c843
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 0x9c883
cmpq $0x0, 0x2160(%rbx)
je 0x9c883
leaq 0x7(%rsp), %rdx
movb $0x0, (%rdx)
movq 0x8(%r15), %rax
movq 0x10(%rax), %rsi
movq %rbx, %rdi
movl $0x1, %ecx
callq 0x9ccf5
testq %rax, %rax
je 0x9c883
cmpb $0x0, 0x7(%rsp)
je 0x9cb1a
movq 0x128(%rbx), %r12
cmpq %r12, %rbp
je 0x9c9e4
movq 0x10(%rsp), %rax
movq %rax, 0x20(%rbx)
movq %r13, 0x28(%rbx)
movq 0x28(%rsp), %rax
movq %rax, 0x10(%rbx)
movq 0x30(%rsp), %rax
movq %rax, (%rbx)
movq %r14, 0x8(%rbx)
movq 0x20(%rsp), %rax
movq %rax, 0x4e0(%rbx)
movq 0x18(%rsp), %rax
movq %rax, 0x4f0(%rbx)
movq 0x110(%rbx), %rax
movq %rax, 0x528(%rbx)
cmpq %r12, %rbp
je 0x9c8e9
cmpq 0x130(%rbx), %rbp
jne 0x9c94c
movq 0x1958(%rbx), %rbp
movq 0x820(%rbx), %rax
movslq 0x7dc(%rbx), %rcx
movq (%rax,%rcx,8), %rax
incl %ecx
andl $0x7, %ecx
movl %ecx, 0x7dc(%rbx)
leaq 0x7bcb1(%rip), %rcx     # 0x1185c5
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 %rbp, %rsi
callq 0x38dfa
movq %rbp, %rax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
cmpb $0x1c, %al
jne 0x9c975
movq (%r14), %rax
btl $0x1d, %eax
jb 0x9c97f
movq 0x10(%r14), %r14
cmpb $0x1c, (%r14)
je 0x9c962
movq 0x110(%rbx), %r14
movb (%r14), %al
cmpb $0x1c, %al
jne 0x9c9cf
testb $0x2, 0x6(%r14)
je 0x9c9db
movl 0x2c(%r14), %eax
movslq 0x4a4(%rbx), %rcx
cmpq %rcx, %rax
jg 0x9c9db
movl 0x28(%r14), %r12d
testq %r12, %r12
je 0x9c9db
movq 0x20(%r14), %r14
movq 0x498(%rbx), %rcx
movq (%rcx,%rax,8), %r15
cmpl $0x7ff, %r12d           # imm = 0x7FF
ja 0x9cbae
leaq 0xa9f8a(%rip), %rax     # 0x146950
movq (%rax,%r12,8), %r13
jmp 0x9cbe8
movq 0x128(%rbx), %rbp
jmp 0x9c94c
movq 0x20(%r14), %rbp
jmp 0x9c94c
cmpb $0x1, 0x249(%rbx)
jne 0x9ca39
movq 0x2140(%rbx), %rsi
cmpb $0x1b, (%rsi)
movq %rbp, %r12
jne 0x9ca3c
movq %rbx, %rdi
movq %r15, %rdx
callq *0x18(%rsi)
movq 0x20(%rax), %r12
movzbl (%r12), %eax
cmpl $0x28, %eax
je 0x9cc75
cmpl $0x13, %eax
jne 0x9ccd2
movq 0x10(%r12), %rsi
movq 0x110(%rbx), %rdx
movq %rbx, %rdi
callq 0x3527e
jmp 0x9ccd2
movq %rbp, %r12
movq 0x1f0(%rbx), %r8
movzbl (%r8), %eax
leaq 0xaf8e2(%rip), %rcx     # 0x14c330
cmpb $0x0, (%rax,%rcx)
je 0x9cb02
movq 0x18e0(%rbx), %rsi
movq 0x18(%r8), %rdx
movq %rbx, %rdi
movq %r8, 0x8(%rsp)
callq 0xbe9a
cmpb $0x1, (%rax)
jne 0x9c893
movq 0x598(%rbx), %rax
movq 0x8(%rsp), %rsi
movq %rsi, 0x8(%rax)
movq 0x208(%rbx), %rax
movq %rax, 0x1f0(%rbx)
movq 0x90(%rbx), %rax
movq 0x110(%rbx), %r12
cmpq 0x98(%rbx), %rax
ja 0x9cac3
movq %rbx, %rdi
movq %rsi, %rbp
callq 0xa550
movq %rbp, %rsi
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 %rsi, %r12
callq 0x43bf0
movq %rax, %rbp
movq %r12, 0x1f0(%rbx)
movq 0x128(%rbx), %r12
jmp 0x9c893
cmpb $0x14, %al
jne 0x9c893
testb $0x20, 0x2(%r8)
je 0x9c893
jmp 0x9ca58
movq %rax, %r12
movq %rbx, %rdi
movq %rax, %rsi
callq 0x9cdfc
testq %rax, %rax
je 0x9cb32
cmpb $0x1c, (%rax)
je 0x9cb44
movq 0x110(%rbx), %rdx
movq %rbx, %rdi
movq %r12, %rsi
callq 0x3527e
movq %rax, %r12
movq %rbx, %rdi
movq %r15, %rsi
callq 0x9a93
movq %rax, %rbp
cmpq 0x128(%rbx), %rax
jne 0x9c883
testq %r12, %r12
je 0x9c883
movq %r12, %rsi
cmpb $0x1c, (%r12)
jne 0x9c883
movq %rbx, %rdi
movq %r15, %rdx
callq 0xb54b
movq %rax, %rbp
cmpq 0x128(%rbx), %rax
je 0x9c883
movq 0x110(%rbx), %rsi
movq %rbx, %rdi
movq %r15, %rdx
movq %rbp, %rcx
callq 0xbfdc
jmp 0x9c883
movq 0x90(%rbx), %rax
cmpq 0x98(%rbx), %rax
ja 0x9cbcd
movq %rbx, %rdi
callq 0xa550
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 0x9cc0e
movq %rbx, %rdi
callq 0xa550
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), %rbp
movq %rcx, (%rbp)
movq %r14, 0x8(%rbp)
movq %rdx, 0x10(%rbp)
jmp 0x9c94c
movq %r13, 0x8(%rsp)
movq 0x8(%rbx), %r13
movq 0x90(%rbx), %rax
movq 0x110(%rbx), %rbp
cmpq 0x98(%rbx), %rax
ja 0x9cca4
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 0x43bf0
movq 0x8(%rsp), %r13
movq %rbx, %rdi
movq %r15, %rsi
callq 0x9a93
movq %rax, %rbp
movq 0x128(%rbx), %r12
cmpq %r12, %rax
jne 0x9c893
jmp 0x9ca3c