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

// Assembly:
movq %rsi, %rcx
cmpq $0x80, %rsi
jae 0x26991
pushq $0x1
jmp 0x26b2b
cmpq $0x3fff, %rcx           # imm = 0x3FFF
ja 0x269ad
movl %ecx, %eax
shrl $0x8, %eax
orb $-0x80, %al
movb %al, (%rdi)
incq %rdi
pushq $0x2
jmp 0x26b2b
cmpq $0x1fffff, %rcx         # imm = 0x1FFFFF
ja 0x269cd
movl %ecx, %eax
shrl $0x10, %eax
orb $-0x40, %al
movb %al, (%rdi)
movb %ch, 0x1(%rdi)
addq $0x2, %rdi
pushq $0x3
jmp 0x26b2b
cmpq $0xfffffff, %rcx        # imm = 0xFFFFFFF
ja 0x269f5
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 0x26b2b
movq %rcx, %rax
shrq $0x23, %rax
jne 0x26a27
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 0x26b2b
movq %rcx, %rax
shrq $0x2a, %rax
jne 0x26a63
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 0x26b2b
movq %rcx, %rax
shrq $0x31, %rax
jne 0x26aa9
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 0x26b2b
movq %rcx, %rax
shrq $0x38, %rax
jne 0x26aee
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 0x26b2b
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