// File: /workspace/github_c_makefile_star2_O3/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 %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl %edx, %ebp
movq %rsi, %rbx
movq %rdi, %r14
movzbl (%rsi), %eax
cmpq $0x1, %rax
jne 0x95d0e
testb %bpl, %bpl
je 0x95d80
movq 0x280(%r14), %rcx
movq %rbx, %rax
testq %rcx, %rcx
jle 0x95dbc
xorl %edx, %edx
leaq 0xbc6b5(%rip), %rsi     # 0x152340
movq %rbx, %rdi
movq %rbx, %rax
cmpb $0x1, (%rax)
jne 0x95dbc
movq 0x8(%rax), %r8
movzbl (%r8), %r9d
cmpb $0x1, (%r9,%rsi)
jne 0x95cbe
cmpb $0x15, %r9b
jne 0x95dec
testb $0x1, 0x7(%r8)
je 0x95dec
movq 0x10(%rax), %rax
cmpb $0x1, (%rax)
jne 0x95dbc
movq 0x8(%rax), %r8
movzbl (%r8), %r9d
cmpb $0x1, (%r9,%rsi)
jne 0x95cef
cmpb $0x15, %r9b
jne 0x95dec
testb $0x1, 0x7(%r8)
je 0x95dec
movq 0x10(%rax), %rax
movq 0x10(%rdi), %rdi
cmpq %rdi, %rax
je 0x95dec
addq $0x2, %rdx
cmpq %rcx, %rdx
jl 0x95c91
jmp 0x95dbc
leaq 0xb4f0b(%rip), %rcx     # 0x14ac20
cmpb $0x1, (%rax,%rcx)
jne 0x95dec
cmpl $0x15, %eax
jne 0x95f77
movq 0x8(%rbx), %rax
testb %bpl, %bpl
je 0x95d3f
movq 0x280(%r14), %rcx
cmpq %rcx, %rax
cmovgeq %rcx, %rax
testq %rax, %rax
jle 0x95f77
movq 0x10(%rbx), %rcx
xorl %r15d, %r15d
leaq 0xbc5ea(%rip), %rdx     # 0x152340
xorl %esi, %esi
movq (%rcx,%rsi,8), %rdi
movzbl (%rdi), %r8d
cmpb $0x1, (%r8,%rdx)
jne 0x95d73
cmpb $0x15, %r8b
jne 0x95dec
testb $0x1, 0x7(%rdi)
je 0x95dec
incq %rsi
cmpq %rsi, %rax
jne 0x95d58
jmp 0x95f7a
movq %r14, %rdi
movq %rbx, %rsi
callq 0x39d0d
testq %rax, %rax
je 0x95dec
leaq 0xbc5a9(%rip), %rcx     # 0x152340
movq %rbx, %rax
movq 0x8(%rax), %rdx
movzbl (%rdx), %esi
cmpb $0x1, (%rsi,%rcx)
jne 0x95db3
cmpb $0x15, %sil
jne 0x95dec
testb $0x1, 0x7(%rdx)
je 0x95dec
movq 0x10(%rax), %rax
cmpb $0x1, (%rax)
je 0x95d9a
cmpq 0x110(%r14), %rax
je 0x95f77
movzbl (%rax), %ecx
leaq 0xbc56d(%rip), %rdx     # 0x152340
cmpb $0x1, (%rcx,%rdx)
jne 0x95f77
cmpb $0x15, %cl
jne 0x95dec
testb $0x1, 0x7(%rax)
jne 0x95f77
movq 0x6c0(%r14), %r15
movslq 0xc(%r15), %r12
testq %r12, %r12
jle 0x95ec2
movq %r14, 0x10(%rsp)
movl %ebp, 0xc(%rsp)
movq 0x20(%r15), %r13
movq %r12, %r14
shlq $0x2, %r14
cmpl $0x1, %r12d
je 0x95e3d
movabsq $0x1fffffff8, %rbp      # imm = 0x1FFFFFFF8
andq %r14, %rbp
movq %r13, %rdi
xorl %esi, %esi
movq %rbp, %rdx
callq 0x8270
andq $0x4, %r14
je 0x95e4e
addq %rbp, %r13
movq %r13, %rdi
xorl %esi, %esi
movq %r14, %rdx
callq 0x8270
movl 0xc(%r15), %r12d
movq 0x48(%r15), %r13
movslq %r12d, %rbp
cmpl $0x8, %ebp
jb 0x95e74
movq %rbp, %r14
andq $-0x8, %r14
movq %r13, %rdi
xorl %esi, %esi
movq %r14, %rdx
callq 0x8270
addq %r14, %r13
andl $0x7, %ebp
movq 0x10(%rsp), %r14
testq %rbp, %rbp
je 0x95e8f
movq %r13, %rdi
xorl %esi, %esi
movq %rbp, %rdx
callq 0x8270
movl 0xc(%r15), %r12d
testl %r12d, %r12d
jle 0x95eb6
xorl %eax, %eax
movabsq $-0x600000000a0001, %rcx # imm = 0xFF9FFFFFFFF5FFFF
movq (%r15), %rdx
movq (%rdx,%rax,8), %rdx
andq %rcx, (%rdx)
incq %rax
movslq 0xc(%r15), %rdx
cmpq %rdx, %rax
jl 0x95ea0
movl $0x0, 0xc(%r15)
movl 0xc(%rsp), %ebp
movl $0x0, 0x10(%r15)
movb $0x0, 0x18(%r15)
movzbl %bpl, %ecx
movq %r14, %rdi
movq %r15, %rsi
movq %rbx, %rdx
callq 0x9606e
movq (%r15), %rcx
cmpl $0x0, 0xc(%r15)
jle 0x95f0b
xorl %edx, %edx
movq (%rcx,%rdx,8), %rsi
andq $-0xa0001, (%rsi)       # imm = 0xFFF5FFFF
incq %rdx
movslq 0xc(%r15), %rsi
cmpq %rsi, %rdx
jl 0x95eed
testl %esi, %esi
setg %dl
jmp 0x95f0d
xorl %edx, %edx
testb %al, %al
je 0x95f77
xorl %eax, %eax
cmpb $0x1, 0x18(%r15)
jne 0x95f77
testb %dl, %dl
je 0x95f71
movq 0x20(%r15), %rdx
xorl %esi, %esi
xorl %eax, %eax
cmpl $0x0, (%rdx,%rsi,4)
jle 0x95f65
movq (%rcx,%rsi,8), %rdi
orq $0x20000, (%rdi)        # imm = 0x20000
movl %eax, %edi
cmpq %rdi, %rsi
jne 0x95f42
incl %eax
jmp 0x95f65
movq (%rcx,%rsi,8), %rdi
movslq %eax, %r8
movq %rdi, (%rcx,%r8,8)
movl (%rdx,%rsi,4), %edi
incl %eax
movl %edi, (%rdx,%r8,4)
movl $0x0, (%rdx,%rsi,4)
movq $0x0, (%rcx,%rsi,8)
incq %rsi
movslq 0xc(%r15), %rdi
cmpq %rdi, %rsi
jl 0x95f26
movl %eax, 0xc(%r15)
jmp 0x95f7a
xorl %r15d, %r15d
movq %r15, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq