// File: /workspace/github_c_makefile_star2_O2/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)
andq $0x0, 0x68(%rdi)
movq %rdx, (%rdi)
movl %ecx, 0x8(%rdi)
movq %r14, 0x18(%rdi)
movl (%rsi), %eax
movl %eax, 0x20(%rdi)
leaq 0x69e2a(%rip), %rdx     # 0x76970
pushq $-0xf
popq %rsi
pushq $0x70
popq %rcx
callq 0x43e0
testl %eax, %eax
je 0xcb8f
leaq 0x8(%rsp), %rsi
movl %eax, %edi
callq 0x9cf6
leaq 0x6a725(%rip), %rsi     # 0x7728d
leaq 0x69f7a(%rip), %rdx     # 0x76ae9
pushq $0x1
popq %rdi
movq %rax, %rcx
xorl %eax, %eax
callq 0x110c6
pushq $-0x1
popq %r12
movl %r12d, %eax
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
leaq 0x8(%rsp), %r12
pushq $0x4
popq %rsi
movq %r12, %rdi
callq 0x4380
cmpl $0x1, %eax
jne 0xcbcf
leaq 0x8(%rsp), %rdi
callq 0x44e0
testl %eax, %eax
je 0xcc3a
movl %eax, %edi
xorl %esi, %esi
callq 0x9cf6
leaq 0x6a6c7(%rip), %rsi     # 0x7728d
leaq 0x6a6d0(%rip), %rdx     # 0x7729d
jmp 0xcb6f
cmpl $-0x3, %eax
movl $0x0, %esi
cmoveq %r12, %rsi
movl %eax, %edi
callq 0x9cf6
leaq 0x6a6a4(%rip), %rsi     # 0x7728d
leaq 0x6a61f(%rip), %rdx     # 0x7720f
pushq $0x1
popq %rdi
movq %rax, %rcx
xorl %eax, %eax
callq 0x110c6
movq %r12, %rdi
callq 0x44e0
pushq $-0x1
popq %r12
testl %eax, %eax
je 0xcb80
movl %eax, %edi
xorl %esi, %esi
callq 0x9cf6
leaq 0x6a66c(%rip), %rsi     # 0x7728d
leaq 0x6a675(%rip), %rdx     # 0x7729d
pushq $0x3
popq %rdi
movq %rax, %rcx
xorl %eax, %eax
callq 0x110c6
jmp 0xcb80
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 0xcb80
leaq 0x6a621(%rip), %rsi     # 0x7728d
leaq 0x6a648(%rip), %rdx     # 0x772bb
pushq $0x1
popq %rdi
xorl %eax, %eax
callq 0x110c6
pushq $-0x2
jmp 0xcb7e