// File: /workspace/github_cpp_makefile_star2_O3/karel-brinda[P]ococo/ext/htslib/cram/cram_io.c
// Function: ltf8_decode
int ltf8_decode(cram_fd *fd, int64_t *val_p) {
    int c = hgetc(fd->fp);
    int64_t val = (unsigned char)c;
    if (c == -1)
	return -1;

    if (val < 0x80) {
	*val_p =   val;
	return 1;

    } else if (val < 0xc0) {
	val = (val<<8) | (unsigned char)hgetc(fd->fp);
	*val_p = val & (((1LL<<(6+8)))-1);
	return 2;

    } else if (val < 0xe0) {
	val = (val<<8) | (unsigned char)hgetc(fd->fp);
	val = (val<<8) | (unsigned char)hgetc(fd->fp);
	*val_p = val & ((1LL<<(5+2*8))-1);
	return 3;

    } else if (val < 0xf0) {
	val = (val<<8) | (unsigned char)hgetc(fd->fp);
	val = (val<<8) | (unsigned char)hgetc(fd->fp);
	val = (val<<8) | (unsigned char)hgetc(fd->fp);
	*val_p = val & ((1LL<<(4+3*8))-1);
	return 4;

    } else if (val < 0xf8) {
	val = (val<<8) | (unsigned char)hgetc(fd->fp);
	val = (val<<8) | (unsigned char)hgetc(fd->fp);
	val = (val<<8) | (unsigned char)hgetc(fd->fp);
	val = (val<<8) | (unsigned char)hgetc(fd->fp);
	*val_p = val & ((1LL<<(3+4*8))-1);
	return 5;

    } else if (val < 0xfc) {
	val = (val<<8) | (unsigned char)hgetc(fd->fp);
	val = (val<<8) | (unsigned char)hgetc(fd->fp);
	val = (val<<8) | (unsigned char)hgetc(fd->fp);
	val = (val<<8) | (unsigned char)hgetc(fd->fp);
	val = (val<<8) | (unsigned char)hgetc(fd->fp);
	*val_p = val & ((1LL<<(2+5*8))-1);
	return 6;

    } else if (val < 0xfe) {
	val = (val<<8) | (unsigned char)hgetc(fd->fp);
	val = (val<<8) | (unsigned char)hgetc(fd->fp);
	val = (val<<8) | (unsigned char)hgetc(fd->fp);
	val = (val<<8) | (unsigned char)hgetc(fd->fp);
	val = (val<<8) | (unsigned char)hgetc(fd->fp);
	val = (val<<8) | (unsigned char)hgetc(fd->fp);
	*val_p = val & ((1LL<<(1+6*8))-1);
	return 7;

    } else if (val < 0xff) {
	val = (val<<8) | (unsigned char)hgetc(fd->fp);
	val = (val<<8) | (unsigned char)hgetc(fd->fp);
	val = (val<<8) | (unsigned char)hgetc(fd->fp);
	val = (val<<8) | (unsigned char)hgetc(fd->fp);
	val = (val<<8) | (unsigned char)hgetc(fd->fp);
	val = (val<<8) | (unsigned char)hgetc(fd->fp);
	val = (val<<8) | (unsigned char)hgetc(fd->fp);
	*val_p = val & ((1LL<<(7*8))-1);
	return 8;

    } else {
	val = (val<<8) | (unsigned char)hgetc(fd->fp);
	val = (val<<8) | (unsigned char)hgetc(fd->fp);
	val = (val<<8) | (unsigned char)hgetc(fd->fp);
	val = (val<<8) | (unsigned char)hgetc(fd->fp);
	val = (val<<8) | (unsigned char)hgetc(fd->fp);
	val = (val<<8) | (unsigned char)hgetc(fd->fp);
	val = (val<<8) | (unsigned char)hgetc(fd->fp);
	val = (val<<8) | (unsigned char)hgetc(fd->fp);
	*val_p = val;
    }

    return 9;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %rsi, %rbx
movq %rdi, %r14
movq (%rdi), %rdi
movq 0x8(%rdi), %rax
cmpq %rax, 0x10(%rdi)
jbe 0x30528
leaq 0x1(%rax), %rcx
movq %rcx, 0x8(%rdi)
movzbl (%rax), %r15d
jmp 0x30536
callq 0x4703e
cmpl $-0x1, %eax
je 0x30595
movzbl %al, %r15d
movl $0x1, %eax
cmpl $0x80, %r15d
jb 0x307e3
cmpl $0xbf, %r15d
ja 0x3056f
shll $0x8, %r15d
movq (%r14), %rdi
movq 0x8(%rdi), %rax
cmpq %rax, 0x10(%rdi)
jbe 0x3059f
leaq 0x1(%rax), %rcx
movq %rcx, 0x8(%rdi)
movzbl (%rax), %eax
jmp 0x305a4
cmpl $0xdf, %r15d
ja 0x305bb
movq (%r14), %rdi
movq 0x8(%rdi), %rax
movq 0x10(%rdi), %rdx
cmpq %rax, %rdx
jbe 0x305e8
leaq 0x1(%rax), %rcx
movq %rcx, 0x8(%rdi)
movzbl (%rax), %eax
jmp 0x305f8
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
jmp 0x307e6
callq 0x4703e
movzbl %al, %eax
andl $0x3f00, %r15d          # imm = 0x3F00
orq %rax, %r15
movl $0x2, %eax
jmp 0x307e3
cmpl $0xef, %r15d
ja 0x30615
movq (%r14), %rdi
movq 0x8(%rdi), %rax
movq 0x10(%rdi), %rcx
cmpq %rax, %rcx
jbe 0x30661
leaq 0x1(%rax), %rdx
movq %rdx, 0x8(%rdi)
movzbl (%rax), %eax
jmp 0x30671
callq 0x4703e
movq (%r14), %rdi
movq 0x8(%rdi), %rcx
movq 0x10(%rdi), %rdx
shll $0x10, %r15d
shll $0x8, %eax
movzwl %ax, %r14d
cmpq %rcx, %rdx
jbe 0x30642
leaq 0x1(%rcx), %rax
movq %rax, 0x8(%rdi)
movzbl (%rcx), %eax
jmp 0x30647
cmpl $0xf7, %r15d
ja 0x30691
movq (%r14), %rdi
movq 0x8(%rdi), %rax
movq 0x10(%rdi), %rcx
cmpq %rax, %rcx
jbe 0x3070a
leaq 0x1(%rax), %rdx
movq %rdx, 0x8(%rdi)
movzbl (%rax), %eax
jmp 0x3071a
callq 0x4703e
movzbl %al, %eax
andl $0x1f0000, %r15d        # imm = 0x1F0000
orq %r14, %r15
orq %rax, %r15
movl $0x3, %eax
jmp 0x307e3
callq 0x4703e
movq (%r14), %rdi
movq 0x8(%rdi), %rdx
movq 0x10(%rdi), %rcx
shll $0x10, %r15d
shll $0x8, %eax
movzwl %ax, %r12d
orl %r15d, %r12d
cmpq %rdx, %rcx
jbe 0x306c2
leaq 0x1(%rdx), %rsi
movq %rsi, 0x8(%rdi)
movzbl (%rdx), %eax
jmp 0x306d2
cmpl $0xfb, %r15d
ja 0x3073a
movq (%r14), %rdi
movq 0x8(%rdi), %rax
movq 0x10(%rdi), %rcx
cmpq %rax, %rcx
jbe 0x307ef
leaq 0x1(%rax), %rdx
movq %rdx, 0x8(%rdi)
movzbl (%rax), %eax
jmp 0x307ff
callq 0x4703e
movq (%r14), %rdi
movq 0x8(%rdi), %rsi
movq 0x10(%rdi), %rcx
movzbl %al, %eax
orl %eax, %r12d
shll $0x8, %r12d
cmpq %rsi, %rcx
jbe 0x306ee
leaq 0x1(%rsi), %rax
movq %rax, 0x8(%rdi)
movzbl (%rsi), %eax
jmp 0x306f3
callq 0x4703e
movzbl %al, %eax
andl $0xfffff00, %r12d       # imm = 0xFFFFF00
orq %rax, %r12
movl $0x4, %eax
jmp 0x307e0
callq 0x4703e
movq (%r14), %rdi
movq 0x8(%rdi), %rdx
movq 0x10(%rdi), %rcx
shll $0x10, %r15d
shll $0x8, %eax
movzwl %ax, %r12d
orl %r15d, %r12d
cmpq %rdx, %rcx
jbe 0x3076b
leaq 0x1(%rdx), %rsi
movq %rsi, 0x8(%rdi)
movzbl (%rdx), %eax
jmp 0x3077b
cmpl $0xfd, %r15d
ja 0x3081f
movq (%r14), %rdi
movq 0x8(%rdi), %rax
movq 0x10(%rdi), %rcx
cmpq %rax, %rcx
jbe 0x308f6
leaq 0x1(%rax), %rdx
movq %rdx, 0x8(%rdi)
movzbl (%rax), %eax
jmp 0x30906
callq 0x4703e
movq (%r14), %rdi
movq 0x8(%rdi), %rsi
movq 0x10(%rdi), %rcx
movzbl %al, %eax
orq %rax, %r12
cmpq %rsi, %rcx
jbe 0x30793
leaq 0x1(%rsi), %rdx
movq %rdx, 0x8(%rdi)
movzbl (%rsi), %eax
jmp 0x307a3
callq 0x4703e
movq (%r14), %rdi
movq 0x8(%rdi), %rdx
movq 0x10(%rdi), %rcx
shlq $0x10, %r12
shll $0x8, %eax
movzwl %ax, %r14d
cmpq %rdx, %rcx
jbe 0x307c0
leaq 0x1(%rdx), %rax
movq %rax, 0x8(%rdi)
movzbl (%rdx), %eax
jmp 0x307c5
callq 0x4703e
movzbl %al, %eax
movabsq $0x7ffff0000, %rcx      # imm = 0x7FFFF0000
andq %rcx, %r12
orq %r14, %r12
orq %rax, %r12
movl $0x5, %eax
movq %r12, %r15
movq %r15, (%rbx)
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
callq 0x4703e
movq (%r14), %rdi
movq 0x8(%rdi), %rdx
movq 0x10(%rdi), %rcx
shll $0x10, %r15d
shll $0x8, %eax
movzwl %ax, %r12d
orl %r15d, %r12d
cmpq %rdx, %rcx
jbe 0x30850
leaq 0x1(%rdx), %rsi
movq %rsi, 0x8(%rdi)
movzbl (%rdx), %eax
jmp 0x30860
movq (%r14), %rdi
movq 0x8(%rdi), %rdx
movq 0x10(%rdi), %rcx
cmpl $0xff, %r15d
jne 0x30926
cmpq %rdx, %rcx
jbe 0x30a11
leaq 0x1(%rdx), %rax
movq %rax, 0x8(%rdi)
movzbl (%rdx), %ebp
jmp 0x30a23
callq 0x4703e
movq (%r14), %rdi
movq 0x8(%rdi), %rsi
movq 0x10(%rdi), %rcx
movzbl %al, %eax
orq %rax, %r12
cmpq %rsi, %rcx
jbe 0x30878
leaq 0x1(%rsi), %rdx
movq %rdx, 0x8(%rdi)
movzbl (%rsi), %eax
jmp 0x30888
callq 0x4703e
movq (%r14), %rdi
movq 0x8(%rdi), %rdx
movq 0x10(%rdi), %rcx
shlq $0x10, %r12
shll $0x8, %eax
movzwl %ax, %r15d
orq %r12, %r15
cmpq %rdx, %rcx
jbe 0x308a8
leaq 0x1(%rdx), %rsi
movq %rsi, 0x8(%rdi)
movzbl (%rdx), %eax
jmp 0x308b8
callq 0x4703e
movq (%r14), %rdi
movq 0x8(%rdi), %rsi
movq 0x10(%rdi), %rcx
movzbl %al, %eax
orq %rax, %r15
shlq $0x8, %r15
cmpq %rsi, %rcx
jbe 0x308d4
leaq 0x1(%rsi), %rax
movq %rax, 0x8(%rdi)
movzbl (%rsi), %eax
jmp 0x308d9
callq 0x4703e
movzbl %al, %eax
movabsq $0x3ffffffff00, %rcx    # imm = 0x3FFFFFFFF00
andq %rcx, %r15
orq %rax, %r15
movl $0x6, %eax
jmp 0x307e3
callq 0x4703e
movq (%r14), %rdi
movq 0x8(%rdi), %rdx
movq 0x10(%rdi), %rcx
shll $0x10, %r15d
shll $0x8, %eax
movzwl %ax, %r12d
orl %r15d, %r12d
cmpq %rdx, %rcx
jbe 0x3093f
leaq 0x1(%rdx), %rsi
movq %rsi, 0x8(%rdi)
movzbl (%rdx), %eax
jmp 0x3094f
cmpq %rdx, %rcx
jbe 0x30a35
leaq 0x1(%rdx), %rsi
movq %rsi, 0x8(%rdi)
movzbl (%rdx), %eax
jmp 0x30a45
callq 0x4703e
movq (%r14), %rdi
movq 0x8(%rdi), %rsi
movq 0x10(%rdi), %rcx
movzbl %al, %eax
orq %rax, %r12
cmpq %rsi, %rcx
jbe 0x30967
leaq 0x1(%rsi), %rdx
movq %rdx, 0x8(%rdi)
movzbl (%rsi), %eax
jmp 0x30977
callq 0x4703e
movq (%r14), %rdi
movq 0x8(%rdi), %rdx
movq 0x10(%rdi), %rcx
shlq $0x10, %r12
shll $0x8, %eax
movzwl %ax, %r15d
orq %r12, %r15
cmpq %rdx, %rcx
jbe 0x30997
leaq 0x1(%rdx), %rsi
movq %rsi, 0x8(%rdi)
movzbl (%rdx), %eax
jmp 0x309a7
callq 0x4703e
movq (%r14), %rdi
movq 0x8(%rdi), %rsi
movq 0x10(%rdi), %rcx
movzbl %al, %eax
orq %rax, %r15
cmpq %rsi, %rcx
jbe 0x309bf
leaq 0x1(%rsi), %rdx
movq %rdx, 0x8(%rdi)
movzbl (%rsi), %eax
jmp 0x309cf
callq 0x4703e
movq (%r14), %rdi
movq 0x8(%rdi), %rdx
movq 0x10(%rdi), %rcx
shlq $0x10, %r15
shll $0x8, %eax
movzwl %ax, %r14d
cmpq %rdx, %rcx
jbe 0x309ec
leaq 0x1(%rdx), %rax
movq %rax, 0x8(%rdi)
movzbl (%rdx), %eax
jmp 0x309f1
callq 0x4703e
movzbl %al, %eax
movabsq $0x1ffffffff0000, %rcx  # imm = 0x1FFFFFFFF0000
andq %rcx, %r15
orq %r14, %r15
orq %rax, %r15
movl $0x7, %eax
jmp 0x307e3
callq 0x4703e
movl %eax, %ebp
movq (%r14), %rdi
movq 0x8(%rdi), %rax
movq 0x10(%rdi), %rcx
cmpq %rax, %rcx
jbe 0x30a5e
leaq 0x1(%rax), %rdx
movq %rdx, 0x8(%rdi)
movzbl (%rax), %eax
jmp 0x30a6e
callq 0x4703e
movq (%r14), %rdi
movq 0x8(%rdi), %rsi
movq 0x10(%rdi), %rcx
shll $0x8, %eax
movzwl %ax, %r15d
cmpq %rsi, %rcx
jbe 0x30a8d
leaq 0x1(%rsi), %rdx
movq %rdx, 0x8(%rdi)
movzbl (%rsi), %eax
jmp 0x30a9d
callq 0x4703e
movq (%r14), %rdi
movq 0x8(%rdi), %rdx
movq 0x10(%rdi), %rcx
shll $0x10, %ebp
shll $0x8, %eax
movzwl %ax, %r12d
orl %ebp, %r12d
cmpq %rdx, %rcx
jbe 0x30ab8
leaq 0x1(%rdx), %rsi
movq %rsi, 0x8(%rdi)
movzbl (%rdx), %eax
jmp 0x30ac8
callq 0x4703e
movq (%r14), %rdi
movq 0x8(%rdi), %rdx
movq 0x10(%rdi), %rcx
movzbl %al, %ebp
orl %r15d, %ebp
shll $0x8, %ebp
cmpq %rdx, %rcx
jbe 0x30ae1
leaq 0x1(%rdx), %rsi
movq %rsi, 0x8(%rdi)
movzbl (%rdx), %eax
jmp 0x30af1
callq 0x4703e
movq (%r14), %rdi
movq 0x8(%rdi), %rsi
movq 0x10(%rdi), %rcx
movzbl %al, %r15d
orl %r12d, %r15d
cmpq %rsi, %rcx
jbe 0x30b0a
leaq 0x1(%rsi), %rdx
movq %rdx, 0x8(%rdi)
movzbl (%rsi), %eax
jmp 0x30b1a
callq 0x4703e
movq (%r14), %rdi
movq 0x8(%rdi), %rsi
movq 0x10(%rdi), %rcx
movzbl %al, %r12d
orl %ebp, %r12d
cmpq %rsi, %rcx
jbe 0x30b3a
leaq 0x1(%rsi), %rdx
movq %rdx, 0x8(%rdi)
movzbl (%rsi), %eax
jmp 0x30b4a
callq 0x4703e
movq (%r14), %rdi
movq 0x8(%rdi), %rdx
movq 0x10(%rdi), %rcx
shlq $0x10, %r15
shll $0x8, %eax
movzwl %ax, %r12d
orq %r15, %r12
cmpq %rdx, %rcx
jbe 0x30b6a
leaq 0x1(%rdx), %rsi
movq %rsi, 0x8(%rdi)
movzbl (%rdx), %eax
jmp 0x30b7a
callq 0x4703e
movq (%r14), %rdi
movq 0x8(%rdi), %rdx
movq 0x10(%rdi), %rcx
shlq $0x10, %r12
shll $0x8, %eax
movzwl %ax, %r15d
orq %r12, %r15
cmpq %rdx, %rcx
jbe 0x30b92
leaq 0x1(%rdx), %rsi
movq %rsi, 0x8(%rdi)
movzbl (%rdx), %eax
jmp 0x30ba2
callq 0x4703e
movq (%r14), %rdi
movq 0x8(%rdi), %rsi
movq 0x10(%rdi), %rcx
movzbl %al, %eax
orq %rax, %r12
cmpq %rsi, %rcx
jbe 0x30bba
leaq 0x1(%rsi), %rdx
movq %rdx, 0x8(%rdi)
movzbl (%rsi), %eax
jmp 0x30bca
callq 0x4703e
movq (%r14), %rdi
movq 0x8(%rdi), %rsi
movq 0x10(%rdi), %rcx
movzbl %al, %eax
orq %rax, %r15
cmpq %rsi, %rcx
jbe 0x30bea
leaq 0x1(%rsi), %rdx
movq %rdx, 0x8(%rdi)
movzbl (%rsi), %eax
jmp 0x30bfa
callq 0x4703e
movq (%r14), %rdi
movq 0x8(%rdi), %rdx
movq 0x10(%rdi), %rcx
shlq $0x10, %r12
shll $0x8, %eax
movzwl %ax, %r15d
orq %r12, %r15
cmpq %rdx, %rcx
jbe 0x30c17
leaq 0x1(%rdx), %rsi
movq %rsi, 0x8(%rdi)
movzbl (%rdx), %eax
jmp 0x30c27
callq 0x4703e
movq (%r14), %rdi
movq 0x8(%rdi), %rdx
movq 0x10(%rdi), %rcx
shlq $0x10, %r15
shll $0x8, %eax
movzwl %ax, %r14d
cmpq %rdx, %rcx
jbe 0x30c43
leaq 0x1(%rdx), %rax
movq %rax, 0x8(%rdi)
movzbl (%rdx), %eax
jmp 0x30c48
callq 0x4703e
movq (%r14), %rdi
movq 0x8(%rdi), %rsi
movq 0x10(%rdi), %rcx
movzbl %al, %eax
orq %rax, %r15
shlq $0x8, %r15
cmpq %rsi, %rcx
jbe 0x30c62
leaq 0x1(%rsi), %rax
movq %rax, 0x8(%rdi)
movzbl (%rsi), %eax
jmp 0x30c67
callq 0x4703e
movzbl %al, %eax
andq $-0x10000, %r15         # imm = 0xFFFF0000
orq %r14, %r15
orq %rax, %r15
movl $0x8, %eax
jmp 0x307e3
callq 0x4703e
movzbl %al, %eax
orq %rax, %r15
movl $0x9, %eax
jmp 0x307e3