// File: /workspace/github_cpp_makefile_star2_O3/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
movl $0x1, %eax
cmpq $0x80, %rsi
jb 0x30308
cmpq $0x3fff, %rcx           # imm = 0x3FFF
ja 0x30175
movl %ecx, %eax
shrl $0x8, %eax
orb $-0x80, %al
movb %al, (%rdi)
incq %rdi
movl $0x2, %eax
jmp 0x30308
cmpq $0x1fffff, %rcx         # imm = 0x1FFFFF
ja 0x30198
movl %ecx, %eax
shrl $0x10, %eax
orb $-0x40, %al
movb %al, (%rdi)
movb %ch, 0x1(%rdi)
addq $0x2, %rdi
movl $0x3, %eax
jmp 0x30308
cmpq $0xfffffff, %rcx        # imm = 0xFFFFFFF
ja 0x301c3
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
movl $0x4, %eax
jmp 0x30308
movq %rcx, %rax
shrq $0x23, %rax
jne 0x301f8
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
movl $0x5, %eax
jmp 0x30308
movq %rcx, %rax
shrq $0x2a, %rax
jne 0x30237
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
movl $0x6, %eax
jmp 0x30308
movq %rcx, %rax
shrq $0x31, %rax
jne 0x30280
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
movl $0x7, %eax
jmp 0x30308
movq %rcx, %rax
shrq $0x38, %rax
jne 0x302c8
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
movl $0x8, %eax
jmp 0x30308
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
movl $0x9, %eax
movb %cl, (%rdi)
retq