// File: /workspace/github_c_makefile_star2_O3/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 0x618a5
movq 0x10(%rax), %rdx
cmpb $0x1, (%rdx)
jne 0x618c0
movq 0x8(%rdx), %rcx
cmpb $0x1c, (%rcx)
jne 0x6190d
cmpq 0x2150(%rdi), %rcx
je 0x61932
movq 0x10(%rdx), %rdx
cmpb $0x1, (%rdx)
jne 0x6194c
movq 0x8(%rdx), %r9
cmpb $0x7, (%r9)
je 0x61953
movq 0x1050(%rdi), %rdx
movq 0xf3d7c(%rip), %r8      # 0x155610
movq %r9, %rsi
movq %rax, %rcx
movl $0x3, %r9d
jmp 0xe659
movq 0x1050(%rdi), %rdx
movq %rax, %rcx
movl $0xa, %r8d
movl $0x1, %r9d
jmp 0xe42d
testb $0x1, 0x2(%rsi)
jne 0x619f3
movq 0x8(%rdi), %rcx
movq 0x18(%rcx), %r8
movq 0x20(%rsi), %rdx
movl $0x18, %eax
cmpq %rdx, %r8
je 0x618f8
jle 0x618ef
movq 0x10(%rcx), %rcx
movq 0x18(%rcx), %r8
cmpq %r8, %rdx
jl 0x618e2
cmpq %rdx, %r8
jne 0x61978
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 0xe5041(%rip), %rdx     # 0x146960
movq 0x140(%rdi), %r8
movq 0xe902b(%rip), %r9      # 0x14a958
jmp 0xa4e4
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 0x619d6
cmpq $0x0, 0x20(%rsi)
je 0x619a5
movq 0x8(%rcx), %rax
testq %rax, %rax
je 0x619a5
cmpq %rsi, 0x8(%rax)
je 0x619ac
movq 0x18(%rax), %rax
jmp 0x61967
movl $0x10, %eax
cmpb $0x1c, (%rcx)
jne 0x618f8
movq 0x8(%rcx), %rdx
testq %rdx, %rdx
je 0x6199f
cmpq %rsi, 0x8(%rdx)
je 0x618fc
movq 0x18(%rdx), %rdx
jmp 0x6198a
movq 0x10(%rcx), %rcx
jmp 0x6197d
movq 0x128(%rdi), %rax
cmpb $0x20, (%rax)
movq 0x118(%rdi), %rax
je 0x6190c
cmpq %rax, %r9
je 0x619ce
movq 0x10(%rsi), %rcx
cmpb $0x20, (%rcx)
je 0x6190c
movq 0x120(%rdi), %rax
retq
movq 0x120(%rdi), %rax
cmpq %rax, %r9
jne 0x6190c
movq 0x10(%rsi), %rcx
cmpb $0x20, (%rcx)
jne 0x6190c
movq 0x118(%rdi), %rax
retq