// File: /workspace/github_c_makefile_star2_O0/BernardTatin[P]s7sh/s7.c
// Function: g_symbol_to_dynamic_value
static s7_pointer g_symbol_to_dynamic_value(s7_scheme *sc, s7_pointer args)
    {
#define H_symbol_to_dynamic_value "(symbol->dynamic-value sym) returns the dynamic binding of the symbol sym"
#define Q_symbol_to_dynamic_value s7_make_signature(sc, 2, sc->T, sc->is_symbol_symbol)

        s7_pointer sym, val;
        int64_t i, top_id;

        sym = car(args);
        if (!is_symbol(sym))
            return(method_or_bust(sc, sym, sc->symbol_to_dynamic_value_symbol, args, T_SYMBOL, 1));

        if (is_global(sym))
            return(slot_value(global_slot(sym)));

        if (let_id(sc->envir) == symbol_id(sym))
            return(slot_value(local_slot(sym)));

        top_id = -1;
        val = find_dynamic_value(sc, sc->envir, sym, &top_id);
        if (top_id == symbol_id(sym))
            return(val);

        for (i = s7_stack_top(sc) - 1; i > 0; i -= 4)
            if (is_let_unchecked(stack_let(sc->stack, i))) /* OP_GC_PROTECT envir slot can be anything (even free) */
            {
                s7_pointer cur_val;
                cur_val = find_dynamic_value(sc, stack_let(sc->stack, i), sym, &top_id);
                if (cur_val != sc->unused)
                    val = cur_val;
                if (top_id == symbol_id(sym))
                    return(val);
            }

        if (val == sc->unused)
            return(s7_symbol_value(sc, sym));
        return(val);
    }

// Assembly:
subq $0x48, %rsp
movq %rdi, 0x38(%rsp)
movq %rsi, 0x30(%rsp)
movq 0x30(%rsp), %rax
movq 0x8(%rax), %rax
movq %rax, 0x28(%rsp)
movq 0x28(%rsp), %rax
movzbl (%rax), %eax
cmpl $0xa, %eax
je 0x6702f
movq 0x38(%rsp), %rdi
movq 0x28(%rsp), %rsi
movq 0x38(%rsp), %rax
movq 0x15b0(%rax), %rdx
movq 0x30(%rsp), %rcx
movl $0xa, %r8d
movl $0x1, %r9d
callq 0x13c50
movq %rax, 0x40(%rsp)
jmp 0x671d9
movq 0x28(%rsp), %rax
movq (%rax), %rax
andq $0x10000, %rax          # imm = 0x10000
cmpq $0x0, %rax
je 0x6705a
movq 0x28(%rsp), %rax
movq 0x10(%rax), %rax
movq 0x10(%rax), %rax
movq %rax, 0x40(%rsp)
jmp 0x671d9
movq 0x38(%rsp), %rax
movq 0x8(%rax), %rax
movq 0x18(%rax), %rax
movq 0x28(%rsp), %rcx
cmpq 0x20(%rcx), %rax
jne 0x67089
movq 0x28(%rsp), %rax
movq 0x18(%rax), %rax
movq 0x10(%rax), %rax
movq %rax, 0x40(%rsp)
jmp 0x671d9
movq $-0x1, 0x10(%rsp)
movq 0x38(%rsp), %rdi
movq 0x38(%rsp), %rax
movq 0x8(%rax), %rsi
movq 0x28(%rsp), %rdx
leaq 0x10(%rsp), %rcx
callq 0x1ba6a0
movq %rax, 0x20(%rsp)
movq 0x10(%rsp), %rax
movq 0x28(%rsp), %rcx
cmpq 0x20(%rcx), %rax
jne 0x670d3
movq 0x20(%rsp), %rax
movq %rax, 0x40(%rsp)
jmp 0x671d9
movq 0x38(%rsp), %rax
movq 0x50(%rax), %rax
movq 0x38(%rsp), %rcx
movq 0x48(%rcx), %rcx
subq %rcx, %rax
sarq $0x3, %rax
subq $0x1, %rax
movq %rax, 0x18(%rsp)
cmpq $0x0, 0x18(%rsp)
jle 0x671a6
movq 0x38(%rsp), %rax
movq 0x38(%rax), %rax
movq 0x10(%rax), %rax
movq 0x18(%rsp), %rcx
subq $0x2, %rcx
movq (%rax,%rcx,8), %rax
movzbl (%rax), %eax
cmpl $0x1c, %eax
jne 0x67191
movq 0x38(%rsp), %rdi
movq 0x38(%rsp), %rax
movq 0x38(%rax), %rax
movq 0x10(%rax), %rax
movq 0x18(%rsp), %rcx
subq $0x2, %rcx
movq (%rax,%rcx,8), %rsi
movq 0x28(%rsp), %rdx
leaq 0x10(%rsp), %rcx
callq 0x1ba6a0
movq %rax, 0x8(%rsp)
movq 0x8(%rsp), %rax
movq 0x38(%rsp), %rcx
cmpq 0x140(%rcx), %rax
je 0x67173
movq 0x8(%rsp), %rax
movq %rax, 0x20(%rsp)
movq 0x10(%rsp), %rax
movq 0x28(%rsp), %rcx
cmpq 0x20(%rcx), %rax
jne 0x6718f
movq 0x20(%rsp), %rax
movq %rax, 0x40(%rsp)
jmp 0x671d9
jmp 0x67191
jmp 0x67193
movq 0x18(%rsp), %rax
subq $0x4, %rax
movq %rax, 0x18(%rsp)
jmp 0x670f5
movq 0x20(%rsp), %rax
movq 0x38(%rsp), %rcx
cmpq 0x140(%rcx), %rax
jne 0x671cf
movq 0x38(%rsp), %rdi
movq 0x28(%rsp), %rsi
callq 0xb3a0
movq %rax, 0x40(%rsp)
jmp 0x671d9
movq 0x20(%rsp), %rax
movq %rax, 0x40(%rsp)
movq 0x40(%rsp), %rax
addq $0x48, %rsp
retq
nopw %cs:(%rax,%rax)