// File: /workspace/github_c_makefile_star2_O1/icebert[P]pblat/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 0x55179
leaq 0x1(%rax), %rcx
movq %rcx, 0x8(%rdi)
movzbl (%rax), %eax
jmp 0x5517e
callq 0x6af26
movzbl %al, %r12d
movb %r12b, 0xf(%rsp)
cmpl $0x7f, %r12d
ja 0x551a6
movq %r12, (%r14)
movl (%rbx), %edi
leaq 0xf(%rsp), %rsi
movl $0x1, %ebp
movl $0x1, %edx
jmp 0x55937
cmpl $0xbf, %r12d
ja 0x551cd
shll $0x8, %r12d
movq (%r15), %rdi
movq 0x8(%rdi), %rax
cmpq %rax, 0x10(%rdi)
jbe 0x551f0
leaq 0x1(%rax), %rcx
movq %rcx, 0x8(%rdi)
movzbl (%rax), %eax
jmp 0x551f5
cmpl $0xdf, %r12d
ja 0x5521e
movq (%r15), %rdi
movq 0x8(%rdi), %rax
cmpq %rax, 0x10(%rdi)
jbe 0x55248
leaq 0x1(%rax), %rcx
movq %rcx, 0x8(%rdi)
movzbl (%rax), %eax
jmp 0x5524d
callq 0x6af26
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 0x55937
cmpl $0xef, %r12d
ja 0x55276
movq (%r15), %rdi
movq 0x8(%rdi), %rax
cmpq %rax, 0x10(%rdi)
jbe 0x552d5
leaq 0x1(%rax), %rcx
movq %rcx, 0x8(%rdi)
movzbl (%rax), %eax
jmp 0x552da
callq 0x6af26
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 0x552a4
leaq 0x1(%rax), %rcx
movq %rcx, 0x8(%rdi)
movzbl (%rax), %eax
jmp 0x552a9
cmpl $0xf7, %r12d
ja 0x55306
movq (%r15), %rdi
movq 0x8(%rdi), %rax
cmpq %rax, 0x10(%rdi)
jbe 0x5538f
leaq 0x1(%rax), %rcx
movq %rcx, 0x8(%rdi)
movzbl (%rax), %eax
jmp 0x55394
callq 0x6af26
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 0x55937
callq 0x6af26
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 0x55334
leaq 0x1(%rax), %rcx
movq %rcx, 0x8(%rdi)
movzbl (%rax), %eax
jmp 0x55339
cmpl $0xfb, %r12d
ja 0x553c0
movq (%r15), %rdi
movq 0x8(%rdi), %rax
cmpq %rax, 0x10(%rdi)
jbe 0x5547c
leaq 0x1(%rax), %rcx
movq %rcx, 0x8(%rdi)
movzbl (%rax), %eax
jmp 0x55481
callq 0x6af26
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 0x55361
leaq 0x1(%rax), %rcx
movq %rcx, 0x8(%rdi)
movzbl (%rax), %eax
jmp 0x55366
callq 0x6af26
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 0x55937
callq 0x6af26
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 0x553ee
leaq 0x1(%rax), %rcx
movq %rcx, 0x8(%rdi)
movzbl (%rax), %eax
jmp 0x553f3
cmpl $0xfd, %r12d
ja 0x554ad
movq (%r15), %rdi
movq 0x8(%rdi), %rax
cmpq %rax, 0x10(%rdi)
jbe 0x55599
leaq 0x1(%rax), %rcx
movq %rcx, 0x8(%rdi)
movzbl (%rax), %eax
jmp 0x5559e
callq 0x6af26
movb %al, 0x11(%rsp)
movzbl %al, %eax
orq %rax, %r13
movq (%r15), %rdi
movq 0x8(%rdi), %rax
cmpq %rax, 0x10(%rdi)
jbe 0x55417
leaq 0x1(%rax), %rcx
movq %rcx, 0x8(%rdi)
movzbl (%rax), %eax
jmp 0x5541c
callq 0x6af26
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 0x55445
leaq 0x1(%rax), %rcx
movq %rcx, 0x8(%rdi)
movzbl (%rax), %eax
jmp 0x5544a
callq 0x6af26
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 0x55937
callq 0x6af26
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 0x554de
leaq 0x1(%rax), %rcx
movq %rcx, 0x8(%rdi)
movzbl (%rax), %eax
jmp 0x554e3
movq (%r15), %rdi
movq 0x8(%rdi), %rax
movq 0x10(%rdi), %rcx
cmpl $0xff, %r12d
jne 0x555ca
cmpq %rax, %rcx
jbe 0x556cb
leaq 0x1(%rax), %rcx
movq %rcx, 0x8(%rdi)
movzbl (%rax), %ebp
jmp 0x556d2
callq 0x6af26
movb %al, 0x11(%rsp)
movzbl %al, %eax
orq %rax, %r13
movq (%r15), %rdi
movq 0x8(%rdi), %rax
cmpq %rax, 0x10(%rdi)
jbe 0x55507
leaq 0x1(%rax), %rcx
movq %rcx, 0x8(%rdi)
movzbl (%rax), %eax
jmp 0x5550c
callq 0x6af26
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 0x55538
leaq 0x1(%rax), %rcx
movq %rcx, 0x8(%rdi)
movzbl (%rax), %eax
jmp 0x5553d
callq 0x6af26
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 0x55565
leaq 0x1(%rax), %rcx
movq %rcx, 0x8(%rdi)
movzbl (%rax), %eax
jmp 0x5556a
callq 0x6af26
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 0x55937
callq 0x6af26
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 0x555e3
leaq 0x1(%rax), %rcx
movq %rcx, 0x8(%rdi)
movzbl (%rax), %eax
jmp 0x555e8
cmpq %rax, %rcx
jbe 0x556f1
leaq 0x1(%rax), %rcx
movq %rcx, 0x8(%rdi)
movzbl (%rax), %eax
jmp 0x556f6
callq 0x6af26
movb %al, 0x11(%rsp)
movzbl %al, %eax
orq %rax, %r13
movq (%r15), %rdi
movq 0x8(%rdi), %rax
cmpq %rax, 0x10(%rdi)
jbe 0x5560c
leaq 0x1(%rax), %rcx
movq %rcx, 0x8(%rdi)
movzbl (%rax), %eax
jmp 0x55611
callq 0x6af26
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 0x5563d
leaq 0x1(%rax), %rcx
movq %rcx, 0x8(%rdi)
movzbl (%rax), %eax
jmp 0x55642
callq 0x6af26
movb %al, 0x13(%rsp)
movzbl %al, %eax
orq %rax, %r12
movq (%r15), %rdi
movq 0x8(%rdi), %rax
cmpq %rax, 0x10(%rdi)
jbe 0x55666
leaq 0x1(%rax), %rcx
movq %rcx, 0x8(%rdi)
movzbl (%rax), %eax
jmp 0x5566b
callq 0x6af26
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 0x55694
leaq 0x1(%rax), %rcx
movq %rcx, 0x8(%rdi)
movzbl (%rax), %eax
jmp 0x55699
callq 0x6af26
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 0x55937
callq 0x6af26
movl %eax, %ebp
movb %bpl, 0x10(%rsp)
movq (%r15), %rdi
movq 0x8(%rdi), %rax
cmpq %rax, 0x10(%rdi)
jbe 0x5571b
leaq 0x1(%rax), %rcx
movq %rcx, 0x8(%rdi)
movzbl (%rax), %eax
jmp 0x55720
callq 0x6af26
movb %al, 0x10(%rsp)
shll $0x8, %eax
movzwl %ax, %r12d
movq (%r15), %rdi
movq 0x8(%rdi), %rax
cmpq %rax, 0x10(%rdi)
jbe 0x5574b
leaq 0x1(%rax), %rcx
movq %rcx, 0x8(%rdi)
movzbl (%rax), %eax
jmp 0x55750
callq 0x6af26
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 0x55777
leaq 0x1(%rax), %rcx
movq %rcx, 0x8(%rdi)
movzbl (%rax), %eax
jmp 0x5577c
callq 0x6af26
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 0x557a1
leaq 0x1(%rax), %rcx
movq %rcx, 0x8(%rdi)
movzbl (%rax), %eax
jmp 0x557a6
callq 0x6af26
movb %al, 0x12(%rsp)
movzbl %al, %r12d
orl %r13d, %r12d
movq (%r15), %rdi
movq 0x8(%rdi), %rax
cmpq %rax, 0x10(%rdi)
jbe 0x557cb
leaq 0x1(%rax), %rcx
movq %rcx, 0x8(%rdi)
movzbl (%rax), %eax
jmp 0x557d0
callq 0x6af26
movb %al, 0x12(%rsp)
movzbl %al, %r13d
orl %ebp, %r13d
movq (%r15), %rdi
movq 0x8(%rdi), %rax
cmpq %rax, 0x10(%rdi)
jbe 0x557fc
leaq 0x1(%rax), %rcx
movq %rcx, 0x8(%rdi)
movzbl (%rax), %eax
jmp 0x55801
callq 0x6af26
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 0x5582d
leaq 0x1(%rax), %rcx
movq %rcx, 0x8(%rdi)
movzbl (%rax), %eax
jmp 0x55832
callq 0x6af26
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 0x55856
leaq 0x1(%rax), %rcx
movq %rcx, 0x8(%rdi)
movzbl (%rax), %eax
jmp 0x5585b
callq 0x6af26
movb %al, 0x14(%rsp)
movzbl %al, %eax
orq %rax, %r13
movq (%r15), %rdi
movq 0x8(%rdi), %rax
cmpq %rax, 0x10(%rdi)
jbe 0x5587f
leaq 0x1(%rax), %rcx
movq %rcx, 0x8(%rdi)
movzbl (%rax), %eax
jmp 0x55884
callq 0x6af26
movb %al, 0x14(%rsp)
movzbl %al, %eax
orq %rax, %r12
movq (%r15), %rdi
movq 0x8(%rdi), %rax
cmpq %rax, 0x10(%rdi)
jbe 0x558b0
leaq 0x1(%rax), %rcx
movq %rcx, 0x8(%rdi)
movzbl (%rax), %eax
jmp 0x558b5
callq 0x6af26
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 0x558de
leaq 0x1(%rax), %rcx
movq %rcx, 0x8(%rdi)
movzbl (%rax), %eax
jmp 0x558e3
callq 0x6af26
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 0x5590b
leaq 0x1(%rax), %rcx
movq %rcx, 0x8(%rdi)
movzbl (%rax), %eax
jmp 0x55910
callq 0x6af26
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 0x5594f
leaq 0x1(%rax), %rcx
movq %rcx, 0x8(%rdi)
movzbl (%rax), %eax
jmp 0x55954
callq 0x6af26
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 0x64b0
movl %eax, (%rbx)
movl %ebp, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x6af26
leaq 0xf(%rsp), %rsi
movb %al, 0x8(%rsi)
movzbl %al, %eax
orq %rax, %r12
movl (%rbx), %edi
movl $0x9, %ebp
movl $0x9, %edx
callq 0x64b0
movl %eax, (%rbx)
movq %r12, (%r14)
jmp 0x5593e