// File: /workspace/github_c_makefile_star2_O0/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:
subq $0x98, %rsp
movq %rdi, 0x88(%rsp)
movq %rsi, 0x80(%rsp)
movq 0x80(%rsp), %rax
movq 0x8(%rax), %rax
movq %rax, 0x78(%rsp)
movq 0x78(%rsp), %rax
movzbl (%rax), %eax
cmpl $0xa, %eax
je 0x6a1a7
movq 0x88(%rsp), %rdi
movq 0x78(%rsp), %rsi
movq 0x88(%rsp), %rax
movq 0x1050(%rax), %rdx
movq 0x80(%rsp), %rcx
movl $0xa, %r8d
movl $0x1, %r9d
callq 0x13c50
movq %rax, 0x90(%rsp)
jmp 0x6a5e8
movq 0x80(%rsp), %rax
movq 0x10(%rax), %rax
movzbl (%rax), %eax
cmpl $0x1, %eax
jne 0x6a56a
movq 0x80(%rsp), %rax
movq 0x10(%rax), %rax
movq 0x8(%rax), %rax
movq %rax, 0x70(%rsp)
movq 0x70(%rsp), %rax
movzbl (%rax), %eax
cmpl $0x1c, %eax
je 0x6a307
movq 0x88(%rsp), %rax
movq %rax, 0x30(%rsp)
movq 0x88(%rsp), %rax
movq 0x1050(%rax), %rax
movq 0x8(%rax), %rax
movq %rax, 0x38(%rsp)
movq $0x2, 0x58(%rsp)
movq 0x58(%rsp), %rax
andq $-0x800, %rax           # imm = 0xF800
cmpq $0x0, %rax
jne 0x6a23e
movq 0x58(%rsp), %rcx
leaq 0x1ac250(%rip), %rax    # 0x216480
movq (%rax,%rcx,8), %rax
movq %rax, 0x28(%rsp)
jmp 0x6a2c1
jmp 0x6a240
movq 0x88(%rsp), %rax
movq 0x90(%rax), %rax
movq 0x88(%rsp), %rcx
cmpq 0x98(%rcx), %rax
ja 0x6a26d
movq 0x88(%rsp), %rdi
callq 0xc670
movq 0x88(%rsp), %rcx
movq 0x90(%rcx), %rax
movq %rax, %rdx
addq $-0x8, %rdx
movq %rdx, 0x90(%rcx)
movq -0x8(%rax), %rax
movq %rax, 0x48(%rsp)
movq 0x48(%rsp), %rax
movq $0xb, (%rax)
movq 0x58(%rsp), %rcx
movq 0x48(%rsp), %rax
movq %rcx, 0x8(%rax)
movq 0x48(%rsp), %rax
movq %rax, 0x40(%rsp)
movq 0x40(%rsp), %rax
movq %rax, 0x28(%rsp)
movq 0x38(%rsp), %rsi
movq 0x30(%rsp), %rdi
movq 0x28(%rsp), %rax
movq %rax, 0x50(%rsp)
movq 0x50(%rsp), %rdx
movq 0x70(%rsp), %rcx
movq 0x88(%rsp), %rax
movq 0x140(%rax), %r8
movq 0x1b0193(%rip), %r9     # 0x21a488
callq 0xc560
movq %rax, 0x90(%rsp)
jmp 0x6a5e8
movq 0x70(%rsp), %rax
movq 0x88(%rsp), %rcx
cmpq 0x2150(%rcx), %rax
jne 0x6a37c
movq 0x78(%rsp), %rax
movq 0x8(%rax), %rax
movq 0x20(%rax), %rax
movq 0x10(%rax), %rax
sarq $0x8, %rax
andq $0xff, %rax
movzbl %al, %eax
cmpl $0x0, %eax
je 0x6a356
movq 0x88(%rsp), %rax
movq 0x118(%rax), %rax
movq %rax, 0x20(%rsp)
jmp 0x6a36a
movq 0x88(%rsp), %rax
movq 0x120(%rax), %rax
movq %rax, 0x20(%rsp)
movq 0x20(%rsp), %rax
movq %rax, 0x90(%rsp)
jmp 0x6a5e8
movq 0x80(%rsp), %rax
movq 0x10(%rax), %rax
movq 0x10(%rax), %rax
movzbl (%rax), %eax
cmpl $0x1, %eax
jne 0x6a400
movq 0x80(%rsp), %rax
movq 0x10(%rax), %rax
movq 0x10(%rax), %rax
movq 0x8(%rax), %rax
movq %rax, 0x68(%rsp)
movq 0x68(%rsp), %rdi
callq 0x9c50
testb $0x1, %al
jne 0x6a3fe
movq 0x88(%rsp), %rdi
movq 0x68(%rsp), %rsi
movq 0x88(%rsp), %rax
movq 0x1050(%rax), %rdx
movq 0x80(%rsp), %rcx
movq 0x1badda(%rip), %r8     # 0x2251c0
movl $0x3, %r9d
callq 0x14130
movq %rax, 0x90(%rsp)
jmp 0x6a5e8
jmp 0x6a414
movq 0x88(%rsp), %rax
movq 0x120(%rax), %rax
movq %rax, 0x68(%rsp)
movq 0x70(%rsp), %rax
movq 0x88(%rsp), %rcx
cmpq 0x150(%rcx), %rax
jne 0x6a4a9
movq 0x68(%rsp), %rax
movq 0x88(%rsp), %rcx
cmpq 0x120(%rcx), %rax
jne 0x6a48d
movq 0x78(%rsp), %rax
movq 0x10(%rax), %rax
movzbl (%rax), %eax
cmpl $0x20, %eax
jne 0x6a467
movq 0x88(%rsp), %rax
movq 0x118(%rax), %rax
movq %rax, 0x18(%rsp)
jmp 0x6a47b
movq 0x88(%rsp), %rax
movq 0x120(%rax), %rax
movq %rax, 0x18(%rsp)
movq 0x18(%rsp), %rax
movq %rax, 0x90(%rsp)
jmp 0x6a5e8
movq 0x88(%rsp), %rax
movq 0x120(%rax), %rax
movq %rax, 0x90(%rsp)
jmp 0x6a5e8
movq 0x88(%rsp), %rdi
movq 0x78(%rsp), %rsi
movq 0x70(%rsp), %rdx
callq 0x101d0
movq %rax, 0x60(%rsp)
movq 0x60(%rsp), %rax
movzbl (%rax), %eax
cmpl $0x20, %eax
jne 0x6a4ee
movq 0x88(%rsp), %rax
movq 0x118(%rax), %rax
movq %rax, 0x90(%rsp)
jmp 0x6a5e8
movq 0x68(%rsp), %rax
movq 0x88(%rsp), %rcx
cmpq 0x118(%rcx), %rax
jne 0x6a520
movq 0x88(%rsp), %rax
movq 0x120(%rax), %rax
movq %rax, 0x90(%rsp)
jmp 0x6a5e8
movq 0x78(%rsp), %rax
movq 0x10(%rax), %rax
movzbl (%rax), %eax
cmpl $0x20, %eax
jne 0x6a547
movq 0x88(%rsp), %rax
movq 0x118(%rax), %rax
movq %rax, 0x10(%rsp)
jmp 0x6a55b
movq 0x88(%rsp), %rax
movq 0x120(%rax), %rax
movq %rax, 0x10(%rsp)
movq 0x10(%rsp), %rax
movq %rax, 0x90(%rsp)
jmp 0x6a5e8
movq 0x78(%rsp), %rax
movq (%rax), %rax
andq $0x10000, %rax          # imm = 0x10000
cmpq $0x0, %rax
je 0x6a597
movq 0x88(%rsp), %rax
movq 0x118(%rax), %rax
movq %rax, 0x90(%rsp)
jmp 0x6a5e8
movq 0x88(%rsp), %rdi
movq 0x78(%rsp), %rsi
callq 0xfc80
movzbl (%rax), %eax
cmpl $0x20, %eax
jne 0x6a5c7
movq 0x88(%rsp), %rax
movq 0x118(%rax), %rax
movq %rax, 0x8(%rsp)
jmp 0x6a5db
movq 0x88(%rsp), %rax
movq 0x120(%rax), %rax
movq %rax, 0x8(%rsp)
movq 0x8(%rsp), %rax
movq %rax, 0x90(%rsp)
movq 0x90(%rsp), %rax
addq $0x98, %rsp
retq
nopl (%rax,%rax)