// File: /workspace/github_c_makefile_star2_O3/BernardTatin[P]s7sh/s7.c
// Function: collect_shared_info
static bool collect_shared_info(s7_scheme *sc, shared_info *ci, s7_pointer top, bool stop_at_print_length)
    {
        /* look for top in current list.
         * As we collect objects (guaranteed to have structure) we set the collected bit.  If we ever
         *   encounter an object with that bit on, we've seen it before so we have a possible cycle.
         *   Once the collection pass is done, we run through our list, and clear all these bits.
         */
        bool top_cyclic;

        if (is_collected_or_shared(top))
        {
            if (is_shared(top))
                return(false);
            return(check_collected(top, ci));
        }

        /* top not seen before -- add it to the list */
        set_collected(top);

        if (ci->top == ci->size)
            enlarge_shared_info(ci);
        ci->objs[ci->top++] = top;

        top_cyclic = false;
        /* now search the rest of this structure */
        if (is_pair(top))
        {
            s7_pointer p, cp;
            if ((has_structure(car(top))) &&
                    (collect_shared_info(sc, ci, car(top), stop_at_print_length)))
                top_cyclic = true;

            for (p = cdr(top); is_pair(p); p = cdr(p))
            {
                if (is_collected_or_shared(p))
                {
                    set_cyclic(top);
                    set_cyclic(p);
                    if (is_shared(p))
                    {
                        if (!top_cyclic)
                            for (cp = top; cp != p; cp = cdr(cp)) set_shared(cp);
                        return(top_cyclic);
                    }
                    return(check_collected(p, ci));
                }
                set_collected(p);
                if (ci->top == ci->size)
                    enlarge_shared_info(ci);
                ci->objs[ci->top++] = p;
                if ((has_structure(car(p))) &&
                        (collect_shared_info(sc, ci, car(p), stop_at_print_length)))
                    top_cyclic = true;
            }
            if ((has_structure(p)) &&
                    (collect_shared_info(sc, ci, p, stop_at_print_length)))
            {
                set_cyclic(top);
                return(true);
            }
            if (!top_cyclic)
                for (cp = top; is_pair(cp); cp = cdr(cp)) set_shared(cp);
            else set_cyclic(top);
            return(top_cyclic);
        }

        switch (type(top))
        {
            case T_VECTOR:
                if (collect_vector_info(sc, ci, top, stop_at_print_length))
                    top_cyclic = true;
                break;

            case T_ITERATOR:
                if ((is_sequence(iterator_sequence(top))) && /* might be a function with +iterator+ local */
                        (collect_shared_info(sc, ci, iterator_sequence(top), stop_at_print_length)))
                {
                    if (peek_shared_ref(ci, iterator_sequence(top)) == 0)
                        check_collected(iterator_sequence(top), ci);
                    top_cyclic = true;
                }
                break;

            case T_HASH_TABLE:
                if (hash_table_entries(top) > 0)
                {
                    s7_int i, len;
                    hash_entry_t **entries;
                    bool keys_safe;

                    keys_safe = ((hash_table_checker(top) != hash_equal) &&
                            (hash_table_checker(top) != hash_equivalent) &&
                            (!hash_table_checker_locked(top)));
                    entries = hash_table_elements(top);
                    len = hash_table_mask(top) + 1;
                    for (i = 0; i < len; i++)
                    {
                        hash_entry_t *p;
                        for (p = entries[i]; p; p = hash_entry_next(p))
                        {
                            if ((!keys_safe) &&
                                    (has_structure(hash_entry_key(p))) &&
                                    (collect_shared_info(sc, ci, hash_entry_key(p), stop_at_print_length)))
                                top_cyclic = true;
                            if ((has_structure(hash_entry_value(p))) &&
                                    (collect_shared_info(sc, ci, hash_entry_value(p), stop_at_print_length)))
                            {
                                if ((is_c_pointer(hash_entry_value(p))) ||
                                        (is_iterator(hash_entry_value(p))) ||
                                        (is_c_object(hash_entry_value(p))))
                                    check_collected(top, ci);
                                top_cyclic = true;
                            }
                        }
                    }
                }
                break;

            case T_SLOT: /* this can be hit if we somehow collect_shared_info on sc->rootlet via collect_vector_info (see the let case below) */
                if ((has_structure(slot_value(top))) &&
                        (collect_shared_info(sc, ci, slot_value(top), stop_at_print_length)))
                    top_cyclic = true;
                break;

            case T_LET:
                if (top == sc->rootlet)
                {
                    if (collect_vector_info(sc, ci, top, stop_at_print_length))
                        top_cyclic = true;
                }
                else
                {
                    s7_pointer p, q;
                    for (q = top; is_let(q) && (q != sc->rootlet); q = outlet(q))
                    {
                        for (p = let_slots(q); tis_slot(p); p = next_slot(p))
                            if ((has_structure(slot_value(p))) &&
                                    (collect_shared_info(sc, ci, slot_value(p), stop_at_print_length)))
                            {
                                top_cyclic = true;
                                if ((is_c_pointer(slot_value(p))) ||
                                        (is_iterator(slot_value(p))) ||
                                        (is_c_object(slot_value(p))))
                                    check_collected(top, ci);
                            }
                    }
                }
                break;

            case T_CLOSURE:
            case T_CLOSURE_STAR:
                if (collect_shared_info(sc, ci, closure_body(top), stop_at_print_length))
                {
                    if (peek_shared_ref(ci, top) == 0)
                        check_collected(top, ci);
                    top_cyclic = true;
                }
                break;

            case T_C_POINTER:
                if ((has_structure(c_pointer_type(top))) &&
                        (collect_shared_info(sc, ci, c_pointer_type(top), stop_at_print_length)))
                {
                    if (peek_shared_ref(ci, c_pointer_type(top)) == 0)
                        check_collected(c_pointer_type(top), ci);
                    top_cyclic = true;
                }
                if ((has_structure(c_pointer_info(top))) &&
                        (collect_shared_info(sc, ci, c_pointer_info(top), stop_at_print_length)))
                {
                    if (peek_shared_ref(ci, c_pointer_info(top)) == 0)
                        check_collected(c_pointer_info(top), ci);
                    top_cyclic = true;
                }
                break;

            case T_C_OBJECT:
                if ((c_object_to_list(sc, top)) &&
                        (c_object_set(sc, top)) &&
                        (collect_shared_info(sc, ci, (*(c_object_to_list(sc, top)))(sc, set_plist_1(sc, top)), stop_at_print_length)))
                {
                    if (peek_shared_ref(ci, top) == 0)
                        check_collected(top, ci);
                    top_cyclic = true;
                }
                break;
        }

        if (!top_cyclic)
            set_shared(top);
        else set_cyclic(top);
        return(top_cyclic);
    }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rdx, %r14
movq %rsi, %r15
movq (%rdx), %rax
testl $0xa0000, %eax          # imm = 0xA0000
je 0x960a6
btl $0x13, %eax
jb 0x966f1
movq %r14, %rdi
movq %r15, %rsi
callq 0x967a9
jmp 0x96779
movl %ecx, %ebp
movq %rdi, %r12
orq $0x20000, %rax          # imm = 0x20000
movq %rax, (%r14)
movl 0xc(%r15), %eax
cmpl 0x8(%r15), %eax
jne 0x960ca
movq %r15, %rdi
callq 0x967fa
movl 0xc(%r15), %eax
movq (%r15), %rcx
leal 0x1(%rax), %edx
movl %edx, 0xc(%r15)
cltq
movq %r14, (%rcx,%rax,8)
movzbl (%r14), %ecx
leal -0x14(%rcx), %eax
cmpl $0x15, %eax
ja 0x9614e
leaq 0x71f37(%rip), %rcx     # 0x108024
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq 0x10(%r14), %rdx
movzbl %bpl, %ecx
movq %r12, %rdi
movq %r15, %rsi
callq 0x9606e
testb %al, %al
je 0x966ec
testb $0x2, 0x2(%r14)
movq %r14, %rdi
je 0x9676c
movslq 0xc(%r15), %rax
movq %r14, %rdi
testq %rax, %rax
jle 0x9676c
movq (%r15), %rdx
xorl %ecx, %ecx
cmpq %r14, (%rdx,%rcx,8)
je 0x966f8
incq %rcx
cmpq %rcx, %rax
jne 0x96134
movq %r14, %rdi
jmp 0x9676c
cmpl $0x1, %ecx
jne 0x966ec
movq 0x8(%r14), %rdx
movzbl (%rdx), %eax
leaq 0xbc1db(%rip), %rcx     # 0x152340
movq %rcx, %rbx
cmpb $0x1, (%rax,%rcx)
movq %r12, 0x18(%rsp)
jne 0x964cc
cmpb $0x15, %al
jne 0x96185
testb $0x1, 0x7(%rdx)
jne 0x964cc
movzbl %bpl, %ecx
movq %r12, %rdi
movq %r15, %rsi
callq 0x9606e
movl %eax, %r13d
jmp 0x964cf
movq 0x8(%r14), %rdx
movzbl (%rdx), %eax
leaq 0xbc9d6(%rip), %rcx     # 0x152b80
cmpb $0x0, (%rax,%rcx)
jne 0x961ba
testb $0x40, 0x3(%rdx)
je 0x966ec
movzbl %bpl, %ecx
movq %r12, %rdi
movq %r15, %rsi
callq 0x9606e
testb %al, %al
je 0x966ec
movq 0x8(%r14), %rdi
testb $0x2, 0x2(%rdi)
je 0x9676c
movslq 0xc(%r15), %rax
testq %rax, %rax
jle 0x9676c
movq (%r15), %rdx
xorl %ecx, %ecx
cmpq %rdi, (%rdx,%rcx,8)
je 0x96762
incq %rcx
cmpq %rcx, %rax
jne 0x961f1
jmp 0x9676c
movq 0x10(%r14), %rdx
movzbl (%rdx), %eax
leaq 0xbc12a(%rip), %rbx     # 0x152340
cmpb $0x1, (%rax,%rbx)
jne 0x96469
cmpb $0x15, %al
jne 0x9622e
testb $0x1, 0x7(%rdx)
jne 0x96469
movzbl %bpl, %ecx
movq %r12, %r13
movq %r12, %rdi
movq %r15, %rsi
callq 0x9606e
testb %al, %al
je 0x9646c
movq 0x10(%r14), %rdi
testb $0x2, 0x2(%rdi)
je 0x9679a
movslq 0xc(%r15), %rax
testq %rax, %rax
jle 0x9679a
movq (%r15), %rdx
xorl %ecx, %ecx
cmpq %rdi, (%rdx,%rcx,8)
je 0x9678a
incq %rcx
cmpq %rcx, %rax
jne 0x96268
jmp 0x9679a
movq 0x28(%r14), %rax
cmpq $0x0, 0x18(%rax)
jle 0x966ec
movq 0x18(%r14), %rax
leaq -0x58e6f(%rip), %rcx    # 0x3d42a
cmpq %rcx, %rax
sete %cl
leaq 0x6b8(%rip), %rdx       # 0x9695e
cmpq %rdx, %rax
sete %al
orb %cl, %al
je 0x965ca
xorl %r13d, %r13d
jmp 0x965d9
movq 0x8d8(%r12), %rax
movq 0x8(%r14), %rcx
movq (%rax,%rcx,8), %rcx
movq 0x78(%rcx), %rax
testq %rax, %rax
je 0x966ec
cmpq $0x0, 0x50(%rcx)
je 0x966ec
movq 0x700(%r12), %rcx
movq %r14, 0x8(%rcx)
movq 0x700(%r12), %rsi
movq %r12, %rdi
callq *%rax
movzbl %bpl, %ecx
movq %r12, %rdi
movq %r15, %rsi
movq %rax, %rdx
callq 0x9606e
testb %al, %al
je 0x966ec
testb $0x2, 0x2(%r14)
movq %r14, %rdi
je 0x9676c
movslq 0xc(%r15), %rax
movq %r14, %rdi
testq %rax, %rax
jle 0x9676c
movq (%r15), %rdx
xorl %ecx, %ecx
cmpq %r14, (%rdx,%rcx,8)
je 0x966f8
incq %rcx
cmpq %rcx, %rax
jne 0x9633a
jmp 0x96146
cmpq %r14, 0x150(%r12)
je 0x96413
movq %r14, %rax
movq %r15, %r14
movq $0x0, 0x8(%rsp)
leaq 0xbbfcb(%rip), %rbx     # 0x152340
movzbl %bpl, %ebp
movq %rax, 0x10(%rsp)
movq %rax, %r15
cmpq 0x150(%r12), %r15
je 0x966dc
movq 0x8(%r15), %r13
testq %r13, %r13
je 0x96400
movq 0x10(%r13), %rdx
movzbl (%rdx), %eax
cmpb $0x1, (%rax,%rbx)
jne 0x963f1
cmpb $0x15, %al
jne 0x963af
testb $0x1, 0x7(%rdx)
jne 0x963f1
movq %r12, %rdi
movq %r14, %rsi
movl %ebp, %ecx
callq 0x9606e
testb %al, %al
je 0x963f1
movq 0x10(%r13), %rax
movzbl (%rax), %eax
cmpq $0x21, %rax
ja 0x963f7
movb $0x1, %cl
movq %rcx, 0x8(%rsp)
movabsq $0x220100000, %rcx      # imm = 0x220100000
btq %rax, %rcx
jae 0x963f1
movq 0x10(%rsp), %rdi
movq %r14, %rsi
callq 0x967a9
movq 0x18(%r13), %r13
jmp 0x96393
movb $0x1, %al
movq %rax, 0x8(%rsp)
jmp 0x963f1
movq 0x10(%r15), %r15
cmpb $0x1c, (%r15)
je 0x96381
jmp 0x966dc
movzbl %bpl, %ecx
movq %r12, %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0x96874
jmp 0x9645c
movq 0x10(%r14), %rdx
movzbl (%rdx), %eax
leaq 0xbbf0b(%rip), %rcx     # 0x152340
cmpb $0x1, (%rax,%rcx)
jne 0x966ec
cmpb $0x15, %al
jne 0x9644d
testb $0x1, 0x7(%rdx)
jne 0x966ec
movzbl %bpl, %ecx
movq %r12, %rdi
movq %r15, %rsi
callq 0x9606e
testb %al, %al
je 0x966ec
jmp 0x96774
movq %r12, %r13
xorl %edx, %edx
movq %rdx, 0x8(%rsp)
movq 0x18(%r14), %rdx
movzbl (%rdx), %eax
cmpb $0x1, (%rax,%rbx)
movq %r14, 0x10(%rsp)
jne 0x966dc
cmpb $0x15, %al
jne 0x96497
testb $0x1, 0x7(%rdx)
jne 0x966dc
movzbl %bpl, %ecx
movq %r13, %rdi
movq %r15, %rbx
movq %r15, %rsi
callq 0x9606e
testb %al, %al
je 0x966dc
movq 0x10(%rsp), %r14
movq 0x18(%r14), %rdi
testb $0x2, 0x2(%rdi)
jne 0x96741
movq %rbx, %r15
jmp 0x9676c
xorl %r13d, %r13d
movq 0x10(%r14), %r12
movb (%r12), %al
cmpb $0x1, %al
jne 0x9656f
movzbl %bpl, %eax
movl %eax, 0x8(%rsp)
movq (%r12), %rax
testl $0xa0000, %eax          # imm = 0xA0000
jne 0x96707
orq $0x20000, %rax          # imm = 0x20000
movq %rax, (%r12)
movl 0xc(%r15), %eax
cmpl 0x8(%r15), %eax
jne 0x96516
movq %r15, %rdi
callq 0x967fa
movl 0xc(%r15), %eax
movq (%r15), %rcx
leal 0x1(%rax), %edx
movl %edx, 0xc(%r15)
cltq
movq %r12, (%rcx,%rax,8)
movq 0x8(%r12), %rdx
movzbl (%rdx), %eax
cmpb $0x1, (%rax,%rbx)
jne 0x9655e
cmpb $0x15, %al
jne 0x9653e
testb $0x1, 0x7(%rdx)
jne 0x9655e
movq 0x18(%rsp), %rdi
movq %r15, %rsi
movl 0x8(%rsp), %ecx
callq 0x9606e
movzbl %r13b, %r13d
testb %al, %al
movl $0x1, %eax
cmovnel %eax, %r13d
movq 0x10(%r12), %r12
movb (%r12), %al
cmpb $0x1, %al
je 0x964e7
movzbl %al, %ecx
cmpb $0x1, (%rcx,%rbx)
jne 0x965a0
cmpb $0x15, %al
jne 0x96584
testb $0x1, 0x7(%r12)
jne 0x965a0
movzbl %bpl, %ecx
movq 0x18(%rsp), %rdi
movq %r15, %rsi
movq %r12, %rdx
callq 0x9606e
testb %al, %al
jne 0x96774
testb $0x1, %r13b
jne 0x96774
cmpb $0x1, (%r14)
jne 0x966f1
xorl %eax, %eax
orb $0x8, 0x2(%r14)
movq 0x10(%r14), %r14
cmpb $0x1, (%r14)
je 0x965b6
jmp 0x9677b
leaq 0xb469f(%rip), %rax     # 0x14ac70
cmpq %rax, 0x20(%r14)
sete %r13b
movq 0x8(%r14), %rax
movq %rax, 0x28(%rsp)
testq %rax, %rax
js 0x966ec
movq %r14, 0x10(%rsp)
movq 0x10(%r14), %rax
movq %rax, 0x20(%rsp)
movq $0x0, 0x8(%rsp)
leaq 0xbbd37(%rip), %rbx     # 0x152340
movzbl %bpl, %ebp
xorl %ecx, %ecx
movq 0x20(%rsp), %rax
movq %rcx, 0x30(%rsp)
movq (%rax,%rcx,8), %r14
testq %r14, %r14
je 0x966c5
testb %r13b, %r13b
jne 0x9665a
movq (%r14), %rdx
movzbl (%rdx), %eax
cmpb $0x1, (%rax,%rbx)
jne 0x9665a
cmpb $0x15, %al
jne 0x96641
testb $0x1, 0x7(%rdx)
jne 0x9665a
movq %r12, %rdi
movq %r15, %rsi
movl %ebp, %ecx
callq 0x9606e
movq 0x8(%rsp), %rcx
orb %al, %cl
movq %rcx, 0x8(%rsp)
movq 0x20(%r14), %rdx
movzbl (%rdx), %eax
cmpb $0x1, (%rax,%rbx)
jne 0x966b3
cmpb $0x15, %al
jne 0x96671
testb $0x1, 0x7(%rdx)
jne 0x966b3
movq %r12, %rdi
movq %r15, %rsi
movl %ebp, %ecx
callq 0x9606e
testb %al, %al
je 0x966b3
movq 0x20(%r14), %rax
movzbl (%rax), %eax
cmpq $0x21, %rax
ja 0x966bc
movb $0x1, %cl
movq %rcx, 0x8(%rsp)
movabsq $0x220100000, %rcx      # imm = 0x220100000
btq %rax, %rcx
jae 0x966b3
movq 0x10(%rsp), %rdi
movq %r15, %rsi
callq 0x967a9
movq 0x18(%r14), %r14
jmp 0x9661d
movb $0x1, %al
movq %rax, 0x8(%rsp)
jmp 0x966b3
movq 0x30(%rsp), %rcx
leaq 0x1(%rcx), %rax
cmpq 0x28(%rsp), %rcx
movq %rax, %rcx
jne 0x9660f
testb $0x1, 0x8(%rsp)
movq 0x10(%rsp), %r14
jne 0x96774
orb $0x8, 0x2(%r14)
xorl %eax, %eax
jmp 0x9677b
movq 0x20(%r15), %rax
cmpl $0x0, (%rax,%rcx,4)
movq %r14, %rdi
jne 0x96774
jmp 0x9676c
orb $0x20, 0x6(%r14)
orb $0x20, 0x6(%r12)
testb $0x8, 0x2(%r12)
jne 0x96722
movq %r12, %rdi
jmp 0x96099
movb $0x1, %al
testb $0x1, %r13b
jne 0x9677b
cmpq %r14, %r12
je 0x966f1
xorl %eax, %eax
orb $0x8, 0x2(%r14)
movq 0x10(%r14), %r14
cmpq %r12, %r14
jne 0x96731
jmp 0x9677b
movq %rbx, %r15
movslq 0xc(%rbx), %rax
testq %rax, %rax
jle 0x9676c
movq (%r15), %rdx
xorl %ecx, %ecx
cmpq %rdi, (%rdx,%rcx,8)
je 0x96762
incq %rcx
cmpq %rcx, %rax
jne 0x96752
jmp 0x9676c
movq 0x20(%r15), %rax
cmpl $0x0, (%rax,%rcx,4)
jne 0x96774
movq %r15, %rsi
callq 0x967a9
orb $0x20, 0x6(%r14)
movb $0x1, %al
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x20(%r15), %rax
movb $0x1, %dl
cmpl $0x0, (%rax,%rcx,4)
jne 0x9646e
movq %r15, %rsi
callq 0x967a9
movb $0x1, %dl
jmp 0x9646e