// File: /workspace/github_c_makefile_star2_O2/BernardTatin[P]s7sh/s7.c
// Function: slashify_string_to_port
static void slashify_string_to_port(s7_scheme *sc, s7_pointer port, const char *p, s7_int len, bool quoted)
    {
        uint8_t *pcur, *pend, *pstart = NULL;

        if (len == 0)
        {
            if (quoted)
                port_write_string(port)(sc, "\"\"", 2, port);
            return;
        }
        pend = (uint8_t *)(p + len);

        /* what about the trailing nulls? Guile writes them out (as does s7 currently)
         *    but that is not ideal.  I'd like to use ~S for error messages, so that
         *    strings are clearly identified via the double-quotes, but this way of
         *    writing them is ugly:
         *      (let ((str (make-string 8 #\null))) (set! (str 0) #\a) str) -> "a\x00\x00\x00\x00\x00\x00\x00"
         *    but it would be misleading to omit them because:
         *      (let ((str (make-string 8 #\null))) (set! (str 0) #\a) (string-append str "bc")) -> "a\x00\x00\x00\x00\x00\x00\x00bc"
         * also it is problematic to use sc->print_length here because
         *    it is normally (say) 8 which truncates just about every string.  In CL, *print-length*
         *    does not affect strings, symbols, or bit-vectors.  But if the string is enormous,
         *    this function can bring us to a complete halt, which is annoying if it is the error
         *    handler that is trying to write the string.  I think if port is sc->error_port, I'll
         *    truncate strings to some reasonable size -- (*s7* 'max-format-length) maybe.
         */
        if ((len > sc->max_format_length) &&
                (port == sc->error_port))
            len = sc->max_format_length;
        if (quoted) port_write_character(port)(sc, '"', port);
        for (pcur = (uint8_t *)p; pcur < pend; pcur++)
        {
            if (slashify_table[*pcur])
            {
                if (pstart) pstart++; else pstart = (uint8_t *)p;
                if (pstart != pcur)
                {
                    port_write_string(port)(sc, (char *)pstart, pcur - pstart, port);
                    pstart = pcur;
                }
                port_write_character(port)(sc, '\\', port);
                switch (*pcur)
                {
                    case '"':   port_write_character(port)(sc, '"', port);   break;
                    case '\\':  port_write_character(port)(sc, '\\', port);  break;
                    case '\'':  port_write_character(port)(sc, '\'', port);  break;
                    case '\t':  port_write_character(port)(sc, 't', port);   break;
                    case '\r':  port_write_character(port)(sc, 'r', port);   break;
                    case '\b':  port_write_character(port)(sc, 'b', port);   break;
                    case '\f':  port_write_character(port)(sc, 'f', port);   break;
                    case '\?':  port_write_character(port)(sc, '?', port);   break;
                    case 'x':   port_write_character(port)(sc, 'x', port);   break;
                    default:
                                {
                                    s7_int n;
                                    port_write_character(port)(sc, 'x', port);
                                    n = (s7_int)(*pcur);
                                    if (n < 16)
                                        port_write_character(port)(sc, '0', port);
                                    else port_write_character(port)(sc, dignum[(n / 16) % 16], port);
                                    port_write_character(port)(sc, dignum[n % 16], port);
                                    port_write_character(port)(sc, ';', port);
                                }
                                break;
                }
            }
        }
        if (!pstart)
            port_write_string(port)(sc, (char *)p, len, port);
        else
        {
            pstart++;
            if (pstart != pcur)
                port_write_string(port)(sc, (char *)pstart, pcur - pstart, port);
        }
        if (quoted) port_write_character(port)(sc, '"', port);
    }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rdx, 0x8(%rsp)
movq %rsi, %rbx
movq %rdi, %r14
testq %rcx, %rcx
je 0xc2a57
movq 0x2c0(%r14), %rax
movq %rcx, %rdx
cmpq %rcx, %rax
jge 0xc285d
cmpq %rbx, 0x190(%r14)
cmovneq %rcx, %rax
movq %rax, %rdx
movq %rdx, 0x20(%rsp)
movl %r8d, 0x14(%rsp)
testb %r8b, %r8b
je 0xc2886
movq 0x8(%rbx), %rax
movq 0x48(%rax), %rax
pushq $0x22
popq %rsi
movq %r14, %rdi
movq %rbx, %rdx
movq %rcx, %r15
callq *0x8(%rax)
movq %r15, %rcx
movq 0x8(%rsp), %r13
addq %r13, %rcx
pushq $0x1
popq %rbp
subq %r13, %rbp
xorl %r15d, %r15d
leaq 0x624c2(%rip), %rdx     # 0x124d60
movq %r13, %r12
movq %r14, 0x18(%rsp)
movq %rcx, (%rsp)
cmpq %rcx, %r13
jae 0xc2a33
movzbl (%r13), %eax
cmpb $0x1, (%rax,%rdx)
jne 0xc2a25
testq %r15, %r15
leaq 0x1(%r15), %r15
cmoveq 0x8(%rsp), %r15
cmpq %r15, %r13
je 0xc28f1
movq 0x8(%rbx), %rax
movq 0x48(%rax), %rax
movq %r12, %rdx
subq %r15, %rdx
movq %r14, %rdi
movq %r15, %rsi
movq %rbx, %rcx
callq *0x10(%rax)
movq %r13, %r15
movq 0x8(%rbx), %rax
movq 0x48(%rax), %rax
movq %r14, %rdi
pushq $0x5c
popq %rsi
movq %rbx, %rdx
callq *0x8(%rax)
movzbl (%r13), %ecx
movq 0x8(%rbx), %rax
movq 0x48(%rax), %rax
movq 0x8(%rax), %rax
leal -0x8(%rcx), %edx
cmpl $0x5, %edx
jbe 0xc2951
cmpl $0x78, %ecx
je 0xc2a01
cmpl $0x27, %ecx
je 0xc2a0f
cmpl $0x3f, %ecx
je 0xc2a08
cmpl $0x5c, %ecx
je 0xc29fa
cmpl $0x22, %ecx
jne 0xc296b
movq %r14, %rdi
pushq $0x22
jmp 0xc2a14
leaq 0x123ec(%rip), %rsi     # 0xd4d44
movslq (%rsi,%rdx,4), %rcx
addq %rsi, %rcx
jmpq *%rcx
movq %r14, %rdi
pushq $0x62
jmp 0xc2a14
movq %r14, %rdi
pushq $0x78
popq %rsi
movq %rbx, %rdx
callq *%rax
movzbl (%r13), %r14d
movb $0x30, %al
cmpq $0x10, %r14
jb 0xc2993
movl %r14d, %eax
shrl $0x4, %eax
leaq 0x25850(%rip), %rcx     # 0xe81e0
movb (%rax,%rcx), %al
movq 0x8(%rbx), %rcx
movq 0x48(%rcx), %rcx
movzbl %al, %esi
movq 0x18(%rsp), %rdi
movq %rbx, %rdx
callq *0x8(%rcx)
movq 0x8(%rbx), %rax
movq 0x48(%rax), %rax
andl $0xf, %r14d
leaq 0x25824(%rip), %rcx     # 0xe81e0
movzbl (%r14,%rcx), %esi
movq 0x18(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rdx
callq *0x8(%rax)
movq 0x8(%rbx), %rax
movq 0x48(%rax), %rax
movq %r14, %rdi
pushq $0x3b
popq %rsi
movq %rbx, %rdx
callq *0x8(%rax)
jmp 0xc2a1a
movq %r14, %rdi
pushq $0x66
jmp 0xc2a14
movq %r14, %rdi
pushq $0x74
jmp 0xc2a14
movq %r14, %rdi
pushq $0x72
jmp 0xc2a14
movq %r14, %rdi
pushq $0x5c
jmp 0xc2a14
movq %r14, %rdi
pushq $0x78
jmp 0xc2a14
movq %r14, %rdi
pushq $0x3f
jmp 0xc2a14
movq %r14, %rdi
pushq $0x27
popq %rsi
movq %rbx, %rdx
callq *%rax
movq (%rsp), %rcx
leaq 0x6233b(%rip), %rdx     # 0x124d60
incq %r13
decq %rbp
incq %r12
jmp 0xc28aa
testq %r15, %r15
je 0xc2a88
leaq 0x1(%r15), %rsi
cmpq %rsi, %r13
je 0xc2aa3
movq 0x8(%rbx), %rax
movq 0x48(%rax), %rax
addq %rbp, %r15
negq %r15
movq %r14, %rdi
movq %r15, %rdx
jmp 0xc2a9d
testb %r8b, %r8b
je 0xc2acf
movq 0x8(%rbx), %rax
movq 0x48(%rax), %rax
movq 0x10(%rax), %rax
leaq 0x23d3f(%rip), %rsi     # 0xe67ae
pushq $0x2
popq %rdx
movq %r14, %rdi
movq %rbx, %rcx
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmpq *%rax
movq 0x8(%rbx), %rax
movq 0x48(%rax), %rax
movq %r14, %rdi
movq 0x8(%rsp), %rsi
movq 0x20(%rsp), %rdx
movq %rbx, %rcx
callq *0x10(%rax)
cmpb $0x0, 0x14(%rsp)
je 0xc2acf
movq 0x8(%rbx), %rax
movq 0x48(%rax), %rax
movq 0x8(%rax), %rax
pushq $0x22
popq %rsi
movq %r14, %rdi
movq %rbx, %rdx
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmpq *%rax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq