// File: /workspace/github_c_makefile_star2_O1/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 0x58764
movq $-0x1, %r8
xorl %ecx, %ecx
movq %rdx, %r9
movq %rdx, %rax
shrq $0x7, %rax
incq %r8
addq $0x7, %rcx
cmpq $0x7f, %r9
movq %rax, %r9
ja 0x586ff
leaq (,%rsi,8), %r9
subq %rsi, %r9
xorl %eax, %eax
cmpq %rcx, %r9
jl 0x58763
addq $-0x7, %rcx
cmpq $0x9, %r8
movl $0x9, %esi
cmovbq %r8, %rsi
incq %rsi
xorl %eax, %eax
xorl %r8d, %r8d
testl %ecx, %ecx
setne %r8b
movq %rdx, %r9
shrq %cl, %r9
andl $0x7f, %r9d
shll $0x7, %r8d
orl %r9d, %r8d
movb %r8b, (%rdi,%rax)
incq %rax
addl $-0x7, %ecx
cmpl %eax, %esi
jne 0x5873b
retq
cmpq $0x7f, %rdx
ja 0x58772
movb %dl, (%rdi)
movl $0x1, %eax
retq
cmpq $0x3fff, %rdx           # imm = 0x3FFF
ja 0x58790
movl %edx, %eax
shrl $0x7, %eax
orb $-0x80, %al
movb %al, (%rdi)
andb $0x7f, %dl
movb %dl, 0x1(%rdi)
movl $0x2, %eax
retq
cmpq $0x1fffff, %rdx         # imm = 0x1FFFFF
ja 0x587b8
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)
movl $0x3, %eax
retq
cmpq $0xfffffff, %rdx        # imm = 0xFFFFFFF
ja 0x587ea
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)
movl $0x4, %eax
retq
movq %rdx, %rax
shrq $0x23, %rax
jne 0x58828
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)
movl $0x5, %eax
retq
movq %rdx, %rcx
shrq $0x2a, %rcx
jne 0x5886b
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)
movl $0x6, %eax
retq
movq %rdx, %rsi
shrq $0x31, %rsi
jne 0x588b4
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)
movl $0x7, %eax
retq
movq %rdx, %r8
shrq $0x38, %r8
jne 0x58905
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)
movl $0x8, %eax
retq
testq %rdx, %rdx
js 0x5895a
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)
movl $0x9, %eax
retq
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)
movl $0xa, %eax
retq
nop