// File: /workspace/github_cpp_makefile_star2_O3/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 0x30ca8
leaq 0x1(%rax), %rcx
movq %rcx, 0x8(%rdi)
movzbl (%rax), %eax
jmp 0x30cad
callq 0x4703e
movzbl %al, %r12d
movb %r12b, 0xf(%rsp)
cmpl $0x7f, %r12d
ja 0x30cd5
movq %r12, (%r14)
movl (%rbx), %edi
leaq 0xf(%rsp), %rsi
movl $0x1, %ebp
movl $0x1, %edx
jmp 0x314c9
cmpl $0xbf, %r12d
ja 0x30cfc
shll $0x8, %r12d
movq (%r15), %rdi
movq 0x8(%rdi), %rax
cmpq %rax, 0x10(%rdi)
jbe 0x30d22
leaq 0x1(%rax), %rcx
movq %rcx, 0x8(%rdi)
movzbl (%rax), %eax
jmp 0x30d27
cmpl $0xdf, %r12d
ja 0x30d50
movq (%r15), %rdi
movq 0x8(%rdi), %rax
movq 0x10(%rdi), %rdx
cmpq %rax, %rdx
jbe 0x30d7d
leaq 0x1(%rax), %rcx
movq %rcx, 0x8(%rdi)
movzbl (%rax), %eax
jmp 0x30d8d
callq 0x4703e
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 0x314c9
cmpl $0xef, %r12d
ja 0x30dae
movq (%r15), %rdi
movq 0x8(%rdi), %rax
movq 0x10(%rdi), %rcx
cmpq %rax, %rcx
jbe 0x30e10
leaq 0x1(%rax), %rdx
movq %rdx, 0x8(%rdi)
movzbl (%rax), %eax
jmp 0x30e20
callq 0x4703e
movq (%r15), %rdi
movq 0x8(%rdi), %rcx
movq 0x10(%rdi), %rdx
movb %al, 0x10(%rsp)
shll $0x10, %r12d
shll $0x8, %eax
movzwl %ax, %r15d
cmpq %rcx, %rdx
jbe 0x30ddf
leaq 0x1(%rcx), %rax
movq %rax, 0x8(%rdi)
movzbl (%rcx), %eax
jmp 0x30de4
cmpl $0xf7, %r12d
ja 0x30e44
movq (%r15), %rdi
movq 0x8(%rdi), %rax
movq 0x10(%rdi), %rcx
cmpq %rax, %rcx
jbe 0x30ed3
leaq 0x1(%rax), %rdx
movq %rdx, 0x8(%rdi)
movzbl (%rax), %eax
jmp 0x30ee3
callq 0x4703e
leaq 0xf(%rsp), %rsi
movb %al, 0x2(%rsi)
movzbl %al, %eax
andl $0x1f0000, %r12d        # imm = 0x1F0000
orq %r15, %r12
orq %rax, %r12
movq %r12, (%r14)
movl (%rbx), %edi
movl $0x3, %ebp
movl $0x3, %edx
jmp 0x314c9
callq 0x4703e
movq (%r15), %rdi
movq 0x8(%rdi), %rdx
movq 0x10(%rdi), %rcx
movb %al, 0x10(%rsp)
shll $0x10, %r12d
shll $0x8, %eax
movzwl %ax, %r13d
orl %r12d, %r13d
cmpq %rdx, %rcx
jbe 0x30e75
leaq 0x1(%rdx), %rsi
movq %rsi, 0x8(%rdi)
movzbl (%rdx), %eax
jmp 0x30e85
cmpl $0xfb, %r12d
ja 0x30f07
movq (%r15), %rdi
movq 0x8(%rdi), %rax
movq 0x10(%rdi), %rcx
cmpq %rax, %rcx
jbe 0x30fcc
leaq 0x1(%rax), %rdx
movq %rdx, 0x8(%rdi)
movzbl (%rax), %eax
jmp 0x30fdc
callq 0x4703e
movq (%r15), %rdi
movq 0x8(%rdi), %rsi
movq 0x10(%rdi), %rcx
movb %al, 0x11(%rsp)
movzbl %al, %eax
orl %eax, %r13d
shll $0x8, %r13d
cmpq %rsi, %rcx
jbe 0x30ea5
leaq 0x1(%rsi), %rax
movq %rax, 0x8(%rdi)
movzbl (%rsi), %eax
jmp 0x30eaa
callq 0x4703e
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 0x314c9
callq 0x4703e
movq (%r15), %rdi
movq 0x8(%rdi), %rdx
movq 0x10(%rdi), %rcx
movb %al, 0x10(%rsp)
shll $0x10, %r12d
shll $0x8, %eax
movzwl %ax, %r13d
orl %r12d, %r13d
cmpq %rdx, %rcx
jbe 0x30f38
leaq 0x1(%rdx), %rsi
movq %rsi, 0x8(%rdi)
movzbl (%rdx), %eax
jmp 0x30f48
cmpl $0xfd, %r12d
ja 0x31000
movq (%r15), %rdi
movq 0x8(%rdi), %rax
movq 0x10(%rdi), %rcx
cmpq %rax, %rcx
jbe 0x310f5
leaq 0x1(%rax), %rdx
movq %rdx, 0x8(%rdi)
movzbl (%rax), %eax
jmp 0x31105
callq 0x4703e
movq (%r15), %rdi
movq 0x8(%rdi), %rsi
movq 0x10(%rdi), %rcx
movb %al, 0x11(%rsp)
movzbl %al, %eax
orq %rax, %r13
cmpq %rsi, %rcx
jbe 0x30f64
leaq 0x1(%rsi), %rdx
movq %rdx, 0x8(%rdi)
movzbl (%rsi), %eax
jmp 0x30f74
callq 0x4703e
movq (%r15), %rdi
movq 0x8(%rdi), %rdx
movq 0x10(%rdi), %rcx
movb %al, 0x12(%rsp)
shlq $0x10, %r13
shll $0x8, %eax
movzwl %ax, %r15d
cmpq %rdx, %rcx
jbe 0x30f95
leaq 0x1(%rdx), %rax
movq %rax, 0x8(%rdi)
movzbl (%rdx), %eax
jmp 0x30f9a
callq 0x4703e
leaq 0xf(%rsp), %rsi
movb %al, 0x4(%rsi)
movzbl %al, %eax
movabsq $0x7ffff0000, %rcx      # imm = 0x7FFFF0000
andq %rcx, %r13
orq %r15, %r13
orq %rax, %r13
movq %r13, (%r14)
movl (%rbx), %edi
movl $0x5, %ebp
movl $0x5, %edx
jmp 0x314c9
callq 0x4703e
movq (%r15), %rdi
movq 0x8(%rdi), %rdx
movq 0x10(%rdi), %rcx
movb %al, 0x10(%rsp)
shll $0x10, %r12d
shll $0x8, %eax
movzwl %ax, %r13d
orl %r12d, %r13d
cmpq %rdx, %rcx
jbe 0x31031
leaq 0x1(%rdx), %rsi
movq %rsi, 0x8(%rdi)
movzbl (%rdx), %eax
jmp 0x31041
movq (%r15), %rdi
movq 0x8(%rdi), %rdx
movq 0x10(%rdi), %rcx
cmpl $0xff, %r12d
jne 0x31129
cmpq %rdx, %rcx
jbe 0x31236
leaq 0x1(%rdx), %rax
movq %rax, 0x8(%rdi)
movzbl (%rdx), %ebp
jmp 0x31248
callq 0x4703e
movq (%r15), %rdi
movq 0x8(%rdi), %rsi
movq 0x10(%rdi), %rcx
movb %al, 0x11(%rsp)
movzbl %al, %eax
orq %rax, %r13
cmpq %rsi, %rcx
jbe 0x3105d
leaq 0x1(%rsi), %rdx
movq %rdx, 0x8(%rdi)
movzbl (%rsi), %eax
jmp 0x3106d
callq 0x4703e
movq (%r15), %rdi
movq 0x8(%rdi), %rdx
movq 0x10(%rdi), %rcx
movb %al, 0x12(%rsp)
shlq $0x10, %r13
shll $0x8, %eax
movzwl %ax, %r12d
orq %r13, %r12
cmpq %rdx, %rcx
jbe 0x31091
leaq 0x1(%rdx), %rsi
movq %rsi, 0x8(%rdi)
movzbl (%rdx), %eax
jmp 0x310a1
callq 0x4703e
movq (%r15), %rdi
movq 0x8(%rdi), %rsi
movq 0x10(%rdi), %rcx
movb %al, 0x13(%rsp)
movzbl %al, %eax
orq %rax, %r12
shlq $0x8, %r12
cmpq %rsi, %rcx
jbe 0x310c1
leaq 0x1(%rsi), %rax
movq %rax, 0x8(%rdi)
movzbl (%rsi), %eax
jmp 0x310c6
callq 0x4703e
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 0x314c9
callq 0x4703e
movq (%r15), %rdi
movq 0x8(%rdi), %rdx
movq 0x10(%rdi), %rcx
movb %al, 0x10(%rsp)
shll $0x10, %r12d
shll $0x8, %eax
movzwl %ax, %r13d
orl %r12d, %r13d
cmpq %rdx, %rcx
jbe 0x31142
leaq 0x1(%rdx), %rsi
movq %rsi, 0x8(%rdi)
movzbl (%rdx), %eax
jmp 0x31152
cmpq %rdx, %rcx
jbe 0x3125f
leaq 0x1(%rdx), %rsi
movq %rsi, 0x8(%rdi)
movzbl (%rdx), %eax
jmp 0x3126f
callq 0x4703e
movq (%r15), %rdi
movq 0x8(%rdi), %rsi
movq 0x10(%rdi), %rcx
movb %al, 0x11(%rsp)
movzbl %al, %eax
orq %rax, %r13
cmpq %rsi, %rcx
jbe 0x3116e
leaq 0x1(%rsi), %rdx
movq %rdx, 0x8(%rdi)
movzbl (%rsi), %eax
jmp 0x3117e
callq 0x4703e
movq (%r15), %rdi
movq 0x8(%rdi), %rdx
movq 0x10(%rdi), %rcx
movb %al, 0x12(%rsp)
shlq $0x10, %r13
shll $0x8, %eax
movzwl %ax, %r12d
orq %r13, %r12
cmpq %rdx, %rcx
jbe 0x311a2
leaq 0x1(%rdx), %rsi
movq %rsi, 0x8(%rdi)
movzbl (%rdx), %eax
jmp 0x311b2
callq 0x4703e
movq (%r15), %rdi
movq 0x8(%rdi), %rsi
movq 0x10(%rdi), %rcx
movb %al, 0x13(%rsp)
movzbl %al, %eax
orq %rax, %r12
cmpq %rsi, %rcx
jbe 0x311ce
leaq 0x1(%rsi), %rdx
movq %rdx, 0x8(%rdi)
movzbl (%rsi), %eax
jmp 0x311de
callq 0x4703e
movq (%r15), %rdi
movq 0x8(%rdi), %rdx
movq 0x10(%rdi), %rcx
movb %al, 0x14(%rsp)
shlq $0x10, %r12
shll $0x8, %eax
movzwl %ax, %r15d
cmpq %rdx, %rcx
jbe 0x311ff
leaq 0x1(%rdx), %rax
movq %rax, 0x8(%rdi)
movzbl (%rdx), %eax
jmp 0x31204
callq 0x4703e
leaq 0xf(%rsp), %rsi
movb %al, 0x6(%rsi)
movzbl %al, %eax
movabsq $0x1ffffffff0000, %rcx  # imm = 0x1FFFFFFFF0000
andq %rcx, %r12
orq %r15, %r12
orq %rax, %r12
movq %r12, (%r14)
movl (%rbx), %edi
movl $0x7, %ebp
movl $0x7, %edx
jmp 0x314c9
callq 0x4703e
movl %eax, %ebp
movq (%r15), %rdi
movq 0x8(%rdi), %rax
movq 0x10(%rdi), %rcx
movb %bpl, 0x10(%rsp)
cmpq %rax, %rcx
jbe 0x3128c
leaq 0x1(%rax), %rdx
movq %rdx, 0x8(%rdi)
movzbl (%rax), %eax
jmp 0x3129c
callq 0x4703e
movq (%r15), %rdi
movq 0x8(%rdi), %rsi
movq 0x10(%rdi), %rcx
movb %al, 0x10(%rsp)
shll $0x8, %eax
movzwl %ax, %r12d
cmpq %rsi, %rcx
jbe 0x312bf
leaq 0x1(%rsi), %rdx
movq %rdx, 0x8(%rdi)
movzbl (%rsi), %eax
jmp 0x312cf
callq 0x4703e
movq (%r15), %rdi
movq 0x8(%rdi), %rdx
movq 0x10(%rdi), %rcx
movb %al, 0x11(%rsp)
shll $0x10, %ebp
shll $0x8, %eax
movzwl %ax, %r12d
orl %ebp, %r12d
cmpq %rdx, %rcx
jbe 0x312ee
leaq 0x1(%rdx), %rsi
movq %rsi, 0x8(%rdi)
movzbl (%rdx), %eax
jmp 0x312fe
callq 0x4703e
movq (%r15), %rdi
movq 0x8(%rdi), %rdx
movq 0x10(%rdi), %rcx
movb %al, 0x11(%rsp)
movzbl %al, %ebp
orl %r12d, %ebp
shll $0x8, %ebp
cmpq %rdx, %rcx
jbe 0x3131b
leaq 0x1(%rdx), %rsi
movq %rsi, 0x8(%rdi)
movzbl (%rdx), %eax
jmp 0x3132b
callq 0x4703e
movq (%r15), %rdi
movq 0x8(%rdi), %rsi
movq 0x10(%rdi), %rcx
movb %al, 0x12(%rsp)
movzbl %al, %r13d
orl %r12d, %r13d
cmpq %rsi, %rcx
jbe 0x31348
leaq 0x1(%rsi), %rdx
movq %rdx, 0x8(%rdi)
movzbl (%rsi), %eax
jmp 0x31358
callq 0x4703e
movq (%r15), %rdi
movq 0x8(%rdi), %rsi
movq 0x10(%rdi), %rcx
movb %al, 0x12(%rsp)
movzbl %al, %r13d
orl %ebp, %r13d
cmpq %rsi, %rcx
jbe 0x3137c
leaq 0x1(%rsi), %rdx
movq %rdx, 0x8(%rdi)
movzbl (%rsi), %eax
jmp 0x3138c
callq 0x4703e
movq (%r15), %rdi
movq 0x8(%rdi), %rdx
movq 0x10(%rdi), %rcx
movb %al, 0x13(%rsp)
shlq $0x10, %r13
shll $0x8, %eax
movzwl %ax, %r12d
orq %r13, %r12
cmpq %rdx, %rcx
jbe 0x313b0
leaq 0x1(%rdx), %rsi
movq %rsi, 0x8(%rdi)
movzbl (%rdx), %eax
jmp 0x313c0
callq 0x4703e
movq (%r15), %rdi
movq 0x8(%rdi), %rdx
movq 0x10(%rdi), %rcx
movb %al, 0x13(%rsp)
shlq $0x10, %r13
shll $0x8, %eax
movzwl %ax, %r12d
orq %r13, %r12
cmpq %rdx, %rcx
jbe 0x313dc
leaq 0x1(%rdx), %rsi
movq %rsi, 0x8(%rdi)
movzbl (%rdx), %eax
jmp 0x313ec
callq 0x4703e
movq (%r15), %rdi
movq 0x8(%rdi), %rsi
movq 0x10(%rdi), %rcx
movb %al, 0x14(%rsp)
movzbl %al, %eax
orq %rax, %r12
cmpq %rsi, %rcx
jbe 0x31408
leaq 0x1(%rsi), %rdx
movq %rdx, 0x8(%rdi)
movzbl (%rsi), %eax
jmp 0x31418
callq 0x4703e
movq (%r15), %rdi
movq 0x8(%rdi), %rsi
movq 0x10(%rdi), %rcx
movb %al, 0x14(%rsp)
movzbl %al, %eax
orq %rax, %r12
cmpq %rsi, %rcx
jbe 0x3143c
leaq 0x1(%rsi), %rdx
movq %rdx, 0x8(%rdi)
movzbl (%rsi), %eax
jmp 0x3144c
callq 0x4703e
movq (%r15), %rdi
movq 0x8(%rdi), %rdx
movq 0x10(%rdi), %rcx
movb %al, 0x15(%rsp)
shlq $0x10, %r12
shll $0x8, %eax
movzwl %ax, %r13d
orq %r12, %r13
cmpq %rdx, %rcx
jbe 0x3146d
leaq 0x1(%rdx), %rsi
movq %rsi, 0x8(%rdi)
movzbl (%rdx), %eax
jmp 0x3147d
callq 0x4703e
movq (%r15), %rdi
movq 0x8(%rdi), %rdx
movq 0x10(%rdi), %rcx
movb %al, 0x15(%rsp)
shlq $0x10, %r12
shll $0x8, %eax
movzwl %ax, %r15d
cmpq %rdx, %rcx
jbe 0x3149d
leaq 0x1(%rdx), %rax
movq %rax, 0x8(%rdi)
movzbl (%rdx), %eax
jmp 0x314a2
callq 0x4703e
movq (%r15), %rdi
movq 0x8(%rdi), %rsi
movq 0x10(%rdi), %rcx
movb %al, 0x16(%rsp)
movzbl %al, %eax
orq %rax, %r13
shlq $0x8, %r13
cmpq %rsi, %rcx
jbe 0x314e1
leaq 0x1(%rsi), %rax
movq %rax, 0x8(%rdi)
movzbl (%rsi), %eax
jmp 0x314e6
callq 0x4703e
leaq 0xf(%rsp), %rsi
movb %al, 0x7(%rsi)
movzbl %al, %eax
andq $-0x10000, %r12         # imm = 0xFFFF0000
orq %r15, %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 0x4703e
leaq 0xf(%rsp), %rsi
movb %al, 0x8(%rsi)
movzbl %al, %eax
orq %rax, %r13
movl (%rbx), %edi
movl $0x9, %ebp
movl $0x9, %edx
callq 0x43b0
movl %eax, (%rbx)
movq %r13, (%r14)
jmp 0x314d0