// File: /workspace/github_c_makefile_star2_O1/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 0xbee9
movq %r15, %rdi
callq 0xb389
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 0xbf21
cmpl $0x1c, %eax
je 0xbf21
movq $0x0, 0x18(%rbx)
movb (%r14), %al
movzbl %al, %ecx
leal -0x13(%rcx), %edx
cmpl $0x1a, %edx
ja 0xc09a
leaq 0x103206(%rip), %rcx    # 0x10f140
movslq (%rcx,%rdx,4), %rdx
addq %rcx, %rdx
jmpq *%rdx
cmpb $0x26, %al
jb 0xbf58
movq %r15, %rdi
movq %r14, %rsi
xorl %edx, %edx
callq 0x41fac
testb %al, %al
jne 0xbf83
movq 0x12f8(%r15), %rax
movq 0x8(%rax), %rsi
movq 0x1429ee(%rip), %rdx    # 0x14e958
movq 0x140(%r15), %r8
movq 0x14e3b8(%rip), %r9     # 0x15a330
movq %r15, %rdi
movq %r14, %rcx
callq 0xb31d
movq 0x16d8(%r15), %rdx
movq %r15, %rdi
movq %r14, %rsi
callq 0x40e7b
testq %rax, %rax
je 0xc038
cmpq 0x120(%r15), %rax
je 0xc038
movq 0x14299e(%rip), %r12    # 0x14e950
movq 0x90(%r15), %rax
movq 0x110(%r15), %r13
cmpq 0x98(%r15), %rax
ja 0xbfd1
movq %r15, %rdi
callq 0xb389
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 0x2dc12(%rip), %rax     # 0x39c17
movq %rax, 0x28(%rbx)
testb $0x40, 0x3(%r14)
je 0xc0c4
cmpb $0x1, 0x24c(%r15)
jne 0xc0c4
movq %r15, %rdi
movq %r14, %rsi
callq 0x39c45
cltq
movq %rax, 0x20(%rbx)
jmp 0xc368
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 0x106f53(%rip), %rax    # 0x112fdf
movq %rax, 0x10(%r8)
movq $0x3b, 0x8(%r8)
jmp 0xc0fd
cmpl $0x1, %ecx
je 0xc335
cmpl $0x2, %ecx
jne 0xc0e4
movq $0x0, 0x20(%rbx)
leaq 0x2db58(%rip), %rax     # 0x39c0f
movq %rax, 0x28(%rbx)
andb $0x7f, 0x3(%rbx)
jmp 0xc368
xorl %eax, %eax
cmpb $0x0, 0x146b3b(%rip)    # 0x152c08
movabsq $0x7fffffffffffffff, %rcx # imm = 0x7FFFFFFFFFFFFFFF
cmoveq %rax, %rcx
movq %rcx, 0x20(%rbx)
jmp 0xc368
movq 0x12f8(%r15), %rax
movq 0x8(%rax), %rsi
movq 0x140(%r15), %rcx
movq 0x146b13(%rip), %r8     # 0x152c10
movq %r15, %rdi
movq %r14, %rdx
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
jmp 0xfac8
movq 0x8d8(%r15), %rax
movq 0x8(%r14), %rcx
movq (%rax,%rcx,8), %rax
movq 0x58(%rax), %rax
testq %rax, %rax
je 0xc150
movq 0x730(%r15), %rcx
movq %r14, 0x8(%rcx)
movq 0x730(%r15), %rsi
movq %r15, %rdi
callq *%rax
movb (%rax), %dl
cmpb $0xb, %dl
jne 0xc14b
movq 0x8(%rax), %rcx
cmpb $0xb, %dl
je 0xc157
movq $-0x1, %rcx
movq %rcx, 0x20(%rbx)
movq %rbx, 0x520(%r15)
movq %r15, %rdi
movq %r14, %rsi
callq 0x3977e
movq 0x110(%r15), %r12
movq %r12, 0x520(%r15)
testq %rax, %rax
jne 0xc2a5
movq 0x1427c5(%rip), %r13    # 0x14e950
movq 0x90(%r15), %rax
cmpq 0x98(%r15), %rax
ja 0xc1a3
movq %r15, %rdi
callq 0xb389
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 0x2db32(%rip), %rax     # 0x39d2b
jmp 0xc364
movq 0x8(%r14), %rax
movq %rax, 0x20(%rbx)
leaq 0x2d81d(%rip), %rax     # 0x39a2a
jmp 0xc364
movq 0x8(%r14), %rax
movq %rax, 0x20(%rbx)
leaq 0x2d84e(%rip), %rax     # 0x39a6f
jmp 0xc364
movq 0x8(%r14), %rax
movq %rax, 0x20(%rbx)
leaq 0x2d7b1(%rip), %rax     # 0x399e6
jmp 0xc364
movq 0x8(%r14), %rax
movq %rax, 0x20(%rbx)
leaq 0x2d860(%rip), %rax     # 0x39aa9
jmp 0xc364
movq 0x8(%r14), %rax
movq %rax, 0x20(%rbx)
leaq 0x2d8df(%rip), %rax     # 0x39b3c
jmp 0xc364
cmpq %r14, 0x150(%r15)
je 0xc34a
cmpq %r14, 0x2150(%r15)
je 0xc375
movq %rbx, 0x520(%r15)
movq %r15, %rdi
movq %r14, %rsi
callq 0x3977e
movq 0x110(%r15), %rcx
movq %rcx, 0x520(%r15)
testq %rax, %rax
je 0xc389
movq $0x0, (%rbx)
movq 0x90(%r15), %rcx
leaq 0x8(%rcx), %rdx
movq %rdx, 0x90(%r15)
movq %rbx, (%rcx)
movq %rax, %rbx
jmp 0xc368
xorl %eax, %eax
movq %rax, 0x20(%rbx)
movq %rax, 0x10(%rbx)
movq $-0x1, 0x18(%rbx)
leaq 0x2d646(%rip), %rax     # 0x39928
movq %rax, 0x28(%rbx)
testb $0x8, 0x3(%r14)
je 0xc368
orb $0x4, 0x6(%rbx)
movq 0x28(%r14), %rax
incl 0xc(%rax)
movq 0x7a0(%r15), %r14
movq 0x8(%r14), %rsi
cmpq %rsi, 0x10(%r14)
jne 0xc320
leaq (%rsi,%rsi), %rax
movq %rax, 0x8(%r14)
movq (%r14), %rdi
shlq $0x4, %rsi
callq 0x9510
movq %rax, (%r14)
movq (%r14), %rax
movq 0x10(%r14), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, 0x10(%r14)
movq %rbx, (%rax,%rcx,8)
jmp 0xc368
movq %r14, 0x10(%rbx)
leaq 0x2d886(%rip), %rax     # 0x39bc6
movq %rax, 0x28(%rbx)
movq %r14, 0x20(%rbx)
jmp 0xc368
movq 0x10(%r14), %rax
movq (%rax), %rax
movq %rax, 0x10(%rbx)
movq $0x0, 0x18(%rbx)
leaq 0x2d36f(%rip), %rax     # 0x396d3
movq %rax, 0x28(%rbx)
movq %rbx, %rax
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
leaq 0xe5f31(%rip), %rax     # 0xf22ad
movq %rax, 0x28(%rbx)
xorps %xmm0, %xmm0
movups %xmm0, 0x10(%rbx)
jmp 0xc368
movq 0x8(%r14), %rax
movq %rax, 0x18(%rbx)
leaq 0x2d4fe(%rip), %rax     # 0x39896
movq %rax, 0x28(%rbx)
movq $0x0, 0x10(%rbx)
jmp 0xc368