// File: /workspace/github_c_makefile_star2_O2/BernardTatin[P]s7sh/s7.c
// Function: make_shared_info
static shared_info *make_shared_info(s7_scheme *sc, s7_pointer top, bool stop_at_print_length)
    {
        /* for the printer */
        shared_info *ci;
        int32_t i, refs;
        s7_pointer *ci_objs;
        int32_t *ci_refs;
        bool no_problem = true, cyclic = false;
        s7_int k, stop_len;

        /* check for simple cases first */
        if (is_pair(top))
        {
            s7_pointer x;
            x = top;
            if (stop_at_print_length)
            {
                s7_pointer slow;
                stop_len = sc->print_length;
                slow = top;
                for (k = 0; k < stop_len; k += 2)
                {
                    if (!is_pair(x))
                        break;
                    if (has_structure(car(x)))
                    {
                        no_problem = false;
                        break;
                    }
                    x = cdr(x);
                    if (!is_pair(x))
                        break;
                    if (has_structure(car(x)))
                    {
                        no_problem = false;
                        break;
                    }
                    x = cdr(x);
                    slow = cdr(slow);
                    if (x == slow)
                    {
                        no_problem = false;
                        break;
                    }
                }
            }
            else
            {
                if (s7_list_length(sc, top) == 0) /* it is circular at the top level (following cdr) */
                    no_problem = false;
                else
                {
                    for (; is_pair(x); x = cdr(x))
                        if (has_structure(car(x)))
                        {
                            /* it can help a little in some cases to scan vectors here (and slots):
                             *   if no element has structure, it's ok (maybe also hash_table_entries == 0)
                             */
                            no_problem = false;
                            break;
                        }
                }
            }
            if ((no_problem) &&
                    (!is_null(x)) &&
                    (has_structure(x)))
                no_problem = false;

            if (no_problem)
                return(NULL);
        }
        else
        {
            if (is_any_vector(top))
            {
                if (!is_normal_vector(top))
                    return(NULL);

                stop_len = vector_length(top);
                if ((stop_at_print_length) &&
                        (stop_len > sc->print_length))
                    stop_len = sc->print_length;

                for (k = 0; k < stop_len; k++)
                    if (has_structure(vector_element(top, k)))
                    {
                        no_problem = false;
                        break;
                    }
                if (no_problem)
                    return(NULL);
            }
        }

        ci = new_shared_info(sc);

        /* collect all pointers associated with top */
        cyclic = collect_shared_info(sc, ci, top, stop_at_print_length);

        ci_objs = ci->objs;
        for (i = 0; i < ci->top; i++)
            clear_collected_and_shared(ci_objs[i]);

        if (!cyclic)
            return(NULL);

        if (!(ci->has_hits))
            return(NULL);

        ci_refs = ci->refs;
        /* find if any were referenced twice (once for just being there, so twice=shared)
         *   we know there's at least one such reference because has_hits is true.
         */
        for (i = 0, refs = 0; i < ci->top; i++)
            if (ci_refs[i] > 0)
            {
                set_collected(ci_objs[i]);
                if (i == refs)
                    refs++;
                else
                {
                    ci_objs[refs] = ci_objs[i];
                    ci_refs[refs++] = ci_refs[i];
                    ci_refs[i] = 0;
                    ci_objs[i] = NULL;
                }
            }
        ci->top = refs;
        return(ci);
    }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movl %edx, %ebp
movq %rsi, %rbx
movq %rdi, %r14
movzbl (%rsi), %eax
cmpq $0x1, %rax
jne 0x77ae5
testb %bpl, %bpl
je 0x77b54
movq 0x280(%r14), %rcx
pushq $-0x2
popq %rdx
leaq 0xa98de(%rip), %rsi     # 0x121340
movq %rbx, %rax
movq %rbx, %rdi
addq $0x2, %rdx
cmpq %rcx, %rdx
jge 0x77b96
cmpb $0x1, (%rax)
jne 0x77b96
movq 0x8(%rax), %r8
movzbl (%r8), %r9d
cmpb $0x1, (%r9,%rsi)
jne 0x77aa2
cmpb $0x15, %r9b
jne 0x77bc6
testb $0x1, 0x7(%r8)
je 0x77bc6
movq 0x10(%rax), %rax
cmpb $0x1, (%rax)
jne 0x77b96
movq 0x8(%rax), %r8
movzbl (%r8), %r9d
cmpb $0x1, (%r9,%rsi)
jne 0x77ad3
cmpb $0x15, %r9b
jne 0x77bc6
testb $0x1, 0x7(%r8)
je 0x77bc6
movq 0x10(%rax), %rax
movq 0x10(%rdi), %rdi
cmpq %rdi, %rax
jne 0x77a68
jmp 0x77bc6
leaq 0xa2134(%rip), %rcx     # 0x119c20
cmpb $0x1, (%rax,%rcx)
jne 0x77bc6
cmpl $0x15, %eax
jne 0x77c5e
movq 0x8(%rbx), %rax
testb %bpl, %bpl
je 0x77b16
movq 0x280(%r14), %rcx
cmpq %rcx, %rax
cmovgeq %rcx, %rax
xorl %r15d, %r15d
testq %rax, %rax
cmovleq %r15, %rax
leaq 0xa9819(%rip), %rcx     # 0x121340
xorl %edx, %edx
cmpq %rdx, %rax
je 0x77c61
movq 0x10(%rbx), %rsi
movq (%rsi,%rdx,8), %rsi
movzbl (%rsi), %edi
cmpb $0x1, (%rdi,%rcx)
jne 0x77b4f
cmpb $0x15, %dil
jne 0x77bc6
testb $0x1, 0x7(%rsi)
je 0x77bc6
incq %rdx
jmp 0x77b29
movq %r14, %rdi
movq %rbx, %rsi
callq 0x2dada
testq %rax, %rax
je 0x77bc6
movb $0x1, %dl
leaq 0xa97d3(%rip), %rcx     # 0x121340
movq %rbx, %rax
cmpb $0x1, %dl
jne 0x77b96
movq 0x8(%rax), %rdx
movzbl (%rdx), %esi
cmpb $0x1, (%rsi,%rcx)
jne 0x77b8e
cmpb $0x15, %sil
jne 0x77bc6
testb $0x1, 0x7(%rdx)
je 0x77bc6
movq 0x10(%rax), %rax
movb (%rax), %dl
jmp 0x77b70
cmpq 0x110(%r14), %rax
je 0x77c5e
movzbl (%rax), %ecx
leaq 0xa9793(%rip), %rdx     # 0x121340
cmpb $0x1, (%rcx,%rdx)
jne 0x77c5e
cmpb $0x15, %cl
jne 0x77bc6
testb $0x1, 0x7(%rax)
jne 0x77c5e
movq %r14, %rdi
callq 0x77cff
movq %rax, %r15
movzbl %bpl, %ecx
movq %r14, %rdi
movq %rax, %rsi
movq %rbx, %rdx
callq 0x77d5f
movq (%r15), %rcx
xorl %edx, %edx
movslq 0xc(%r15), %rdi
cmpq %rdi, %rdx
jge 0x77c01
movq (%rcx,%rdx,8), %rsi
andq $-0xa0001, (%rsi)       # imm = 0xFFF5FFFF
incq %rdx
jmp 0x77be8
testb %al, %al
je 0x77c5e
xorl %eax, %eax
cmpb $0x1, 0x18(%r15)
jne 0x77c5e
movq 0x20(%r15), %rdx
xorl %esi, %esi
movslq %edi, %rdi
cmpq %rdi, %rsi
jge 0x77c6f
cmpl $0x0, (%rdx,%rsi,4)
jle 0x77c55
movq (%rcx,%rsi,8), %rdi
orq $0x20000, (%rdi)        # imm = 0x20000
movl %eax, %edi
cmpq %rdi, %rsi
jne 0x77c38
incl %eax
jmp 0x77c55
movq (%rcx,%rsi,8), %rdi
movslq %eax, %r8
movq %rdi, (%rcx,%r8,8)
movl (%rdx,%rsi,4), %edi
movl %edi, (%rdx,%r8,4)
andl $0x0, (%rdx,%rsi,4)
incl %eax
andq $0x0, (%rcx,%rsi,8)
incq %rsi
movl 0xc(%r15), %edi
jmp 0x77c14
xorl %r15d, %r15d
movq %r15, %rax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
movl %eax, 0xc(%r15)
jmp 0x77c61