// File: /workspace/github_c_makefile_star2_O2/samtools[P]htslib/cram/../htscodecs/htscodecs/varint.h
// Function: var_put_u64
static inline
int var_put_u64(uint8_t *cp, const uint8_t *endp, uint64_t i) {
    if (endp && (endp-cp) < 10)
        return var_put_u64_safe(cp, endp, i);

    // maximum of 10 bytes written
    if (i < (1<<7)) {
        *cp = i;
        return 1;
    } else if (i < (1<<14)) {
        *cp++ = ((i>> 7) & 0x7f) | 128;
        *cp++ =   i      & 0x7f;
        return 2;
    } else if (i < (1<<21)) {
        *cp++ = ((i>>14) & 0x7f) | 128;
        *cp++ = ((i>> 7) & 0x7f) | 128;
        *cp++ =   i      & 0x7f;
        return 3;
    } else if (i < (1<<28)) {
        *cp++ = ((i>>21) & 0x7f) | 128;
        *cp++ = ((i>>14) & 0x7f) | 128;
        *cp++ = ((i>> 7) & 0x7f) | 128;
        *cp++ =   i      & 0x7f;
        return 4;
    } else if (i < (1ULL<<35)) {
        *cp++ = ((i>>28) & 0x7f) | 128;
        *cp++ = ((i>>21) & 0x7f) | 128;
        *cp++ = ((i>>14) & 0x7f) | 128;
        *cp++ = ((i>> 7) & 0x7f) | 128;
        *cp++ =   i      & 0x7f;
        return 5;
    } else if (i < (1ULL<<42)) {
        *cp++ = ((i>>35) & 0x7f) | 128;
        *cp++ = ((i>>28) & 0x7f) | 128;
        *cp++ = ((i>>21) & 0x7f) | 128;
        *cp++ = ((i>>14) & 0x7f) | 128;
        *cp++ = ((i>> 7) & 0x7f) | 128;
        *cp++ =   i      & 0x7f;
        return 6;
    } else if (i < (1ULL<<49)) {
        *cp++ = ((i>>42) & 0x7f) | 128;
        *cp++ = ((i>>35) & 0x7f) | 128;
        *cp++ = ((i>>28) & 0x7f) | 128;
        *cp++ = ((i>>21) & 0x7f) | 128;
        *cp++ = ((i>>14) & 0x7f) | 128;
        *cp++ = ((i>> 7) & 0x7f) | 128;
        *cp++ =   i      & 0x7f;
        return 7;
    } else if (i < (1ULL<<56)) {
        *cp++ = ((i>>49) & 0x7f) | 128;
        *cp++ = ((i>>42) & 0x7f) | 128;
        *cp++ = ((i>>35) & 0x7f) | 128;
        *cp++ = ((i>>28) & 0x7f) | 128;
        *cp++ = ((i>>21) & 0x7f) | 128;
        *cp++ = ((i>>14) & 0x7f) | 128;
        *cp++ = ((i>> 7) & 0x7f) | 128;
        *cp++ =   i      & 0x7f;
        return 8;
    } else if (i < (1ULL<<63)) {
        *cp++ = ((i>>56) & 0x7f) | 128;
        *cp++ = ((i>>49) & 0x7f) | 128;
        *cp++ = ((i>>42) & 0x7f) | 128;
        *cp++ = ((i>>35) & 0x7f) | 128;
        *cp++ = ((i>>28) & 0x7f) | 128;
        *cp++ = ((i>>21) & 0x7f) | 128;
        *cp++ = ((i>>14) & 0x7f) | 128;
        *cp++ = ((i>> 7) & 0x7f) | 128;
        *cp++ =   i      & 0x7f;
        return 9;
    } else {
        *cp++ = ((i>>63) & 0x7f) | 128;
        *cp++ = ((i>>56) & 0x7f) | 128;
        *cp++ = ((i>>49) & 0x7f) | 128;
        *cp++ = ((i>>42) & 0x7f) | 128;
        *cp++ = ((i>>35) & 0x7f) | 128;
        *cp++ = ((i>>28) & 0x7f) | 128;
        *cp++ = ((i>>21) & 0x7f) | 128;
        *cp++ = ((i>>14) & 0x7f) | 128;
        *cp++ = ((i>> 7) & 0x7f) | 128;
        *cp++ =   i      & 0x7f;
    }

    return 10;
}

// Assembly:
testq %rsi, %rsi
sete %al
subq %rdi, %rsi
cmpq $0xa, %rsi
setge %cl
orb %al, %cl
jne 0x47301
pushq $-0xe
popq %r8
xorl %ecx, %ecx
movq %rdx, %r9
movq %rdx, %rax
shrq $0x7, %rax
addl $0x7, %r8d
addq $0x7, %rcx
cmpq $0x7f, %r9
movq %rax, %r9
ja 0x472a4
imulq $0x7, %rsi, %rsi
xorl %eax, %eax
cmpq %rcx, %rsi
jl 0x47300
leal 0x7(%r8), %ecx
xorl %eax, %eax
cmpl $0xa, %eax
je 0x472fb
xorl %esi, %esi
testl %ecx, %ecx
setne %sil
movq %rdx, %r9
shrq %cl, %r9
andl $0x7f, %r9d
shll $0x7, %esi
orl %r9d, %esi
movb %sil, (%rdi,%rax)
incq %rax
addl $-0x7, %ecx
addl $-0x7, %r8d
cmpl $-0xe, %r8d
jne 0x472ca
addq %rdi, %rax
subl %edi, %eax
retq
cmpq $0x7f, %rdx
ja 0x47310
movb %dl, (%rdi)
pushq $0x1
jmp 0x47549
cmpq $0x3fff, %rdx           # imm = 0x3FFF
ja 0x4732f
movl %edx, %eax
shrl $0x7, %eax
orb $-0x80, %al
movb %al, (%rdi)
andb $0x7f, %dl
movb %dl, 0x1(%rdi)
pushq $0x2
jmp 0x47549
cmpq $0x1fffff, %rdx         # imm = 0x1FFFFF
ja 0x47358
movl %edx, %eax
shrl $0xe, %eax
orb $-0x80, %al
movb %al, (%rdi)
movl %edx, %eax
shrl $0x7, %eax
orb $-0x80, %al
movb %al, 0x1(%rdi)
andb $0x7f, %dl
movb %dl, 0x2(%rdi)
pushq $0x3
jmp 0x47549
cmpq $0xfffffff, %rdx        # imm = 0xFFFFFFF
ja 0x4738b
movl %edx, %eax
shrl $0x15, %eax
orb $-0x80, %al
movb %al, (%rdi)
movl %edx, %eax
shrl $0xe, %eax
orb $-0x80, %al
movb %al, 0x1(%rdi)
movl %edx, %eax
shrl $0x7, %eax
orb $-0x80, %al
movb %al, 0x2(%rdi)
andb $0x7f, %dl
movb %dl, 0x3(%rdi)
pushq $0x4
jmp 0x47549
movq %rdx, %rax
shrq $0x23, %rax
jne 0x473ca
movq %rdx, %rax
shrq $0x1c, %rax
orb $-0x80, %al
movb %al, (%rdi)
movl %edx, %eax
shrl $0x15, %eax
orb $-0x80, %al
movb %al, 0x1(%rdi)
movl %edx, %eax
shrl $0xe, %eax
orb $-0x80, %al
movb %al, 0x2(%rdi)
movl %edx, %eax
shrl $0x7, %eax
orb $-0x80, %al
movb %al, 0x3(%rdi)
andb $0x7f, %dl
movb %dl, 0x4(%rdi)
pushq $0x5
jmp 0x47549
movq %rdx, %rcx
shrq $0x2a, %rcx
jne 0x4740e
orb $-0x80, %al
movb %al, (%rdi)
movq %rdx, %rax
shrq $0x1c, %rax
orb $-0x80, %al
movb %al, 0x1(%rdi)
movl %edx, %eax
shrl $0x15, %eax
orb $-0x80, %al
movb %al, 0x2(%rdi)
movl %edx, %eax
shrl $0xe, %eax
orb $-0x80, %al
movb %al, 0x3(%rdi)
movl %edx, %eax
shrl $0x7, %eax
orb $-0x80, %al
movb %al, 0x4(%rdi)
andb $0x7f, %dl
movb %dl, 0x5(%rdi)
pushq $0x6
jmp 0x47549
movq %rdx, %rsi
shrq $0x31, %rsi
jne 0x47458
orb $-0x80, %cl
movb %cl, (%rdi)
orb $-0x80, %al
movb %al, 0x1(%rdi)
movq %rdx, %rax
shrq $0x1c, %rax
orb $-0x80, %al
movb %al, 0x2(%rdi)
movl %edx, %eax
shrl $0x15, %eax
orb $-0x80, %al
movb %al, 0x3(%rdi)
movl %edx, %eax
shrl $0xe, %eax
orb $-0x80, %al
movb %al, 0x4(%rdi)
movl %edx, %eax
shrl $0x7, %eax
orb $-0x80, %al
movb %al, 0x5(%rdi)
andb $0x7f, %dl
movb %dl, 0x6(%rdi)
pushq $0x7
jmp 0x47549
movq %rdx, %r8
shrq $0x38, %r8
jne 0x474aa
orb $-0x80, %sil
movb %sil, (%rdi)
orb $-0x80, %cl
movb %cl, 0x1(%rdi)
orb $-0x80, %al
movb %al, 0x2(%rdi)
movq %rdx, %rax
shrq $0x1c, %rax
orb $-0x80, %al
movb %al, 0x3(%rdi)
movl %edx, %eax
shrl $0x15, %eax
orb $-0x80, %al
movb %al, 0x4(%rdi)
movl %edx, %eax
shrl $0xe, %eax
orb $-0x80, %al
movb %al, 0x5(%rdi)
movl %edx, %eax
shrl $0x7, %eax
orb $-0x80, %al
movb %al, 0x6(%rdi)
andb $0x7f, %dl
movb %dl, 0x7(%rdi)
pushq $0x8
jmp 0x47549
testq %rdx, %rdx
js 0x474fd
orb $-0x80, %r8b
movb %r8b, (%rdi)
orb $-0x80, %sil
movb %sil, 0x1(%rdi)
orb $-0x80, %cl
movb %cl, 0x2(%rdi)
orb $-0x80, %al
movb %al, 0x3(%rdi)
movq %rdx, %rax
shrq $0x1c, %rax
orb $-0x80, %al
movb %al, 0x4(%rdi)
movl %edx, %eax
shrl $0x15, %eax
orb $-0x80, %al
movb %al, 0x5(%rdi)
movl %edx, %eax
shrl $0xe, %eax
orb $-0x80, %al
movb %al, 0x6(%rdi)
movl %edx, %eax
shrl $0x7, %eax
orb $-0x80, %al
movb %al, 0x7(%rdi)
andb $0x7f, %dl
movb %dl, 0x8(%rdi)
pushq $0x9
jmp 0x47549
movb $-0x7f, (%rdi)
movb %r8b, 0x1(%rdi)
orb $-0x80, %sil
movb %sil, 0x2(%rdi)
orb $-0x80, %cl
movb %cl, 0x3(%rdi)
orb $-0x80, %al
movb %al, 0x4(%rdi)
movq %rdx, %rax
shrq $0x1c, %rax
orb $-0x80, %al
movb %al, 0x5(%rdi)
movl %edx, %eax
shrl $0x15, %eax
orb $-0x80, %al
movb %al, 0x6(%rdi)
movl %edx, %eax
shrl $0xe, %eax
orb $-0x80, %al
movb %al, 0x7(%rdi)
movl %edx, %eax
shrl $0x7, %eax
orb $-0x80, %al
movb %al, 0x8(%rdi)
andb $0x7f, %dl
movb %dl, 0x9(%rdi)
pushq $0xa
popq %rax
retq