// File: /workspace/github_c_makefile_star2_O1/BernardTatin[P]s7sh/s7.c
// Function: g_make_iterator
static s7_pointer g_make_iterator(s7_scheme *sc, s7_pointer args)
    {
#define H_make_iterator "(make-iterator sequence carrier) returns an iterator object that returns the next value \
        in the sequence each time it is called.  When it reaches the end, it returns " ITERATOR_END_NAME "."
#define Q_make_iterator s7_make_signature(sc, 3, sc->is_iterator_symbol, sc->is_sequence_symbol, sc->is_pair_symbol)

        s7_pointer iter, seq, carrier;
        /* we need to call s7_make_iterator before fixing up the optional second arg in case let->method */

        seq = car(args);
        carrier = (is_pair(cdr(args))) ? cadr(args) : NULL;
        iter = s7_make_iterator(sc, seq);

        if (carrier)
        {
            if (!is_pair(carrier))
                return(simple_wrong_type_argument(sc, sc->make_iterator_symbol, carrier, T_PAIR));
            if (is_immutable_pair(carrier))
                return(immutable_object_error(sc, set_elist_3(sc, immutable_error_string, sc->make_iterator_symbol, carrier)));

            if (is_hash_table(iterator_sequence(iter)))
            {
                iterator_current(iter) = carrier;
                set_mark_seq(iter);
            }
            else
            {
                if ((is_let(iterator_sequence(iter))) &&
                        (iterator_sequence(iter) != sc->rootlet))
                {
                    iterator_let_cons(iter) = carrier;
                    set_mark_seq(iter);
                }
                else         /* (let-temporarily (((*s7* 'safety) 1)) (make-iterator "asdf" (cons 1 2))) */
                {
                    if (sc->safety > MORE_SAFETY_WARNINGS)
                        s7_warn(sc, 256, "(make-iterator %s %s) does not need the second argument\n", DISPLAY_80(seq), DISPLAY_80(carrier));
                }
            }
        }
        return(iter);
    }

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq 0x8(%rsi), %r12
movq 0x10(%rsi), %rax
cmpb $0x1, (%rax)
jne 0x6645a
movq 0x8(%rax), %r15
jmp 0x6645d
xorl %r15d, %r15d
movq %rbx, %rdi
movq %r12, %rsi
callq 0xbec2
movq %rax, %r14
testq %r15, %r15
je 0x6657b
cmpb $0x1, (%r15)
jne 0x664f2
testb $0x1, 0x3(%r15)
jne 0x66521
movq 0x8(%r14), %rax
movzbl (%rax), %ecx
cmpl $0x1c, %ecx
je 0x66565
cmpl $0x1b, %ecx
je 0x66572
cmpq $0x3, 0x6a0(%rbx)
jl 0x6657b
movl $0x50, %edx
movq %rbx, %rdi
movq %r12, %rsi
callq 0x469c9
movq 0x10(%rax), %r12
movl $0x50, %edx
movq %rbx, %rdi
movq %r15, %rsi
callq 0x469c9
movq 0x10(%rax), %r8
leaq 0xbdffe(%rip), %rdx     # 0x1244d9
movl $0x100, %esi            # imm = 0x100
movq %rbx, %rdi
movq %r12, %rcx
xorl %eax, %eax
callq 0xfc3d
jmp 0x6657b
movq 0x12f8(%rbx), %rax
movq 0x8(%rax), %rsi
movq 0x140(%rbx), %rcx
movq 0xec55d(%rip), %r8      # 0x152a68
movq %rbx, %rdi
movq %r15, %rdx
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
jmp 0xfac8
movq 0xec440(%rip), %rax     # 0x152968
movq 0x12f8(%rbx), %rcx
movq 0x6e8(%rbx), %rdx
movq %rax, 0x8(%rdx)
movq 0x10(%rdx), %rax
movq %rcx, 0x8(%rax)
movq 0x10(%rax), %rax
movq %r15, 0x8(%rax)
movq 0x6e8(%rbx), %rdx
movq 0xea8(%rbx), %r14
movq %rbx, %rdi
movq %r14, %rsi
callq 0x3b366
jmp 0x6657b
cmpq 0x150(%rbx), %rax
je 0x6649e
movq %r15, 0x10(%r14)
orb $0x4, 0x3(%r14)
movq %r14, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq