// File: /workspace/github_c_makefile_star2_O2/BernardTatin[P]s7sh/s7.c
// Function: s7_make_iterator
s7_pointer s7_make_iterator(s7_scheme *sc, s7_pointer e)
    {
        s7_pointer iter, p;

        new_cell(sc, iter, T_ITERATOR | T_SAFE_PROCEDURE | T_ITER_OK);
        iterator_sequence(iter) = e;
        if ((!is_let(e)) && (!is_pair(e)))
            iterator_position(iter) = 0;

        switch (type(e))
        {
            case T_LET:
                if (e == sc->rootlet)
                {
                    iterator_current(iter) = rootlet_element(e, 0); /* unfortunately tricky -- let_iterate uses different fields */
                    iterator_position(iter) = 0;
                    iterator_next(iter) = rootlet_iterate;
                    return(iter);
                }
                if (e == sc->s7_let)
                    return(s7_let_make_iterator(sc, iter));

                sc->temp6 = iter;
                p = iterator_method(sc, e);
                sc->temp6 = sc->nil;
                if (p) {free_cell(sc, iter); return(p);}
                iterator_set_current_slot(iter, let_slots(e));
                iterator_next(iter) = let_iterate;
                iterator_let_cons(iter) = NULL;
                break;

            case T_HASH_TABLE:
                iterator_hash_current(iter) = NULL;
                iterator_current(iter) = NULL;
                iterator_position(iter) = -1;
                iterator_next(iter) = hash_table_iterate;
                if (is_weak_hash_table(e))
                {
                    set_weak_hash_iterator(iter);
                    weak_hash_iters(e)++;
                    add_weak_hash_iterator(sc, iter);
                }
                break;

            case T_STRING:
                iterator_length(iter) = string_length(e);
                iterator_next(iter) = string_iterate;
                break;

            case T_BYTE_VECTOR:
                iterator_length(iter) = byte_vector_length(e);
                iterator_next(iter) = byte_vector_iterate;
                break;

            case T_VECTOR:
                iterator_length(iter) = vector_length(e);
                iterator_next(iter) = vector_iterate;
                break;

            case T_INT_VECTOR:
                iterator_length(iter) = vector_length(e);
                iterator_next(iter) = int_vector_iterate;
                break;

            case T_FLOAT_VECTOR:
                iterator_length(iter) = vector_length(e);
                iterator_next(iter) = float_vector_iterate;
                break;

            case T_PAIR:
                iterator_current(iter) = e;
                iterator_next(iter) = pair_iterate;
                iterator_set_slow(iter, e);
                break;

            case T_NIL: /* (make-iterator #()) -> #<iterator: vector>, so I guess () should also work */
                iterator_length(iter) = 0;
                iterator_next(iter) = iterator_finished;
                clear_iter_ok(iter);
                break;

            case T_MACRO:   case T_MACRO_STAR:
            case T_BACRO:   case T_BACRO_STAR:
            case T_CLOSURE: case T_CLOSURE_STAR:
                if (is_iterable_closure(sc, e))
                {
                    p = cons(sc, small_int(0), sc->nil);
                    iterator_current(iter) = p;
                    set_mark_seq(iter);
                    iterator_next(iter) = closure_iterate;
                    if (has_active_methods(sc, e))
                        iterator_length(iter) = closure_length(sc, e);
                    else iterator_length(iter) = s7_int_max;
                }
                else
                {
                    free_cell(sc, iter);
                    return(simple_wrong_type_argument_with_type(sc, sc->make_iterator_symbol, e,
                                wrap_string(sc, "a function or macro with a '+iterator+ local that is not #f", 59)));
                }
                break;

            case T_C_OBJECT:
                iterator_length(iter) = c_object_length_to_int(sc, e);
                sc->temp6 = iter;
                p = iterator_method(sc, e);
                sc->temp6 = sc->nil;
                if (p) {free_cell(sc, iter); return(p);}
                iterator_current(iter) = list_2(sc, e, small_int(0));
                set_mark_seq(iter);
                iterator_next(iter) = c_object_iterate;
                break;

            default:
                return(simple_wrong_type_argument_with_type(sc, sc->make_iterator_symbol, e, a_sequence_string));
        }
        return(iter);
    }

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movq %rsi, %r14
movq %rdi, %r15
movq 0x90(%rdi), %rax
cmpq 0x98(%rdi), %rax
ja 0xa3f5
movq %r15, %rdi
callq 0x9c27
movq 0x90(%r15), %rax
leaq -0x8(%rax), %rcx
movq %rcx, 0x90(%r15)
movq -0x8(%rax), %rbx
movl $0x8020001d, %eax       # imm = 0x8020001D
movq %rax, (%rbx)
movq %r14, 0x8(%rbx)
movzbl (%r14), %eax
cmpl $0x1, %eax
je 0xa426
cmpl $0x1c, %eax
je 0xa426
andq $0x0, 0x18(%rbx)
movb (%r14), %al
movzbl %al, %eax
leal -0x13(%rax), %ecx
cmpl $0x1a, %ecx
ja 0xa595
leaq 0xc7d04(%rip), %rax     # 0xd2140
movslq (%rax,%rcx,4), %rcx
addq %rax, %rcx
jmpq *%rcx
movq %r15, %rdi
movq %r14, %rsi
xorl %edx, %edx
callq 0x32378
testb %al, %al
jne 0xa481
movq 0x12f8(%r15), %rax
movq 0x8(%rax), %rsi
movq 0x10b4f0(%rip), %rdx    # 0x115958
movq 0x140(%r15), %r8
movq 0x116eba(%rip), %r9     # 0x121330
movq %r15, %rdi
movq %r14, %rcx
callq 0x9bbb
movq 0x16d8(%r15), %rdx
movq %r15, %rdi
movq %r14, %rsi
callq 0x31541
testq %rax, %rax
je 0xa536
cmpq 0x120(%r15), %rax
je 0xa536
movq 0x10b4a0(%rip), %r12    # 0x115950
movq 0x90(%r15), %rax
movq 0x110(%r15), %r13
cmpq 0x98(%r15), %rax
ja 0xa4d6
movq %r15, %rdi
callq 0x9c27
movq 0x90(%r15), %rax
leaq -0x8(%rax), %rcx
movq %rcx, 0x90(%r15)
movq -0x8(%rax), %rax
movq $0x200001, (%rax)       # imm = 0x200001
movq %r12, 0x8(%rax)
movq %r13, 0x10(%rax)
movq %rax, 0x10(%rbx)
orb $0x4, 0x3(%rbx)
leaq 0x20f28(%rip), %rax     # 0x2b42b
movq %rax, 0x28(%rbx)
testb $0x40, 0x3(%r14)
je 0xa5bf
cmpb $0x1, 0x24c(%r15)
jne 0xa5bf
movq %r15, %rdi
movq %r14, %rsi
callq 0x2b459
cltq
movq %rax, 0x20(%rbx)
jmp 0xa7f2
andq $0x0, (%rbx)
movq 0x90(%r15), %rax
leaq 0x8(%rax), %rcx
movq %rcx, 0x90(%r15)
movq %rbx, (%rax)
movq 0x12f8(%r15), %rax
movq 0x8(%rax), %rsi
movq 0x140(%r15), %rcx
movq 0x820(%r15), %rax
movslq 0x7dc(%r15), %rdx
movq (%rax,%rdx,8), %r8
leal 0x1(%rdx), %eax
andl $0x7, %eax
movl %eax, 0x7dc(%r15)
leaq 0xcbb08(%rip), %rax     # 0xd608f
movq %rax, 0x10(%r8)
movq $0x3b, 0x8(%r8)
jmp 0xa5f8
cmpl $0x1, %eax
je 0xa7c2
cmpl $0x2, %eax
jne 0xa5df
andq $0x0, 0x20(%rbx)
leaq 0x20e74(%rip), %rax     # 0x2b423
movq %rax, 0x28(%rbx)
movq $0x20001d, (%rbx)       # imm = 0x20001D
jmp 0xa7f2
xorl %eax, %eax
cmpb $0x0, 0x10f640(%rip)    # 0x119c08
movabsq $0x7fffffffffffffff, %rcx # imm = 0x7FFFFFFFFFFFFFFF
cmoveq %rax, %rcx
movq %rcx, 0x20(%rbx)
jmp 0xa7f2
movq 0x12f8(%r15), %rax
movq 0x8(%rax), %rsi
movq 0x140(%r15), %rcx
movq 0x10f618(%rip), %r8     # 0x119c10
movq %r15, %rdi
movq %r14, %rdx
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
jmp 0xd456
movq %r15, %rdi
movq %r14, %rsi
callq 0x2b4f0
movq %rax, 0x20(%rbx)
movq %rbx, 0x520(%r15)
movq %r15, %rdi
movq %r14, %rsi
callq 0x2afe5
movq 0x110(%r15), %r12
movq %r12, 0x520(%r15)
testq %rax, %rax
jne 0xa765
movq 0x10b305(%rip), %r13    # 0x115950
movq 0x90(%r15), %rax
cmpq 0x98(%r15), %rax
ja 0xa66a
movq %r15, %rdi
callq 0x9c27
movq 0x90(%r15), %rax
leaq -0x8(%rax), %rcx
movq %rcx, 0x90(%r15)
movq -0x8(%rax), %rax
movl $0x200001, %ecx         # imm = 0x200001
movq %rcx, (%rax)
movq %r13, 0x8(%rax)
movq %r12, 0x10(%rax)
movq 0x90(%r15), %rdx
leaq -0x8(%rdx), %rsi
movq %rsi, 0x90(%r15)
movq -0x8(%rdx), %rdx
movq %rcx, (%rdx)
movq %r14, 0x8(%rdx)
movq %rax, 0x10(%rdx)
movq %rdx, 0x10(%rbx)
orb $0x4, 0x3(%rbx)
leaq 0x20e75(%rip), %rax     # 0x2b52e
jmp 0xa7ee
movq 0x8(%r14), %rax
movq %rax, 0x20(%rbx)
leaq 0x20b71(%rip), %rax     # 0x2b23e
jmp 0xa7ee
movq 0x8(%r14), %rax
movq %rax, 0x20(%rbx)
leaq 0x20ba2(%rip), %rax     # 0x2b283
jmp 0xa7ee
movq 0x8(%r14), %rax
movq %rax, 0x20(%rbx)
leaq 0x20b05(%rip), %rax     # 0x2b1fa
jmp 0xa7ee
movq 0x8(%r14), %rax
movq %rax, 0x20(%rbx)
leaq 0x20bb4(%rip), %rax     # 0x2b2bd
jmp 0xa7ee
movq 0x8(%r14), %rax
movq %rax, 0x20(%rbx)
leaq 0x20c33(%rip), %rax     # 0x2b350
jmp 0xa7ee
cmpq %r14, 0x150(%r15)
je 0xa7d7
cmpq %r14, 0x2150(%r15)
je 0xa7ff
movq %rbx, 0x520(%r15)
movq %r15, %rdi
movq %r14, %rsi
callq 0x2afe5
movq 0x110(%r15), %rcx
movq %rcx, 0x520(%r15)
testq %rax, %rax
je 0xa813
andq $0x0, (%rbx)
movq 0x90(%r15), %rcx
leaq 0x8(%rcx), %rdx
movq %rdx, 0x90(%r15)
movq %rbx, (%rcx)
movq %rax, %rbx
jmp 0xa7f2
andq $0x0, 0x20(%rbx)
andq $0x0, 0x10(%rbx)
orq $-0x1, 0x18(%rbx)
leaq 0x209f6(%rip), %rax     # 0x2b18f
movq %rax, 0x28(%rbx)
testb $0x8, 0x3(%r14)
je 0xa7f2
movw $0x4, 0x6(%rbx)
movq 0x28(%r14), %rax
incl 0xc(%rax)
movq 0x7a0(%r15), %rdi
movq %rbx, %rsi
callq 0xb999
jmp 0xa7f2
movq %r14, 0x10(%rbx)
leaq 0x20c0d(%rip), %rax     # 0x2b3da
movq %rax, 0x28(%rbx)
movq %r14, 0x20(%rbx)
jmp 0xa7f2
movq 0x10(%r14), %rax
movq (%rax), %rax
movq %rax, 0x10(%rbx)
andq $0x0, 0x18(%rbx)
leaq 0x2074c(%rip), %rax     # 0x2af3a
movq %rax, 0x28(%rbx)
movq %rbx, %rax
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
leaq 0xaf196(%rip), %rax     # 0xb999c
movq %rax, 0x28(%rbx)
xorps %xmm0, %xmm0
movups %xmm0, 0x10(%rbx)
jmp 0xa7f2
movq 0x8(%r14), %rax
movq %rax, 0x18(%rbx)
leaq 0x208db(%rip), %rax     # 0x2b0fd
movq %rax, 0x28(%rbx)
andq $0x0, 0x10(%rbx)
jmp 0xa7f2