// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x30, %rsp
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
cmpl $0xa, -0x8(%rbp)
jae 0x988d
movq -0x10(%rbp), %rdi
movq -0x10(%rbp), %rax
movq (%rax), %rsi
addq $0x2, %rsi
callq 0x9040
cmpl $0x0, %eax
jge 0x984a
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x999a
movl -0x8(%rbp), %eax
addl $0x30, %eax
movb %al, %dl
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x10(%rbp), %rsi
movq (%rsi), %rcx
movq %rcx, %rdi
addq $0x1, %rdi
movq %rdi, (%rsi)
movb %dl, (%rax,%rcx)
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x10(%rbp), %rcx
movq (%rcx), %rcx
movb $0x0, (%rax,%rcx)
movl $0x0, -0x4(%rbp)
jmp 0x999a
movl -0x8(%rbp), %eax
bsrl %eax, %eax
xorl $0x1f, %eax
movl %eax, -0x14(%rbp)
movl -0x14(%rbp), %eax
movl %eax, %ecx
leaq 0xe396b(%rip), %rax     # 0xed210
movl (%rax,%rcx,4), %eax
movl -0x8(%rbp), %ecx
movl -0x14(%rbp), %edx
movl %edx, %esi
leaq 0xe39d9(%rip), %rdx     # 0xed290
cmpl (%rdx,%rsi,4), %ecx
setb %cl
andb $0x1, %cl
movzbl %cl, %ecx
subl %ecx, %eax
movl %eax, -0x14(%rbp)
movq -0x10(%rbp), %rdi
movq -0x10(%rbp), %rax
movq (%rax), %rsi
movl -0x14(%rbp), %eax
addq %rax, %rsi
addq $0x2, %rsi
callq 0x9040
cmpl $0x0, %eax
jge 0x98f3
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x999a
movl -0x14(%rbp), %eax
movl %eax, -0x18(%rbp)
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x10(%rbp), %rcx
addq (%rcx), %rax
movq %rax, -0x20(%rbp)
cmpl $0xa, -0x8(%rbp)
jb 0x995d
movl -0x8(%rbp), %eax
movl $0x64, %ecx
xorl %edx, %edx
divl %ecx
shll %edx
movl %edx, %eax
movl %eax, %ecx
leaq 0xe39e5(%rip), %rax     # 0xed310
addq %rcx, %rax
movq %rax, -0x28(%rbp)
movl -0x8(%rbp), %eax
movl $0x64, %ecx
xorl %edx, %edx
divl %ecx
movl %eax, -0x8(%rbp)
movq -0x20(%rbp), %rax
movl -0x18(%rbp), %ecx
subl $0x2, %ecx
movl %ecx, -0x18(%rbp)
movl %ecx, %ecx
movq -0x28(%rbp), %rdx
movw (%rdx), %dx
movw %dx, (%rax,%rcx)
jmp 0x990c
cmpl $0x1, -0x18(%rbp)
jne 0x9971
movl -0x8(%rbp), %eax
addl $0x30, %eax
movb %al, %cl
movq -0x20(%rbp), %rax
movb %cl, (%rax)
movl -0x14(%rbp), %eax
movl %eax, %ecx
movq -0x10(%rbp), %rax
addq (%rax), %rcx
movq %rcx, (%rax)
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x10(%rbp), %rcx
movq (%rcx), %rcx
movb $0x0, (%rax,%rcx)
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)