// File: /workspace/github_c_makefile_star2_O2/BernardTatin[P]s7sh/s7.c
// Function: let_to_port
static void let_to_port(s7_scheme *sc, s7_pointer obj, s7_pointer port, use_write_t use_write, shared_info *ci)
    {
        /* if outer env points to (say) method list, the object needs to specialize object->string itself */
        if (has_active_methods(sc, obj))
        {
            s7_pointer print_func;
            print_func = find_method(sc, obj, sc->object_to_string_symbol);
            if (print_func != sc->undefined)
            {
                s7_pointer p;
                /* what needs to be protected here? for one, the function might not return a string! */

                clear_has_methods(obj);
                if (use_write == P_WRITE)
                    p = s7_apply_function(sc, print_func, list_1(sc, obj));
                else p = s7_apply_function(sc, print_func, list_2(sc, obj, (use_write == P_DISPLAY) ? sc->F : sc->key_readable_symbol));
                set_has_methods(obj);

                if ((is_string(p)) &&
                        (string_length(p) > 0))
                    port_write_string(port)(sc, string_value(p), string_length(p), port);
                return;
            }
        }

        if (obj == sc->rootlet)
            port_write_string(port)(sc, "(rootlet)", 9, port);
        else
        {
            if (obj == sc->s7_let)
                port_write_string(port)(sc, "*s7*", 4, port);
            else
            {
                if (sc->short_print)
                    port_write_string(port)(sc, "#<let>", 6, port);
                else
                {
                    /* circles can happen here:
                     *    (let () (let ((b (curlet))) (curlet))):    #<let 'b #<let>>
                     * or (let ((b #f)) (set! b (curlet)) (curlet)): #1=#<let 'b #1#>
                     */
                    if (use_write == P_READABLE)
                    {
                        int32_t lref;
                        if ((ci) &&
                                (is_cyclic(obj)) &&
                                ((lref = peek_shared_ref(ci, obj)) != 0))
                        {
                            if (lref < 0) lref = -lref;
                            if ((ci->defined[lref]) || (port == ci->cycle_port))
                            {
                                char buf[128];
                                int32_t len;
                                len = catstrs_direct(buf, "<", pos_int_to_str_direct(sc, lref), ">", NULL);
                                port_write_string(ci->cycle_port)(sc, buf, len, ci->cycle_port);
                                return;
                            }
                            if ((outlet(obj) != sc->nil) &&
                                    (outlet(obj) != sc->rootlet))
                            {
                                char buf[128];
                                int32_t len;
                                len = catstrs_direct(buf, "  (set! (outlet <", pos_int_to_str_direct(sc, lref), ">) ", NULL);
                                port_write_string(ci->cycle_port)(sc, buf, len, ci->cycle_port);
                                let_to_port(sc, outlet(obj), ci->cycle_port, use_write, ci);
                                port_write_string(ci->cycle_port)(sc, ")\n", 2, ci->cycle_port);
                            }
                            if (has_methods(obj))
                                port_write_string(port)(sc, "(openlet ", 9, port);
                            /* not immutable here because we'll need to set the let fields below, then declare it immutable */
                            if (let_has_setter(sc, obj))
                            {
                                port_write_string(port)(sc, "(let (", 6, port);
                                slot_list_to_port_with_cycle(sc, obj, let_slots(obj), port, ci, true);
                                port_write_string(port)(sc, ") ", 2, port);
                                slot_setters_to_port(sc, obj, port, ci);
                                port_write_string(port)(sc, " (curlet))", 10, port);
                            }
                            else
                            {
                                port_write_string(port)(sc, "(inlet", 6, port);
                                slot_list_to_port_with_cycle(sc, obj, let_slots(obj), port, ci, false);
                                port_write_character(port)(sc, ')', port);
                            }
                            if (has_methods(obj))
                                port_write_character(port)(sc, ')', port);
                        }
                        else
                        {
                            if (has_methods(obj))
                                port_write_string(port)(sc, "(openlet ", 9, port);
                            if (is_immutable(obj))
                                port_write_string(port)(sc, "(immutable! ", 12, port);

                            /* this ignores outlet -- but is that a problem? */
                            /* (object->string (let ((i 0)) (set! (setter 'i) integer?) (curlet)) :readable) -> "(let ((i 0)) (set! (setter 'i) #_integer?) (curlet))" */
                            if (let_has_setter(sc, obj))
                            {
                                port_write_string(port)(sc, "(let (", 6, port);
                                slot_list_to_port(sc, let_slots(obj), port, ci, true);
                                port_write_string(port)(sc, ") ", 2, port);
                                slot_setters_to_port(sc, obj, port, ci);
                                /* perhaps set outlet here?? */
                                port_write_string(port)(sc, " (curlet))", 10, port);
                            }
                            else
                            {
                                if ((outlet(obj) != sc->nil) &&
                                        (outlet(obj) != sc->rootlet))
                                {
                                    int32_t ref;
                                    port_write_string(port)(sc, "(sublet ", 8, port);
                                    if ((ci) && ((ref = peek_shared_ref(ci, outlet(obj))) < 0))
                                    {
                                        char buf[128];
                                        int32_t len;
                                        len = catstrs_direct(buf, "<", pos_int_to_str_direct(sc, -ref), ">", NULL);
                                        port_write_string(port)(sc, buf, len, port);
                                    }
                                    else
                                    {
                                        s7_pointer name;
                                        name = s7_let_ref(sc, obj, make_symbol(sc, "class-name"));
                                        if (is_symbol(name))
                                            symbol_to_port(sc, name, port, P_DISPLAY, ci);
                                        else let_to_port(sc, outlet(obj), port, use_write, ci);
                                    }
                                }
                                else port_write_string(port)(sc, "(inlet", 6, port);
                                slot_list_to_port(sc, let_slots(obj), port, ci, false);
                                port_write_character(port)(sc, ')', port);
                            }
                            if (is_immutable(obj))
                                port_write_character(port)(sc, ')', port);
                            if (has_methods(obj))
                                port_write_character(port)(sc, ')', port);
                        }
                    }
                    else /* not readable write */
                    {
                        port_write_string(port)(sc, "(inlet", 6, port);
                        if (is_funclet(obj))
                            funclet_slots_to_port(sc, obj, port, use_write, ci);
                        else slot_to_port_1(sc, let_slots(obj), port, use_write, ci, 0);
                        port_write_character(port)(sc, ')', port);
                    }}}}
    }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x98, %rsp
movl %ecx, %ebp
movq %rdx, (%rsp)
movq %rsi, %r15
movq %rdi, %rbx
movq (%rsi), %r12
movq %r12, %r13
andq $0x40000000, %r13       # imm = 0x40000000
movq %r8, 0x8(%rsp)
je 0xbf96c
cmpb $0x1, 0x24c(%rbx)
jne 0xbf96c
movq 0x1380(%rbx), %rdx
movq %rbx, %rdi
movq %r15, %rsi
callq 0x888f
movq 0x8(%rsp), %r8
cmpq 0x128(%rbx), %rax
je 0xbf96c
movq %rax, %rsi
andq $-0x40000001, %r12      # imm = 0xBFFFFFFF
movq %r12, (%r15)
testl %ebp, %ebp
je 0xbfc19
cmpl $0x1, %ebp
jne 0xbfc20
movq 0x90(%rbx), %rax
movq 0x110(%rbx), %r14
cmpq 0x98(%rbx), %rax
ja 0xbfc7b
leaq 0x90(%rbx), %r12
movq %rbx, %rdi
movq %rsi, %r13
callq 0x9c27
movq %r13, %rsi
jmp 0xbfc77
movq 0x150(%rbx), %r14
cmpq %r15, %r14
je 0xbf9a5
cmpq %r15, 0x2150(%rbx)
je 0xbf9c0
cmpb $0x1, 0x248(%rbx)
jne 0xbf9f0
movq (%rsp), %rcx
movq 0x8(%rcx), %rax
movq 0x48(%rax), %rax
movq 0x10(%rax), %rax
leaq 0x26e1a(%rip), %rsi     # 0xe67bb
pushq $0x6
jmp 0xbf9d9
movq (%rsp), %rcx
movq 0x8(%rcx), %rax
movq 0x48(%rax), %rax
movq 0x10(%rax), %rax
leaq 0x26df5(%rip), %rsi     # 0xe67b1
pushq $0x9
jmp 0xbf9d9
movq (%rsp), %rcx
movq 0x8(%rcx), %rax
movq 0x48(%rax), %rax
movq 0x10(%rax), %rax
leaq 0x23956(%rip), %rsi     # 0xe332d
pushq $0x4
popq %rdx
movq %rbx, %rdi
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmpq *%rax
cmpl $0x2, %ebp
jne 0xbfaf5
testq %r8, %r8
sete %al
btq $0x35, %r12
setae %cl
orb %al, %cl
jne 0xbfb3e
movq %r8, %rdi
movq %r15, %rsi
callq 0x7855f
movq 0x8(%rsp), %rcx
testl %eax, %eax
je 0xbfb3e
movl %eax, %esi
negl %esi
cmovsl %eax, %esi
movq 0x48(%rcx), %rax
cmpb $0x0, (%rax,%rsi)
jne 0xbfe53
movq (%rsp), %rax
cmpq %rax, 0x28(%rcx)
je 0xbfe53
movq 0x10(%r15), %rax
cmpq %r14, %rax
je 0xbff9b
cmpq 0x110(%rbx), %rax
movq (%rsp), %r14
je 0xbff9f
movq %rbx, %rdi
callq 0x91f9
leaq 0x26d4b(%rip), %rsi     # 0xe67c2
leaq 0x26d56(%rip), %rcx     # 0xe67d4
leaq 0x10(%rsp), %r13
movq %r13, %rdi
movq %rax, %rdx
xorl %r8d, %r8d
xorl %eax, %eax
callq 0xb3a5
movq 0x8(%rsp), %r12
movq 0x28(%r12), %rcx
movq 0x8(%rcx), %rdx
movq 0x48(%rdx), %r8
movslq %eax, %rdx
movq %rbx, %rdi
movq %r13, %rsi
callq *0x10(%r8)
movq 0x10(%r15), %rsi
movq 0x28(%r12), %rdx
pushq $0x2
popq %rcx
movq %rbx, %rdi
movq %r12, %r8
callq 0xbf8bf
movq 0x28(%r12), %rcx
movq 0x8(%rcx), %rax
movq 0x48(%rax), %rax
leaq 0x26a9c(%rip), %rsi     # 0xe6579
pushq $0x2
popq %rdx
movq %rbx, %rdi
callq *0x10(%rax)
movq (%r15), %r13
andl $0x40000000, %r13d      # imm = 0x40000000
jmp 0xbff9f
movq (%rsp), %r14
movq 0x8(%r14), %rax
movq 0x48(%rax), %rax
leaq 0x26ce5(%rip), %rsi     # 0xe67ed
pushq $0x6
popq %rdx
movq %rbx, %rdi
movq %r14, %rcx
callq *0x10(%rax)
leaq 0x8(%r15), %r13
testb $0x20, 0x3(%r15)
jne 0xbfce7
movq (%r13), %rsi
movq %rbx, %rdi
movq %r14, %rdx
movl %ebp, %ecx
movq 0x8(%rsp), %r8
callq 0xc3056
jmp 0xbfe2b
testq %r13, %r13
movq (%rsp), %r14
je 0xbfb65
movq 0x8(%r14), %rax
movq 0x48(%rax), %rax
leaq 0x26c82(%rip), %rsi     # 0xe67d8
pushq $0x9
popq %rdx
movq %rbx, %rdi
movq %r14, %rcx
callq *0x10(%rax)
movq (%r15), %r12
btl $0x18, %r12d
jae 0xbfb87
movq 0x8(%r14), %rax
movq 0x48(%rax), %rax
leaq 0x22f69(%rip), %rsi     # 0xe2ae4
pushq $0xc
popq %rdx
movq %rbx, %rdi
movq %r14, %rcx
callq *0x10(%rax)
movq %r15, %rdi
callq 0xc2ade
testb %al, %al
je 0xbfd81
movq 0x8(%r14), %rax
movq 0x48(%rax), %rax
leaq 0x22f28(%rip), %rsi     # 0xe2ace
pushq $0x6
popq %rdx
movq %rbx, %rdi
movq %r14, %rcx
callq *0x10(%rax)
movq 0x8(%r15), %rsi
pushq $0x1
popq %r8
movq %rbx, %rdi
movq %r14, %rdx
movq 0x8(%rsp), %r12
movq %r12, %rcx
callq 0xc2f23
movq 0x8(%r14), %rax
movq 0x48(%rax), %rax
leaq 0x26b79(%rip), %rsi     # 0xe6755
pushq $0x2
popq %rdx
movq %rbx, %rdi
movq %r14, %rcx
callq *0x10(%rax)
movq %rbx, %rdi
movq %r15, %rsi
movq %r14, %rdx
movq %r12, %rcx
callq 0xc2e27
movq 0x8(%r14), %rax
movq 0x48(%rax), %rax
leaq 0x26bda(%rip), %rsi     # 0xe67e2
pushq $0xa
popq %rdx
movq %rbx, %rdi
movq %r14, %rcx
callq *0x10(%rax)
jmp 0xbfee5
movl $0x120, %eax            # imm = 0x120
jmp 0xbfc25
movl $0x18a0, %eax           # imm = 0x18A0
movq (%rbx,%rax), %r13
movq 0x90(%rbx), %rax
movq 0x110(%rbx), %rbp
leaq 0x90(%rbx), %r12
cmpq 0x98(%rbx), %rax
ja 0xbfc5c
movq %rbx, %rdi
movq %rsi, %r14
callq 0x9c27
movq %r14, %rsi
movq 0x90(%rbx), %rax
leaq -0x8(%rax), %rcx
movq %rcx, (%r12)
movq -0x8(%rax), %r14
movq $0x200001, (%r14)       # imm = 0x200001
movq %r13, 0x8(%r14)
movq %rbp, 0x10(%r14)
movq (%r12), %rax
leaq -0x8(%rax), %rcx
movq %rcx, 0x90(%rbx)
movq -0x8(%rax), %rdx
movq $0x200001, (%rdx)       # imm = 0x200001
movq %r15, 0x8(%rdx)
movq %r14, 0x10(%rdx)
movq %rbx, %rdi
callq 0xa34c
orb $0x40, 0x3(%r15)
cmpb $0x13, (%rax)
jne 0xbff20
movq 0x8(%rax), %rdx
testq %rdx, %rdx
jle 0xbff20
movq (%rsp), %rcx
movq 0x8(%rcx), %rsi
movq 0x48(%rsi), %rsi
movq 0x10(%rsi), %r8
movq 0x10(%rax), %rsi
movq %rbx, %rdi
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmpq *%r8
xorl %r12d, %r12d
pushq $0x20
popq %r15
movq (%r13), %r13
testq %r13, %r13
je 0xbfe2b
movq 0x8(%r14), %rax
movq 0x48(%rax), %rax
movq %rbx, %rdi
movl %r15d, %esi
movq %r14, %rdx
callq *0x8(%rax)
movzbl (%r13), %eax
movq 0x8(%rsp), %r8
testq %r8, %r8
je 0xbfd4c
leaq 0x6161b(%rip), %rcx     # 0x121340
cmpb $0x1, (%rax,%rcx)
jne 0xbfd4c
cmpl $0x15, %eax
jne 0xbfd3a
testb $0x1, 0x7(%r13)
pushq $0x15
popq %rax
jne 0xbfd4c
movq %rbx, %rdi
movq %r13, %rsi
movq %r14, %rdx
movl %ebp, %ecx
callq 0x77872
jmp 0xbfd62
movq %rbx, %rdi
movq %r13, %rsi
movq %r14, %rdx
movl %ebp, %ecx
leaq 0x61622(%rip), %r9      # 0x121380
callq *(%r9,%rax,8)
movq 0x280(%rbx), %rax
incq %rax
cmpq %rax, %r12
je 0xbfe10
incq %r12
addq $0x18, %r13
jmp 0xbfcee
movq 0x10(%r15), %rax
cmpq 0x110(%rbx), %rax
je 0xbfe9f
cmpq 0x150(%rbx), %rax
je 0xbfe9f
movq 0x8(%r14), %rax
movq 0x48(%rax), %rax
leaq 0x26a46(%rip), %rsi     # 0xe67f4
pushq $0x8
popq %rdx
movq %rbx, %rdi
movq %r14, %rcx
callq *0x10(%rax)
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0xbfdd5
movq 0x10(%r15), %rsi
callq 0x7855f
testl %eax, %eax
js 0xbff4e
leaq 0x165db(%rip), %rsi     # 0xd63b7
movq %rbx, %rdi
callq 0x94d4
movq %rbx, %rdi
movq %r15, %rsi
movq %rax, %rdx
callq 0xa842
cmpb $0xa, (%rax)
jne 0xbff32
movq %rbx, %rdi
movq %rax, %rsi
movq %r14, %rdx
xorl %ecx, %ecx
callq 0xc0840
jmp 0xbfeba
movq 0x8(%r14), %rax
movq 0x48(%rax), %rax
leaq 0x22d22(%rip), %rsi     # 0xe2b41
pushq $0x4
popq %rdx
movq %rbx, %rdi
movq %r14, %rcx
callq *0x10(%rax)
movq 0x8(%r14), %rax
movq 0x48(%rax), %rax
movq 0x8(%rax), %rax
pushq $0x29
popq %rsi
movq %rbx, %rdi
movq %r14, %rdx
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmpq *%rax
movq %rbx, %rdi
movq %rcx, %r15
callq 0x91f9
leaq 0x269a6(%rip), %rsi     # 0xe680b
leaq 0x26c75(%rip), %rcx     # 0xe6ae1
leaq 0x10(%rsp), %r14
movq %r14, %rdi
movq %rax, %rdx
xorl %r8d, %r8d
xorl %eax, %eax
callq 0xb3a5
movq 0x28(%r15), %rcx
movq 0x8(%rcx), %rdx
movq 0x48(%rdx), %r8
movslq %eax, %rdx
movq %rbx, %rdi
movq %r14, %rsi
callq *0x10(%r8)
jmp 0xbff20
movq 0x8(%r14), %rax
movq 0x48(%rax), %rax
leaq 0x2693f(%rip), %rsi     # 0xe67ed
pushq $0x6
popq %rdx
movq %rbx, %rdi
movq %r14, %rcx
callq *0x10(%rax)
movq 0x8(%r15), %rsi
movq %rbx, %rdi
movq %r14, %rdx
movq 0x8(%rsp), %rcx
xorl %r8d, %r8d
callq 0xc2f23
movq 0x8(%r14), %rax
movq 0x48(%rax), %rax
pushq $0x29
popq %rsi
movq %rbx, %rdi
movq %r14, %rdx
callq *0x8(%rax)
movq (%r15), %rax
btl $0x18, %eax
jae 0xbff05
movq 0x8(%r14), %rax
movq 0x48(%rax), %rax
pushq $0x29
popq %rsi
movq %rbx, %rdi
movq %r14, %rdx
callq *0x8(%rax)
movq (%r15), %rax
btl $0x1e, %eax
jae 0xbff20
movq (%rsp), %rdx
movq 0x8(%rdx), %rax
movq 0x48(%rax), %rax
pushq $0x29
popq %rsi
movq %rbx, %rdi
callq *0x8(%rax)
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x10(%r15), %rsi
pushq $0x2
popq %rcx
movq %rbx, %rdi
movq %r14, %rdx
movq 0x8(%rsp), %r8
callq 0xbf8bf
jmp 0xbfeba
negl %eax
movq %rbx, %rdi
movq %rax, %rsi
callq 0x91f9
leaq 0x268a9(%rip), %rsi     # 0xe680b
leaq 0x26b78(%rip), %rcx     # 0xe6ae1
leaq 0x10(%rsp), %r13
movq %r13, %rdi
movq %rax, %rdx
xorl %r8d, %r8d
xorl %eax, %eax
callq 0xb3a5
movq 0x8(%r14), %rcx
movq 0x48(%rcx), %r8
movslq %eax, %rdx
movq %rbx, %rdi
movq %r13, %rsi
movq %r14, %rcx
callq *0x10(%r8)
jmp 0xbfeba
movq (%rsp), %r14
testq %r13, %r13
je 0xbffbf
movq 0x8(%r14), %rax
movq 0x48(%rax), %rax
leaq 0x26825(%rip), %rsi     # 0xe67d8
pushq $0x9
popq %rdx
movq %rbx, %rdi
movq %r14, %rcx
callq *0x10(%rax)
movq %r15, %rdi
callq 0xc2ade
movq 0x8(%r14), %rcx
movq 0x48(%rcx), %rcx
movq 0x10(%rcx), %r8
testb %al, %al
je 0xc0051
leaq 0x22af0(%rip), %rsi     # 0xe2ace
pushq $0x6
popq %rdx
movq %rbx, %rdi
movq %r14, %rcx
callq *%r8
movq 0x8(%r15), %rdx
pushq $0x1
popq %r9
movq %rbx, %rdi
movq %r15, %rsi
movq %r14, %rcx
movq 0x8(%rsp), %r12
movq %r12, %r8
callq 0xc2afb
movq 0x8(%r14), %rax
movq 0x48(%rax), %rax
leaq 0x2673e(%rip), %rsi     # 0xe6755
pushq $0x2
popq %rdx
movq %rbx, %rdi
movq %r14, %rcx
callq *0x10(%rax)
movq %rbx, %rdi
movq %r15, %rsi
movq %r14, %rdx
movq %r12, %rcx
callq 0xc2e27
movq 0x8(%r14), %rax
movq 0x48(%rax), %rax
leaq 0x2679f(%rip), %rsi     # 0xe67e2
pushq $0xa
popq %rdx
movq %rbx, %rdi
movq %r14, %rcx
callq *0x10(%rax)
jmp 0xc0092
leaq 0x26795(%rip), %rsi     # 0xe67ed
pushq $0x6
popq %rdx
movq %rbx, %rdi
movq %r14, %rcx
callq *%r8
movq 0x8(%r15), %rdx
movq %rbx, %rdi
movq %r15, %rsi
movq %r14, %rcx
movq 0x8(%rsp), %r8
xorl %r9d, %r9d
callq 0xc2afb
movq 0x8(%r14), %rax
movq 0x48(%rax), %rax
pushq $0x29
popq %rsi
movq %rbx, %rdi
movq %r14, %rdx
callq *0x8(%rax)
testb $0x40, 0x3(%r15)
jne 0xbff0b
jmp 0xbff20