// File: /workspace/github_c_makefile_star2_O1/BernardTatin[P]s7sh/s7.c
// Function: g_is_defined
static s7_pointer g_is_defined(s7_scheme *sc, s7_pointer args)
    {
#define H_is_defined "(defined? symbol (env (curlet)) ignore-globals) returns #t if symbol has a binding (a value) in the environment env.  Only env is searched if ignore-globals is not #f."
#define Q_is_defined s7_make_signature(sc, 4, sc->is_boolean_symbol, sc->is_symbol_symbol, sc->is_let_symbol, sc->is_boolean_symbol)

        s7_pointer sym;
        /* is this correct?
         *    (defined? '_x) #f (symbol->value '_x) #<undefined>
         *    (define x #<undefined>) (defined? 'x) #t
         * can't return the value here because it might be #f
         */

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

        if (is_pair(cdr(args)))
        {
            s7_pointer e, b, x;

            e = cadr(args);
            if (!is_let(e))
                return(wrong_type_argument_with_type(sc, sc->is_defined_symbol, 2, e, a_let_string));
            if (e == sc->s7_let)
                return(make_boolean(sc, symbol_s7_let(sym) != 0));

            if (is_pair(cddr(args)))
            {
                b = caddr(args);
                if (!s7_is_boolean(b))
                    return(method_or_bust_with_type(sc, b, sc->is_defined_symbol, args, a_boolean_string, 3));
            }
            else b = sc->F;

            if (e == sc->rootlet) /* we checked (let? e) above */
            {
                if (b == sc->F)
                    return(make_boolean(sc, is_slot(global_slot(sym)))); /* new_symbol and gensym initialize global_slot to #<undefined> */
                return(sc->F);
            }

            x = symbol_to_local_slot(sc, sym, e);
            if (is_slot(x))
                return(sc->T);

            if (b == sc->T)
                return(sc->F);
            return(make_boolean(sc, is_slot(global_slot(sym))));
        }
        if (is_global(sym))
            return(sc->T);
        return(make_boolean(sc, is_slot(symbol_to_slot(sc, sym))));
    }

// Assembly:
movq %rsi, %rax
movq 0x8(%rsi), %rsi
cmpb $0xa, (%rsi)
jne 0x66849
movq 0x10(%rax), %rdx
cmpb $0x1, (%rdx)
jne 0x66864
movq 0x8(%rdx), %rcx
cmpb $0x1c, (%rcx)
jne 0x668e4
cmpq 0x2150(%rdi), %rcx
je 0x66909
movq 0x10(%rdx), %rdx
cmpb $0x1, (%rdx)
jne 0x66923
movq 0x8(%rdx), %r9
cmpb $0x7, (%r9)
je 0x6692a
movq 0x1050(%rdi), %rdx
movq 0xf6dd8(%rip), %r8      # 0x15d610
movq %r9, %rsi
movq %rax, %rcx
movl $0x3, %r9d
jmp 0xf3da
movq 0x1050(%rdi), %rdx
movq %rax, %rcx
movl $0xa, %r8d
movl $0x1, %r9d
jmp 0xf1ae
testb $0x1, 0x2(%rsi)
jne 0x6696b
movq 0x8(%rdi), %rcx
movq 0x18(%rcx), %r8
movq 0x20(%rsi), %rdx
movl $0x18, %eax
cmpq %rdx, %r8
je 0x668cf
jle 0x66893
movq 0x10(%rcx), %rcx
movq 0x18(%rcx), %r8
cmpq %r8, %rdx
jl 0x66886
cmpq %rdx, %r8
je 0x668cf
movl $0x10, %eax
cmpb $0x1c, (%rcx)
jne 0x668cf
movq 0x8(%rcx), %rdx
testq %rdx, %rdx
sete %r9b
je 0x668bb
cmpq %rsi, 0x8(%rdx)
je 0x668be
movq 0x18(%rdx), %rdx
jmp 0x668a6
movq %r8, %rdx
testb %r9b, %r9b
je 0x668d3
movq 0x10(%rcx), %rcx
cmpb $0x1c, (%rcx)
movq %rdx, %r8
je 0x668a2
movq (%rsi,%rax), %rdx
xorl %eax, %eax
cmpb $0x20, (%rdx)
setne %al
movq 0x118(%rdi,%rax,8), %rax
retq
movq 0x1050(%rdi), %rax
movq 0x8(%rax), %rsi
movq 0xe806a(%rip), %rdx     # 0x14e960
movq 0x140(%rdi), %r8
movq 0xec054(%rip), %r9      # 0x152958
jmp 0xb31d
movq 0x8(%rsi), %rax
movq 0x20(%rax), %rax
xorl %ecx, %ecx
cmpb $0x0, 0x11(%rax)
sete %cl
movq 0x118(%rdi,%rcx,8), %rax
retq
movq 0x120(%rdi), %r9
cmpq 0x150(%rdi), %rcx
je 0x66952
cmpq $0x0, 0x20(%rsi)
je 0x66977
movq 0x8(%rcx), %rax
testq %rax, %rax
sete %cl
je 0x66977
cmpq %rsi, 0x8(%rax)
je 0x66973
movq 0x18(%rax), %rax
jmp 0x6693e
movq 0x120(%rdi), %rax
cmpq %rax, %r9
jne 0x668e3
movq 0x10(%rsi), %rcx
cmpb $0x20, (%rcx)
jne 0x668e3
movq 0x118(%rdi), %rax
retq
testb %cl, %cl
je 0x6697e
movq 0x128(%rdi), %rax
cmpb $0x20, (%rax)
movq 0x118(%rdi), %rax
je 0x668e3
cmpq %rax, %r9
je 0x669a0
movq 0x10(%rsi), %rcx
cmpb $0x20, (%rcx)
je 0x668e3
movq 0x120(%rdi), %rax
retq