// File: /workspace/github_c_makefile_star2_O3/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
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 0x35b25
leaq 0x1(%rdi), %r15
movb %dl, (%rdi)
movl %edx, 0x4(%rsp)
leaq (%rdi,%rsi), %rax
movq %rax, 0x20(%rsp)
movq %rbx, 0x18(%rsp)
movq %rdi, 0x8(%rsp)
subq %rdi, %rbx
movq %rsi, 0x10(%rsp)
testq %r13, %r13
je 0x35b53
xorl %eax, %eax
cmpq %r13, %r12
setb %al
jmp 0x35b58
movsbl (%r12), %eax
testl %eax, %eax
je 0x35c1e
movb (%r12), %bpl
movzbl %bpl, %r14d
movl $0x2, %eax
cmpl $0x9, %r14d
jle 0x35b89
cmpl $0xa, %r14d
je 0x35b98
cmpl $0x5c, %r14d
je 0x35bca
cmpl $0xd, %r14d
jne 0x35ba0
movb $0x72, %cl
jmp 0x35bcc
testl %r14d, %r14d
je 0x35b9c
cmpl $0x9, %r14d
jne 0x35ba0
movb $0x74, %cl
jmp 0x35bcc
movb $0x6e, %cl
jmp 0x35bcc
movb $0x30, %cl
jmp 0x35bcc
movl 0x4(%rsp), %edx
movl %edx, %ecx
cmpb %dl, %bpl
je 0x35bcc
callq 0x4510
movq 0x10(%rsp), %rsi
movq (%rax), %rax
xorl %ecx, %ecx
testb $0x40, 0x1(%rax,%r14,2)
sete %cl
leaq (%rcx,%rcx,2), %rax
incq %rax
movl %ebp, %ecx
leaq (%rbx,%r15), %rdx
addq %rax, %rdx
cmpq %rsi, %rdx
jae 0x35c37
cmpl $0x2, %eax
je 0x35c09
cmpl $0x4, %eax
jne 0x35c10
movq 0x20(%rsp), %rsi
subq %r15, %rsi
movzbl %cl, %ecx
movq %r15, %rdi
leaq 0x63206(%rip), %rdx     # 0x98dfd
xorl %eax, %eax
callq 0x4800
movq 0x10(%rsp), %rsi
addq $0x4, %r15
jmp 0x35c16
movb $0x5c, (%r15)
incq %r15
movb %cl, (%r15)
incq %r15
incq %r12
jmp 0x35b44
movl 0x4(%rsp), %eax
testb %al, %al
je 0x35c2c
movb %al, (%r15)
incq %r15
movq 0x8(%rsp), %rax
movb $0x0, (%r15)
jmp 0x35c82
xorl %edx, %edx
movl 0x4(%rsp), %edi
testb %dil, %dil
setne %dl
movq 0x8(%rsp), %rax
movq %rax, %rcx
subq 0x18(%rsp), %rcx
addq %r15, %rcx
subq %rax, %rdx
addq %r15, %rdx
addq $0x3, %rdx
decq %rsi
cmpq %rsi, %rdx
cmovbq %rdx, %rsi
subq %r15, %rsi
addq %rsi, %rcx
addq $-0x3, %rcx
testb %dil, %dil
je 0x35c7c
movb %dil, (%rcx)
incq %rcx
movl $0x2e2e2e, (%rcx)       # imm = 0x2E2E2E
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq