// File: /workspace/github_c_makefile_star2_O3/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, %r14
movq 0x8(%rsi), %r12
movq 0x10(%rsi), %rax
cmpb $0x1, (%rax)
jne 0x6155f
movq 0x8(%rax), %r15
movq %r14, %rdi
movq %r12, %rsi
callq 0xb067
movq %rax, %rbx
testq %r15, %r15
je 0x615fd
cmpb $0x1, (%r15)
jne 0x61575
testb $0x1, 0x3(%r15)
jne 0x615a4
movq 0x8(%rbx), %rax
movzbl (%rax), %ecx
cmpl $0x1c, %ecx
je 0x615e8
cmpl $0x1b, %ecx
je 0x615f5
cmpq $0x3, 0x6a0(%r14)
jl 0x615fd
movl $0x50, %edx
movq %r14, %rdi
movq %r12, %rsi
callq 0x43f21
movq 0x10(%rax), %r12
movl $0x50, %edx
movq %r14, %rdi
movq %r15, %rsi
callq 0x43f21
movq 0x10(%rax), %r8
leaq 0xba0a1(%rip), %rdx     # 0x11b5e9
movl $0x100, %esi            # imm = 0x100
movq %r14, %rdi
movq %r12, %rcx
xorl %eax, %eax
callq 0xeea2
jmp 0x615fd
movq %r14, %rdi
movq %r12, %rsi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
jmp 0xb067
movq 0x12f8(%r14), %rax
movq 0x8(%rax), %rsi
movq 0x140(%r14), %rcx
movq 0xe94da(%rip), %r8      # 0x14aa68
movq %r14, %rdi
movq %r15, %rdx
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
jmp 0xed2a
movq 0xe93bd(%rip), %rax     # 0x14a968
movq 0x12f8(%r14), %rcx
movq 0x6e8(%r14), %rdx
movq %rax, 0x8(%rdx)
movq 0x10(%rdx), %rax
movq %rcx, 0x8(%rax)
movq 0x10(%rax), %rax
movq %r15, 0x8(%rax)
movq 0x6e8(%r14), %rdx
movq 0xea8(%r14), %rbx
movq %r14, %rdi
movq %rbx, %rsi
callq 0x38dfa
jmp 0x615fd
cmpq 0x150(%r14), %rax
je 0x6150b
movq %r15, 0x10(%rbx)
orb $0x4, 0x3(%rbx)
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq