// File: /workspace/github_c_makefile_star2_O3/samtools[P]htslib/bgzf.c
// Function: bgzf_uncompress
static int bgzf_uncompress(uint8_t *dst, size_t *dlen,
                           const uint8_t *src, size_t slen,
                           uint32_t expected_crc) {
    z_stream zs = {
        .zalloc = NULL,
        .zfree = NULL,
        .msg = NULL,
        .next_in = (Bytef*)src,
        .avail_in = slen,
        .next_out = (Bytef*)dst,
        .avail_out = *dlen
    };

    int ret = inflateInit2(&zs, -15);
    if (ret != Z_OK) {
        hts_log_error("Call to inflateInit2 failed: %s", bgzf_zerr(ret, &zs));
        return -1;
    }
    if ((ret = inflate(&zs, Z_FINISH)) != Z_STREAM_END) {
        hts_log_error("Inflate operation failed: %s", bgzf_zerr(ret, ret == Z_DATA_ERROR ? &zs : NULL));
        if ((ret = inflateEnd(&zs)) != Z_OK) {
            hts_log_warning("Call to inflateEnd failed: %s", bgzf_zerr(ret, NULL));
        }
        return -1;
    }
    if ((ret = inflateEnd(&zs)) != Z_OK) {
        hts_log_error("Call to inflateEnd failed: %s", bgzf_zerr(ret, NULL));
        return -1;
    }
    *dlen = *dlen - zs.avail_out;

    uint32_t crc = crc32(crc32(0L, NULL, 0L), (unsigned char *)dst, *dlen);
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
    // Pretend the CRC was OK so the fuzzer doesn't have to get it right
    crc = expected_crc;
#endif
    if (crc != expected_crc) {
        hts_log_error("CRC32 checksum mismatch");
        return -2;
    }

    return 0;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x78, %rsp
movl %r8d, %ebx
movq %rsi, %r15
movq %rdi, %r14
xorps %xmm0, %xmm0
leaq 0x8(%rsp), %rdi
movups %xmm0, 0x8(%rdi)
movups %xmm0, 0x18(%rdi)
movups %xmm0, 0x58(%rdi)
movups %xmm0, 0x48(%rdi)
movups %xmm0, 0x38(%rdi)
movups %xmm0, 0x28(%rdi)
movq $0x0, 0x68(%rdi)
movq %rdx, (%rdi)
movl %ecx, 0x8(%rdi)
movq %r14, 0x18(%rdi)
movl (%rsi), %eax
movl %eax, 0x20(%rdi)
leaq 0x86310(%rip), %rdx     # 0x949c0
movl $0xfffffff1, %esi       # imm = 0xFFFFFFF1
movl $0x70, %ecx
callq 0x43e0
testl %eax, %eax
je 0xe701
leaq 0x8(%rsp), %rsi
movl %eax, %edi
callq 0xadc9
leaq 0x86c07(%rip), %rsi     # 0x952dd
leaq 0x8645c(%rip), %rdx     # 0x94b39
movl $0x1, %edi
movq %rax, %rcx
xorl %eax, %eax
callq 0x13de5
movl $0xffffffff, %r12d      # imm = 0xFFFFFFFF
movl %r12d, %eax
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
leaq 0x8(%rsp), %r12
movq %r12, %rdi
movl $0x4, %esi
callq 0x4380
cmpl $0x1, %eax
jne 0xe743
leaq 0x8(%rsp), %rdi
callq 0x44e0
testl %eax, %eax
je 0xe7b4
movl %eax, %edi
xorl %esi, %esi
callq 0xadc9
leaq 0x86ba3(%rip), %rsi     # 0x952dd
leaq 0x86bac(%rip), %rdx     # 0x952ed
jmp 0xe6dd
cmpl $-0x3, %eax
movl $0x0, %esi
cmoveq %r12, %rsi
movl %eax, %edi
callq 0xadc9
leaq 0x86b80(%rip), %rsi     # 0x952dd
leaq 0x86afb(%rip), %rdx     # 0x9525f
movl $0x1, %edi
movq %rax, %rcx
xorl %eax, %eax
callq 0x13de5
movq %r12, %rdi
callq 0x44e0
movl $0xffffffff, %r12d      # imm = 0xFFFFFFFF
testl %eax, %eax
je 0xe6f2
movl %eax, %edi
xorl %esi, %esi
callq 0xadc9
leaq 0x86b44(%rip), %rsi     # 0x952dd
leaq 0x86b4d(%rip), %rdx     # 0x952ed
movl $0x3, %edi
movq %rax, %rcx
xorl %eax, %eax
callq 0x13de5
jmp 0xe6f2
movl 0x28(%rsp), %eax
subq %rax, (%r15)
xorl %r12d, %r12d
xorl %edi, %edi
xorl %esi, %esi
xorl %edx, %edx
callq 0x4320
movl (%r15), %edx
movq %rax, %rdi
movq %r14, %rsi
callq 0x4320
cmpl %ebx, %eax
je 0xe6f2
leaq 0x86af7(%rip), %rsi     # 0x952dd
leaq 0x86b1e(%rip), %rdx     # 0x9530b
movl $0x1, %edi
xorl %eax, %eax
callq 0x13de5
movl $0xfffffffe, %r12d      # imm = 0xFFFFFFFE
jmp 0xe6f2