// File: /workspace/github_c_makefile_star2_O3/samtools[P]htslib/./htslib/kstring.h
// Function: kputuw
static inline int kputuw(unsigned x, kstring_t *s)
{
#if HAVE___BUILTIN_CLZ && UINT_MAX == 4294967295U
    static const unsigned int kputuw_num_digits[32] = {
        10, 10, 10,  9,  9,  9,  8,  8,
        8,   7,  7,  7,  7,  6,  6,  6,
        5,   5,  5,  4,  4,  4,  4,  3,
        3,   3,  2,  2,  2,  1,  1,  1
    };
    static const unsigned int kputuw_thresholds[32] = {
        0,        0, 1000000000U, 0,       0, 100000000U,   0,      0,
        10000000, 0,          0,  0, 1000000,         0,    0, 100000,
        0,        0,      10000,  0,       0,         0, 1000,      0,
        0,      100,          0,  0,      10,         0,    0,      0
    };
#else
    uint64_t m;
#endif
    static const char kputuw_dig2r[] =
        "00010203040506070809"
        "10111213141516171819"
        "20212223242526272829"
        "30313233343536373839"
        "40414243444546474849"
        "50515253545556575859"
        "60616263646566676869"
        "70717273747576777879"
        "80818283848586878889"
        "90919293949596979899";
    unsigned int l, j;
    char *cp;

    // Trivial case - also prevents __builtin_clz(0), which is undefined
    if (x < 10) {
        if (ks_resize(s, s->l + 2) < 0)
            return EOF;
        s->s[s->l++] = '0'+x;
        s->s[s->l] = 0;
        return 0;
    }

    // Find out how many digits are to be printed.
#if HAVE___BUILTIN_CLZ && UINT_MAX == 4294967295U
    /*
     * Table method - should be quick if clz can be done in hardware.
     * Find the most significant bit of the value to print and look
     * up in a table to find out how many decimal digits are needed.
     * This number needs to be adjusted by 1 for cases where the decimal
     * length could vary for a given number of bits (for example,
     * a four bit number could be between 8 and 15).
     */

    l = __builtin_clz(x);
    l = kputuw_num_digits[l] - (x < kputuw_thresholds[l]);
#else
    // Fallback for when clz is not available
    m = 1;
    l = 0;
    do {
        l++;
        m *= 10;
    } while (x >= m);
#endif

    if (ks_resize(s, s->l + l + 2) < 0)
        return EOF;

    // Add digits two at a time
    j = l;
    cp = s->s + s->l;
    while (x >= 10) {
        const char *d = &kputuw_dig2r[2*(x%100)];
        x /= 100;
        memcpy(&cp[j-=2], d, 2);
    }

    // Last one (if necessary).  We know that x < 10 by now.
    if (j == 1)
        cp[0] = x + '0';

    s->l += l;
    s->s[s->l] = 0;
    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %rbx
movl %edi, %r14d
cmpl $0x9, %edi
ja 0x31bb4
movq (%rbx), %rcx
leaq 0x2(%rcx), %rax
cmpq %rax, 0x8(%rbx)
jae 0x31c2d
movq %rax, %rcx
shrq $0x3e, %rcx
movq %rax, %rdx
shrq %rdx
xorl %r15d, %r15d
testq %rcx, %rcx
cmoveq %rdx, %r15
addq %rax, %r15
movq 0x10(%rbx), %rdi
movq %r15, %rsi
callq 0x4840
testq %rax, %rax
je 0x31cbc
movq %rax, 0x10(%rbx)
movq %r15, 0x8(%rbx)
movq (%rbx), %rcx
jmp 0x31c31
bsrl %r14d, %eax
xorl $0x1f, %eax
shll $0x2, %eax
leaq 0x6597b(%rip), %rcx     # 0x97540
movl (%rax,%rcx), %r13d
leaq 0x659f0(%rip), %rcx     # 0x975c0
xorl %ebp, %ebp
cmpl %r14d, (%rax,%rcx)
seta %bpl
movl %r13d, %r12d
subl %ebp, %r12d
movq (%rbx), %rcx
leaq (%rcx,%r12), %rax
addq $0x2, %rax
cmpq %rax, 0x8(%rbx)
jae 0x31c49
movq %rax, %rcx
shrq $0x3e, %rcx
movq %rax, %rdx
shrq %rdx
xorl %r15d, %r15d
testq %rcx, %rcx
cmoveq %rdx, %r15
addq %rax, %r15
movq 0x10(%rbx), %rdi
movq %r15, %rsi
callq 0x4840
testq %rax, %rax
je 0x31cbc
movq %rax, 0x10(%rbx)
movq %r15, 0x8(%rbx)
movq (%rbx), %rcx
jmp 0x31c4d
movq 0x10(%rbx), %rax
orb $0x30, %r14b
leaq 0x1(%rcx), %rdx
movq %rdx, (%rbx)
movb %r14b, (%rax,%rcx)
movq 0x10(%rbx), %r12
addq (%rbx), %r12
jmp 0x31ca6
movq 0x10(%rbx), %rax
addq %rax, %rcx
negl %ebp
leal -0x2(%r13,%rbp), %eax
leaq 0x62b32(%rip), %rdx     # 0x94790
movl %r14d, %esi
movl %r14d, %edi
imulq $0x51eb851f, %rdi, %r14 # imm = 0x51EB851F
shrq $0x25, %r14
imull $0x64, %r14d, %edi
movl %esi, %r8d
subl %edi, %r8d
movl %eax, %edi
movzwl (%rdx,%r8,2), %r8d
movw %r8w, (%rcx,%rdi)
addl $-0x2, %eax
cmpl $0x3e7, %esi            # imm = 0x3E7
ja 0x31c5e
cmpl $-0x1, %eax
jne 0x31c9c
orb $0x30, %r14b
movb %r14b, (%rcx)
addq (%rbx), %r12
movq %r12, (%rbx)
addq 0x10(%rbx), %r12
movb $0x0, (%r12)
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
jmp 0x31cad
nopw %cs:(%rax,%rax)
nopw %cs:(%rax,%rax)