// File: /workspace/github_c_makefile_star2_O3/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 0xb095
movq %r15, %rdi
callq 0xa550
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 0xb0c9
cmpl $0x1c, %eax
je 0xb0c9
movq $0x0, 0x18(%rbx)
movb (%r14), %al
movzbl %al, %eax
leal -0x13(%rax), %ecx
cmpl $0x1a, %ecx
ja 0xb23b
leaq 0xfb051(%rip), %rax     # 0x106130
movslq (%rax,%rcx,4), %rcx
addq %rax, %rcx
jmpq *%rcx
movq %r15, %rdi
movq %r14, %rsi
xorl %edx, %edx
callq 0x3f86f
testb %al, %al
jne 0xb124
movq 0x12f8(%r15), %rax
movq 0x8(%rax), %rsi
movq 0x13b84d(%rip), %rdx    # 0x146958
movq 0x140(%r15), %r8
movq 0x147217(%rip), %r9     # 0x152330
movq %r15, %rdi
movq %r14, %rcx
callq 0xa4e4
movq 0x16d8(%r15), %rdx
movq %r15, %rdi
movq %r14, %rsi
callq 0x3e86d
testq %rax, %rax
je 0xb1d9
cmpq 0x120(%r15), %rax
je 0xb1d9
movq 0x13b7fd(%rip), %r12    # 0x146950
movq 0x90(%r15), %rax
movq 0x110(%r15), %r13
cmpq 0x98(%r15), %rax
ja 0xb179
movq %r15, %rdi
callq 0xa550
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 0x2c580(%rip), %rax     # 0x37726
movq %rax, 0x28(%rbx)
testb $0x40, 0x3(%r14)
je 0xb268
cmpb $0x1, 0x24c(%r15)
jne 0xb268
movq %r15, %rdi
movq %r14, %rsi
callq 0x37754
cltq
movq %rax, 0x20(%rbx)
jmp 0xb507
movq $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 0xfeec2(%rip), %rax     # 0x10a0ef
movq %rax, 0x10(%r8)
movq $0x3b, 0x8(%r8)
jmp 0xb2a1
cmpl $0x1, %eax
je 0xb4d4
cmpl $0x2, %eax
jne 0xb288
movq $0x0, 0x20(%rbx)
leaq 0x2c4c6(%rip), %rax     # 0x3771e
movq %rax, 0x28(%rbx)
movq $0x20001d, (%rbx)       # imm = 0x20001D
jmp 0xb507
xorl %eax, %eax
cmpb $0x0, 0x13f997(%rip)    # 0x14ac08
movabsq $0x7fffffffffffffff, %rcx # imm = 0x7FFFFFFFFFFFFFFF
cmoveq %rax, %rcx
movq %rcx, 0x20(%rbx)
jmp 0xb507
movq 0x12f8(%r15), %rax
movq 0x8(%rax), %rsi
movq 0x140(%r15), %rcx
movq 0x13f96f(%rip), %r8     # 0x14ac10
movq %r15, %rdi
movq %r14, %rdx
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
jmp 0xed2a
movq 0x8d8(%r15), %rax
movq 0x8(%r14), %rcx
movq (%rax,%rcx,8), %rax
movq 0x58(%rax), %rax
movq $-0x1, %r12
testq %rax, %rax
je 0xb2f4
movq 0x730(%r15), %rcx
movq %r14, 0x8(%rcx)
movq 0x730(%r15), %rsi
movq %r15, %rdi
callq *%rax
cmpb $0xb, (%rax)
jne 0xb2f4
movq 0x8(%rax), %r12
movq %r12, 0x20(%rbx)
movq %rbx, 0x520(%r15)
movq %r15, %rdi
movq %r14, %rsi
callq 0x372e0
movq 0x110(%r15), %r12
movq %r12, 0x520(%r15)
testq %rax, %rax
jne 0xb442
movq 0x13b628(%rip), %r13    # 0x146950
movq 0x90(%r15), %rax
cmpq 0x98(%r15), %rax
ja 0xb347
movq %r15, %rdi
callq 0xa550
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 0x2c457(%rip), %rax     # 0x377ed
jmp 0xb503
movq 0x8(%r14), %rax
movq %rax, 0x20(%rbx)
leaq 0x2c18f(%rip), %rax     # 0x37539
jmp 0xb503
movq 0x8(%r14), %rax
movq %rax, 0x20(%rbx)
leaq 0x2c1c0(%rip), %rax     # 0x3757e
jmp 0xb503
movq 0x8(%r14), %rax
movq %rax, 0x20(%rbx)
leaq 0x2c123(%rip), %rax     # 0x374f5
jmp 0xb503
movq 0x8(%r14), %rax
movq %rax, 0x20(%rbx)
leaq 0x2c1d2(%rip), %rax     # 0x375b8
jmp 0xb503
movq 0x8(%r14), %rax
movq %rax, 0x20(%rbx)
leaq 0x2c251(%rip), %rax     # 0x3764b
jmp 0xb503
cmpq %r14, 0x150(%r15)
je 0xb4e9
cmpq %r14, 0x2150(%r15)
je 0xb514
movq %rbx, 0x520(%r15)
movq %r15, %rdi
movq %r14, %rsi
callq 0x372e0
movq 0x110(%r15), %rcx
movq %rcx, 0x520(%r15)
testq %rax, %rax
je 0xb528
movq $0x0, (%rbx)
movq 0x90(%r15), %rcx
leaq 0x8(%rcx), %rdx
movq %rdx, 0x90(%r15)
movq %rbx, (%rcx)
movq %rax, %rbx
jmp 0xb507
xorl %eax, %eax
movq %rax, 0x20(%rbx)
movq %rax, 0x10(%rbx)
movq $-0x1, 0x18(%rbx)
leaq 0x2c00b(%rip), %rax     # 0x3748a
movq %rax, 0x28(%rbx)
testb $0x8, 0x3(%r14)
je 0xb507
movw $0x4, 0x6(%rbx)
movq 0x28(%r14), %rax
incl 0xc(%rax)
movq 0x7a0(%r15), %r14
movq (%r14), %rax
movq 0x10(%r14), %rsi
cmpq 0x8(%r14), %rsi
jne 0xb4c6
leaq (%rsi,%rsi), %rcx
movq %rcx, 0x8(%r14)
shlq $0x4, %rsi
movq %rax, %rdi
callq 0x8510
movq %rax, (%r14)
movq 0x10(%r14), %rsi
leaq 0x1(%rsi), %rcx
movq %rcx, 0x10(%r14)
movq %rbx, (%rax,%rsi,8)
jmp 0xb507
movq %r14, 0x10(%rbx)
leaq 0x2c1f6(%rip), %rax     # 0x376d5
movq %rax, 0x28(%rbx)
movq %r14, 0x20(%rbx)
jmp 0xb507
movq 0x10(%r14), %rax
movq (%rax), %rax
movq %rax, 0x10(%rbx)
movq $0x0, 0x18(%rbx)
leaq 0x2bd32(%rip), %rax     # 0x37235
movq %rax, 0x28(%rbx)
movq %rbx, %rax
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
leaq 0xde048(%rip), %rax     # 0xe9563
movq %rax, 0x28(%rbx)
xorps %xmm0, %xmm0
movups %xmm0, 0x10(%rbx)
jmp 0xb507
movq 0x8(%r14), %rax
movq %rax, 0x18(%rbx)
leaq 0x2bec1(%rip), %rax     # 0x373f8
movq %rax, 0x28(%rbx)
movq $0x0, 0x10(%rbx)
jmp 0xb507