// File: /workspace/github_c_makefile_star2_O2/samtools[P]htslib/textutils.c
// Function: hts_strprint
const char *
hts_strprint(char *buf, size_t buflen, char quote, const char *s, size_t len)
{
    const char *slim = (len < SIZE_MAX)? &s[len] : NULL;
    char *t = buf, *bufend = buf + buflen;

    size_t qlen = quote? 1 : 0;
    if (quote) *t++ = quote;

    for (; slim? (s < slim) : (*s); s++) {
        char c;
        size_t clen;
        switch (*s) {
        case '\n': c = 'n'; clen = 2; break;
        case '\r': c = 'r'; clen = 2; break;
        case '\t': c = 't'; clen = 2; break;
        case '\0': c = '0'; clen = 2; break;
        case '\\': c = '\\'; clen = 2; break;
        default:
            c = *s;
            if (c == quote) clen = 2;
            else clen = isprint_c(c)? 1 : 4;
            break;
        }

        if (t-buf + clen + qlen >= buflen) {
            while (t-buf + 3 + qlen >= buflen) t--;
            if (quote) *t++ = quote;
            strcpy(t, "...");
            return buf;
        }

        if (clen == 4) {
            snprintf(t, bufend - t, "\\x%02X", (unsigned char) c);
            t += clen;
        }
        else {
            if (clen == 2) *t++ = '\\';
            *t++ = c;
        }
    }

    if (quote) *t++ = quote;
    *t = '\0';
    return buf;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rcx, %r12
movq %rsi, %r14
leaq (%rcx,%r8), %rax
xorl %r13d, %r13d
cmpq $-0x1, %r8
cmovneq %rax, %r13
xorl %ebx, %ebx
movq %rdi, %r15
testb %dl, %dl
setne %bl
je 0x2b90b
leaq 0x1(%rdi), %r15
movb %dl, (%rdi)
movl %edx, 0xc(%rsp)
leaq (%rdi,%r14), %rax
movq %rax, 0x20(%rsp)
movq %rbx, 0x18(%rsp)
movq %rdi, 0x10(%rsp)
subq %rdi, %rbx
pushq $0x2
popq %rsi
testq %r13, %r13
je 0x2b937
xorl %eax, %eax
cmpq %r13, %r12
setb %al
jmp 0x2b93c
movsbl (%r12), %eax
testl %eax, %eax
je 0x2b9f4
movzbl (%r12), %ebp
testl %ebp, %ebp
je 0x2b99f
cmpl $0x9, %ebp
je 0x2b965
cmpl $0xa, %ebp
je 0x2b96d
cmpl $0x5c, %ebp
je 0x2b969
cmpl $0xd, %ebp
jne 0x2b971
movb $0x72, %al
jmp 0x2b9a1
movb $0x74, %al
jmp 0x2b9a1
movl %ebp, %eax
jmp 0x2b9a1
movb $0x6e, %al
jmp 0x2b9a1
movl 0xc(%rsp), %edx
movl %edx, %eax
movq %rsi, %rcx
cmpb %dl, %bpl
je 0x2b9a4
callq 0x4510
pushq $0x2
popq %rsi
movq (%rax), %rax
xorl %ecx, %ecx
testb $0x40, 0x1(%rax,%rbp,2)
sete %cl
leaq (%rcx,%rcx,2), %rcx
incq %rcx
movl %ebp, %eax
jmp 0x2b9a4
movb $0x30, %al
movq %rsi, %rcx
leaq (%rbx,%r15), %rdx
addq %rcx, %rdx
cmpq %r14, %rdx
jae 0x2ba0d
cmpl $0x2, %ecx
je 0x2b9df
cmpl $0x4, %ecx
jne 0x2b9e6
movq 0x20(%rsp), %rsi
subq %r15, %rsi
movzbl %al, %ecx
movq %r15, %rdi
leaq 0x4f38e(%rip), %rdx     # 0x7ad5d
xorl %eax, %eax
callq 0x4800
pushq $0x2
popq %rsi
addq $0x4, %r15
jmp 0x2b9ec
movb $0x5c, (%r15)
incq %r15
movb %al, (%r15)
incq %r15
incq %r12
jmp 0x2b928
movl 0xc(%rsp), %eax
testb %al, %al
je 0x2ba02
movb %al, (%r15)
incq %r15
movq 0x10(%rsp), %rax
movb $0x0, (%r15)
jmp 0x2ba58
xorl %edx, %edx
movl 0xc(%rsp), %esi
testb %sil, %sil
setne %dl
movq 0x10(%rsp), %rax
movq %rax, %rcx
subq 0x18(%rsp), %rcx
addq %r15, %rcx
subq %rax, %rdx
addq %r15, %rdx
addq $0x3, %rdx
decq %r14
cmpq %r14, %rdx
cmovbq %rdx, %r14
subq %r15, %r14
addq %r14, %rcx
addq $-0x3, %rcx
testb %sil, %sil
je 0x2ba52
movb %sil, (%rcx)
incq %rcx
movl $0x2e2e2e, (%rcx)       # imm = 0x2E2E2E
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq