// File: /workspace/github_c_makefile_star2_O1/BernardTatin[P]s7sh/s7.c
// Function: g_member
static s7_pointer g_member(s7_scheme *sc, s7_pointer args)
                {
#define H_member "(member obj list (func #f)) looks for obj in list and returns the list from that point if it is found, otherwise #f. \
                    member uses equal?  If 'func' is a function of 2 arguments, it is used for the comparison instead of 'equal?"
#define Q_member s7_make_signature(sc, 4, s7_make_signature(sc, 2, sc->is_pair_symbol, sc->not_symbol), sc->T, sc->is_list_symbol, sc->is_procedure_symbol)

                    /* this could be extended to accept sequences:
                     *    (member #\a "123123abnfc" char=?) -> "abnfc"
                     *    (member "abc" "123abc321" string=?) -> "abc321" but there's the string length complication
                     *    (member 1 #(0 1 2) =) -> #(1 2) etc but what would it do for a hash-table?
                     * the third arg can be weird: (member #f (list #t) cons) -> (#t) -- cons returns '(#f . #t) which is true, so we get '(#t)
                     * should this be an error: (member '(1 2 3) () '(1 . 2)) -- the third arg is bogus, but the second is nil
                     *
                     * here as in assoc, sort, and make-hash-table we accept macros, but I can't think of a good reason to do so.
                     */

                    s7_pointer x, obj, eq_func = NULL;
                    x = cadr(args);

                    if ((!is_pair(x)) && (!is_null(x)))
                        return(method_or_bust_with_type(sc, x, sc->member_symbol, args, a_list_string, 2));

                    if (is_not_null(cddr(args)))
                    {
                        /* check third arg before second (trailing arg error check) */
                        eq_func = caddr(args);

                        if (type(eq_func) < T_CONTINUATION)
                            return(method_or_bust_with_type(sc, eq_func, sc->member_symbol, args, a_procedure_string, 3));

                        if (!s7_is_aritable(sc, eq_func, 2))
                            return(wrong_type_argument_with_type(sc, sc->member_symbol, 3, eq_func, an_eq_func_string));
                    }

                    if (is_null(x)) return(sc->F);
                    if (eq_func)
                    {
                        s7_pointer y, slow;

                        if ((is_safe_procedure(eq_func)) &&
                                (is_c_function(eq_func)))
                        {
                            s7_function func;
                            func = c_function_call(eq_func);
                            if (func == g_is_eq) return(s7_memq(sc, car(args), x));
                            if (func == g_is_eqv) return(g_memv(sc, args));
#if (!WITH_GMP)
                            if (func == g_less) func = g_less_2;
                            if (func == g_greater) func = g_greater_2;
#endif
                            set_car(sc->t2_1, car(args));

                            for (slow = x; is_pair(x); x = cdr(x), slow = cdr(slow))
                            {
                                set_car(sc->t2_2, car(x));
                                if (is_true(sc, func(sc, sc->t2_1)))
                                    return(x);

                                if (!is_pair(cdr(x)))
                                    return(sc->F);
                                x = cdr(x);
                                if (x == slow)
                                    return(sc->F);

                                set_car(sc->t2_2, car(x));
                                if (is_true(sc, func(sc, sc->t2_1)))
                                    return(x);
                            }
                            return(sc->F);
                        }

                        if ((is_closure(eq_func)) &&
                                (is_pair(closure_args(eq_func))) &&
                                (is_pair(cdr(closure_args(eq_func))))) /* not dotted arg list */
                        {
                            s7_pointer body;
                            body = closure_body(eq_func);
                            if ((!no_bool_opt(body)) &&
                                    (is_null(cdr(body))))
                            {
                                s7_function func;
                                new_frame_with_two_slots(sc, sc->envir, sc->envir, car(closure_args(eq_func)), car(args), cadr(closure_args(eq_func)), sc->F);
                                func = s7_bool_optimize(sc, body);
                                if (func == opt_bool_any)
                                {
                                    opt_info *o;
                                    s7_pointer b;
                                    o = sc->opts[0];
                                    b = next_slot(let_slots(sc->envir));
                                    if (o->v[0].fb == p_to_b)
                                    {
                                        s7_pointer (*fp)(opt_info *o);
                                        fp = o->v[7].fp;
                                        for (slow = x; is_pair(x); x = cdr(x), slow = cdr(slow))
                                        {
                                            slot_set_value(b, car(x));
                                            sc->pc = 0;
                                            if (fp(o) != sc->F) return(x);
                                            if (!is_pair(cdr(x))) return(sc->F);
                                            x = cdr(x);
                                            if (x == slow) return(sc->F);
                                            slot_set_value(b, car(x));
                                            sc->pc = 0;
                                            if (fp(o) != sc->F) return(x);
                                        }
                                    }
                                    else
                                    {
                                        for (slow = x; is_pair(x); x = cdr(x), slow = cdr(slow))
                                        {
                                            slot_set_value(b, car(x));
                                            sc->pc = 0;
                                            if (o->v[0].fb(o)) return(x);
                                            if (!is_pair(cdr(x))) return(sc->F);
                                            x = cdr(x);
                                            if (x == slow) return(sc->F);
                                            slot_set_value(b, car(x));
                                            sc->pc = 0;
                                            if (o->v[0].fb(o)) return(x);
                                        }
                                    }
                                    return(sc->F);
                                }
                                else set_no_bool_opt(body);
                            }
                        }

                        y = cons(sc, args, sc->nil); /* this could probably be handled with a counter cell (cdr here is unused) */
                        set_opt1_fast(y, x);
                        set_opt2_slow(y, x);
                        push_stack(sc, OP_MEMBER_IF, cons(sc, y, sc->nil), eq_func);
                        if (needs_copied_args(eq_func))
                            push_stack(sc, OP_APPLY, list_2(sc, car(args), car(x)), eq_func);
                        else
                        {
                            set_car(sc->t2_1, car(args));
                            set_car(sc->t2_2, car(x));
                            push_stack(sc, OP_APPLY, sc->t2_1, eq_func);
                        }
                        return(sc->unspecified);
                    }

                    obj = car(args);
                    if (is_simple(obj))
                        return(s7_memq(sc, obj, x));

                    /* the only things that aren't simply == here are c_object, string, number, vector, hash-table, pair, and c_pointer
                     *   but all the other cases are unlikely.
                     */
                    if (s7_is_number(obj))
                        return(memv_number(sc, obj, x));

                    return(member(sc, obj, x));
                }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rsi, %r15
movq %rdi, %rbx
movq 0x10(%rsi), %rax
movq 0x8(%rax), %r14
cmpb $0x1, (%r14)
je 0x7b995
cmpq 0x110(%rbx), %r14
je 0x7b995
movq 0x1330(%rbx), %rdx
movq 0xe1c5c(%rip), %r8      # 0x15d5e0
movq %rbx, %rdi
movq %r14, %rsi
movq %r15, %rcx
movl $0x2, %r9d
jmp 0x7b9ca
movq 0x10(%rax), %rax
cmpq 0x110(%rbx), %rax
je 0x7b9dd
movq 0x8(%rax), %r12
cmpb $0x24, (%r12)
ja 0x7b9e2
movq 0x1330(%rbx), %rdx
movq 0xe1c45(%rip), %r8      # 0x15d600
movq %rbx, %rdi
movq %r12, %rsi
movq %r15, %rcx
movl $0x3, %r9d
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xf3da
xorl %r12d, %r12d
jmp 0x7b9fa
movl $0x2, %edx
movq %rbx, %rdi
movq %r12, %rsi
callq 0x41fac
testb %al, %al
je 0x7bb14
movq 0x110(%rbx), %rax
cmpq %rax, %r14
je 0x7c016
testq %r12, %r12
je 0x7bdc6
testb $0x20, 0x2(%r12)
je 0x7bb4d
cmpb $0x30, (%r12)
jb 0x7bb4d
movq 0x10(%r12), %rax
leaq 0xa209(%rip), %rcx      # 0x85c3f
cmpq %rcx, %rax
je 0x7bf53
leaq 0xa223(%rip), %rcx      # 0x85c69
cmpq %rcx, %rax
je 0x7c02f
leaq -0x93ed(%rip), %rcx     # 0x72669
cmpq %rcx, %rax
leaq 0x3ded7(%rip), %rcx     # 0xb9937
cmovneq %rax, %rcx
leaq -0x8d60(%rip), %rax     # 0x72d0b
cmpq %rax, %rcx
leaq 0x3dade(%rip), %r12     # 0xb9553
cmovneq %rcx, %r12
movq 0x8(%r15), %rax
movq 0x570(%rbx), %rcx
movq %rax, 0x8(%rcx)
cmpb $0x1, (%r14)
jne 0x7c016
movq %r14, %r15
movq 0x8(%r14), %rax
movq 0x578(%rbx), %rcx
movq %rax, 0x8(%rcx)
movq 0x570(%rbx), %rsi
movq %rbx, %rdi
callq *%r12
movq 0x120(%rbx), %r13
cmpq %r13, %rax
jne 0x7c048
movq 0x10(%r14), %r14
cmpb $0x1, (%r14)
jne 0x7c01d
cmpq %r15, %r14
je 0x7c01d
movq 0x8(%r14), %rax
movq 0x578(%rbx), %rcx
movq %rax, 0x8(%rcx)
movq 0x570(%rbx), %rsi
movq %rbx, %rdi
callq *%r12
cmpq 0x120(%rbx), %rax
jne 0x7c048
movq 0x10(%r14), %r14
movq 0x10(%r15), %r15
cmpb $0x1, (%r14)
je 0x7ba95
jmp 0x7c016
movq 0x1330(%rbx), %rax
movq 0x8(%rax), %rsi
movq 0xd2e42(%rip), %rdx     # 0x14e968
movq 0x140(%rbx), %r8
movq 0xe1ab4(%rip), %r9      # 0x15d5e8
movq %rbx, %rdi
movq %r12, %rcx
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xb31d
cmpb $0x28, (%r12)
jne 0x7bcbd
movq 0x8(%r12), %rcx
cmpb $0x1, (%rcx)
jne 0x7bcbd
movq 0x10(%rcx), %rdx
cmpb $0x1, (%rdx)
jne 0x7bcbd
movq 0x10(%r12), %r13
movb $0x1, %sil
testb $0x8, 0x3(%r13)
jne 0x7bcb4
cmpq %rax, 0x10(%r13)
jne 0x7bcb4
movq 0x8(%rcx), %rbp
movq 0x8(%r15), %rsi
movq 0x8(%rdx), %rdi
movq 0x90(%rbx), %rax
movq 0x120(%rbx), %r8
cmpq 0x98(%rbx), %rax
ja 0x7bbd7
movq %rdi, 0x10(%rsp)
movq %rbx, %rdi
movq %r8, 0x8(%rsp)
movq %rsi, (%rsp)
callq 0xb389
movq (%rsp), %rsi
movq 0x8(%rsp), %r8
movq 0x10(%rsp), %rdi
movq 0x90(%rbx), %rax
leaq -0x8(%rax), %rcx
movq %rcx, 0x90(%rbx)
movq -0x8(%rax), %rax
movq $0x20001c, (%rax)       # imm = 0x20001C
movq 0x250(%rbx), %rcx
incq %rcx
movq %rcx, 0x250(%rbx)
movq %rcx, 0x18(%rax)
movq 0x8(%rbx), %rcx
movq %rcx, 0x10(%rax)
movq %rax, 0x8(%rbx)
movq 0x90(%rbx), %rcx
leaq -0x8(%rcx), %rdx
movq %rdx, 0x90(%rbx)
movq -0x8(%rcx), %rcx
movl $0x20, %edx
movq %rdx, (%rcx)
movq %rbp, 0x8(%rcx)
movq %rsi, 0x10(%rcx)
movq %rcx, 0x18(%rbp)
movq 0x250(%rbx), %rsi
movq %rsi, 0x20(%rbp)
incl 0x28(%rbp)
movq %rcx, 0x8(%rax)
movq 0x90(%rbx), %rax
leaq -0x8(%rax), %rsi
movq %rsi, 0x90(%rbx)
movq -0x8(%rax), %rax
movq %rdx, (%rax)
movq %rdi, 0x8(%rax)
movq %r8, 0x10(%rax)
movq %rax, 0x18(%rdi)
movq 0x250(%rbx), %rdx
movq %rdx, 0x20(%rdi)
incl 0x28(%rdi)
movq $0x0, 0x18(%rax)
movq %rax, 0x18(%rcx)
movq %rbx, %rdi
movq %r13, %rsi
callq 0x1070ea
leaq 0x8b48f(%rip), %rcx     # 0x107131
cmpq %rcx, %rax
setne %sil
je 0x7c04d
orb $0x8, 0x3(%r13)
testb %sil, %sil
je 0x7c01d
movq 0x90(%rbx), %rax
movq 0x110(%rbx), %rbp
cmpq 0x98(%rbx), %rax
ja 0x7bcdc
movq %rbx, %rdi
callq 0xb389
movq 0x90(%rbx), %rax
leaq -0x8(%rax), %rcx
movq %rcx, 0x90(%rbx)
movq -0x8(%rax), %r13
movq $0x200001, (%r13)       # imm = 0x200001
movq %r15, 0x8(%r13)
movq %rbp, 0x10(%r13)
movq %r14, 0x18(%r13)
movq %r14, 0x20(%r13)
movq 0x50(%rbx), %rax
movq %r12, (%rax)
movq 0x8(%rbx), %rax
movq 0x50(%rbx), %rcx
movq %rax, 0x8(%rcx)
movq 0x90(%rbx), %rax
movq 0x110(%rbx), %rbp
cmpq 0x98(%rbx), %rax
ja 0x7bd3c
movq %rbx, %rdi
callq 0xb389
movq 0x90(%rbx), %rax
leaq -0x8(%rax), %rcx
movq %rcx, 0x90(%rbx)
movq -0x8(%rax), %rax
movq $0x200001, (%rax)       # imm = 0x200001
movq %r13, 0x8(%rax)
movq %rbp, 0x10(%rax)
movq 0x50(%rbx), %rcx
movq %rax, 0x10(%rcx)
movq 0x50(%rbx), %rax
movq $0x210, 0x18(%rax)      # imm = 0x210
movq 0x50(%rbx), %rax
addq $0x20, %rax
movq %rax, 0x50(%rbx)
testb $0x10, 0x3(%r12)
jne 0x7bdea
movq 0x8(%r15), %rax
movq 0x570(%rbx), %rcx
movq %rax, 0x8(%rcx)
movq 0x8(%r14), %rax
movq 0x578(%rbx), %rcx
movq %rax, 0x8(%rcx)
movq 0x50(%rbx), %rax
movq %r12, (%rax)
movq 0x8(%rbx), %rax
movq 0x50(%rbx), %rcx
movq %rax, 0x8(%rcx)
movq 0x570(%rbx), %rax
jmp 0x7be67
movq 0x8(%r15), %r15
movzbl (%r15), %eax
leaq 0xdf2cb(%rip), %rcx     # 0x15b0a0
cmpb $0x1, (%rax,%rcx)
jne 0x7be8c
movq %rbx, %rdi
movq %r15, %rsi
jmp 0x7bf5a
movq %r12, (%rax)
movq 0x8(%rbx), %rax
movq 0x50(%rbx), %rcx
movq %rax, 0x8(%rcx)
movq 0x8(%r15), %r15
movq 0x8(%r14), %r14
movq 0x90(%rbx), %rax
movq 0x110(%rbx), %r12
cmpq 0x98(%rbx), %rax
ja 0x7be20
movq %rbx, %rdi
callq 0xb389
movq 0x90(%rbx), %rax
leaq -0x8(%rax), %rcx
movq %rcx, 0x90(%rbx)
movq -0x8(%rax), %rcx
movl $0x200001, %edx         # imm = 0x200001
movq %rdx, (%rcx)
movq %r14, 0x8(%rcx)
movq %r12, 0x10(%rcx)
movq 0x90(%rbx), %rax
leaq -0x8(%rax), %rsi
movq %rsi, 0x90(%rbx)
movq -0x8(%rax), %rax
movq %rdx, (%rax)
movq %r15, 0x8(%rax)
movq %rcx, 0x10(%rax)
movq 0x50(%rbx), %rcx
movq %rax, 0x10(%rcx)
movq 0x50(%rbx), %rax
movq $0x198, 0x18(%rax)      # imm = 0x198
addq $0x20, 0x50(%rbx)
movq 0x130(%rbx), %r13
jmp 0x7c01d
leaq 0xd6add(%rip), %rcx     # 0x152970
cmpb $0x1, (%rax,%rcx)
jne 0x7beb5
movq %rbx, %rdi
movq %r15, %rsi
movq %r14, %rdx
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x107157
cmpl $0x13, %eax
jne 0x7bf70
movq %r14, %r12
movq 0x8(%r14), %rax
cmpq %r15, %rax
je 0x7c048
cmpb $0x13, (%rax)
jne 0x7bef2
movq 0x8(%r15), %rdx
cmpq 0x8(%rax), %rdx
jne 0x7bef2
movq 0x10(%r15), %rdi
movq 0x10(%rax), %rsi
callq 0x9253a
testb %al, %al
jne 0x7c048
movq 0x10(%r14), %r13
cmpb $0x1, (%r13)
jne 0x7c016
movq 0x8(%r13), %rax
cmpq %r15, %rax
je 0x7c01d
cmpb $0x13, (%rax)
jne 0x7bf32
movq 0x8(%r15), %rdx
cmpq 0x8(%rax), %rdx
jne 0x7bf32
movq 0x10(%r15), %rdi
movq 0x10(%rax), %rsi
callq 0x9253a
testb %al, %al
jne 0x7c01d
movq 0x10(%r13), %r14
cmpb $0x1, (%r14)
jne 0x7c016
movq 0x10(%r12), %r12
cmpq %r12, %r14
jne 0x7bec1
jmp 0x7c016
movq 0x8(%r15), %rsi
movq %rbx, %rdi
movq %r14, %rdx
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x3c432
leaq 0xdeda9(%rip), %r12     # 0x15ad20
movq %r14, %rbp
movq 0x8(%r14), %rdx
movzbl (%r15), %eax
movq %rbx, %rdi
movq %r15, %rsi
xorl %ecx, %ecx
callq *(%r12,%rax,8)
testb %al, %al
jne 0x7c048
movq 0x10(%r14), %r13
cmpb $0x1, (%r13)
jne 0x7c016
movq 0x8(%r13), %rdx
movzbl (%r15), %eax
movq %rbx, %rdi
movq %r15, %rsi
xorl %ecx, %ecx
callq *(%r12,%rax,8)
testb %al, %al
jne 0x7c01d
movq 0x10(%r13), %r13
cmpb $0x1, (%r13)
jne 0x7c016
movq 0x8(%r13), %rdx
movzbl (%r15), %eax
movq %rbx, %rdi
movq %r15, %rsi
xorl %ecx, %ecx
callq *(%r12,%rax,8)
testb %al, %al
jne 0x7c01d
movq 0x10(%r13), %r13
cmpb $0x1, (%r13)
jne 0x7c016
movq 0x8(%r13), %rdx
movzbl (%r15), %eax
movq %rbx, %rdi
movq %r15, %rsi
xorl %ecx, %ecx
callq *(%r12,%rax,8)
testb %al, %al
jne 0x7c01d
movq 0x10(%r13), %r14
cmpb $0x1, (%r14)
jne 0x7c016
movq 0x10(%rbp), %rbp
cmpq %rbp, %r14
jne 0x7bf7a
movq 0x120(%rbx), %r13
movq %r13, %rax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rbx, %rdi
movq %r15, %rsi
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x7b7e9
movq %r14, %r13
jmp 0x7c01d
movq 0x2260(%rbx), %rcx
movq 0x8(%rbx), %rax
movq 0x8(%rax), %rax
movq 0x18(%rax), %rax
movq %rax, 0x8(%rsp)
leaq 0x34f3e(%rip), %rax     # 0xb0faa
movq %rcx, 0x10(%rsp)
cmpq %rax, (%rcx)
movb %sil, (%rsp)
je 0x7c102
cmpb $0x1, (%r14)
jne 0x7c1f4
movq %r14, %rbp
movq 0x8(%r14), %rax
movq 0x8(%rsp), %rcx
movq %rax, 0x10(%rcx)
movl $0x0, 0x2258(%rbx)
movq 0x10(%rsp), %rdi
callq *(%rdi)
testb %al, %al
jne 0x7c1ec
movq 0x10(%r14), %r13
cmpb $0x1, (%r13)
jne 0x7c1f4
cmpq %rbp, %r13
je 0x7c1f1
movq 0x8(%r13), %rax
movq 0x8(%rsp), %rcx
movq %rax, 0x10(%rcx)
movl $0x0, 0x2258(%rbx)
movq 0x10(%rsp), %rdi
callq *(%rdi)
testb %al, %al
jne 0x7c204
movq 0x10(%r13), %r14
movq 0x10(%rbp), %rbp
cmpb $0x1, (%r14)
je 0x7c08b
jmp 0x7c1f4
cmpb $0x1, (%r14)
sete %bpl
jne 0x7c1e4
movq 0x10(%rsp), %rdi
movq 0x38(%rdi), %rdx
movq 0x8(%r14), %rax
movq 0x8(%rsp), %rcx
movq %rax, 0x10(%rcx)
movl $0x0, 0x2258(%rbx)
movq %rdx, 0x20(%rsp)
callq *%rdx
movq 0x120(%rbx), %rcx
cmpq %rcx, %rax
je 0x7c14b
movq %r14, %r13
jmp 0x7c1e4
movq %r14, 0x18(%rsp)
movq 0x10(%r14), %r13
cmpb $0x1, (%r13)
jne 0x7c20c
cmpq 0x18(%rsp), %r13
je 0x7c209
movq 0x8(%r13), %rax
movq 0x8(%rsp), %rcx
movq %rax, 0x10(%rcx)
movl $0x0, 0x2258(%rbx)
movq 0x10(%rsp), %rdi
callq *0x20(%rsp)
cmpq 0x120(%rbx), %rax
jne 0x7c211
movq 0x10(%r13), %r14
cmpb $0x1, (%r14)
sete %bpl
jne 0x7c1e4
movq 0x18(%rsp), %rax
movq 0x10(%rax), %rax
movq %rax, 0x18(%rsp)
movq 0x8(%r14), %rax
movq 0x8(%rsp), %rcx
movq %rax, 0x10(%rcx)
movl $0x0, 0x2258(%rbx)
movq 0x10(%rsp), %rdi
callq *0x20(%rsp)
movq 0x120(%rbx), %rcx
movq %r14, %r13
cmpq %rcx, %rax
je 0x7c150
jmp 0x7c1e4
testb $0x1, %bpl
je 0x7c1f4
jmp 0x7c1fb
movq %r14, %r13
jmp 0x7c1fb
movq %r13, %r14
movq 0x120(%rbx), %r13
movb (%rsp), %sil
jmp 0x7bcb4
movq %r13, %r14
jmp 0x7c1fb
movq %r13, %r14
movq %rcx, %r13
jmp 0x7c1e4
movq %r13, %r14
jmp 0x7c1e4