// File: /workspace/github_cpp_makefile_star2_O2/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
callq 0x266a9
movzbl %al, %r13d
movb %r13b, 0xf(%rsp)
cmpl $0x7f, %r13d
ja 0x27166
movq %r13, (%r14)
movl (%rbx), %edi
leaq 0xf(%rsp), %rsi
pushq $0x1
jmp 0x27194
cmpl $0xbf, %r13d
ja 0x271af
movq (%r15), %rdi
callq 0x266a9
leaq 0xf(%rsp), %rsi
movb %al, 0x1(%rsi)
movzbl %al, %eax
andl $0x3f, %r13d
shll $0x8, %r13d
orl %eax, %r13d
movq %r13, (%r14)
movl (%rbx), %edi
pushq $0x2
popq %rbp
movl %ebp, %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
cmpl $0xdf, %r13d
ja 0x271fb
movq (%r15), %rdi
callq 0x266a9
leaq 0xf(%rsp), %r12
movb %al, 0x1(%r12)
shll $0x8, %eax
movzwl %ax, %ebp
movq (%r15), %rdi
callq 0x266a9
movb %al, 0x2(%r12)
movzbl %al, %eax
andl $0x1f, %r13d
shll $0x10, %r13d
orl %ebp, %r13d
orl %eax, %r13d
movq %r13, (%r14)
movl (%rbx), %edi
pushq $0x3
popq %rbp
movq %r12, %rsi
jmp 0x27195
cmpl $0xef, %r13d
ja 0x2726d
movq (%r15), %rdi
callq 0x266a9
leaq 0xf(%rsp), %rcx
movb %al, 0x1(%rcx)
movq %rcx, %r12
shll $0x10, %r13d
shll $0x8, %eax
movzwl %ax, %ebp
orl %r13d, %ebp
movq (%r15), %rdi
callq 0x266a9
movl %eax, %r13d
movb %r13b, 0x2(%r12)
movl $0xff, %r12d
andl %r12d, %r13d
orl %ebp, %r13d
shll $0x8, %r13d
movq (%r15), %rdi
callq 0x266a9
leaq 0xf(%rsp), %rsi
movb %al, 0x3(%rsi)
andl %r12d, %eax
andl $0xfffff00, %r13d       # imm = 0xFFFFF00
orl %eax, %r13d
movq %r13, (%r14)
movl (%rbx), %edi
pushq $0x4
jmp 0x27194
cmpl $0xf7, %r13d
ja 0x27304
movq (%r15), %rdi
callq 0x266a9
movl %eax, %ebp
leaq 0xf(%rsp), %r12
movb %bpl, 0x1(%r12)
shll $0x10, %r13d
shll $0x8, %ebp
movl $0xffff, %eax           # imm = 0xFFFF
andl %eax, %ebp
orl %r13d, %ebp
movq (%r15), %rdi
callq 0x266a9
movl %eax, %r13d
movb %r13b, 0x2(%r12)
movl $0xff, %eax
andl %eax, %r13d
orl %ebp, %r13d
movq (%r15), %rdi
callq 0x266a9
movl %eax, %ebp
movb %bpl, 0x3(%r12)
shll $0x8, %ebp
movl $0xffff, %eax           # imm = 0xFFFF
andl %eax, %ebp
movq (%r15), %rdi
callq 0x266a9
movb %al, 0x4(%r12)
movl $0xff, %ecx
andl %ecx, %eax
andl $0x7ffff, %r13d         # imm = 0x7FFFF
shlq $0x10, %r13
orq %rbp, %r13
orq %rax, %r13
movq %r13, (%r14)
movl (%rbx), %edi
pushq $0x5
jmp 0x271f5
cmpl $0xfb, %r13d
ja 0x273c0
movq (%r15), %rdi
callq 0x266a9
movl %eax, %ebp
leaq 0xf(%rsp), %r12
movb %bpl, 0x1(%r12)
shll $0x10, %r13d
shll $0x8, %ebp
movl $0xffff, %eax           # imm = 0xFFFF
andl %eax, %ebp
orl %r13d, %ebp
movq (%r15), %rdi
callq 0x266a9
movl %eax, %r13d
movb %r13b, 0x2(%r12)
movl $0xff, %eax
andl %eax, %r13d
orl %ebp, %r13d
movq (%r15), %rdi
callq 0x266a9
movl %eax, %ebp
movb %bpl, 0x3(%r12)
shlq $0x10, %r13
shll $0x8, %ebp
movl $0xffff, %eax           # imm = 0xFFFF
andl %eax, %ebp
orq %r13, %rbp
movq (%r15), %rdi
callq 0x266a9
movl %eax, %r13d
movb %r13b, 0x4(%r12)
movl $0xff, %eax
andl %eax, %r13d
orq %rbp, %r13
shlq $0x8, %r13
movq (%r15), %rdi
callq 0x266a9
movb %al, 0x5(%r12)
movl $0xff, %ecx
andl %ecx, %eax
movabsq $0x3ffffffff00, %rcx    # imm = 0x3FFFFFFFF00
andq %r13, %rcx
orq %rax, %rcx
movq %rcx, (%r14)
movl (%rbx), %edi
pushq $0x6
jmp 0x271f5
cmpl $0xfd, %r13d
ja 0x27498
movq (%r15), %rdi
callq 0x266a9
movl %eax, %ebp
leaq 0xf(%rsp), %r12
movb %bpl, 0x1(%r12)
shll $0x10, %r13d
shll $0x8, %ebp
movl $0xffff, %eax           # imm = 0xFFFF
andl %eax, %ebp
orl %r13d, %ebp
movq (%r15), %rdi
callq 0x266a9
movl %eax, %r13d
movb %r13b, 0x2(%r12)
movl $0xff, %eax
andl %eax, %r13d
orl %ebp, %r13d
movq (%r15), %rdi
callq 0x266a9
movl %eax, %ebp
movb %bpl, 0x3(%r12)
shlq $0x10, %r13
shll $0x8, %ebp
movl $0xffff, %eax           # imm = 0xFFFF
andl %eax, %ebp
orq %r13, %rbp
movq (%r15), %rdi
callq 0x266a9
movl %eax, %r13d
movb %r13b, 0x4(%r12)
movl $0xff, %eax
andl %eax, %r13d
orq %rbp, %r13
movq (%r15), %rdi
callq 0x266a9
movl %eax, %ebp
movb %bpl, 0x5(%r12)
shlq $0x10, %r13
shll $0x8, %ebp
movl $0xffff, %eax           # imm = 0xFFFF
andl %eax, %ebp
movq (%r15), %rdi
callq 0x266a9
movb %al, 0x6(%r12)
movl $0xff, %ecx
andl %ecx, %eax
movabsq $0x1ffffffff0000, %rcx  # imm = 0x1FFFFFFFF0000
andq %r13, %rcx
orq %rbp, %rcx
orq %rax, %rcx
movq %rcx, (%r14)
movl (%rbx), %edi
pushq $0x7
jmp 0x271f5
movq (%r15), %rdi
callq 0x266a9
movl %eax, %ebp
movb %bpl, 0x10(%rsp)
cmpl $0xff, %r13d
jne 0x275a4
movq (%r15), %rdi
callq 0x266a9
movl %eax, %r13d
leaq 0xf(%rsp), %r12
movb %r13b, 0x2(%r12)
shll $0x10, %ebp
shll $0x8, %r13d
movl $0xffff, %eax           # imm = 0xFFFF
andl %eax, %r13d
orl %ebp, %r13d
movq (%r15), %rdi
callq 0x266a9
movl %eax, %ebp
movb %bpl, 0x3(%r12)
movl $0xff, %eax
andl %eax, %ebp
orl %r13d, %ebp
movq (%r15), %rdi
callq 0x266a9
movl %eax, %r13d
movb %r13b, 0x4(%r12)
shlq $0x10, %rbp
shll $0x8, %r13d
movl $0xffff, %eax           # imm = 0xFFFF
andl %eax, %r13d
orq %rbp, %r13
movq (%r15), %rdi
callq 0x266a9
movl %eax, %ebp
movb %bpl, 0x5(%r12)
movl $0xff, %eax
andl %eax, %ebp
orq %r13, %rbp
movq (%r15), %rdi
callq 0x266a9
movl %eax, %r13d
movb %r13b, 0x6(%r12)
shlq $0x10, %rbp
shll $0x8, %r13d
movl $0xffff, %eax           # imm = 0xFFFF
andl %eax, %r13d
orq %rbp, %r13
movq (%r15), %rdi
callq 0x266a9
movl %eax, %ebp
movb %bpl, 0x7(%r12)
movl $0xff, %eax
andl %eax, %ebp
orq %r13, %rbp
shlq $0x8, %rbp
movq (%r15), %rdi
callq 0x266a9
movl %eax, %r15d
movb %r15b, 0x8(%r12)
movl $0xff, %eax
andl %eax, %r15d
orq %rbp, %r15
movl (%rbx), %edi
pushq $0x9
popq %rbp
movq %r12, %rsi
movl %ebp, %edx
callq 0x43b0
movl %eax, (%rbx)
movq %r15, (%r14)
jmp 0x2719e
shll $0x8, %ebp
movl $0xffff, %eax           # imm = 0xFFFF
andl %eax, %ebp
movq (%r15), %rdi
callq 0x266a9
movl %eax, %r13d
leaq 0xf(%rsp), %r12
movb %r13b, 0x2(%r12)
movl $0xff, %eax
andl %eax, %r13d
orl %ebp, %r13d
shll $0x8, %r13d
movq (%r15), %rdi
callq 0x266a9
movl %eax, %ebp
movb %bpl, 0x3(%r12)
movl $0xff, %eax
andl %eax, %ebp
orl %r13d, %ebp
movq (%r15), %rdi
callq 0x266a9
movl %eax, %r12d
leaq 0xf(%rsp), %rax
movb %r12b, 0x4(%rax)
shlq $0x10, %rbp
shll $0x8, %r12d
movl $0xffff, %eax           # imm = 0xFFFF
andl %eax, %r12d
orq %rbp, %r12
movq (%r15), %rdi
callq 0x266a9
movl %eax, %r13d
leaq 0xf(%rsp), %rbp
movb %r13b, 0x5(%rbp)
movl $0xff, %eax
andl %eax, %r13d
orq %r12, %r13
movq (%r15), %rdi
callq 0x266a9
movl %eax, %r12d
movb %r12b, 0x6(%rbp)
shlq $0x10, %r13
shll $0x8, %r12d
movl $0xffff, %eax           # imm = 0xFFFF
andl %eax, %r12d
movq (%r15), %rdi
callq 0x266a9
movb %al, 0x7(%rbp)
movq %rbp, %rsi
movl $0xff, %ecx
andl %ecx, %eax
movabsq $0xffffffffff0000, %rcx # imm = 0xFFFFFFFFFF0000
andq %r13, %rcx
orq %r12, %rcx
orq %rax, %rcx
movq %rcx, (%r14)
movl (%rbx), %edi
pushq $0x8
jmp 0x27194