// File: /workspace/github_c_makefile_star2_O2/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 0x5f52c
cmpq %rax, %r14
movq %r14, %rax
je 0x5f52c
movq 0x1330(%rbx), %rdx
movq 0xc50c0(%rip), %r8      # 0x1245e0
pushq $0x2
popq %r9
movq %rbx, %rdi
movq %r14, %rsi
jmp 0x5f558
movq 0x10(%rcx), %rcx
cmpq %rax, %rcx
je 0x5f56e
movq 0x8(%rcx), %r12
cmpb $0x24, (%r12)
ja 0x5f5ad
movq 0x1330(%rbx), %rdx
movq 0xc50b2(%rip), %r8      # 0x124600
pushq $0x3
popq %r9
movq %rbx, %rdi
movq %r12, %rsi
movq %r15, %rcx
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xcf9a
cmpq %rax, %r14
je 0x5fabd
movq 0x8(%r15), %r12
movzbl (%r12), %eax
leaq 0xc2b19(%rip), %rcx     # 0x1220a0
cmpb $0x1, (%rax,%rcx)
jne 0x5f70a
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 0x2dc6b
pushq $0x2
popq %rdx
movq %rbx, %rdi
movq %r12, %rsi
callq 0x32378
testb %al, %al
je 0x5f6d1
movq 0x110(%rbx), %rbp
cmpq %rbp, %r14
je 0x5fabd
movq (%r12), %rax
btl $0x15, %eax
setae %cl
cmpb $0x30, %al
setb %dl
orb %cl, %dl
jne 0x5f7ad
movq 0x10(%r12), %rax
leaq 0x71e8(%rip), %rcx      # 0x667df
cmpq %rcx, %rax
je 0x5fb78
leaq 0x7202(%rip), %rcx      # 0x66809
cmpq %rcx, %rax
je 0x5fb8c
leaq -0x78b6(%rip), %rcx     # 0x57d61
cmpq %rcx, %rax
leaq 0x2ebdf(%rip), %rcx     # 0x8e200
cmovneq %rax, %rcx
leaq -0x72ee(%rip), %rax     # 0x5833e
cmpq %rax, %rcx
leaq 0x2e97e(%rip), %r12     # 0x8dfb4
cmovneq %rcx, %r12
movq 0x8(%r15), %rax
movq 0x570(%rbx), %rcx
movq %rax, 0x8(%rcx)
movq %r14, %r13
cmpb $0x1, (%r13)
jne 0x5fabd
movq 0x8(%r13), %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 0x5fba5
movq 0x10(%r13), %r13
cmpb $0x1, (%r13)
jne 0x5fac4
cmpq %r14, %r13
je 0x5fac4
movq 0x8(%r13), %rax
movq 0x578(%rbx), %rcx
movq %rax, 0x8(%rcx)
movq 0x570(%rbx), %rsi
movq %rbx, %rdi
callq *%r12
cmpq 0x120(%rbx), %rax
jne 0x5fba5
movq 0x10(%r13), %r13
movq 0x10(%r14), %r14
jmp 0x5f64c
movq 0x1330(%rbx), %rax
movq 0x8(%rax), %rsi
movq 0xb6285(%rip), %rdx     # 0x115968
movq 0x140(%rbx), %r8
movq 0xc4ef7(%rip), %r9      # 0x1245e8
movq %rbx, %rdi
movq %r12, %rcx
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x9bbb
leaq 0xba25f(%rip), %rcx     # 0x119970
cmpb $0x1, (%rax,%rcx)
jne 0x5f733
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 0xcac73
cmpl $0x13, %eax
jne 0x5fa12
movq %r14, %r13
movq 0x8(%r14), %rsi
cmpq %r12, %rsi
je 0x5fb84
cmpb $0x13, (%rsi)
jne 0x5f761
movq %r12, %rdi
callq 0xc57a7
testb %al, %al
jne 0x5fb84
movq 0x10(%r14), %r15
cmpb $0x1, (%r15)
jne 0x5fabd
movq 0x8(%r15), %rsi
cmpq %r12, %rsi
je 0x5fac4
cmpb $0x13, (%rsi)
jne 0x5f791
movq %r12, %rdi
callq 0xc57a7
testb %al, %al
jne 0x5fac4
movq 0x10(%r15), %r14
cmpb $0x1, (%r14)
jne 0x5fabd
movq 0x10(%r13), %r13
cmpq %r13, %r14
jne 0x5f73f
jmp 0x5fabd
cmpb $0x28, %al
jne 0x5f90c
movq 0x8(%r12), %rax
cmpb $0x1, (%rax)
jne 0x5f90c
movq 0x10(%rax), %rcx
cmpb $0x1, (%rcx)
jne 0x5f90c
movq 0x10(%r12), %r13
testb $0x8, 0x3(%r13)
jne 0x5f90c
cmpq %rbp, 0x10(%r13)
jne 0x5f90c
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 0x5f838
movq %rdi, (%rsp)
movq %rbx, %rdi
movq %r8, 0x10(%rsp)
movq %rsi, 0x8(%rsp)
callq 0x9c27
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
pushq $0x20
popq %rdx
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)
andq $0x0, 0x18(%rax)
movq %rax, 0x18(%rcx)
movq %rbx, %rdi
movq %r13, %rsi
callq 0xcac0c
leaq 0x6b359(%rip), %rcx     # 0xcac50
cmpq %rcx, %rax
je 0x5fbad
orb $0x8, 0x3(%r13)
movq 0x110(%rbx), %rbp
movq 0x90(%rbx), %rax
cmpq 0x98(%rbx), %rax
ja 0x5f92b
movq %rbx, %rdi
callq 0x9c27
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 0x5f98b
movq %rbx, %rdi
callq 0x9c27
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 0x5fad6
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 0x5fb53
leaq 0xc2307(%rip), %r13     # 0x121d20
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 0x5fb84
movq 0x10(%r14), %r15
cmpb $0x1, (%r15)
jne 0x5fabd
movq 0x8(%r15), %rdx
movzbl (%r12), %eax
movq %rbx, %rdi
movq %r12, %rsi
xorl %ecx, %ecx
callq *(%r13,%rax,8)
testb %al, %al
jne 0x5fac4
movq 0x10(%r15), %r15
cmpb $0x1, (%r15)
jne 0x5fabd
movq 0x8(%r15), %rdx
movzbl (%r12), %eax
movq %rbx, %rdi
movq %r12, %rsi
xorl %ecx, %ecx
callq *(%r13,%rax,8)
testb %al, %al
jne 0x5fac4
movq 0x10(%r15), %r15
cmpb $0x1, (%r15)
jne 0x5fabd
movq 0x8(%r15), %rdx
movzbl (%r12), %eax
movq %rbx, %rdi
movq %r12, %rsi
xorl %ecx, %ecx
callq *(%r13,%rax,8)
testb %al, %al
jne 0x5fac4
movq 0x10(%r15), %r14
cmpb $0x1, (%r14)
jne 0x5fabd
movq 0x10(%rbp), %rbp
cmpq %rbp, %r14
jne 0x5fa1c
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 0x5fb13
movq %rbx, %rdi
callq 0x9c27
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 0x5fac4
movq 0x8(%r15), %rsi
movq %rbx, %rdi
jmp 0x5f597
movq %r14, %r15
jmp 0x5fac4
movq %rbx, %rdi
movq %r15, %rsi
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x5f381
movq %r13, %r15
jmp 0x5fac4
movq 0x2260(%rbx), %rcx
movq 0x8(%rbx), %rax
movq 0x8(%rax), %rax
movq 0x18(%rax), %r13
leaq 0x2850b(%rip), %rax     # 0x880d2
movq %rcx, (%rsp)
cmpq %rax, (%rcx)
je 0x5fc38
movq %r14, %r15
cmpb $0x1, (%r15)
jne 0x5fabd
movq 0x8(%r15), %rax
movq %rax, 0x10(%r13)
andl $0x0, 0x2258(%rbx)
movq (%rsp), %rdi
callq *(%rdi)
testb %al, %al
jne 0x5fac4
movq 0x10(%r15), %r15
cmpb $0x1, (%r15)
jne 0x5fabd
cmpq %r14, %r15
je 0x5fabd
movq 0x8(%r15), %rax
movq %rax, 0x10(%r13)
andl $0x0, 0x2258(%rbx)
movq (%rsp), %rdi
callq *(%rdi)
testb %al, %al
jne 0x5fac4
movq 0x10(%r15), %r15
movq 0x10(%r14), %r14
jmp 0x5fbd3
movq (%rsp), %rax
movq 0x38(%rax), %r15
movq %r14, %rbp
cmpb $0x1, (%rbp)
jne 0x5fabd
movq 0x8(%rbp), %rax
movq %r13, %r12
movq %rax, 0x10(%r13)
andl $0x0, 0x2258(%rbx)
movq (%rsp), %rdi
movq %r15, %r13
callq *%r15
movq 0x120(%rbx), %r15
cmpq %r15, %rax
jne 0x5fcbc
movq 0x10(%rbp), %rbp
cmpb $0x1, (%rbp)
jne 0x5fac4
cmpq %r14, %rbp
je 0x5fac4
movq 0x8(%rbp), %rax
movq %rax, 0x10(%r12)
andl $0x0, 0x2258(%rbx)
movq (%rsp), %rdi
movq %r13, %r15
callq *%r13
cmpq 0x120(%rbx), %rax
jne 0x5fcbc
movq 0x10(%rbp), %rbp
movq 0x10(%r14), %r14
movq %r12, %r13
jmp 0x5fc43
movq %rbp, %r15
jmp 0x5fac4