// File: /workspace/github_c_makefile_star2_O0/BernardTatin[P]s7sh/s7.c
// Function: s7_let_ref
inline s7_pointer s7_let_ref(s7_scheme *sc, s7_pointer env, s7_pointer symbol)
    {
        s7_pointer x, y;
        /* (let ((a 1)) ((curlet) 'a))
         * ((rootlet) 'abs)
         */
        if (!is_let(env))
            return(wrong_type_argument_with_type(sc, sc->let_ref_symbol, 1, env, a_let_string));

        if (!is_symbol(symbol))
        {
#if S7_DEBUGGING
            if ((env != sc->rootlet) && (has_let_ref_fallback(env)))
#else
                if (has_let_ref_fallback(env))
#endif
                    return(call_let_ref_fallback(sc, env, symbol));
            return(wrong_type_argument_with_type(sc, sc->let_ref_symbol, 2, symbol, a_symbol_string));
        }

        check_method_uncopied(sc, env, sc->let_ref_symbol, list_2(sc, env, symbol));
        /* a let-ref method is almost impossible to write without creating an infinite loop:
         *   any reference to the let will probably call let-ref somewhere, calling us again, and looping.
         *   This is not a problem in c-objects and funclets because c-object-ref and funclet-ref don't exist.
         *   After much wasted debugging, I decided to make let-ref and let-set! immutable.
         */

        if (is_keyword(symbol))
            symbol = keyword_symbol(symbol);

        if (env == sc->rootlet)
        {
            y = global_slot(symbol);
            if (is_slot(y))
                return(slot_value(y));
            return(sc->undefined);
        }

        if (let_id(env) == symbol_id(symbol))
            return(slot_value(local_slot(symbol))); /* this obviously has to follow the global-env check */

        for (x = env; is_let(x); x = outlet(x))
            for (y = let_slots(x); tis_slot(y); y = next_slot(y))
                if (slot_symbol(y) == symbol)
                    return(slot_value(y));

        if (has_methods(env)) /* this is not a redundant check -- if has_methods, don't check global slot */
        {
            /* If a let is a mock-hash-table (for example), implicit
             *   indexing of the hash-table collides with the same thing for the let (field names
             *   versus keys), and we can't just try again here because that makes it too easy to
             *   get into infinite recursion.  So, 'let-ref-fallback...
             */
            if (has_let_ref_fallback(env))
                return(call_let_ref_fallback(sc, env, symbol));
        }
        else
        {
            y = global_slot(symbol);  /* (let () ((curlet) 'pi)) */
            if (is_slot(y))
                return(slot_value(y));
        }
        return(sc->undefined);
    }

// Assembly:
subq $0xf8, %rsp
movq %rdi, 0xe8(%rsp)
movq %rsi, 0xe0(%rsp)
movq %rdx, 0xd8(%rsp)
movq 0xe0(%rsp), %rax
movzbl (%rax), %eax
cmpl $0x1c, %eax
je 0xe60c
movq 0xe8(%rsp), %rax
movq %rax, 0x50(%rsp)
movq 0xe8(%rsp), %rax
movq 0x1230(%rax), %rax
movq 0x8(%rax), %rax
movq %rax, 0x58(%rsp)
movq $0x1, 0xc0(%rsp)
movq 0xc0(%rsp), %rax
andq $-0x800, %rax           # imm = 0xF800
cmpq $0x0, %rax
jne 0xe525
movq 0xc0(%rsp), %rcx
leaq 0x207f69(%rip), %rax    # 0x216480
movq (%rax,%rcx,8), %rax
movq %rax, 0x48(%rsp)
jmp 0xe5bd
jmp 0xe527
movq 0xe8(%rsp), %rax
movq 0x90(%rax), %rax
movq 0xe8(%rsp), %rcx
cmpq 0x98(%rcx), %rax
ja 0xe554
movq 0xe8(%rsp), %rdi
callq 0xc670
movq 0xe8(%rsp), %rcx
movq 0x90(%rcx), %rax
movq %rax, %rdx
addq $-0x8, %rdx
movq %rdx, 0x90(%rcx)
movq -0x8(%rax), %rax
movq %rax, 0xb0(%rsp)
movq 0xb0(%rsp), %rax
movq $0xb, (%rax)
movq 0xc0(%rsp), %rcx
movq 0xb0(%rsp), %rax
movq %rcx, 0x8(%rax)
movq 0xb0(%rsp), %rax
movq %rax, 0xa8(%rsp)
movq 0xa8(%rsp), %rax
movq %rax, 0x48(%rsp)
movq 0x58(%rsp), %rsi
movq 0x50(%rsp), %rdi
movq 0x48(%rsp), %rax
movq %rax, 0xb8(%rsp)
movq 0xb8(%rsp), %rdx
movq 0xe0(%rsp), %rcx
movq 0xe8(%rsp), %rax
movq 0x140(%rax), %r8
movq 0x20be8e(%rip), %r9     # 0x21a488
callq 0xc560
movq %rax, 0xf0(%rsp)
jmp 0xeb70
movq 0xd8(%rsp), %rax
movzbl (%rax), %eax
cmpl $0xa, %eax
je 0xe7ac
movq 0xe0(%rsp), %rax
movq (%rax), %rax
andq $0x44000000, %rax       # imm = 0x44000000
cmpq $0x44000000, %rax       # imm = 0x44000000
jne 0xe663
movq 0xe8(%rsp), %rdi
movq 0xe0(%rsp), %rsi
movq 0xd8(%rsp), %rdx
callq 0xeb80
movq %rax, 0xf0(%rsp)
jmp 0xeb70
movq 0xe8(%rsp), %rax
movq %rax, 0x38(%rsp)
movq 0xe8(%rsp), %rax
movq 0x1230(%rax), %rax
movq 0x8(%rax), %rax
movq %rax, 0x40(%rsp)
movq $0x2, 0xa0(%rsp)
movq 0xa0(%rsp), %rax
andq $-0x800, %rax           # imm = 0xF800
cmpq $0x0, %rax
jne 0xe6c5
movq 0xa0(%rsp), %rcx
leaq 0x207dc9(%rip), %rax    # 0x216480
movq (%rax,%rcx,8), %rax
movq %rax, 0x30(%rsp)
jmp 0xe75d
jmp 0xe6c7
movq 0xe8(%rsp), %rax
movq 0x90(%rax), %rax
movq 0xe8(%rsp), %rcx
cmpq 0x98(%rcx), %rax
ja 0xe6f4
movq 0xe8(%rsp), %rdi
callq 0xc670
movq 0xe8(%rsp), %rcx
movq 0x90(%rcx), %rax
movq %rax, %rdx
addq $-0x8, %rdx
movq %rdx, 0x90(%rcx)
movq -0x8(%rax), %rax
movq %rax, 0x90(%rsp)
movq 0x90(%rsp), %rax
movq $0xb, (%rax)
movq 0xa0(%rsp), %rcx
movq 0x90(%rsp), %rax
movq %rcx, 0x8(%rax)
movq 0x90(%rsp), %rax
movq %rax, 0x88(%rsp)
movq 0x88(%rsp), %rax
movq %rax, 0x30(%rsp)
movq 0x40(%rsp), %rsi
movq 0x38(%rsp), %rdi
movq 0x30(%rsp), %rax
movq %rax, 0x98(%rsp)
movq 0x98(%rsp), %rdx
movq 0xd8(%rsp), %rcx
movq 0xe8(%rsp), %rax
movq 0x140(%rax), %r8
movq 0x20bcf6(%rip), %r9     # 0x21a490
callq 0xc560
movq %rax, 0xf0(%rsp)
jmp 0xeb70
movq 0xe0(%rsp), %rax
movq (%rax), %rax
andq $0x40000000, %rax       # imm = 0x40000000
cmpq $0x0, %rax
je 0xe944
movq 0xe8(%rsp), %rax
testb $0x1, 0x24c(%rax)
je 0xe944
movq 0xe8(%rsp), %rax
movq %rax, 0x28(%rsp)
movq 0xe8(%rsp), %rdi
movq 0xe0(%rsp), %rsi
callq 0x9a10
movq 0x28(%rsp), %rdi
movq %rax, %rsi
movq 0xe8(%rsp), %rax
movq 0x1230(%rax), %rdx
callq 0x98d0
movq %rax, 0x80(%rsp)
movq 0xe8(%rsp), %rcx
cmpq 0x128(%rcx), %rax
je 0xe944
movq 0xe8(%rsp), %rax
movq %rax, 0x8(%rsp)
movq 0x80(%rsp), %rax
movq %rax, 0x10(%rsp)
movq 0xe8(%rsp), %rax
movq %rax, 0x18(%rsp)
movq 0xe0(%rsp), %rax
movq %rax, 0x20(%rsp)
movq 0xd8(%rsp), %rax
movq %rax, 0x70(%rsp)
movq 0xe8(%rsp), %rax
movq 0x110(%rax), %rax
movq %rax, 0x68(%rsp)
movq 0xe8(%rsp), %rax
movq 0x90(%rax), %rax
movq 0xe8(%rsp), %rcx
cmpq 0x98(%rcx), %rax
ja 0xe8b9
movq 0xe8(%rsp), %rdi
callq 0xc670
movq 0xe8(%rsp), %rcx
movq 0x90(%rcx), %rax
movq %rax, %rdx
addq $-0x8, %rdx
movq %rdx, 0x90(%rcx)
movq -0x8(%rax), %rax
movq %rax, 0x78(%rsp)
movq 0x78(%rsp), %rax
movq $0x200001, (%rax)       # imm = 0x200001
movq 0x20(%rsp), %rsi
movq 0x18(%rsp), %rdi
movq 0x70(%rsp), %rcx
movq 0x78(%rsp), %rax
movq %rcx, 0x8(%rax)
movq 0x68(%rsp), %rcx
movq 0x78(%rsp), %rax
movq %rcx, 0x10(%rax)
movq 0x78(%rsp), %rax
movq %rax, 0x60(%rsp)
movq 0x60(%rsp), %rdx
callq 0xd9f0
movq 0x8(%rsp), %rdi
movq 0x10(%rsp), %rsi
movq %rax, %rdx
callq 0xda50
movq %rax, 0xf0(%rsp)
jmp 0xeb70
movq 0xd8(%rsp), %rax
movzwl 0x6(%rax), %eax
andl $0x80, %eax
cmpl $0x0, %eax
je 0xe976
movq 0xd8(%rsp), %rax
movq 0x8(%rax), %rax
movq 0x20(%rax), %rax
movq 0x18(%rax), %rax
movq %rax, 0xd8(%rsp)
movq 0xe0(%rsp), %rax
movq 0xe8(%rsp), %rcx
cmpq 0x150(%rcx), %rax
jne 0xe9e8
movq 0xd8(%rsp), %rax
movq 0x10(%rax), %rax
movq %rax, 0xc8(%rsp)
movq 0xc8(%rsp), %rax
movzbl (%rax), %eax
cmpl $0x20, %eax
jne 0xe9cc
movq 0xc8(%rsp), %rax
movq 0x10(%rax), %rax
movq %rax, 0xf0(%rsp)
jmp 0xeb70
movq 0xe8(%rsp), %rax
movq 0x128(%rax), %rax
movq %rax, 0xf0(%rsp)
jmp 0xeb70
movq 0xe0(%rsp), %rax
movq 0x18(%rax), %rax
movq 0xd8(%rsp), %rcx
cmpq 0x20(%rcx), %rax
jne 0xea1f
movq 0xd8(%rsp), %rax
movq 0x18(%rax), %rax
movq 0x10(%rax), %rax
movq %rax, 0xf0(%rsp)
jmp 0xeb70
movq 0xe0(%rsp), %rax
movq %rax, 0xd0(%rsp)
movq 0xd0(%rsp), %rax
movzbl (%rax), %eax
cmpl $0x1c, %eax
jne 0xeac4
movq 0xd0(%rsp), %rax
movq 0x8(%rax), %rax
movq %rax, 0xc8(%rsp)
cmpq $0x0, 0xc8(%rsp)
je 0xeaa9
movq 0xc8(%rsp), %rax
movq 0x8(%rax), %rax
cmpq 0xd8(%rsp), %rax
jne 0xea91
movq 0xc8(%rsp), %rax
movq 0x10(%rax), %rax
movq %rax, 0xf0(%rsp)
jmp 0xeb70
jmp 0xea93
movq 0xc8(%rsp), %rax
movq 0x18(%rax), %rax
movq %rax, 0xc8(%rsp)
jmp 0xea57
jmp 0xeaab
movq 0xd0(%rsp), %rax
movq 0x10(%rax), %rax
movq %rax, 0xd0(%rsp)
jmp 0xea2f
movq 0xe0(%rsp), %rax
movq (%rax), %rax
andq $0x40000000, %rax       # imm = 0x40000000
cmpq $0x0, %rax
je 0xeb1d
movq 0xe0(%rsp), %rax
movq (%rax), %rax
andq $0x44000000, %rax       # imm = 0x44000000
cmpq $0x44000000, %rax       # imm = 0x44000000
jne 0xeb1b
movq 0xe8(%rsp), %rdi
movq 0xe0(%rsp), %rsi
movq 0xd8(%rsp), %rdx
callq 0xeb80
movq %rax, 0xf0(%rsp)
jmp 0xeb70
jmp 0xeb59
movq 0xd8(%rsp), %rax
movq 0x10(%rax), %rax
movq %rax, 0xc8(%rsp)
movq 0xc8(%rsp), %rax
movzbl (%rax), %eax
cmpl $0x20, %eax
jne 0xeb57
movq 0xc8(%rsp), %rax
movq 0x10(%rax), %rax
movq %rax, 0xf0(%rsp)
jmp 0xeb70
jmp 0xeb59
movq 0xe8(%rsp), %rax
movq 0x128(%rax), %rax
movq %rax, 0xf0(%rsp)
movq 0xf0(%rsp), %rax
addq $0xf8, %rsp
retq