// File: /workspace/github_c_makefile_star2_O1/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 0x32d6b
movq (%rbx), %rax
addq $0x2, %rax
cmpq %rax, 0x8(%rbx)
jae 0x32d49
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 0x32e4d
movq %rax, 0x10(%rbx)
movq %r15, 0x8(%rbx)
orb $0x30, %r14b
movq (%rbx), %rax
movq 0x10(%rbx), %rcx
leaq 0x1(%rax), %rdx
movq %rdx, (%rbx)
movb %r14b, (%rcx,%rax)
movq 0x10(%rbx), %r12
addq (%rbx), %r12
jmp 0x32e37
bsrl %r14d, %eax
xorl $0x1f, %eax
shll $0x2, %eax
leaq 0x677b4(%rip), %rcx     # 0x9a530
movl (%rax,%rcx), %r13d
leaq 0x67829(%rip), %rcx     # 0x9a5b0
xorl %ebp, %ebp
cmpl %r14d, (%rax,%rcx)
seta %bpl
movl %r13d, %r12d
subl %ebp, %r12d
movq (%rbx), %rax
addq %r12, %rax
addq $0x2, %rax
cmpq %rax, 0x8(%rbx)
jae 0x32dda
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 0x32e4d
movq %rax, 0x10(%rbx)
movq %r15, 0x8(%rbx)
negl %ebp
movq 0x10(%rbx), %rax
addq (%rbx), %rax
leal -0x2(%r13,%rbp), %ecx
leaq 0x649a1(%rip), %rdx     # 0x97790
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 %ecx, %edi
movzwl (%rdx,%r8,2), %r8d
movw %r8w, (%rax,%rdi)
addl $-0x2, %ecx
cmpl $0x3e7, %esi            # imm = 0x3E7
ja 0x32def
cmpl $-0x1, %ecx
jne 0x32e2d
orb $0x30, %r14b
movb %r14b, (%rax)
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 0x32e3e
nopw %cs:(%rax,%rax)