// File: /workspace/github_c_makefile_star2_O0/samtools[P]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 = hgetc(fd->fp);
    if (val < 0)
        return -1;

    c[0] = val;

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

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

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

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

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

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

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

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

    } else {
        uint64_t uval;
        if (hread(fd->fp, &c[1], 8) < 8)
            return -1;
        uval =             c[1];
        uval = (uval<<8) | c[2];
        uval = (uval<<8) | c[3];
        uval = (uval<<8) | c[4];
        uval = (uval<<8) | c[5];
        uval = (uval<<8) | c[6];
        uval = (uval<<8) | c[7];
        uval = (uval<<8) | c[8];
        *crc = crc32(*crc, c, 9);
        // Avoid implementation-defined behaviour on negative values
        *val_p = c[1] < 0x80 ? (int64_t) uval : -((int64_t) (0xffffffffffffffffULL - uval)) - 1;
    }

    return 9;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rdi
callq 0x6cbf0
cltq
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x38(%rbp)
jge 0x6db59
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x6e214
movq -0x38(%rbp), %rax
movb %al, -0x29(%rbp)
cmpq $0x80, -0x38(%rbp)
jge 0x6db9f
movq -0x38(%rbp), %rcx
movq -0x18(%rbp), %rax
movq %rcx, (%rax)
movq -0x20(%rbp), %rax
movl (%rax), %eax
movl %eax, %edi
leaq -0x29(%rbp), %rsi
movl $0x1, %edx
callq 0x4310
movl %eax, %ecx
movq -0x20(%rbp), %rax
movl %ecx, (%rax)
movl $0x1, -0x4(%rbp)
jmp 0x6e214
cmpq $0xc0, -0x38(%rbp)
jge 0x6dc1e
movq -0x10(%rbp), %rax
movq (%rax), %rdi
callq 0x6cbf0
movl %eax, -0x3c(%rbp)
cmpl $0x0, -0x3c(%rbp)
jge 0x6dbca
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x6e214
movq -0x38(%rbp), %rax
shlq $0x8, %rax
movl -0x3c(%rbp), %ecx
movb %cl, -0x28(%rbp)
movzbl %cl, %ecx
orq %rcx, %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rcx
andq $0x3fff, %rcx           # imm = 0x3FFF
movq -0x18(%rbp), %rax
movq %rcx, (%rax)
movq -0x20(%rbp), %rax
movl (%rax), %eax
movl %eax, %edi
leaq -0x29(%rbp), %rsi
movl $0x2, %edx
callq 0x4310
movl %eax, %ecx
movq -0x20(%rbp), %rax
movl %ecx, (%rax)
movl $0x2, -0x4(%rbp)
jmp 0x6e214
cmpq $0xe0, -0x38(%rbp)
jge 0x6dcb9
movq -0x10(%rbp), %rax
movq (%rax), %rdi
leaq -0x29(%rbp), %rsi
addq $0x1, %rsi
movl $0x2, %edx
callq 0x6cee0
cmpq $0x2, %rax
jge 0x6dc57
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x6e214
movq -0x38(%rbp), %rax
shlq $0x8, %rax
movzbl -0x28(%rbp), %ecx
orq %rcx, %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
shlq $0x8, %rax
movzbl -0x27(%rbp), %ecx
orq %rcx, %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rcx
andq $0x1fffff, %rcx         # imm = 0x1FFFFF
movq -0x18(%rbp), %rax
movq %rcx, (%rax)
movq -0x20(%rbp), %rax
movl (%rax), %eax
movl %eax, %edi
leaq -0x29(%rbp), %rsi
movl $0x3, %edx
callq 0x4310
movl %eax, %ecx
movq -0x20(%rbp), %rax
movl %ecx, (%rax)
movl $0x3, -0x4(%rbp)
jmp 0x6e214
cmpq $0xf0, -0x38(%rbp)
jge 0x6dd67
movq -0x10(%rbp), %rax
movq (%rax), %rdi
leaq -0x29(%rbp), %rsi
addq $0x1, %rsi
movl $0x3, %edx
callq 0x6cee0
cmpq $0x3, %rax
jge 0x6dcf2
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x6e214
movq -0x38(%rbp), %rax
shlq $0x8, %rax
movzbl -0x28(%rbp), %ecx
orq %rcx, %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
shlq $0x8, %rax
movzbl -0x27(%rbp), %ecx
orq %rcx, %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
shlq $0x8, %rax
movzbl -0x26(%rbp), %ecx
orq %rcx, %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rcx
andq $0xfffffff, %rcx        # imm = 0xFFFFFFF
movq -0x18(%rbp), %rax
movq %rcx, (%rax)
movq -0x20(%rbp), %rax
movl (%rax), %eax
movl %eax, %edi
leaq -0x29(%rbp), %rsi
movl $0x4, %edx
callq 0x4310
movl %eax, %ecx
movq -0x20(%rbp), %rax
movl %ecx, (%rax)
movl $0x4, -0x4(%rbp)
jmp 0x6e214
cmpq $0xf8, -0x38(%rbp)
jge 0x6de2b
movq -0x10(%rbp), %rax
movq (%rax), %rdi
leaq -0x29(%rbp), %rsi
addq $0x1, %rsi
movl $0x4, %edx
callq 0x6cee0
cmpq $0x4, %rax
jge 0x6dda0
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x6e214
movq -0x38(%rbp), %rax
shlq $0x8, %rax
movzbl -0x28(%rbp), %ecx
orq %rcx, %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
shlq $0x8, %rax
movzbl -0x27(%rbp), %ecx
orq %rcx, %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
shlq $0x8, %rax
movzbl -0x26(%rbp), %ecx
orq %rcx, %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
shlq $0x8, %rax
movzbl -0x25(%rbp), %ecx
orq %rcx, %rax
movq %rax, -0x38(%rbp)
movabsq $0x7ffffffff, %rcx      # imm = 0x7FFFFFFFF
andq -0x38(%rbp), %rcx
movq -0x18(%rbp), %rax
movq %rcx, (%rax)
movq -0x20(%rbp), %rax
movl (%rax), %eax
movl %eax, %edi
leaq -0x29(%rbp), %rsi
movl $0x5, %edx
callq 0x4310
movl %eax, %ecx
movq -0x20(%rbp), %rax
movl %ecx, (%rax)
movl $0x5, -0x4(%rbp)
jmp 0x6e214
cmpq $0xfc, -0x38(%rbp)
jge 0x6df02
movq -0x10(%rbp), %rax
movq (%rax), %rdi
leaq -0x29(%rbp), %rsi
addq $0x1, %rsi
movl $0x5, %edx
callq 0x6cee0
cmpq $0x5, %rax
jge 0x6de64
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x6e214
movq -0x38(%rbp), %rax
shlq $0x8, %rax
movzbl -0x28(%rbp), %ecx
orq %rcx, %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
shlq $0x8, %rax
movzbl -0x27(%rbp), %ecx
orq %rcx, %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
shlq $0x8, %rax
movzbl -0x26(%rbp), %ecx
orq %rcx, %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
shlq $0x8, %rax
movzbl -0x25(%rbp), %ecx
orq %rcx, %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
shlq $0x8, %rax
movzbl -0x24(%rbp), %ecx
orq %rcx, %rax
movq %rax, -0x38(%rbp)
movabsq $0x3ffffffffff, %rcx    # imm = 0x3FFFFFFFFFF
andq -0x38(%rbp), %rcx
movq -0x18(%rbp), %rax
movq %rcx, (%rax)
movq -0x20(%rbp), %rax
movl (%rax), %eax
movl %eax, %edi
leaq -0x29(%rbp), %rsi
movl $0x6, %edx
callq 0x4310
movl %eax, %ecx
movq -0x20(%rbp), %rax
movl %ecx, (%rax)
movl $0x6, -0x4(%rbp)
jmp 0x6e214
cmpq $0xfe, -0x38(%rbp)
jge 0x6dfec
movq -0x10(%rbp), %rax
movq (%rax), %rdi
leaq -0x29(%rbp), %rsi
addq $0x1, %rsi
movl $0x6, %edx
callq 0x6cee0
cmpq $0x6, %rax
jge 0x6df3b
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x6e214
movq -0x38(%rbp), %rax
shlq $0x8, %rax
movzbl -0x28(%rbp), %ecx
orq %rcx, %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
shlq $0x8, %rax
movzbl -0x27(%rbp), %ecx
orq %rcx, %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
shlq $0x8, %rax
movzbl -0x26(%rbp), %ecx
orq %rcx, %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
shlq $0x8, %rax
movzbl -0x25(%rbp), %ecx
orq %rcx, %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
shlq $0x8, %rax
movzbl -0x24(%rbp), %ecx
orq %rcx, %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
shlq $0x8, %rax
movzbl -0x23(%rbp), %ecx
orq %rcx, %rax
movq %rax, -0x38(%rbp)
movabsq $0x1ffffffffffff, %rcx  # imm = 0x1FFFFFFFFFFFF
andq -0x38(%rbp), %rcx
movq -0x18(%rbp), %rax
movq %rcx, (%rax)
movq -0x20(%rbp), %rax
movl (%rax), %eax
movl %eax, %edi
leaq -0x29(%rbp), %rsi
movl $0x7, %edx
callq 0x4310
movl %eax, %ecx
movq -0x20(%rbp), %rax
movl %ecx, (%rax)
movl $0x7, -0x4(%rbp)
jmp 0x6e214
cmpq $0xff, -0x38(%rbp)
jge 0x6e0f1
movq -0x38(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rdi
leaq -0x29(%rbp), %rsi
addq $0x1, %rsi
movl $0x7, %edx
callq 0x6cee0
cmpq $0x7, %rax
jge 0x6e02d
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x6e214
movq -0x48(%rbp), %rax
shlq $0x8, %rax
movzbl -0x28(%rbp), %ecx
orq %rcx, %rax
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rax
shlq $0x8, %rax
movzbl -0x27(%rbp), %ecx
orq %rcx, %rax
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rax
shlq $0x8, %rax
movzbl -0x26(%rbp), %ecx
orq %rcx, %rax
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rax
shlq $0x8, %rax
movzbl -0x25(%rbp), %ecx
orq %rcx, %rax
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rax
shlq $0x8, %rax
movzbl -0x24(%rbp), %ecx
orq %rcx, %rax
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rax
shlq $0x8, %rax
movzbl -0x23(%rbp), %ecx
orq %rcx, %rax
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rax
shlq $0x8, %rax
movzbl -0x22(%rbp), %ecx
orq %rcx, %rax
movq %rax, -0x48(%rbp)
movabsq $0xffffffffffffff, %rcx # imm = 0xFFFFFFFFFFFFFF
andq -0x48(%rbp), %rcx
movq -0x18(%rbp), %rax
movq %rcx, (%rax)
movq -0x20(%rbp), %rax
movl (%rax), %eax
movl %eax, %edi
leaq -0x29(%rbp), %rsi
movl $0x8, %edx
callq 0x4310
movl %eax, %ecx
movq -0x20(%rbp), %rax
movl %ecx, (%rax)
movl $0x8, -0x4(%rbp)
jmp 0x6e214
movq -0x10(%rbp), %rax
movq (%rax), %rdi
leaq -0x29(%rbp), %rsi
addq $0x1, %rsi
movl $0x8, %edx
callq 0x6cee0
cmpq $0x8, %rax
jge 0x6e11c
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x6e214
movzbl -0x28(%rbp), %eax
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rax
shlq $0x8, %rax
movzbl -0x27(%rbp), %ecx
orq %rcx, %rax
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rax
shlq $0x8, %rax
movzbl -0x26(%rbp), %ecx
orq %rcx, %rax
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rax
shlq $0x8, %rax
movzbl -0x25(%rbp), %ecx
orq %rcx, %rax
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rax
shlq $0x8, %rax
movzbl -0x24(%rbp), %ecx
orq %rcx, %rax
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rax
shlq $0x8, %rax
movzbl -0x23(%rbp), %ecx
orq %rcx, %rax
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rax
shlq $0x8, %rax
movzbl -0x22(%rbp), %ecx
orq %rcx, %rax
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rax
shlq $0x8, %rax
movzbl -0x21(%rbp), %ecx
orq %rcx, %rax
movq %rax, -0x50(%rbp)
movq -0x20(%rbp), %rax
movl (%rax), %eax
movl %eax, %edi
leaq -0x29(%rbp), %rsi
movl $0x9, %edx
callq 0x4310
movl %eax, %ecx
movq -0x20(%rbp), %rax
movl %ecx, (%rax)
movzbl -0x28(%rbp), %eax
cmpl $0x80, %eax
jge 0x6e1dc
movq -0x50(%rbp), %rax
movq %rax, -0x58(%rbp)
jmp 0x6e1f4
movq $-0x1, %rcx
subq -0x50(%rbp), %rcx
xorl %eax, %eax
subq %rcx, %rax
subq $0x1, %rax
movq %rax, -0x58(%rbp)
movq -0x58(%rbp), %rcx
movq -0x18(%rbp), %rax
movq %rcx, (%rax)
jmp 0x6e201
jmp 0x6e203
jmp 0x6e205
jmp 0x6e207
jmp 0x6e209
jmp 0x6e20b
jmp 0x6e20d
movl $0x9, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x60, %rsp
popq %rbp
retq
nopl (%rax)