// File: /workspace/github_c_makefile_star2_O3/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 $0x18, %rsp
movq %rsi, %r15
movq %rdi, %rbx
movq 0x10(%rsi), %rcx
movq 0x8(%rcx), %r14
cmpb $0x1, (%r14)
movq 0x110(%rdi), %rax
je 0x75dae
cmpq %rax, %r14
movq %r14, %rax
je 0x75dae
movq 0x1330(%rbx), %rdx
movq 0xdf843(%rip), %r8      # 0x1555e0
movq %rbx, %rdi
movq %r14, %rsi
movq %r15, %rcx
movl $0x2, %r9d
jmp 0x75ddf
movq 0x10(%rcx), %rcx
cmpq %rax, %rcx
je 0x75df2
movq 0x8(%rcx), %r12
cmpb $0x24, (%r12)
ja 0x75e31
movq 0x1330(%rbx), %rdx
movq 0xdf830(%rip), %r8      # 0x155600
movq %rbx, %rdi
movq %r12, %rsi
movq %r15, %rcx
movl $0x3, %r9d
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xe659
cmpq %rax, %r14
je 0x76375
movq 0x8(%r15), %r12
movzbl (%r12), %eax
leaq 0xdd295(%rip), %rcx     # 0x1530a0
cmpb $0x1, (%rax,%rcx)
jne 0x75f97
movq %rbx, %rdi
movq %r12, %rsi
movq %r14, %rdx
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x39ea6
movl $0x2, %edx
movq %rbx, %rdi
movq %r12, %rsi
callq 0x3f86f
testb %al, %al
je 0x75f5e
movq 0x110(%rbx), %rbp
cmpq %rbp, %r14
je 0x76375
movq (%r12), %rax
btl $0x15, %eax
setae %cl
cmpb $0x30, %al
setb %dl
orb %cl, %dl
jne 0x76060
movq 0x10(%r12), %rax
leaq 0x9a56(%rip), %rcx      # 0x7f8d3
cmpq %rcx, %rax
je 0x76430
leaq 0x9a70(%rip), %rcx      # 0x7f8fd
cmpq %rcx, %rax
je 0x7643c
leaq -0x8f70(%rip), %rcx     # 0x6cf2d
cmpq %rcx, %rax
leaq 0x3c823(%rip), %rcx     # 0xb26ca
cmovneq %rax, %rcx
leaq -0x8915(%rip), %rax     # 0x6d59d
cmpq %rax, %rcx
leaq 0x3c468(%rip), %r12     # 0xb2324
cmovneq %rcx, %r12
movq 0x8(%r15), %rax
movq 0x570(%rbx), %rcx
movq %rax, 0x8(%rcx)
cmpb $0x1, (%r14)
jne 0x76375
movq %r14, %r13
movq 0x8(%r14), %rax
movq 0x578(%rbx), %rcx
movq %rax, 0x8(%rcx)
movq 0x570(%rbx), %rsi
movq %rbx, %rdi
callq *%r12
movq 0x120(%rbx), %r15
cmpq %r15, %rax
jne 0x76582
movq 0x10(%r14), %r14
cmpb $0x1, (%r14)
jne 0x7637c
cmpq %r13, %r14
je 0x7637c
movq 0x8(%r14), %rax
movq 0x578(%rbx), %rcx
movq %rax, 0x8(%rcx)
movq 0x570(%rbx), %rsi
movq %rbx, %rdi
callq *%r12
movq 0x120(%rbx), %r15
cmpq %r15, %rax
jne 0x76582
movq 0x10(%r14), %r14
movq 0x10(%r13), %r13
cmpb $0x1, (%r14)
je 0x75edc
jmp 0x7637c
movq 0x1330(%rbx), %rax
movq 0x8(%rax), %rsi
movq 0xd09f8(%rip), %rdx     # 0x146968
movq 0x140(%rbx), %r8
movq 0xdf66a(%rip), %r9      # 0x1555e8
movq %rbx, %rdi
movq %r12, %rcx
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xa4e4
leaq 0xd49d2(%rip), %rcx     # 0x14a970
cmpb $0x1, (%rax,%rcx)
jne 0x75fc0
movq %rbx, %rdi
movq %r12, %rsi
movq %r14, %rdx
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xfdf10
cmpl $0x13, %eax
jne 0x762ca
movq %r14, %r13
movq 0x8(%r14), %rax
cmpq %r12, %rax
je 0x76582
cmpb $0x13, (%rax)
jne 0x75fff
movq 0x8(%r12), %rdx
cmpq 0x8(%rax), %rdx
jne 0x75fff
movq 0x10(%r12), %rdi
movq 0x10(%rax), %rsi
callq 0x8c146
testb %al, %al
jne 0x76582
movq 0x10(%r14), %r15
cmpb $0x1, (%r15)
jne 0x76375
movq 0x8(%r15), %rax
cmpq %r12, %rax
je 0x7637c
cmpb $0x13, (%rax)
jne 0x76040
movq 0x8(%r12), %rdx
cmpq 0x8(%rax), %rdx
jne 0x76040
movq 0x10(%r12), %rdi
movq 0x10(%rax), %rsi
callq 0x8c146
testb %al, %al
jne 0x7637c
movq 0x10(%r15), %r14
cmpb $0x1, (%r14)
jne 0x76375
movq 0x10(%r13), %r13
cmpq %r13, %r14
jne 0x75fcc
jmp 0x76375
cmpb $0x28, %al
jne 0x761c4
movq 0x8(%r12), %rax
cmpb $0x1, (%rax)
jne 0x761c4
movq 0x10(%rax), %rcx
cmpb $0x1, (%rcx)
jne 0x761c4
movq 0x10(%r12), %r13
testb $0x8, 0x3(%r13)
jne 0x761c4
cmpq %rbp, 0x10(%r13)
jne 0x761c4
movq 0x8(%rax), %rbp
movq 0x8(%r15), %rsi
movq 0x8(%rcx), %rdi
movq 0x90(%rbx), %rax
movq 0x120(%rbx), %r8
cmpq 0x98(%rbx), %rax
ja 0x760eb
movq %rdi, (%rsp)
movq %rbx, %rdi
movq %r8, 0x10(%rsp)
movq %rsi, 0x8(%rsp)
callq 0xa550
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %r8
movq (%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 0xfdea3
leaq 0x87d3b(%rip), %rcx     # 0xfdeea
cmpq %rcx, %rax
je 0x76455
orb $0x8, 0x3(%r13)
movq 0x110(%rbx), %rbp
movq 0x90(%rbx), %rax
cmpq 0x98(%rbx), %rax
ja 0x761e3
movq %rbx, %rdi
callq 0xa550
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 0x76243
movq %rbx, %rdi
callq 0xa550
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 0x7638e
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 0x7640b
leaq 0xdca4f(%rip), %r13     # 0x152d20
movq %r14, %rbp
movq 0x8(%r14), %rdx
movzbl (%r12), %eax
movq %rbx, %rdi
movq %r12, %rsi
xorl %ecx, %ecx
callq *(%r13,%rax,8)
testb %al, %al
jne 0x76582
movq 0x10(%r14), %r15
cmpb $0x1, (%r15)
jne 0x76375
movq 0x8(%r15), %rdx
movzbl (%r12), %eax
movq %rbx, %rdi
movq %r12, %rsi
xorl %ecx, %ecx
callq *(%r13,%rax,8)
testb %al, %al
jne 0x7637c
movq 0x10(%r15), %r15
cmpb $0x1, (%r15)
jne 0x76375
movq 0x8(%r15), %rdx
movzbl (%r12), %eax
movq %rbx, %rdi
movq %r12, %rsi
xorl %ecx, %ecx
callq *(%r13,%rax,8)
testb %al, %al
jne 0x7637c
movq 0x10(%r15), %r15
cmpb $0x1, (%r15)
jne 0x76375
movq 0x8(%r15), %rdx
movzbl (%r12), %eax
movq %rbx, %rdi
movq %r12, %rsi
xorl %ecx, %ecx
callq *(%r13,%rax,8)
testb %al, %al
jne 0x7637c
movq 0x10(%r15), %r14
cmpb $0x1, (%r14)
jne 0x76375
movq 0x10(%rbp), %rbp
cmpq %rbp, %r14
jne 0x762d4
movq 0x120(%rbx), %r15
movq %r15, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
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 0x763cb
movq %rbx, %rdi
callq 0xa550
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), %r15
jmp 0x7637c
movq 0x8(%r15), %rsi
movq %rbx, %rdi
jmp 0x75e1b
movq %rbx, %rdi
movq %r15, %rsi
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x75bfc
movq 0x2260(%rbx), %rcx
movq 0x8(%rbx), %rax
movq 0x8(%rax), %rax
movq 0x18(%rax), %r13
leaq 0x33c3c(%rip), %rax     # 0xaa0ab
movq %rcx, (%rsp)
cmpq %rax, (%rcx)
je 0x764ef
cmpb $0x1, (%r14)
jne 0x76375
movq %r14, %rbp
movq 0x8(%r14), %rax
movq %rax, 0x10(%r13)
movl $0x0, 0x2258(%rbx)
movq (%rsp), %rdi
callq *(%rdi)
testb %al, %al
jne 0x76582
movq 0x10(%r14), %r15
cmpb $0x1, (%r15)
jne 0x76375
cmpq %rbp, %r15
je 0x76375
movq 0x8(%r15), %rax
movq %rax, 0x10(%r13)
movl $0x0, 0x2258(%rbx)
movq (%rsp), %rdi
callq *(%rdi)
testb %al, %al
jne 0x7637c
movq 0x10(%r15), %r14
movq 0x10(%rbp), %rbp
cmpb $0x1, (%r14)
je 0x76485
jmp 0x76375
cmpb $0x1, (%r14)
jne 0x76375
movq (%rsp), %rax
movq 0x38(%rax), %r15
movq %r14, %rbp
movq 0x8(%r14), %rax
movq %r13, %r12
movq %rax, 0x10(%r13)
movl $0x0, 0x2258(%rbx)
movq (%rsp), %rdi
movq %r15, %r13
callq *%r15
movq 0x120(%rbx), %r15
cmpq %r15, %rax
jne 0x76582
movq 0x10(%r14), %r14
cmpb $0x1, (%r14)
jne 0x7637c
cmpq %rbp, %r14
je 0x7637c
movq 0x8(%r14), %rax
movq %rax, 0x10(%r12)
movl $0x0, 0x2258(%rbx)
movq (%rsp), %rdi
movq %r13, %r15
callq *%r13
cmpq 0x120(%rbx), %rax
jne 0x76582
movq 0x10(%r14), %r14
movq 0x10(%rbp), %rbp
cmpb $0x1, (%r14)
movq %r12, %r13
je 0x76504
jmp 0x76375
movq %r14, %r15
jmp 0x7637c