// File: /workspace/github_c_makefile_star2_O0/samtools[P]htslib/cram/cram_io.c
// Function: cram_uncompress_block
int cram_uncompress_block(cram_block *b) {
    char *uncomp;
    size_t uncomp_size = 0;

#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
    // Pretend the CRC was OK so the fuzzer doesn't have to get it right
    b->crc32_checked = 1;
#endif

    if (b->crc32_checked == 0) {
        uint32_t crc = crc32(b->crc_part, b->data ? b->data : (uc *)"", b->alloc);
        b->crc32_checked = 1;
        if (crc != b->crc32) {
            hts_log_error("Block CRC32 failure");
            return -1;
        }
    }

    if (b->uncomp_size == 0) {
        // blank block
        b->method = RAW;
        return 0;
    }
    assert(b->uncomp_size >= 0); // cram_read_block should ensure this

    switch (b->method) {
    case RAW:
        return 0;

    case GZIP:
        uncomp_size = b->uncomp_size;
        uncomp = zlib_mem_inflate((char *)b->data, b->comp_size, &uncomp_size);

        if (!uncomp)
            return -1;
        if (uncomp_size != b->uncomp_size) {
            free(uncomp);
            return -1;
        }
        free(b->data);
        b->data = (unsigned char *)uncomp;
        b->alloc = uncomp_size;
        b->method = RAW;
        break;

#ifdef HAVE_LIBBZ2
    case BZIP2: {
        unsigned int usize = b->uncomp_size;
        if (!(uncomp = malloc(usize)))
            return -1;
        if (BZ_OK != BZ2_bzBuffToBuffDecompress(uncomp, &usize,
                                                (char *)b->data, b->comp_size,
                                                0, 0)) {
            free(uncomp);
            return -1;
        }
        free(b->data);
        b->data = (unsigned char *)uncomp;
        b->alloc = usize;
        b->method = RAW;
        b->uncomp_size = usize; // Just in case it differs
        break;
    }
#else
    case BZIP2:
        hts_log_error("Bzip2 compression is not compiled into this version. Please rebuild and try again");
        return -1;
#endif

#ifdef HAVE_LIBLZMA
    case LZMA:
        uncomp = lzma_mem_inflate((char *)b->data, b->comp_size, &uncomp_size);
        if (!uncomp)
            return -1;
        if (uncomp_size != b->uncomp_size) {
            free(uncomp);
            return -1;
        }
        free(b->data);
        b->data = (unsigned char *)uncomp;
        b->alloc = uncomp_size;
        b->method = RAW;
        break;
#else
    case LZMA:
        hts_log_error("Lzma compression is not compiled into this version. Please rebuild and try again");
        return -1;
        break;
#endif

    case RANS: {
        unsigned int usize = b->uncomp_size, usize2;
        uncomp = (char *)rans_uncompress(b->data, b->comp_size, &usize2);
        if (!uncomp)
            return -1;
        if (usize != usize2) {
            free(uncomp);
            return -1;
        }
        free(b->data);
        b->data = (unsigned char *)uncomp;
        b->alloc = usize2;
        b->method = RAW;
        b->uncomp_size = usize2; // Just in case it differs
        //fprintf(stderr, "Expanded %d to %d\n", b->comp_size, b->uncomp_size);
        break;
    }

    case FQZ: {
        uncomp_size = b->uncomp_size;
        uncomp = fqz_decompress((char *)b->data, b->comp_size, &uncomp_size, NULL, 0);
        if (!uncomp)
            return -1;
        free(b->data);
        b->data = (unsigned char *)uncomp;
        b->alloc = uncomp_size;
        b->method = RAW;
        b->uncomp_size = uncomp_size;
        break;
    }

    case RANS_PR0: {
        unsigned int usize = b->uncomp_size, usize2;
        uncomp = (char *)rans_uncompress_4x16(b->data, b->comp_size, &usize2);
        if (!uncomp)
            return -1;
        if (usize != usize2) {
            free(uncomp);
            return -1;
        }
        b->orig_method = RANSPR;
        free(b->data);
        b->data = (unsigned char *)uncomp;
        b->alloc = usize2;
        b->method = RAW;
        b->uncomp_size = usize2; // Just incase it differs
        //fprintf(stderr, "Expanded %d to %d\n", b->comp_size, b->uncomp_size);
        break;
    }

    case ARITH_PR0: {
        unsigned int usize = b->uncomp_size, usize2;
        uncomp = (char *)arith_uncompress_to(b->data, b->comp_size, NULL, &usize2);
        if (!uncomp)
            return -1;
        if (usize != usize2) {
            free(uncomp);
            return -1;
        }
        b->orig_method = ARITH;
        free(b->data);
        b->data = (unsigned char *)uncomp;
        b->alloc = usize2;
        b->method = RAW;
        b->uncomp_size = usize2; // Just incase it differs
        //fprintf(stderr, "Expanded %d to %d\n", b->comp_size, b->uncomp_size);
        break;
    }

    case TOK3: {
        uint32_t out_len;
        uint8_t *cp = tok3_decode_names(b->data, b->comp_size, &out_len);
        if (!cp)
            return -1;
        b->orig_method = TOK3;
        b->method = RAW;
        free(b->data);
        b->data = cp;
        b->alloc = out_len;
        b->uncomp_size = out_len;
        break;
    }

    default:
        return -1;
    }

    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x10(%rbp)
movq $0x0, -0x20(%rbp)
movq -0x10(%rbp), %rax
cmpl $0x0, 0x48(%rax)
jne 0x6fa2c
movq -0x10(%rbp), %rax
movl 0x4c(%rax), %eax
movq %rax, -0x58(%rbp)
movq -0x10(%rbp), %rax
cmpq $0x0, 0x20(%rax)
je 0x6f9c6
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x60(%rbp)
jmp 0x6f9d3
leaq 0x805a8(%rip), %rax     # 0xeff75
movq %rax, -0x60(%rbp)
jmp 0x6f9d3
movq -0x58(%rbp), %rdi
movq -0x60(%rbp), %rsi
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rax
movl %eax, %edx
callq 0x4310
movl %eax, -0x24(%rbp)
movq -0x10(%rbp), %rax
movl $0x1, 0x48(%rax)
movl -0x24(%rbp), %eax
movq -0x10(%rbp), %rcx
cmpl 0x18(%rcx), %eax
je 0x6fa2a
movl $0x1, %edi
leaq 0x85c67(%rip), %rsi     # 0xf5677
leaq 0x85c76(%rip), %rdx     # 0xf568d
movb $0x0, %al
callq 0x1b030
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x6ff50
jmp 0x6fa2c
movq -0x10(%rbp), %rax
cmpl $0x0, 0x14(%rax)
jne 0x6fa4c
movq -0x10(%rbp), %rax
movl $0x0, (%rax)
movl $0x0, -0x4(%rbp)
jmp 0x6ff50
movq -0x10(%rbp), %rax
cmpl $0x0, 0x14(%rax)
jl 0x6fa58
jmp 0x6fa77
leaq 0x85c42(%rip), %rdi     # 0xf56a1
leaq 0x85bac(%rip), %rsi     # 0xf5612
movl $0x63b, %edx            # imm = 0x63B
leaq 0x85c43(%rip), %rcx     # 0xf56b5
callq 0x42e0
movq -0x10(%rbp), %rax
movl (%rax), %eax
movq %rax, -0x68(%rbp)
subq $0x8, %rax
ja 0x6ff40
movq -0x68(%rbp), %rax
leaq 0x850c2(%rip), %rcx     # 0xf4b58
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movl $0x0, -0x4(%rbp)
jmp 0x6ff50
movq -0x10(%rbp), %rax
movslq 0x14(%rax), %rax
movq %rax, -0x20(%rbp)
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rdi
movq -0x10(%rbp), %rax
movslq 0x10(%rax), %rsi
leaq -0x20(%rbp), %rdx
callq 0x6eb00
movq %rax, -0x18(%rbp)
cmpq $0x0, -0x18(%rbp)
jne 0x6fae7
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x6ff50
movq -0x20(%rbp), %rax
movq -0x10(%rbp), %rcx
movslq 0x14(%rcx), %rcx
cmpq %rcx, %rax
je 0x6fb0d
movq -0x18(%rbp), %rdi
callq 0x45a0
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x6ff50
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rdi
callq 0x45a0
movq -0x18(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x20(%rax)
movq -0x20(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x28(%rax)
movq -0x10(%rbp), %rax
movl $0x0, (%rax)
jmp 0x6ff49
movq -0x10(%rbp), %rax
movl 0x14(%rax), %eax
movl %eax, -0x28(%rbp)
movl -0x28(%rbp), %eax
movl %eax, %edi
callq 0x4650
movq %rax, -0x18(%rbp)
cmpq $0x0, %rax
jne 0x6fb6b
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x6ff50
movq -0x18(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rdx
movq -0x10(%rbp), %rax
movl 0x10(%rax), %ecx
leaq -0x28(%rbp), %rsi
xorl %r9d, %r9d
movl %r9d, %r8d
callq 0x4540
movl %eax, %ecx
xorl %eax, %eax
cmpl %ecx, %eax
je 0x6fbaa
movq -0x18(%rbp), %rdi
callq 0x45a0
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x6ff50
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rdi
callq 0x45a0
movq -0x18(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x20(%rax)
movl -0x28(%rbp), %eax
movl %eax, %ecx
movq -0x10(%rbp), %rax
movq %rcx, 0x28(%rax)
movq -0x10(%rbp), %rax
movl $0x0, (%rax)
movl -0x28(%rbp), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x14(%rax)
jmp 0x6ff49
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rdi
movq -0x10(%rbp), %rax
movslq 0x10(%rax), %rsi
leaq -0x20(%rbp), %rdx
callq 0x6ff60
movq %rax, -0x18(%rbp)
cmpq $0x0, -0x18(%rbp)
jne 0x6fc19
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x6ff50
movq -0x20(%rbp), %rax
movq -0x10(%rbp), %rcx
movslq 0x14(%rcx), %rcx
cmpq %rcx, %rax
je 0x6fc3f
movq -0x18(%rbp), %rdi
callq 0x45a0
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x6ff50
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rdi
callq 0x45a0
movq -0x18(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x20(%rax)
movq -0x20(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x28(%rax)
movq -0x10(%rbp), %rax
movl $0x0, (%rax)
jmp 0x6ff49
movq -0x10(%rbp), %rax
movl 0x14(%rax), %eax
movl %eax, -0x2c(%rbp)
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rdi
movq -0x10(%rbp), %rax
movl 0x10(%rax), %esi
leaq -0x30(%rbp), %rdx
callq 0xc5370
movq %rax, -0x18(%rbp)
cmpq $0x0, -0x18(%rbp)
jne 0x6fcac
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x6ff50
movl -0x2c(%rbp), %eax
cmpl -0x30(%rbp), %eax
je 0x6fcc9
movq -0x18(%rbp), %rdi
callq 0x45a0
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x6ff50
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rdi
callq 0x45a0
movq -0x18(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x20(%rax)
movl -0x30(%rbp), %eax
movl %eax, %ecx
movq -0x10(%rbp), %rax
movq %rcx, 0x28(%rax)
movq -0x10(%rbp), %rax
movl $0x0, (%rax)
movl -0x30(%rbp), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x14(%rax)
jmp 0x6ff49
movq -0x10(%rbp), %rax
movslq 0x14(%rax), %rax
movq %rax, -0x20(%rbp)
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rdi
movq -0x10(%rbp), %rax
movslq 0x10(%rax), %rsi
leaq -0x20(%rbp), %rdx
xorl %eax, %eax
movl %eax, %ecx
xorl %r8d, %r8d
callq 0x88ec0
movq %rax, -0x18(%rbp)
cmpq $0x0, -0x18(%rbp)
jne 0x6fd4b
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x6ff50
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rdi
callq 0x45a0
movq -0x18(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x20(%rax)
movq -0x20(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x28(%rax)
movq -0x10(%rbp), %rax
movl $0x0, (%rax)
movq -0x20(%rbp), %rax
movl %eax, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x14(%rax)
jmp 0x6ff49
movq -0x10(%rbp), %rax
movl 0x14(%rax), %eax
movl %eax, -0x34(%rbp)
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rdi
movq -0x10(%rbp), %rax
movl 0x10(%rax), %esi
leaq -0x38(%rbp), %rdx
callq 0x92a50
movq %rax, -0x18(%rbp)
cmpq $0x0, -0x18(%rbp)
jne 0x6fdc5
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x6ff50
movl -0x34(%rbp), %eax
cmpl -0x38(%rbp), %eax
je 0x6fde2
movq -0x18(%rbp), %rdi
callq 0x45a0
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x6ff50
movq -0x10(%rbp), %rax
movl $0x5, 0x4(%rax)
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rdi
callq 0x45a0
movq -0x18(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x20(%rax)
movl -0x38(%rbp), %eax
movl %eax, %ecx
movq -0x10(%rbp), %rax
movq %rcx, 0x28(%rax)
movq -0x10(%rbp), %rax
movl $0x0, (%rax)
movl -0x38(%rbp), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x14(%rax)
jmp 0x6ff49
movq -0x10(%rbp), %rax
movl 0x14(%rax), %eax
movl %eax, -0x3c(%rbp)
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rdi
movq -0x10(%rbp), %rax
movl 0x10(%rax), %esi
xorl %eax, %eax
movl %eax, %edx
leaq -0x40(%rbp), %rcx
callq 0x84220
movq %rax, -0x18(%rbp)
cmpq $0x0, -0x18(%rbp)
jne 0x6fe69
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x6ff50
movl -0x3c(%rbp), %eax
cmpl -0x40(%rbp), %eax
je 0x6fe86
movq -0x18(%rbp), %rdi
callq 0x45a0
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x6ff50
movq -0x10(%rbp), %rax
movl $0x6, 0x4(%rax)
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rdi
callq 0x45a0
movq -0x18(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x20(%rax)
movl -0x40(%rbp), %eax
movl %eax, %ecx
movq -0x10(%rbp), %rax
movq %rcx, 0x28(%rax)
movq -0x10(%rbp), %rax
movl $0x0, (%rax)
movl -0x40(%rbp), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x14(%rax)
jmp 0x6ff49
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rdi
movq -0x10(%rbp), %rax
movl 0x10(%rax), %esi
leaq -0x44(%rbp), %rdx
callq 0xcabc0
movq %rax, -0x50(%rbp)
cmpq $0x0, -0x50(%rbp)
jne 0x6fef9
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x6ff50
movq -0x10(%rbp), %rax
movl $0x8, 0x4(%rax)
movq -0x10(%rbp), %rax
movl $0x0, (%rax)
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rdi
callq 0x45a0
movq -0x50(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x20(%rax)
movl -0x44(%rbp), %eax
movl %eax, %ecx
movq -0x10(%rbp), %rax
movq %rcx, 0x28(%rax)
movl -0x44(%rbp), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x14(%rax)
jmp 0x6ff49
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x6ff50
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x70, %rsp
popq %rbp
retq
nopl (%rax)