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

    c[0] = val;

    if (val < 0x80) {
	*val_p =   val;
	*crc = crc32(*crc, c, 1);
	return 1;

    } else if (val < 0xc0) {
	val = (val<<8) | (c[1]=hgetc(fd->fp));;
	*val_p = val & (((1LL<<(6+8)))-1);
	*crc = crc32(*crc, c, 2);
	return 2;

    } else if (val < 0xe0) {
	val = (val<<8) | (c[1]=hgetc(fd->fp));;
	val = (val<<8) | (c[2]=hgetc(fd->fp));;
	*val_p = val & ((1LL<<(5+2*8))-1);
	*crc = crc32(*crc, c, 3);
	return 3;

    } else if (val < 0xf0) {
	val = (val<<8) | (c[1]=hgetc(fd->fp));;
	val = (val<<8) | (c[2]=hgetc(fd->fp));;
	val = (val<<8) | (c[3]=hgetc(fd->fp));;
	*val_p = val & ((1LL<<(4+3*8))-1);
	*crc = crc32(*crc, c, 4);
	return 4;

    } else if (val < 0xf8) {
	val = (val<<8) | (c[1]=hgetc(fd->fp));;
	val = (val<<8) | (c[2]=hgetc(fd->fp));;
	val = (val<<8) | (c[3]=hgetc(fd->fp));;
	val = (val<<8) | (c[4]=hgetc(fd->fp));;
	*val_p = val & ((1LL<<(3+4*8))-1);
	*crc = crc32(*crc, c, 5);
	return 5;

    } else if (val < 0xfc) {
	val = (val<<8) | (c[1]=hgetc(fd->fp));;
	val = (val<<8) | (c[2]=hgetc(fd->fp));;
	val = (val<<8) | (c[3]=hgetc(fd->fp));;
	val = (val<<8) | (c[4]=hgetc(fd->fp));;
	val = (val<<8) | (c[5]=hgetc(fd->fp));;
	*val_p = val & ((1LL<<(2+5*8))-1);
	*crc = crc32(*crc, c, 6);
	return 6;

    } else if (val < 0xfe) {
	val = (val<<8) | (c[1]=hgetc(fd->fp));;
	val = (val<<8) | (c[2]=hgetc(fd->fp));;
	val = (val<<8) | (c[3]=hgetc(fd->fp));;
	val = (val<<8) | (c[4]=hgetc(fd->fp));;
	val = (val<<8) | (c[5]=hgetc(fd->fp));;
	val = (val<<8) | (c[6]=hgetc(fd->fp));;
	*val_p = val & ((1LL<<(1+6*8))-1);
	*crc = crc32(*crc, c, 7);
	return 7;

    } else if (val < 0xff) {
	val = (val<<8) | (c[1]=hgetc(fd->fp));;
	val = (val<<8) | (c[2]=hgetc(fd->fp));;
	val = (val<<8) | (c[3]=hgetc(fd->fp));;
	val = (val<<8) | (c[4]=hgetc(fd->fp));;
	val = (val<<8) | (c[5]=hgetc(fd->fp));;
	val = (val<<8) | (c[6]=hgetc(fd->fp));;
	val = (val<<8) | (c[7]=hgetc(fd->fp));;
	*val_p = val & ((1LL<<(7*8))-1);
	*crc = crc32(*crc, c, 8);
	return 8;

    } else {
	val = (val<<8) | (c[1]=hgetc(fd->fp));;
	val = (val<<8) | (c[2]=hgetc(fd->fp));;
	val = (val<<8) | (c[3]=hgetc(fd->fp));;
	val = (val<<8) | (c[4]=hgetc(fd->fp));;
	val = (val<<8) | (c[5]=hgetc(fd->fp));;
	val = (val<<8) | (c[6]=hgetc(fd->fp));;
	val = (val<<8) | (c[7]=hgetc(fd->fp));;
	val = (val<<8) | (c[8]=hgetc(fd->fp));;
	*crc = crc32(*crc, c, 9);
	*val_p = val;
    }

    return 9;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdx, %rbx
movq %rsi, %r14
movq %rdi, %r15
movq (%rdi), %rdi
movq 0x8(%rdi), %rax
cmpq %rax, 0x10(%rdi)
jbe 0x31861
leaq 0x1(%rax), %rcx
movq %rcx, 0x8(%rdi)
movzbl (%rax), %eax
jmp 0x31866
callq 0x4805a
movzbl %al, %r12d
movb %r12b, 0xf(%rsp)
cmpl $0x7f, %r12d
ja 0x3188e
movq %r12, (%r14)
movl (%rbx), %edi
leaq 0xf(%rsp), %rsi
movl $0x1, %ebp
movl $0x1, %edx
jmp 0x3201f
cmpl $0xbf, %r12d
ja 0x318b5
shll $0x8, %r12d
movq (%r15), %rdi
movq 0x8(%rdi), %rax
cmpq %rax, 0x10(%rdi)
jbe 0x318d8
leaq 0x1(%rax), %rcx
movq %rcx, 0x8(%rdi)
movzbl (%rax), %eax
jmp 0x318dd
cmpl $0xdf, %r12d
ja 0x31906
movq (%r15), %rdi
movq 0x8(%rdi), %rax
cmpq %rax, 0x10(%rdi)
jbe 0x31930
leaq 0x1(%rax), %rcx
movq %rcx, 0x8(%rdi)
movzbl (%rax), %eax
jmp 0x31935
callq 0x4805a
leaq 0xf(%rsp), %rsi
movb %al, 0x1(%rsi)
movzbl %al, %eax
andl $0x3f00, %r12d          # imm = 0x3F00
orq %rax, %r12
movq %r12, (%r14)
movl (%rbx), %edi
movl $0x2, %ebp
movl $0x2, %edx
jmp 0x3201f
cmpl $0xef, %r12d
ja 0x3195e
movq (%r15), %rdi
movq 0x8(%rdi), %rax
cmpq %rax, 0x10(%rdi)
jbe 0x319bd
leaq 0x1(%rax), %rcx
movq %rcx, 0x8(%rdi)
movzbl (%rax), %eax
jmp 0x319c2
callq 0x4805a
movb %al, 0x10(%rsp)
shll $0x10, %r12d
shll $0x8, %eax
movzwl %ax, %r13d
movq (%r15), %rdi
movq 0x8(%rdi), %rax
cmpq %rax, 0x10(%rdi)
jbe 0x3198c
leaq 0x1(%rax), %rcx
movq %rcx, 0x8(%rdi)
movzbl (%rax), %eax
jmp 0x31991
cmpl $0xf7, %r12d
ja 0x319ee
movq (%r15), %rdi
movq 0x8(%rdi), %rax
cmpq %rax, 0x10(%rdi)
jbe 0x31a77
leaq 0x1(%rax), %rcx
movq %rcx, 0x8(%rdi)
movzbl (%rax), %eax
jmp 0x31a7c
callq 0x4805a
leaq 0xf(%rsp), %rsi
movb %al, 0x2(%rsi)
movzbl %al, %eax
andl $0x1f0000, %r12d        # imm = 0x1F0000
orq %r13, %r12
orq %rax, %r12
movq %r12, (%r14)
movl (%rbx), %edi
movl $0x3, %ebp
movl $0x3, %edx
jmp 0x3201f
callq 0x4805a
movb %al, 0x10(%rsp)
shll $0x10, %r12d
shll $0x8, %eax
movzwl %ax, %r13d
orl %r12d, %r13d
movq (%r15), %rdi
movq 0x8(%rdi), %rax
cmpq %rax, 0x10(%rdi)
jbe 0x31a1c
leaq 0x1(%rax), %rcx
movq %rcx, 0x8(%rdi)
movzbl (%rax), %eax
jmp 0x31a21
cmpl $0xfb, %r12d
ja 0x31aa8
movq (%r15), %rdi
movq 0x8(%rdi), %rax
cmpq %rax, 0x10(%rdi)
jbe 0x31b64
leaq 0x1(%rax), %rcx
movq %rcx, 0x8(%rdi)
movzbl (%rax), %eax
jmp 0x31b69
callq 0x4805a
movb %al, 0x11(%rsp)
movzbl %al, %eax
orl %eax, %r13d
shll $0x8, %r13d
movq (%r15), %rdi
movq 0x8(%rdi), %rax
cmpq %rax, 0x10(%rdi)
jbe 0x31a49
leaq 0x1(%rax), %rcx
movq %rcx, 0x8(%rdi)
movzbl (%rax), %eax
jmp 0x31a4e
callq 0x4805a
leaq 0xf(%rsp), %rsi
movb %al, 0x3(%rsi)
movzbl %al, %eax
andl $0xfffff00, %r13d       # imm = 0xFFFFF00
orq %rax, %r13
movq %r13, (%r14)
movl (%rbx), %edi
movl $0x4, %ebp
movl $0x4, %edx
jmp 0x3201f
callq 0x4805a
movb %al, 0x10(%rsp)
shll $0x10, %r12d
shll $0x8, %eax
movzwl %ax, %r13d
orl %r12d, %r13d
movq (%r15), %rdi
movq 0x8(%rdi), %rax
cmpq %rax, 0x10(%rdi)
jbe 0x31ad6
leaq 0x1(%rax), %rcx
movq %rcx, 0x8(%rdi)
movzbl (%rax), %eax
jmp 0x31adb
cmpl $0xfd, %r12d
ja 0x31b95
movq (%r15), %rdi
movq 0x8(%rdi), %rax
cmpq %rax, 0x10(%rdi)
jbe 0x31c81
leaq 0x1(%rax), %rcx
movq %rcx, 0x8(%rdi)
movzbl (%rax), %eax
jmp 0x31c86
callq 0x4805a
movb %al, 0x11(%rsp)
movzbl %al, %eax
orq %rax, %r13
movq (%r15), %rdi
movq 0x8(%rdi), %rax
cmpq %rax, 0x10(%rdi)
jbe 0x31aff
leaq 0x1(%rax), %rcx
movq %rcx, 0x8(%rdi)
movzbl (%rax), %eax
jmp 0x31b04
callq 0x4805a
movb %al, 0x12(%rsp)
shlq $0x10, %r13
shll $0x8, %eax
movzwl %ax, %r12d
movq (%r15), %rdi
movq 0x8(%rdi), %rax
cmpq %rax, 0x10(%rdi)
jbe 0x31b2d
leaq 0x1(%rax), %rcx
movq %rcx, 0x8(%rdi)
movzbl (%rax), %eax
jmp 0x31b32
callq 0x4805a
leaq 0xf(%rsp), %rsi
movb %al, 0x4(%rsi)
movzbl %al, %eax
movabsq $0x7ffff0000, %rcx      # imm = 0x7FFFF0000
andq %rcx, %r13
orq %r12, %r13
orq %rax, %r13
movq %r13, (%r14)
movl (%rbx), %edi
movl $0x5, %ebp
movl $0x5, %edx
jmp 0x3201f
callq 0x4805a
movb %al, 0x10(%rsp)
shll $0x10, %r12d
shll $0x8, %eax
movzwl %ax, %r13d
orl %r12d, %r13d
movq (%r15), %rdi
movq 0x8(%rdi), %rax
cmpq %rax, 0x10(%rdi)
jbe 0x31bc6
leaq 0x1(%rax), %rcx
movq %rcx, 0x8(%rdi)
movzbl (%rax), %eax
jmp 0x31bcb
movq (%r15), %rdi
movq 0x8(%rdi), %rax
movq 0x10(%rdi), %rcx
cmpl $0xff, %r12d
jne 0x31cb2
cmpq %rax, %rcx
jbe 0x31db3
leaq 0x1(%rax), %rcx
movq %rcx, 0x8(%rdi)
movzbl (%rax), %ebp
jmp 0x31dba
callq 0x4805a
movb %al, 0x11(%rsp)
movzbl %al, %eax
orq %rax, %r13
movq (%r15), %rdi
movq 0x8(%rdi), %rax
cmpq %rax, 0x10(%rdi)
jbe 0x31bef
leaq 0x1(%rax), %rcx
movq %rcx, 0x8(%rdi)
movzbl (%rax), %eax
jmp 0x31bf4
callq 0x4805a
movb %al, 0x12(%rsp)
shlq $0x10, %r13
shll $0x8, %eax
movzwl %ax, %r12d
orq %r13, %r12
movq (%r15), %rdi
movq 0x8(%rdi), %rax
cmpq %rax, 0x10(%rdi)
jbe 0x31c20
leaq 0x1(%rax), %rcx
movq %rcx, 0x8(%rdi)
movzbl (%rax), %eax
jmp 0x31c25
callq 0x4805a
movb %al, 0x13(%rsp)
movzbl %al, %eax
orq %rax, %r12
shlq $0x8, %r12
movq (%r15), %rdi
movq 0x8(%rdi), %rax
cmpq %rax, 0x10(%rdi)
jbe 0x31c4d
leaq 0x1(%rax), %rcx
movq %rcx, 0x8(%rdi)
movzbl (%rax), %eax
jmp 0x31c52
callq 0x4805a
leaq 0xf(%rsp), %rsi
movb %al, 0x5(%rsi)
movzbl %al, %eax
movabsq $0x3ffffffff00, %rcx    # imm = 0x3FFFFFFFF00
andq %rcx, %r12
orq %rax, %r12
movq %r12, (%r14)
movl (%rbx), %edi
movl $0x6, %ebp
movl $0x6, %edx
jmp 0x3201f
callq 0x4805a
movb %al, 0x10(%rsp)
shll $0x10, %r12d
shll $0x8, %eax
movzwl %ax, %r13d
orl %r12d, %r13d
movq (%r15), %rdi
movq 0x8(%rdi), %rax
cmpq %rax, 0x10(%rdi)
jbe 0x31ccb
leaq 0x1(%rax), %rcx
movq %rcx, 0x8(%rdi)
movzbl (%rax), %eax
jmp 0x31cd0
cmpq %rax, %rcx
jbe 0x31dd9
leaq 0x1(%rax), %rcx
movq %rcx, 0x8(%rdi)
movzbl (%rax), %eax
jmp 0x31dde
callq 0x4805a
movb %al, 0x11(%rsp)
movzbl %al, %eax
orq %rax, %r13
movq (%r15), %rdi
movq 0x8(%rdi), %rax
cmpq %rax, 0x10(%rdi)
jbe 0x31cf4
leaq 0x1(%rax), %rcx
movq %rcx, 0x8(%rdi)
movzbl (%rax), %eax
jmp 0x31cf9
callq 0x4805a
movb %al, 0x12(%rsp)
shlq $0x10, %r13
shll $0x8, %eax
movzwl %ax, %r12d
orq %r13, %r12
movq (%r15), %rdi
movq 0x8(%rdi), %rax
cmpq %rax, 0x10(%rdi)
jbe 0x31d25
leaq 0x1(%rax), %rcx
movq %rcx, 0x8(%rdi)
movzbl (%rax), %eax
jmp 0x31d2a
callq 0x4805a
movb %al, 0x13(%rsp)
movzbl %al, %eax
orq %rax, %r12
movq (%r15), %rdi
movq 0x8(%rdi), %rax
cmpq %rax, 0x10(%rdi)
jbe 0x31d4e
leaq 0x1(%rax), %rcx
movq %rcx, 0x8(%rdi)
movzbl (%rax), %eax
jmp 0x31d53
callq 0x4805a
movb %al, 0x14(%rsp)
shlq $0x10, %r12
shll $0x8, %eax
movzwl %ax, %r13d
movq (%r15), %rdi
movq 0x8(%rdi), %rax
cmpq %rax, 0x10(%rdi)
jbe 0x31d7c
leaq 0x1(%rax), %rcx
movq %rcx, 0x8(%rdi)
movzbl (%rax), %eax
jmp 0x31d81
callq 0x4805a
leaq 0xf(%rsp), %rsi
movb %al, 0x6(%rsi)
movzbl %al, %eax
movabsq $0x1ffffffff0000, %rcx  # imm = 0x1FFFFFFFF0000
andq %rcx, %r12
orq %r13, %r12
orq %rax, %r12
movq %r12, (%r14)
movl (%rbx), %edi
movl $0x7, %ebp
movl $0x7, %edx
jmp 0x3201f
callq 0x4805a
movl %eax, %ebp
movb %bpl, 0x10(%rsp)
movq (%r15), %rdi
movq 0x8(%rdi), %rax
cmpq %rax, 0x10(%rdi)
jbe 0x31e03
leaq 0x1(%rax), %rcx
movq %rcx, 0x8(%rdi)
movzbl (%rax), %eax
jmp 0x31e08
callq 0x4805a
movb %al, 0x10(%rsp)
shll $0x8, %eax
movzwl %ax, %r12d
movq (%r15), %rdi
movq 0x8(%rdi), %rax
cmpq %rax, 0x10(%rdi)
jbe 0x31e33
leaq 0x1(%rax), %rcx
movq %rcx, 0x8(%rdi)
movzbl (%rax), %eax
jmp 0x31e38
callq 0x4805a
movb %al, 0x11(%rsp)
shll $0x10, %ebp
shll $0x8, %eax
movzwl %ax, %r13d
orl %ebp, %r13d
movq (%r15), %rdi
movq 0x8(%rdi), %rax
cmpq %rax, 0x10(%rdi)
jbe 0x31e5f
leaq 0x1(%rax), %rcx
movq %rcx, 0x8(%rdi)
movzbl (%rax), %eax
jmp 0x31e64
callq 0x4805a
movb %al, 0x11(%rsp)
movzbl %al, %ebp
orl %r12d, %ebp
shll $0x8, %ebp
movq (%r15), %rdi
movq 0x8(%rdi), %rax
cmpq %rax, 0x10(%rdi)
jbe 0x31e89
leaq 0x1(%rax), %rcx
movq %rcx, 0x8(%rdi)
movzbl (%rax), %eax
jmp 0x31e8e
callq 0x4805a
movb %al, 0x12(%rsp)
movzbl %al, %r12d
orl %r13d, %r12d
movq (%r15), %rdi
movq 0x8(%rdi), %rax
cmpq %rax, 0x10(%rdi)
jbe 0x31eb3
leaq 0x1(%rax), %rcx
movq %rcx, 0x8(%rdi)
movzbl (%rax), %eax
jmp 0x31eb8
callq 0x4805a
movb %al, 0x12(%rsp)
movzbl %al, %r13d
orl %ebp, %r13d
movq (%r15), %rdi
movq 0x8(%rdi), %rax
cmpq %rax, 0x10(%rdi)
jbe 0x31ee4
leaq 0x1(%rax), %rcx
movq %rcx, 0x8(%rdi)
movzbl (%rax), %eax
jmp 0x31ee9
callq 0x4805a
movb %al, 0x13(%rsp)
shlq $0x10, %r12
shll $0x8, %eax
movzwl %ax, %r13d
orq %r12, %r13
movq (%r15), %rdi
movq 0x8(%rdi), %rax
cmpq %rax, 0x10(%rdi)
jbe 0x31f15
leaq 0x1(%rax), %rcx
movq %rcx, 0x8(%rdi)
movzbl (%rax), %eax
jmp 0x31f1a
callq 0x4805a
movb %al, 0x13(%rsp)
shlq $0x10, %r13
shll $0x8, %eax
movzwl %ax, %r12d
orq %r13, %r12
movq (%r15), %rdi
movq 0x8(%rdi), %rax
cmpq %rax, 0x10(%rdi)
jbe 0x31f3e
leaq 0x1(%rax), %rcx
movq %rcx, 0x8(%rdi)
movzbl (%rax), %eax
jmp 0x31f43
callq 0x4805a
movb %al, 0x14(%rsp)
movzbl %al, %eax
orq %rax, %r13
movq (%r15), %rdi
movq 0x8(%rdi), %rax
cmpq %rax, 0x10(%rdi)
jbe 0x31f67
leaq 0x1(%rax), %rcx
movq %rcx, 0x8(%rdi)
movzbl (%rax), %eax
jmp 0x31f6c
callq 0x4805a
movb %al, 0x14(%rsp)
movzbl %al, %eax
orq %rax, %r12
movq (%r15), %rdi
movq 0x8(%rdi), %rax
cmpq %rax, 0x10(%rdi)
jbe 0x31f98
leaq 0x1(%rax), %rcx
movq %rcx, 0x8(%rdi)
movzbl (%rax), %eax
jmp 0x31f9d
callq 0x4805a
movb %al, 0x15(%rsp)
shlq $0x10, %r13
shll $0x8, %eax
movzwl %ax, %r12d
orq %r13, %r12
movq (%r15), %rdi
movq 0x8(%rdi), %rax
cmpq %rax, 0x10(%rdi)
jbe 0x31fc6
leaq 0x1(%rax), %rcx
movq %rcx, 0x8(%rdi)
movzbl (%rax), %eax
jmp 0x31fcb
callq 0x4805a
movb %al, 0x15(%rsp)
shlq $0x10, %r12
shll $0x8, %eax
movzwl %ax, %r13d
movq (%r15), %rdi
movq 0x8(%rdi), %rax
cmpq %rax, 0x10(%rdi)
jbe 0x31ff3
leaq 0x1(%rax), %rcx
movq %rcx, 0x8(%rdi)
movzbl (%rax), %eax
jmp 0x31ff8
callq 0x4805a
movb %al, 0x16(%rsp)
movzbl %al, %eax
orq %rax, %r12
shlq $0x8, %r12
movq (%r15), %rdi
movq 0x8(%rdi), %rax
cmpq %rax, 0x10(%rdi)
jbe 0x32037
leaq 0x1(%rax), %rcx
movq %rcx, 0x8(%rdi)
movzbl (%rax), %eax
jmp 0x3203c
callq 0x4805a
leaq 0xf(%rsp), %rsi
movb %al, 0x7(%rsi)
movzbl %al, %eax
andq $-0x10000, %r12         # imm = 0xFFFF0000
orq %r13, %r12
orq %rax, %r12
movq %r12, (%r14)
movl (%rbx), %edi
movl $0x8, %ebp
movl $0x8, %edx
callq 0x43b0
movl %eax, (%rbx)
movl %ebp, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x4805a
leaq 0xf(%rsp), %rsi
movb %al, 0x8(%rsi)
movzbl %al, %eax
orq %rax, %r12
movl (%rbx), %edi
movl $0x9, %ebp
movl $0x9, %edx
callq 0x43b0
movl %eax, (%rbx)
movq %r12, (%r14)
jmp 0x32026