// File: /workspace/github_c_makefile_star2_O2/samtools[P]htslib/cram/cram_io.c
// Function: ltf8_put
static inline int ltf8_put(char *cp, int64_t val) {
    unsigned char *up = (unsigned char *)cp;
    if        (!(val & ~((1LL<<7)-1))) {
        *up = val;
        return 1;
    } else if (!(val & ~((1LL<<(6+8))-1))) {
        *up++ = (val >> 8 ) | 0x80;
        *up   = val & 0xff;
        return 2;
    } else if (!(val & ~((1LL<<(5+2*8))-1))) {
        *up++ = (val >> 16) | 0xc0;
        *up++ = (val >> 8 ) & 0xff;
        *up   = val & 0xff;
        return 3;
    } else if (!(val & ~((1LL<<(4+3*8))-1))) {
        *up++ = (val >> 24) | 0xe0;
        *up++ = (val >> 16) & 0xff;
        *up++ = (val >> 8 ) & 0xff;
        *up   = val & 0xff;
        return 4;
    } else if (!(val & ~((1LL<<(3+4*8))-1))) {
        *up++ = (val >> 32) | 0xf0;
        *up++ = (val >> 24) & 0xff;
        *up++ = (val >> 16) & 0xff;
        *up++ = (val >> 8 ) & 0xff;
        *up   = val & 0xff;
        return 5;
    } else if (!(val & ~((1LL<<(2+5*8))-1))) {
        *up++ = (val >> 40) | 0xf8;
        *up++ = (val >> 32) & 0xff;
        *up++ = (val >> 24) & 0xff;
        *up++ = (val >> 16) & 0xff;
        *up++ = (val >> 8 ) & 0xff;
        *up   = val & 0xff;
        return 6;
    } else if (!(val & ~((1LL<<(1+6*8))-1))) {
        *up++ = (val >> 48) | 0xfc;
        *up++ = (val >> 40) & 0xff;
        *up++ = (val >> 32) & 0xff;
        *up++ = (val >> 24) & 0xff;
        *up++ = (val >> 16) & 0xff;
        *up++ = (val >> 8 ) & 0xff;
        *up   = val & 0xff;
        return 7;
    } else if (!(val & ~((1LL<<(7*8))-1))) {
        *up++ = (val >> 56) | 0xfe;
        *up++ = (val >> 48) & 0xff;
        *up++ = (val >> 40) & 0xff;
        *up++ = (val >> 32) & 0xff;
        *up++ = (val >> 24) & 0xff;
        *up++ = (val >> 16) & 0xff;
        *up++ = (val >> 8 ) & 0xff;
        *up   = val & 0xff;
        return 8;
    } else {
        *up++ = 0xff;
        *up++ = (val >> 56) & 0xff;
        *up++ = (val >> 48) & 0xff;
        *up++ = (val >> 40) & 0xff;
        *up++ = (val >> 32) & 0xff;
        *up++ = (val >> 24) & 0xff;
        *up++ = (val >> 16) & 0xff;
        *up++ = (val >> 8 ) & 0xff;
        *up   = val & 0xff;
        return 9;
    }
}

// Assembly:
movq %rsi, %rcx
cmpq $0x80, %rsi
jae 0x3f05d
pushq $0x1
jmp 0x3f1f7
cmpq $0x3fff, %rcx           # imm = 0x3FFF
ja 0x3f079
movl %ecx, %eax
shrl $0x8, %eax
orb $-0x80, %al
movb %al, (%rdi)
incq %rdi
pushq $0x2
jmp 0x3f1f7
cmpq $0x1fffff, %rcx         # imm = 0x1FFFFF
ja 0x3f099
movl %ecx, %eax
shrl $0x10, %eax
orb $-0x40, %al
movb %al, (%rdi)
movb %ch, 0x1(%rdi)
addq $0x2, %rdi
pushq $0x3
jmp 0x3f1f7
cmpq $0xfffffff, %rcx        # imm = 0xFFFFFFF
ja 0x3f0c1
movl %ecx, %eax
shrl $0x18, %eax
orb $-0x20, %al
movb %al, (%rdi)
movl %ecx, %eax
shrl $0x10, %eax
movb %al, 0x1(%rdi)
movb %ch, 0x2(%rdi)
addq $0x3, %rdi
pushq $0x4
jmp 0x3f1f7
movq %rcx, %rax
shrq $0x23, %rax
jne 0x3f0f3
movq %rcx, %rax
shrq $0x20, %rax
orb $-0x10, %al
movb %al, (%rdi)
movl %ecx, %eax
shrl $0x18, %eax
movb %al, 0x1(%rdi)
movl %ecx, %eax
shrl $0x10, %eax
movb %al, 0x2(%rdi)
movb %ch, 0x3(%rdi)
addq $0x4, %rdi
pushq $0x5
jmp 0x3f1f7
movq %rcx, %rax
shrq $0x2a, %rax
jne 0x3f12f
movq %rcx, %rax
shrq $0x28, %rax
orb $-0x8, %al
movb %al, (%rdi)
movq %rcx, %rax
shrq $0x20, %rax
movb %al, 0x1(%rdi)
movl %ecx, %eax
shrl $0x18, %eax
movb %al, 0x2(%rdi)
movl %ecx, %eax
shrl $0x10, %eax
movb %al, 0x3(%rdi)
movb %ch, 0x4(%rdi)
addq $0x5, %rdi
pushq $0x6
jmp 0x3f1f7
movq %rcx, %rax
shrq $0x31, %rax
jne 0x3f175
movq %rcx, %rax
shrq $0x30, %rax
orb $-0x4, %al
movb %al, (%rdi)
movq %rcx, %rax
shrq $0x28, %rax
movb %al, 0x1(%rdi)
movq %rcx, %rax
shrq $0x20, %rax
movb %al, 0x2(%rdi)
movl %ecx, %eax
shrl $0x18, %eax
movb %al, 0x3(%rdi)
movl %ecx, %eax
shrl $0x10, %eax
movb %al, 0x4(%rdi)
movb %ch, 0x5(%rdi)
addq $0x6, %rdi
pushq $0x7
jmp 0x3f1f7
movq %rcx, %rax
shrq $0x38, %rax
jne 0x3f1ba
movb $-0x2, (%rdi)
movq %rcx, %rax
shrq $0x30, %rax
movb %al, 0x1(%rdi)
movq %rcx, %rax
shrq $0x28, %rax
movb %al, 0x2(%rdi)
movq %rcx, %rax
shrq $0x20, %rax
movb %al, 0x3(%rdi)
movl %ecx, %eax
shrl $0x18, %eax
movb %al, 0x4(%rdi)
movl %ecx, %eax
shrl $0x10, %eax
movb %al, 0x5(%rdi)
movb %ch, 0x6(%rdi)
addq $0x7, %rdi
pushq $0x8
jmp 0x3f1f7
movb $-0x1, (%rdi)
movb %al, 0x1(%rdi)
movq %rcx, %rax
shrq $0x30, %rax
movb %al, 0x2(%rdi)
movq %rcx, %rax
shrq $0x28, %rax
movb %al, 0x3(%rdi)
movq %rcx, %rax
shrq $0x20, %rax
movb %al, 0x4(%rdi)
movl %ecx, %eax
shrl $0x18, %eax
movb %al, 0x5(%rdi)
movl %ecx, %eax
shrl $0x10, %eax
movb %al, 0x6(%rdi)
movb %ch, 0x7(%rdi)
addq $0x8, %rdi
pushq $0x9
popq %rax
movb %cl, (%rdi)
retq