// File: /workspace/github_c_makefile_star2_O1/BernardTatin[P]s7sh/s7.c
// Function: input_port_to_port
static void input_port_to_port(s7_scheme *sc, s7_pointer obj, s7_pointer port, use_write_t use_write, shared_info *ci)
    {
        if (obj == sc->standard_input)
            port_write_string(port)(sc, port_filename(obj), port_filename_length(obj), port);
        else
        {
            if (use_write == P_READABLE)
            {
                if (port_is_closed(obj))
                    port_write_string(port)(sc, "(call-with-input-string \"\" (lambda (p) p))", 42, port);
                else
                {
                    if (is_function_port(obj))
                        port_write_string(port)(sc, "#<input-function-port>", 22, port);
                    else
                    {
                        if (is_file_port(obj))
                        {
                            char str[256];
                            int32_t nlen;
                            str[0] = '\0';
                            nlen = catstrs(str, 256, "(open-input-file \"", port_filename(obj), "\")", NULL);
                            port_write_string(port)(sc, str, nlen, port);
                        }
                        else
                        {
                            s7_int data_len;
                            data_len = port_data_size(obj) - port_position(obj);
                            if (data_len > 100)
                            {
                                const char *filename;
                                filename = (const char *)s7_port_filename(sc, obj);
                                if (filename)
                                {
#define DO_STR_LEN 1024
                                    char do_str[DO_STR_LEN];
                                    int32_t len;
                                    do_str[0] = '\0';
                                    if (port_position(obj) > 0)
                                    {
                                        len = catstrs(do_str, DO_STR_LEN, "(let ((port (open-input-file \"", filename, "\")))", NULL);
                                        port_write_string(port)(sc, do_str, len, port);
                                        do_str[0] = '\0';
                                        len = catstrs(do_str, DO_STR_LEN, " (do ((i 0 (+ i 1)) (c (read-char port) (read-char port))) ((= i ",
                                                pos_int_to_str_direct(sc, port_position(obj) - 1),
                                                ") port)))", NULL);
                                    }
                                    else len = catstrs(do_str, DO_STR_LEN, "(open-input-file \"", filename, "\")", NULL);
                                    port_write_string(port)(sc, do_str, len, port);
                                    return;
                                }
                            }
                            port_write_string(port)(sc, "(open-input-string ", 19, port);
                            /* not port_write_string here because there might be embedded double-quotes */
                            slashify_string_to_port(sc, port, (const char *)(port_data(obj) + port_position(obj)), port_data_size(obj) - port_position(obj), IN_QUOTES);
                            port_write_character(port)(sc, ')', port);
                        }
                    }
                }
            }
            else
            {
                if (is_string_port(obj))
                    port_write_string(port)(sc, "<input-string-port", 18, port);
                else
                {
                    if (is_file_port(obj))
                        port_write_string(port)(sc, "<input-file-port", 16, port);
                    else port_write_string(port)(sc, "<input-function-port", 20, port);
                }
                if (port_is_closed(obj))
                    port_write_string(port)(sc, " (closed)>", 10, port);
                else port_write_character(port)(sc, '>', port);
            }
        }
    }

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x400, %rsp            # imm = 0x400
movq %rdx, %rbx
movq %rsi, %r15
movq %rdi, %r14
cmpq %rsi, 0x1c8(%rdi)
je 0xfa613
movq 0x8(%r15), %rax
cmpl $0x2, %ecx
jne 0xfa630
cmpb $0x1, 0x2(%rax)
jne 0xfa656
movq 0x8(%rbx), %rax
movq 0x48(%rax), %rax
movq 0x10(%rax), %rax
leaq 0x29195(%rip), %rsi     # 0x12379e
movl $0x2a, %edx
jmp 0xfa6c8
movq 0x8(%rbx), %rax
movq 0x48(%rax), %rax
movq 0x10(%rax), %rax
movq 0x8(%r15), %rcx
movq 0x10(%rcx), %rsi
movq 0x30(%rcx), %rdx
jmp 0xfa6c8
movl 0x4(%rax), %ecx
movq 0x8(%rbx), %rax
movq 0x48(%rax), %rax
movq 0x10(%rax), %rax
testl %ecx, %ecx
je 0xfa684
cmpl $0x1, %ecx
jne 0xfa692
leaq 0x29215(%rip), %rsi     # 0x123864
movl $0x12, %edx
jmp 0xfa69e
movl 0x4(%rax), %ecx
testl %ecx, %ecx
je 0xfa701
cmpl $0x2, %ecx
jne 0xfa742
movq 0x8(%rbx), %rax
movq 0x48(%rax), %rax
movq 0x10(%rax), %rax
leaq 0x2914c(%rip), %rsi     # 0x1237c9
movl $0x16, %edx
jmp 0xfa6c8
leaq 0x291ec(%rip), %rsi     # 0x123877
movl $0x10, %edx
jmp 0xfa69e
leaq 0x291ef(%rip), %rsi     # 0x123888
movl $0x14, %edx
movq %r14, %rdi
movq %rbx, %rcx
callq *%rax
movq 0x8(%r15), %rcx
movq 0x8(%rbx), %rax
movq 0x48(%rax), %rax
cmpb $0x1, 0x2(%rcx)
jne 0xfa6e0
movq 0x10(%rax), %rax
leaq 0x291da(%rip), %rsi     # 0x12389d
movl $0xa, %edx
movq %r14, %rdi
movq %rbx, %rcx
addq $0x400, %rsp            # imm = 0x400
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
jmpq *%rax
movq 0x8(%rax), %rax
movq %r14, %rdi
movl $0x3e, %esi
movq %rbx, %rdx
addq $0x400, %rsp            # imm = 0x400
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
jmpq *%rax
movq %rsp, %r15
movb $0x0, (%r15)
movq 0x10(%rax), %rcx
leaq 0x290d9(%rip), %rdx     # 0x1237ec
leaq 0x2acd7(%rip), %r8      # 0x1253f1
movl $0x100, %esi            # imm = 0x100
movq %r15, %rdi
xorl %r9d, %r9d
xorl %eax, %eax
callq 0xa4d7
movq 0x8(%rbx), %rcx
movq 0x48(%rcx), %r8
movslq %eax, %rdx
movq %r14, %rdi
movq %r15, %rsi
jmp 0xfa8bb
movq 0x18(%r15), %rcx
movq 0x20(%r15), %rdx
subq %rdx, %rcx
cmpq $0x65, %rcx
jl 0xfa831
movb (%r15), %cl
andb $-0x2, %cl
cmpb $0x22, %cl
jne 0xfa768
movq 0x10(%rax), %rcx
jmp 0xfa76a
xorl %ecx, %ecx
testq %rcx, %rcx
je 0xfa831
movb $0x0, (%rsp)
testq %rdx, %rdx
jle 0xfa88a
leaq 0x29059(%rip), %rdx     # 0x1237e0
leaq 0x29071(%rip), %r8      # 0x1237ff
xorl %r13d, %r13d
movq %rsp, %r12
movl $0x400, %esi            # imm = 0x400
movq %r12, %rdi
xorl %r9d, %r9d
xorl %eax, %eax
callq 0xa4d7
movq 0x8(%rbx), %rcx
movq 0x48(%rcx), %r8
movslq %eax, %rdx
movq %r14, %rdi
movq %r12, %rsi
movq %rbx, %rcx
callq *0x10(%r8)
movb %r13b, (%r12)
movq 0x20(%r15), %rsi
decq %rsi
leaq 0xb6f(%r14), %rcx
movb %r13b, 0xb6f(%r14)
leaq 0x24c52(%rip), %rdi     # 0x11f430
movabsq $0x6666666666666667, %r8 # imm = 0x6666666666666667
movq %rsi, %rax
imulq %r8
movq %rdx, %rax
shrq $0x3f, %rax
sarq $0x2, %rdx
addq %rax, %rdx
leaq (%rdx,%rdx), %rax
leaq (%rax,%rax,4), %rax
movq %rsi, %r9
subq %rax, %r9
movb (%rdi,%r9), %al
movb %al, -0x1(%rcx)
decq %rcx
addq $0x9, %rsi
cmpq $0x12, %rsi
movq %rdx, %rsi
ja 0xfa7e8
leaq 0x28fdc(%rip), %rdx     # 0x123804
leaq 0x29017(%rip), %r8      # 0x123846
jmp 0xfa898
movq 0x8(%rbx), %rax
movq 0x48(%rax), %rax
leaq 0x29010(%rip), %rsi     # 0x123850
movl $0x13, %edx
movq %r14, %rdi
movq %rbx, %rcx
callq *0x10(%rax)
movq 0x18(%r15), %rcx
movq 0x20(%r15), %rax
movq 0x10(%r15), %rdx
addq %rax, %rdx
subq %rax, %rcx
movq %r14, %rdi
movq %rbx, %rsi
movl $0x1, %r8d
callq 0xfd6c4
movq 0x8(%rbx), %rax
movq 0x48(%rax), %rax
movq 0x8(%rax), %rax
movq %r14, %rdi
movl $0x29, %esi
jmp 0xfa6ec
leaq 0x28f5b(%rip), %rdx     # 0x1237ec
leaq 0x2ab59(%rip), %r8      # 0x1253f1
movq %rsp, %rdi
movl $0x400, %esi            # imm = 0x400
xorl %r9d, %r9d
xorl %eax, %eax
callq 0xa4d7
movq 0x8(%rbx), %rcx
movq 0x48(%rcx), %r8
movslq %eax, %rdx
movq %rsp, %rsi
movq %r14, %rdi
movq %rbx, %rcx
callq *0x10(%r8)
addq $0x400, %rsp            # imm = 0x400
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq