// File: /workspace/github_c_makefile_star2_O1/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
movq %rsp, %rdi
movaps %xmm0, (%rdi)
movaps %xmm0, 0x10(%rdi)
movaps %xmm0, 0x60(%rdi)
movaps %xmm0, 0x50(%rdi)
movaps %xmm0, 0x40(%rdi)
movaps %xmm0, 0x30(%rdi)
movaps %xmm0, 0x20(%rdi)
movq %rdx, (%rdi)
movl %ecx, 0x8(%rdi)
movq %r14, 0x18(%rdi)
movl (%rsi), %eax
movl %eax, 0x20(%rdi)
leaq 0x8918d(%rip), %rdx     # 0x97980
movl $0xfffffff1, %esi       # imm = 0xFFFFFFF1
movl $0x70, %ecx
callq 0x43e0
testl %eax, %eax
je 0xe842
movq %rsp, %rsi
movl %eax, %edi
callq 0xadd0
leaq 0x89a86(%rip), %rsi     # 0x9829d
leaq 0x892db(%rip), %rdx     # 0x97af9
movl $0x1, %edi
movq %rax, %rcx
xorl %eax, %eax
callq 0x14378
movl $0xffffffff, %r12d      # imm = 0xFFFFFFFF
movl %r12d, %eax
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
movq %rsp, %r12
movq %r12, %rdi
movl $0x4, %esi
callq 0x4380
cmpl $0x1, %eax
jne 0xe880
movq %rsp, %rdi
callq 0x44e0
testl %eax, %eax
je 0xe8f1
movl %eax, %edi
xorl %esi, %esi
callq 0xadd0
leaq 0x89a26(%rip), %rsi     # 0x9829d
leaq 0x89a2f(%rip), %rdx     # 0x982ad
jmp 0xe81e
cmpl $-0x3, %eax
movl $0x0, %esi
cmoveq %r12, %rsi
movl %eax, %edi
callq 0xadd0
leaq 0x89a03(%rip), %rsi     # 0x9829d
leaq 0x8997e(%rip), %rdx     # 0x9821f
movl $0x1, %edi
movq %rax, %rcx
xorl %eax, %eax
callq 0x14378
movq %r12, %rdi
callq 0x44e0
movl $0xffffffff, %r12d      # imm = 0xFFFFFFFF
testl %eax, %eax
je 0xe833
movl %eax, %edi
xorl %esi, %esi
callq 0xadd0
leaq 0x899c7(%rip), %rsi     # 0x9829d
leaq 0x899d0(%rip), %rdx     # 0x982ad
movl $0x3, %edi
movq %rax, %rcx
xorl %eax, %eax
callq 0x14378
jmp 0xe833
movl 0x20(%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 0xe833
leaq 0x8997a(%rip), %rsi     # 0x9829d
leaq 0x899a1(%rip), %rdx     # 0x982cb
movl $0x1, %edi
xorl %eax, %eax
callq 0x14378
movl $0xfffffffe, %r12d      # imm = 0xFFFFFFFE
jmp 0xe833