// File: /workspace/github_c_makefile_star2_O1/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 $0x38, %rsp
movq %rcx, %r14
movq %rsi, %r15
leaq (%rcx,%r8), %rax
xorl %r13d, %r13d
cmpq $-0x1, %r8
cmovneq %rax, %r13
xorl %ecx, %ecx
movq %rdi, %r12
testb %dl, %dl
setne %cl
je 0x36ed5
leaq 0x1(%rdi), %r12
movb %dl, (%rdi)
leaq (%rdi,%r15), %rax
movq %rax, 0x30(%rsp)
movq %rdi, %rsi
subq %rcx, %rsi
subq %rdi, %rcx
addq $-0x3, %rsi
cmpb $0x1, %dl
movq %rdi, 0x28(%rsp)
movq %rdi, %rax
adcq $-0x1, %rax
movl $0x3, %edi
subq %rax, %rdi
leaq -0x1(%r15), %r8
movl %edx, 0x4(%rsp)
movq %rcx, 0x20(%rsp)
movq %rsi, 0x18(%rsp)
movq %rdi, 0x10(%rsp)
movq %r8, 0x8(%rsp)
testq %r13, %r13
je 0x36f2d
xorl %eax, %eax
cmpq %r13, %r14
setb %al
jmp 0x36f31
movsbl (%r14), %eax
testl %eax, %eax
je 0x37043
movb (%r14), %bpl
movzbl %bpl, %ebx
movl $0x2, %eax
cmpl $0x9, %ebx
jle 0x36f5e
cmpl $0xa, %ebx
je 0x36f6c
cmpl $0x5c, %ebx
je 0x36fac
cmpl $0xd, %ebx
jne 0x36f76
movb $0x72, %bpl
jmp 0x36fac
testl %ebx, %ebx
je 0x36f71
cmpl $0x9, %ebx
jne 0x36f76
movb $0x74, %bpl
jmp 0x36fac
movb $0x6e, %bpl
jmp 0x36fac
movb $0x30, %bpl
jmp 0x36fac
cmpb %dl, %bpl
je 0x36fac
callq 0x4510
movq 0x8(%rsp), %r8
movq 0x10(%rsp), %rdi
movq 0x18(%rsp), %rsi
movl 0x4(%rsp), %edx
movq (%rax), %rax
xorl %ecx, %ecx
testb $0x40, 0x1(%rax,%rbx,2)
sete %cl
leaq (%rcx,%rcx,2), %rax
incq %rax
movq 0x20(%rsp), %rcx
leaq (%rcx,%r12), %rbx
addq %rax, %rbx
cmpq %r15, %rbx
jae 0x36ffd
cmpl $0x2, %eax
je 0x37026
cmpl $0x4, %eax
jne 0x3702e
movq 0x30(%rsp), %rsi
subq %r12, %rsi
movzbl %bpl, %ecx
movq %r12, %rdi
leaq 0x64e15(%rip), %rdx     # 0x9bded
xorl %eax, %eax
callq 0x4800
movq 0x8(%rsp), %r8
movq 0x10(%rsp), %rdi
movq 0x18(%rsp), %rsi
movq 0x20(%rsp), %rcx
movl 0x4(%rsp), %edx
addq $0x4, %r12
jmp 0x37035
leaq (%rdi,%r12), %rax
cmpq %r8, %rax
cmovaeq %r8, %rax
subq %r12, %rax
addq %rsi, %r12
addq %rax, %r12
testb %dl, %dl
je 0x3701c
movb %dl, (%r12)
incq %r12
movl $0x2e2e2e, (%r12)       # imm = 0x2E2E2E
jmp 0x37035
movb $0x5c, (%r12)
incq %r12
movb %bpl, (%r12)
incq %r12
incq %r14
cmpq %r15, %rbx
jb 0x36f1e
jmp 0x37053
testb %dl, %dl
je 0x3704e
movb %dl, (%r12)
incq %r12
movb $0x0, (%r12)
movq 0x28(%rsp), %rax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq