// File: /workspace/github_c_makefile_star2_O2/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, %r12
movq %rsi, %r14
movq (%rdx), %rax
testl $0xa0000, %eax          # imm = 0xA0000
je 0x77d97
btl $0x13, %eax
jb 0x78338
movq %r12, %rdi
movq %r14, %rsi
callq 0x783b9
jmp 0x7832e
movl %ecx, %ebp
movq %rdi, %r13
orq $0x20000, %rax          # imm = 0x20000
movq %rax, (%r12)
movl 0xc(%r14), %eax
cmpl 0x8(%r14), %eax
jne 0x77dbc
movq %r14, %rdi
callq 0x78405
movl 0xc(%r14), %eax
movq (%r14), %rcx
leal 0x1(%rax), %edx
movl %edx, 0xc(%r14)
cltq
movq %r12, (%rcx,%rax,8)
movzbl (%r12), %ecx
leal -0x14(%rcx), %eax
cmpl $0x15, %eax
ja 0x77e20
leaq 0x5c238(%rip), %rcx     # 0xd4018
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq 0x10(%r12), %rdx
movzbl %bpl, %ecx
movq %r13, %rdi
movq %r14, %rsi
callq 0x77d5f
testb %al, %al
je 0x78332
movq %r14, %rdi
movq %r12, %rsi
callq 0x7855f
testl %eax, %eax
jne 0x78328
movq %r12, %rdi
jmp 0x78112
cmpl $0x1, %ecx
jne 0x78332
movq 0x8(%r12), %rdx
movzbl (%rdx), %eax
leaq 0xa9508(%rip), %rbx     # 0x121340
cmpb $0x1, (%rax,%rbx)
movq %r13, 0x10(%rsp)
movq %r12, %r15
jne 0x7812d
cmpb $0x15, %al
jne 0x77e58
testb $0x1, 0x7(%rdx)
jne 0x7812d
movzbl %bpl, %ecx
movq %r13, %rdi
movq %r14, %rsi
callq 0x77d5f
movl %eax, %r12d
jmp 0x78130
movq 0x8(%r12), %rdx
movzbl (%rdx), %eax
leaq 0xa9d02(%rip), %rcx     # 0x121b80
cmpb $0x0, (%rax,%rcx)
jne 0x77e8e
testb $0x40, 0x3(%rdx)
je 0x78332
movzbl %bpl, %ecx
movq %r13, %rdi
movq %r14, %rsi
callq 0x77d5f
testb %al, %al
je 0x78332
movq 0x8(%r12), %r15
jmp 0x780fc
movq 0x10(%r12), %rdx
movzbl (%rdx), %eax
leaq 0xa9482(%rip), %rbx     # 0x121340
cmpb $0x1, (%rax,%rbx)
jne 0x780ba
cmpb $0x15, %al
jne 0x77ed6
testb $0x1, 0x7(%rdx)
jne 0x780ba
movzbl %bpl, %ecx
movq %r13, %r15
movq %r13, %rdi
movq %r14, %rsi
callq 0x77d5f
testb %al, %al
je 0x780bd
movq %r12, %r13
movq 0x10(%r12), %r12
movq %r14, %rdi
movq %r12, %rsi
callq 0x7855f
movq %r14, %rsi
testl %eax, %eax
je 0x78361
movq %rsi, %r14
jmp 0x7836c
movq 0x28(%r12), %rax
cmpq $0x0, 0x18(%rax)
jle 0x78332
movq 0x18(%r12), %rax
leaq -0x47a2b(%rip), %rcx    # 0x30507
cmpq %rcx, %rax
sete %cl
leaq 0x62d(%rip), %rdx       # 0x7856c
cmpq %rdx, %rax
sete %al
orb %cl, %al
movq %r13, 0x10(%rsp)
je 0x78227
movq %r12, %rax
xorl %r12d, %r12d
jmp 0x7823a
movq 0x8d8(%r13), %rax
movq 0x8(%r12), %rcx
movq (%rax,%rcx,8), %rcx
movq 0x78(%rcx), %rax
testq %rax, %rax
je 0x78332
cmpq $0x0, 0x50(%rcx)
je 0x78332
movq 0x700(%r13), %rcx
movq %r12, 0x8(%rcx)
movq 0x700(%r13), %rsi
movq %r13, %rdi
callq *%rax
movzbl %bpl, %ecx
movq %r13, %rdi
movq %r14, %rsi
movq %rax, %rdx
jmp 0x77df8
cmpq %r12, 0x150(%r13)
je 0x78063
movb $0x1c, %al
movq $0x0, 0x8(%rsp)
leaq 0xa9373(%rip), %rbx     # 0x121340
movzbl %bpl, %ebp
movq %r12, (%rsp)
cmpb $0x1c, %al
jne 0x7811f
cmpq 0x150(%r13), %r12
je 0x7811f
leaq 0x8(%r12), %r15
movq (%r15), %r15
testq %r15, %r15
je 0x78055
movq 0x10(%r15), %rdx
movzbl (%rdx), %eax
cmpb $0x1, (%rax,%rbx)
jne 0x7804f
cmpb $0x15, %al
jne 0x7800e
testb $0x1, 0x7(%rdx)
jne 0x7804f
movq %r13, %rdi
movq %r14, %rsi
movl %ebp, %ecx
callq 0x77d5f
testb %al, %al
je 0x7804f
movq 0x10(%r15), %rax
movzbl (%rax), %eax
movb $0x1, %cl
movq %rcx, 0x8(%rsp)
cmpq $0x21, %rax
ja 0x7804f
movabsq $0x220100000, %rcx      # imm = 0x220100000
btq %rax, %rcx
jae 0x7804f
movq (%rsp), %rdi
movq %r14, %rsi
callq 0x783b9
addq $0x18, %r15
jmp 0x77fef
movq 0x10(%r12), %r12
movb (%r12), %al
jmp 0x77fd5
movzbl %bpl, %ecx
movq %r13, %rdi
movq %r14, %rsi
movq %r12, %rdx
callq 0x78476
jmp 0x780ad
movq 0x10(%r12), %rdx
movzbl (%rdx), %eax
leaq 0xa92ba(%rip), %rcx     # 0x121340
cmpb $0x1, (%rax,%rcx)
jne 0x78332
cmpb $0x15, %al
jne 0x7809e
testb $0x1, 0x7(%rdx)
jne 0x78332
movzbl %bpl, %ecx
movq %r13, %rdi
movq %r14, %rsi
callq 0x77d5f
testb %al, %al
jne 0x78328
jmp 0x78332
movq %r13, %r15
xorl %r13d, %r13d
movq 0x18(%r12), %rdx
movzbl (%rdx), %eax
cmpb $0x1, (%rax,%rbx)
jne 0x78322
cmpb $0x15, %al
jne 0x780e0
testb $0x1, 0x7(%rdx)
jne 0x78322
movzbl %bpl, %ecx
movq %r15, %rdi
movq %r14, %rsi
callq 0x77d5f
testb %al, %al
je 0x78322
movq 0x18(%r12), %r15
movq %r14, %rdi
movq %r15, %rsi
callq 0x7855f
testl %eax, %eax
jne 0x78328
movq %r15, %rdi
movq %r14, %rsi
callq 0x783b9
jmp 0x78328
movq (%rsp), %r12
movq 0x8(%rsp), %r13
jmp 0x78322
xorl %r12d, %r12d
movzbl %bpl, %ebp
movq %r15, %r13
movq 0x10(%r13), %r13
movzbl (%r13), %eax
cmpq $0x1, %rax
jne 0x781bd
movq (%r13), %rax
testl $0xa0000, %eax          # imm = 0xA0000
jne 0x7820a
orq $0x20000, %rax          # imm = 0x20000
movq %rax, (%r13)
movl 0xc(%r14), %eax
cmpl 0x8(%r14), %eax
jne 0x78175
movq %r14, %rdi
callq 0x78405
movl 0xc(%r14), %eax
movq (%r14), %rcx
leal 0x1(%rax), %edx
movl %edx, 0xc(%r14)
cltq
movq %r13, (%rcx,%rax,8)
movq 0x8(%r13), %rdx
movzbl (%rdx), %eax
cmpb $0x1, (%rax,%rbx)
jne 0x78137
cmpb $0x15, %al
jne 0x7819c
testb $0x1, 0x7(%rdx)
jne 0x78137
movq 0x10(%rsp), %rdi
movq %r14, %rsi
movl %ebp, %ecx
callq 0x77d5f
movzbl %r12b, %r12d
testb %al, %al
pushq $0x1
popq %rax
cmovnel %eax, %r12d
jmp 0x78137
cmpb $0x1, (%rax,%rbx)
jne 0x781e5
cmpl $0x15, %eax
jne 0x781cf
testb $0x1, 0x7(%r13)
jne 0x781e5
movq 0x10(%rsp), %rdi
movq %r14, %rsi
movq %r13, %rdx
movl %ebp, %ecx
callq 0x77d5f
testb %al, %al
jne 0x781eb
testb $0x1, %r12b
je 0x781f5
orb $0x20, 0x6(%r15)
jmp 0x7832e
cmpb $0x1, (%r15)
jne 0x78338
orb $0x8, 0x2(%r15)
movq 0x10(%r15), %r15
jmp 0x781f5
orb $0x20, 0x6(%r15)
orb $0x20, 0x6(%r13)
testb $0x8, 0x2(%r13)
jne 0x78349
movq %r13, %rdi
jmp 0x77d8a
leaq 0xa1a42(%rip), %rax     # 0x119c70
cmpq %rax, 0x20(%r12)
movq %r12, %rax
sete %r12b
movq 0x8(%rax), %rcx
movq %rcx, 0x20(%rsp)
movq %rax, (%rsp)
movq 0x10(%rax), %rax
movq %rax, 0x18(%rsp)
xorl %ecx, %ecx
leaq 0xa90e7(%rip), %rbx     # 0x121340
movzbl %bpl, %ebp
xorl %r13d, %r13d
cmpq 0x20(%rsp), %rcx
jg 0x7831e
movq 0x18(%rsp), %rax
movq %rcx, 0x8(%rsp)
leaq (%rax,%rcx,8), %r15
movq (%r15), %r15
testq %r15, %r15
je 0x78311
testb %r12b, %r12b
jne 0x782b2
movq (%r15), %rdx
movzbl (%rdx), %eax
cmpb $0x1, (%rax,%rbx)
jne 0x782b2
cmpb $0x15, %al
jne 0x782a0
testb $0x1, 0x7(%rdx)
jne 0x782b2
movq 0x10(%rsp), %rdi
movq %r14, %rsi
movl %ebp, %ecx
callq 0x77d5f
orb %al, %r13b
movq 0x20(%r15), %rdx
movzbl (%rdx), %eax
cmpb $0x1, (%rax,%rbx)
jne 0x78308
cmpb $0x15, %al
jne 0x782c9
testb $0x1, 0x7(%rdx)
jne 0x78308
movq 0x10(%rsp), %rdi
movq %r14, %rsi
movl %ebp, %ecx
callq 0x77d5f
testb %al, %al
je 0x78308
movq 0x20(%r15), %rax
movzbl (%rax), %eax
movb $0x1, %r13b
cmpq $0x21, %rax
ja 0x78308
movabsq $0x220100000, %rcx      # imm = 0x220100000
btq %rax, %rcx
jae 0x78308
movq (%rsp), %rdi
movq %r14, %rsi
callq 0x783b9
addq $0x18, %r15
jmp 0x78279
movq 0x8(%rsp), %rcx
incq %rcx
jmp 0x78260
movq (%rsp), %r12
testb $0x1, %r13b
je 0x78332
orb $0x20, 0x6(%r12)
movb $0x1, %al
jmp 0x7833a
orb $0x8, 0x2(%r12)
xorl %eax, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movb $0x1, %al
testb $0x1, %r12b
jne 0x7833a
cmpq %r13, %r15
je 0x78338
orb $0x8, 0x2(%r15)
movq 0x10(%r15), %r15
jmp 0x78351
movq %r12, %rdi
movq %rsi, %r14
callq 0x783b9
movq %r13, %r12
movb $0x1, %r13b
jmp 0x780c0