// File: /workspace/github_c_makefile_star2_O1/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
pushq %rax
movl %edx, %ebp
movq %rsi, %rbx
movq %rdi, %r14
movzbl (%rsi), %eax
cmpq $0x1, %rax
jne 0x9c3dd
testb %bpl, %bpl
je 0x9c457
movq 0x280(%r14), %rdx
movb $0x1, %al
testq %rdx, %rdx
jle 0x9c4a2
xorl %esi, %esi
leaq 0xbdfe6(%rip), %rdi     # 0x15a340
movq %rbx, %r8
movq %rbx, %rcx
cmpb $0x1, (%rcx)
jne 0x9c4a5
movq 0x8(%rcx), %r9
movzbl (%r9), %r10d
cmpb $0x1, (%r10,%rdi)
jne 0x9c38d
cmpb $0x15, %r10b
jne 0x9c49c
testb $0x1, 0x7(%r9)
je 0x9c49c
movq 0x10(%rcx), %rcx
cmpb $0x1, (%rcx)
jne 0x9c4a5
movq 0x8(%rcx), %r9
movzbl (%r9), %r10d
cmpb $0x1, (%r10,%rdi)
jne 0x9c3be
cmpb $0x15, %r10b
jne 0x9c49c
testb $0x1, 0x7(%r9)
je 0x9c49c
movq 0x10(%rcx), %rcx
movq 0x10(%r8), %r8
cmpq %r8, %rcx
je 0x9c49c
addq $0x2, %rsi
cmpq %rdx, %rsi
jl 0x9c360
jmp 0x9c4a5
leaq 0xb683c(%rip), %rcx     # 0x152c20
cmpb $0x1, (%rax,%rcx)
jne 0x9c4d7
cmpl $0x15, %eax
jne 0x9c657
movq 0x8(%rbx), %rax
testb %bpl, %bpl
je 0x9c40e
movq 0x280(%r14), %rcx
cmpq %rcx, %rax
cmovgeq %rcx, %rax
testq %rax, %rax
jle 0x9c657
movq 0x10(%rbx), %rcx
xorl %r15d, %r15d
leaq 0xbdf1b(%rip), %rdx     # 0x15a340
xorl %esi, %esi
movq (%rcx,%rsi,8), %rdi
movzbl (%rdi), %r8d
cmpb $0x1, (%r8,%rdx)
jne 0x9c44a
cmpb $0x15, %r8b
jne 0x9c4d7
testb $0x1, 0x7(%rdi)
je 0x9c4d7
incq %rsi
cmpq %rsi, %rax
jne 0x9c427
jmp 0x9c65a
movq %r14, %rdi
movq %rbx, %rsi
callq 0x3c299
testq %rax, %rax
je 0x9c4a0
movb $0x1, %al
cmpb $0x1, (%rbx)
jne 0x9c4a2
leaq 0xbdecb(%rip), %rdx     # 0x15a340
movq %rbx, %rcx
movq 0x8(%rcx), %rsi
movzbl (%rsi), %edi
cmpb $0x1, (%rdi,%rdx)
jne 0x9c491
cmpb $0x15, %dil
jne 0x9c49c
testb $0x1, 0x7(%rsi)
je 0x9c49c
movq 0x10(%rcx), %rcx
cmpb $0x1, (%rcx)
je 0x9c478
jmp 0x9c4a5
xorl %eax, %eax
jmp 0x9c4a5
xorl %eax, %eax
movq %rbx, %rcx
testb %al, %al
je 0x9c4cf
cmpq 0x110(%r14), %rcx
je 0x9c4cf
movzbl (%rcx), %edx
leaq 0xbde84(%rip), %rsi     # 0x15a340
cmpb $0x1, (%rdx,%rsi)
jne 0x9c4cf
cmpb $0x15, %dl
jne 0x9c4cd
testb $0x1, 0x7(%rcx)
jne 0x9c4cf
xorl %eax, %eax
testb %al, %al
jne 0x9c657
movq 0x6c0(%r14), %r15
movslq 0xc(%r15), %r12
testq %r12, %r12
jle 0x9c5a8
movq %r14, (%rsp)
movl %r12d, %eax
movq 0x20(%r15), %r13
shlq $0x2, %r12
movl %ebp, %r14d
cmpl $0x1, %eax
je 0x9c523
movabsq $0x1fffffff8, %rbp      # imm = 0x1FFFFFFF8
andq %r12, %rbp
movq %r13, %rdi
xorl %esi, %esi
movq %rbp, %rdx
callq 0x9270
addq %rbp, %r13
andl $0x4, %r12d
testq %r12, %r12
je 0x9c535
movq %r13, %rdi
xorl %esi, %esi
movq %r12, %rdx
callq 0x9270
movq 0x48(%r15), %r13
movslq 0xc(%r15), %r12
cmpq $0x8, %r12
jb 0x9c55e
movq %r12, %rbp
andq $-0x8, %rbp
movq %r13, %rdi
xorl %esi, %esi
movq %rbp, %rdx
callq 0x9270
addq %rbp, %r13
andl $0x7, %r12d
movl %r14d, %ebp
testq %r12, %r12
movq (%rsp), %r14
je 0x9c577
movq %r13, %rdi
xorl %esi, %esi
movq %r12, %rdx
callq 0x9270
cmpl $0x0, 0xc(%r15)
jle 0x9c5a0
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 0x9c58a
movl $0x0, 0xc(%r15)
movl $0x0, 0x10(%r15)
movb $0x0, 0x18(%r15)
movzbl %bpl, %ecx
movq %r14, %rdi
movq %r15, %rsi
movq %rbx, %rdx
callq 0x9c74f
movq (%r15), %rcx
cmpl $0x0, 0xc(%r15)
jle 0x9c5ea
xorl %edx, %edx
movq (%rcx,%rdx,8), %rsi
andq $-0xa0001, (%rsi)       # imm = 0xFFF5FFFF
incq %rdx
movslq 0xc(%r15), %rsi
cmpq %rsi, %rdx
jl 0x9c5d3
testb %al, %al
je 0x9c657
xorl %eax, %eax
cmpb $0x1, 0x18(%r15)
jne 0x9c657
cmpl $0x0, 0xc(%r15)
jle 0x9c651
movq 0x20(%r15), %rdx
xorl %esi, %esi
xorl %eax, %eax
cmpl $0x0, (%rdx,%rsi,4)
jle 0x9c645
movq (%rcx,%rsi,8), %rdi
orq $0x20000, (%rdi)        # imm = 0x20000
movl %eax, %edi
cmpq %rdi, %rsi
jne 0x9c622
incl %eax
jmp 0x9c645
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 0x9c606
movl %eax, 0xc(%r15)
jmp 0x9c65a
xorl %r15d, %r15d
movq %r15, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq