// File: /workspace/github_c_makefile_star2_O1/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 $0x28, %rsp
movq %rdx, %rbx
movq %rsi, %r14
movq (%rdx), %rax
testl $0xa0000, %eax          # imm = 0xA0000
je 0x9c787
btl $0x13, %eax
jb 0x9cedf
movq %rbx, %rdi
movq %r14, %rsi
callq 0x9cef8
jmp 0x9ced1
movl %ecx, %ebp
movq %rdi, %r15
orq $0x20000, %rax          # imm = 0x20000
movq %rax, (%rbx)
movl 0xc(%r14), %eax
cmpl 0x8(%r14), %eax
jne 0x9c7a7
movq %r14, %rdi
callq 0x9cf49
movq %r15, 0x10(%rsp)
movq (%r14), %rax
movslq 0xc(%r14), %rcx
leal 0x1(%rcx), %edx
movq %r14, (%rsp)
movl %edx, 0xc(%r14)
movq %rbx, (%rax,%rcx,8)
movq %rbx, 0x8(%rsp)
movzbl (%rbx), %eax
xorl %r12d, %r12d
leal -0x14(%rax), %ecx
cmpl $0x15, %ecx
ja 0x9c848
leaq 0x747dc(%rip), %rax     # 0x110fb8
movslq (%rax,%rcx,4), %rcx
addq %rax, %rcx
jmpq *%rcx
movq 0x8(%rsp), %rbx
movq 0x10(%rbx), %rdx
movzbl %bpl, %ecx
movq 0x10(%rsp), %rdi
movq (%rsp), %rsi
callq 0x9c74f
testb %al, %al
je 0x9cda8
testb $0x2, 0x2(%rbx)
je 0x9cdc5
movq (%rsp), %rax
movslq 0xc(%rax), %rax
testq %rax, %rax
jle 0x9cdc5
movq (%rsp), %rcx
movq (%rcx), %rdx
xorl %ecx, %ecx
movq 0x8(%rsp), %rsi
cmpq %rsi, (%rdx,%rcx,8)
je 0x9cdb0
incq %rcx
cmpq %rcx, %rax
jne 0x9c831
jmp 0x9cdc5
cmpl $0x1, %eax
jne 0x9cec2
movq 0x8(%rsp), %r15
movq 0x8(%r15), %rdx
movzbl (%rdx), %eax
leaq 0xbdadc(%rip), %rbx     # 0x15a340
cmpb $0x1, (%rax,%rbx)
jne 0x9cb9d
cmpb $0x15, %al
jne 0x9c87c
testb $0x1, 0x7(%rdx)
jne 0x9cb9d
movzbl %bpl, %ecx
movq 0x10(%rsp), %rdi
movq (%rsp), %rsi
callq 0x9c74f
movl %eax, %r12d
jmp 0x9cba0
movq 0x8(%rsp), %rbx
movq 0x8(%rbx), %rdx
movzbl (%rdx), %eax
leaq 0xbe2d7(%rip), %rcx     # 0x15ab80
cmpb $0x0, (%rax,%rcx)
jne 0x9c8b9
testb $0x40, 0x3(%rdx)
je 0x9cda8
movzbl %bpl, %ecx
movq 0x10(%rsp), %rdi
movq (%rsp), %rsi
callq 0x9c74f
testb %al, %al
je 0x9cda8
movq 0x8(%rbx), %rdi
testb $0x2, 0x2(%rdi)
je 0x9cdca
movq (%rsp), %rax
movslq 0xc(%rax), %rax
testq %rax, %rax
jle 0x9cdca
movq (%rsp), %rcx
movq (%rcx), %rdx
xorl %ecx, %ecx
cmpq %rdi, (%rdx,%rcx,8)
je 0x9cead
incq %rcx
cmpq %rcx, %rax
jne 0x9c8fb
jmp 0x9cdca
movq 0x8(%rsp), %r14
movq 0x10(%r14), %rdx
movzbl (%rdx), %eax
leaq 0xbda1b(%rip), %rbx     # 0x15a340
cmpb $0x1, (%rax,%rbx)
jne 0x9cb8c
cmpb $0x15, %al
movq (%rsp), %r15
jne 0x9c941
testb $0x1, 0x7(%rdx)
jne 0x9cdfd
movzbl %bpl, %ecx
movq 0x10(%rsp), %r13
movq %r13, %rdi
movq %r15, %rsi
callq 0x9c74f
testb %al, %al
je 0x9cdf8
movq 0x10(%r14), %rdi
testb $0x2, 0x2(%rdi)
je 0x9ce38
movslq 0xc(%r15), %rax
testq %rax, %rax
jle 0x9ce38
movq (%r15), %rdx
xorl %ecx, %ecx
cmpq %rdi, (%rdx,%rcx,8)
je 0x9ce2b
incq %rcx
cmpq %rcx, %rax
jne 0x9c97d
jmp 0x9ce38
movq 0x8(%rsp), %rsi
movq 0x28(%rsi), %rax
cmpq $0x0, 0x18(%rax)
jle 0x9cda8
movq 0x18(%rsi), %rax
leaq -0x5cfa2(%rip), %rcx    # 0x3fa11
cmpq %rcx, %rax
sete %cl
leaq 0x6ed(%rip), %rdx       # 0x9d0ad
cmpq %rdx, %rax
sete %al
orb %cl, %al
je 0x9cca8
xorl %r13d, %r13d
jmp 0x9ccb7
movq 0x10(%rsp), %r14
movq 0x8d8(%r14), %rax
movq 0x8(%rsp), %rbx
movq 0x8(%rbx), %rcx
movq (%rax,%rcx,8), %rcx
movq 0x78(%rcx), %rax
testq %rax, %rax
je 0x9cda8
cmpq $0x0, 0x50(%rcx)
je 0x9cda8
movq 0x700(%r14), %rcx
movq %rbx, 0x8(%rcx)
movq 0x700(%r14), %rsi
movq %r14, %rdi
callq *%rax
movzbl %bpl, %ecx
movq %r14, %rdi
movq (%rsp), %rsi
movq %rax, %rdx
callq 0x9c74f
testb %al, %al
je 0x9cda8
testb $0x2, 0x2(%rbx)
je 0x9cdc5
movq (%rsp), %rax
movslq 0xc(%rax), %rax
testq %rax, %rax
jle 0x9cdc5
movq (%rsp), %rcx
movq (%rcx), %rdx
xorl %ecx, %ecx
movq 0x8(%rsp), %rsi
cmpq %rsi, (%rdx,%rcx,8)
je 0x9cdb0
incq %rcx
cmpq %rcx, %rax
jne 0x9ca62
jmp 0x9cdc5
movq 0x8(%rsp), %rdx
movq 0x10(%rsp), %rdi
cmpq %rdx, 0x150(%rdi)
je 0x9cc93
cmpb $0x1c, (%rdx)
jne 0x9cda8
xorl %r12d, %r12d
leaq 0xbd89d(%rip), %rbx     # 0x15a340
movzbl %bpl, %ebp
movabsq $0x220100000, %r14      # imm = 0x220100000
movq %rdx, %r15
movq 0x10(%rsp), %rax
cmpq 0x150(%rax), %r15
je 0x9cec2
movq 0x8(%r15), %r13
testq %r13, %r13
je 0x9cb24
movq 0x10(%r13), %rdx
movzbl (%rdx), %eax
cmpb $0x1, (%rax,%rbx)
jne 0x9cb1e
cmpb $0x15, %al
jne 0x9cae6
testb $0x1, 0x7(%rdx)
jne 0x9cb1e
movq 0x10(%rsp), %rdi
movq (%rsp), %rsi
movl %ebp, %ecx
callq 0x9c74f
testb %al, %al
je 0x9cb1e
movq 0x10(%r13), %rax
movzbl (%rax), %eax
movb $0x1, %r12b
cmpq $0x21, %rax
ja 0x9cb1e
btq %rax, %r14
jae 0x9cb1e
movq 0x8(%rsp), %rdi
movq (%rsp), %rsi
callq 0x9cef8
movq 0x18(%r13), %r13
jmp 0x9caca
movq 0x10(%r15), %r15
cmpb $0x1c, (%r15)
je 0x9cab4
jmp 0x9cec2
movzbl %bpl, %ecx
movq 0x10(%rsp), %rdi
movq (%rsp), %rsi
movq 0x8(%rsp), %rdx
jmp 0x9cc9b
movq 0x8(%rsp), %rax
movq 0x10(%rax), %rdx
movzbl (%rdx), %eax
leaq 0xbd7e3(%rip), %rcx     # 0x15a340
cmpb $0x1, (%rax,%rcx)
jne 0x9cda8
cmpb $0x15, %al
jne 0x9cb75
testb $0x1, 0x7(%rdx)
jne 0x9cda8
movzbl %bpl, %ecx
movq 0x10(%rsp), %rdi
movq (%rsp), %rsi
callq 0x9c74f
jmp 0x9cca0
xorl %r12d, %r12d
movq (%rsp), %r15
movq 0x10(%rsp), %r13
jmp 0x9ce43
xorl %r12d, %r12d
movq 0x10(%r15), %r13
movb (%r13), %al
cmpb $0x1, %al
jne 0x9cc41
movzbl %bpl, %eax
movl %eax, 0x18(%rsp)
movq (%rsp), %r14
movq (%r13), %rax
testl $0xa0000, %eax          # imm = 0xA0000
jne 0x9cddb
orq $0x20000, %rax          # imm = 0x20000
movq %rax, (%r13)
movl 0xc(%r14), %eax
cmpl 0x8(%r14), %eax
jne 0x9cbe7
movq %r14, %rdi
callq 0x9cf49
movq (%r14), %rax
movslq 0xc(%r14), %rcx
leal 0x1(%rcx), %edx
movl %edx, 0xc(%r14)
movq %r13, (%rax,%rcx,8)
movq 0x8(%r13), %rdx
movzbl (%rdx), %eax
cmpb $0x1, (%rax,%rbx)
jne 0x9cc31
cmpb $0x15, %al
jne 0x9cc10
testb $0x1, 0x7(%rdx)
jne 0x9cc31
movq 0x10(%rsp), %rdi
movq (%rsp), %rsi
movl 0x18(%rsp), %ecx
callq 0x9c74f
movzbl %r12b, %r12d
testb %al, %al
movl $0x1, %eax
cmovnel %eax, %r12d
movq 0x10(%r13), %r13
movb (%r13), %al
cmpb $0x1, %al
je 0x9cbbc
movzbl %al, %ecx
cmpb $0x1, (%rcx,%rbx)
jne 0x9cc6e
cmpb $0x15, %al
jne 0x9cc55
testb $0x1, 0x7(%r13)
jne 0x9cc6e
movzbl %bpl, %ecx
movq 0x10(%rsp), %rdi
movq (%rsp), %rsi
movq %r13, %rdx
callq 0x9c74f
testb %al, %al
jne 0x9cc74
testb $0x1, %r12b
je 0x9cc7e
orb $0x20, 0x6(%r15)
jmp 0x9ced1
cmpb $0x1, (%r15)
jne 0x9cee2
orb $0x8, 0x2(%r15)
movq 0x10(%r15), %r15
jmp 0x9cc7e
movzbl %bpl, %ecx
movq (%rsp), %rsi
callq 0x9cfc3
movl %eax, %r12d
jmp 0x9cec2
leaq 0xb5fc1(%rip), %rax     # 0x152c70
cmpq %rax, 0x20(%rsi)
sete %r13b
movq 0x8(%rsi), %rax
movq %rax, 0x18(%rsp)
testq %rax, %rax
js 0x9cda8
movq 0x10(%rsi), %rax
movq %rax, 0x20(%rsp)
xorl %r12d, %r12d
leaq 0xbd664(%rip), %rbx     # 0x15a340
movzbl %bpl, %ebp
xorl %r15d, %r15d
movq 0x20(%rsp), %rax
movq (%rax,%r15,8), %r14
testq %r14, %r14
je 0x9cd91
testb %r13b, %r13b
jne 0x9cd2f
movq (%r14), %rdx
movzbl (%rdx), %eax
cmpb $0x1, (%rax,%rbx)
jne 0x9cd2f
cmpb $0x15, %al
jne 0x9cd10
testb $0x1, 0x7(%rdx)
jne 0x9cd2f
movq 0x10(%rsp), %rdi
movq (%rsp), %rsi
movl %ebp, %ecx
callq 0x9c74f
movzbl %r12b, %r12d
testb %al, %al
movl $0x1, %eax
cmovnel %eax, %r12d
movq 0x20(%r14), %rdx
movzbl (%rdx), %eax
cmpb $0x1, (%rax,%rbx)
jne 0x9cd88
cmpb $0x15, %al
jne 0x9cd46
testb $0x1, 0x7(%rdx)
jne 0x9cd88
movq 0x10(%rsp), %rdi
movq (%rsp), %rsi
movl %ebp, %ecx
callq 0x9c74f
testb %al, %al
je 0x9cd88
movq 0x20(%r14), %rax
movzbl (%rax), %eax
movb $0x1, %r12b
cmpq $0x21, %rax
ja 0x9cd88
movabsq $0x220100000, %rcx      # imm = 0x220100000
btq %rax, %rcx
jae 0x9cd88
movq 0x8(%rsp), %rdi
movq (%rsp), %rsi
callq 0x9cef8
movq 0x18(%r14), %r14
jmp 0x9ccec
leaq 0x1(%r15), %rax
cmpq 0x18(%rsp), %r15
movq %rax, %r15
jne 0x9cce3
jmp 0x9cec2
xorl %r12d, %r12d
jmp 0x9cec2
movq (%rsp), %rax
movq 0x20(%rax), %rax
movb $0x1, %r12b
cmpl $0x0, (%rax,%rcx,4)
jne 0x9cec2
movq 0x8(%rsp), %rdi
movq (%rsp), %rsi
callq 0x9cef8
movb $0x1, %r12b
jmp 0x9cec2
orb $0x20, 0x6(%r15)
orb $0x20, 0x6(%r13)
testb $0x8, 0x2(%r13)
jne 0x9ce05
movq %r13, %rdi
movq (%rsp), %rsi
jmp 0x9c77d
xorl %r12d, %r12d
jmp 0x9ce43
xorl %r12d, %r12d
jmp 0x9cb93
cmpq %r15, %r13
je 0x9cee2
testb $0x1, %r12b
jne 0x9cee2
orb $0x8, 0x2(%r15)
movq 0x10(%r15), %r15
cmpq %r13, %r15
jne 0x9ce18
jmp 0x9cee2
movq 0x20(%r15), %rax
movb $0x1, %r12b
cmpl $0x0, (%rax,%rcx,4)
jne 0x9ce43
movq %r15, %rsi
callq 0x9cef8
movb $0x1, %r12b
movq 0x18(%r14), %rdx
movzbl (%rdx), %eax
cmpb $0x1, (%rax,%rbx)
jne 0x9cec2
cmpb $0x15, %al
jne 0x9ce5a
testb $0x1, 0x7(%rdx)
jne 0x9cec2
movzbl %bpl, %ecx
movq %r13, %rdi
movq %r15, %rsi
callq 0x9c74f
testb %al, %al
je 0x9cec2
movq 0x8(%rsp), %rax
movq 0x18(%rax), %rdi
testb $0x2, 0x2(%rdi)
je 0x9cdca
movq (%rsp), %rax
movslq 0xc(%rax), %rax
testq %rax, %rax
jle 0x9cdca
movq (%rsp), %rcx
movq (%rcx), %rdx
xorl %ecx, %ecx
cmpq %rdi, (%rdx,%rcx,8)
je 0x9cead
incq %rcx
cmpq %rcx, %rax
jne 0x9ce9a
jmp 0x9cdca
movq (%rsp), %rax
movq 0x20(%rax), %rax
movb $0x1, %r12b
cmpl $0x0, (%rax,%rcx,4)
je 0x9cdca
testb $0x1, %r12b
je 0x9ced6
movq 0x8(%rsp), %rax
orb $0x20, 0x6(%rax)
movb $0x1, %r12b
jmp 0x9cee2
movq 0x8(%rsp), %rax
orb $0x8, 0x2(%rax)
xorl %r12d, %r12d
andb $0x1, %r12b
movl %r12d, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq