// File: /workspace/github_c_makefile_star2_O2/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 %r13
pushq %r12
pushq %rbx
movq %rdi, %rbx
movq 0x8(%rsi), %r12
movq 0x10(%rsi), %rax
cmpb $0x1, (%rax)
jne 0x4de1a
movq 0x8(%rax), %r14
jmp 0x4de1d
xorl %r14d, %r14d
movq %rbx, %rdi
movq %r12, %rsi
callq 0xa3c7
movq %rax, %r15
testq %r14, %r14
je 0x4df36
cmpb $0x1, (%r14)
jne 0x4deb2
testb $0x1, 0x3(%r14)
jne 0x4dedf
movq 0x8(%r15), %rax
movzbl (%rax), %ecx
cmpl $0x1c, %ecx
je 0x4df20
cmpl $0x1b, %ecx
je 0x4df2d
cmpq $0x3, 0x6a0(%rbx)
jl 0x4df36
pushq $0x50
popq %r13
movq %rbx, %rdi
movq %r12, %rsi
movq %r13, %rdx
callq 0x36076
movq 0x10(%rax), %r12
movq %rbx, %rdi
movq %r14, %rsi
movq %r13, %rdx
callq 0x36076
movq 0x10(%rax), %r8
leaq 0x996ee(%rip), %rdx     # 0xe7589
movl $0x100, %esi            # imm = 0x100
movq %rbx, %rdi
movq %r12, %rcx
xorl %eax, %eax
callq 0xd5c7
jmp 0x4df36
movq 0x12f8(%rbx), %rax
movq 0x8(%rax), %rsi
movq 0x140(%rbx), %rcx
movq 0xcbb9d(%rip), %r8      # 0x119a68
movq %rbx, %rdi
movq %r14, %rdx
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
jmp 0xd456
movq 0xcba82(%rip), %rax     # 0x119968
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 %r14, 0x8(%rax)
movq 0x6e8(%rbx), %rsi
movq %rbx, %rdi
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
jmp 0x972b
cmpq 0x150(%rbx), %rax
je 0x4de5e
movq %r14, 0x10(%r15)
orb $0x4, 0x3(%r15)
movq %r15, %rax
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq