// File: /workspace/github_c_makefile_star2_O0/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 %rbp
movq %rsp, %rbp
subq $0xc0, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movl %r8d, -0x2c(%rbp)
leaq -0xa0(%rbp), %rdi
xorl %esi, %esi
movl $0x70, %edx
callq 0x4250
movq -0x20(%rbp), %rax
movq %rax, -0xa0(%rbp)
movq -0x28(%rbp), %rax
movl %eax, -0x98(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x88(%rbp)
movq -0x18(%rbp), %rax
movq (%rax), %rax
movl %eax, -0x80(%rbp)
leaq -0xa0(%rbp), %rdi
movl $0xfffffff1, %esi       # imm = 0xFFFFFFF1
leaq 0xdc906(%rip), %rdx     # 0xeeb85
movl $0x70, %ecx
callq 0x43d0
movl %eax, -0xa4(%rbp)
cmpl $0x0, -0xa4(%rbp)
je 0x122d3
movl -0xa4(%rbp), %edi
leaq -0xa0(%rbp), %rsi
callq 0xcd40
movq %rax, %rcx
movl $0x1, %edi
leaq 0xdd1ee(%rip), %rsi     # 0xef4a7
leaq 0xdca3e(%rip), %rdx     # 0xeecfe
movb $0x0, %al
callq 0x1b030
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x1245f
leaq -0xa0(%rbp), %rdi
movl $0x4, %esi
callq 0x4370
movl %eax, -0xa4(%rbp)
cmpl $0x1, %eax
je 0x123a1
movl -0xa4(%rbp), %eax
movl %eax, -0xac(%rbp)
cmpl $-0x3, -0xa4(%rbp)
jne 0x12318
leaq -0xa0(%rbp), %rax
movq %rax, -0xb8(%rbp)
jmp 0x12323
xorl %eax, %eax
movq %rax, -0xb8(%rbp)
jmp 0x12323
movl -0xac(%rbp), %edi
movq -0xb8(%rbp), %rsi
callq 0xcd40
movq %rax, %rcx
movl $0x1, %edi
leaq 0xdd163(%rip), %rsi     # 0xef4a7
leaq 0xdd0de(%rip), %rdx     # 0xef429
movb $0x0, %al
callq 0x1b030
leaq -0xa0(%rbp), %rdi
callq 0x44c0
movl %eax, -0xa4(%rbp)
cmpl $0x0, %eax
je 0x12395
movl -0xa4(%rbp), %edi
xorl %eax, %eax
movl %eax, %esi
callq 0xcd40
movq %rax, %rcx
movl $0x3, %edi
leaq 0xdd120(%rip), %rsi     # 0xef4a7
leaq 0xdd129(%rip), %rdx     # 0xef4b7
movb $0x0, %al
callq 0x1b030
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x1245f
leaq -0xa0(%rbp), %rdi
callq 0x44c0
movl %eax, -0xa4(%rbp)
cmpl $0x0, %eax
je 0x123ed
movl -0xa4(%rbp), %edi
xorl %eax, %eax
movl %eax, %esi
callq 0xcd40
movq %rax, %rcx
movl $0x1, %edi
leaq 0xdd0d1(%rip), %rsi     # 0xef4a7
leaq 0xdd0da(%rip), %rdx     # 0xef4b7
movb $0x0, %al
callq 0x1b030
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x1245f
movq -0x18(%rbp), %rax
movq (%rax), %rcx
movl -0x80(%rbp), %eax
subq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, (%rax)
xorl %eax, %eax
movl %eax, %esi
xorl %edx, %edx
movq %rsi, %rdi
callq 0x4310
movq %rax, %rdi
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rax
movq (%rax), %rax
movl %eax, %edx
callq 0x4310
movl %eax, -0xa8(%rbp)
movl -0xa8(%rbp), %eax
cmpl -0x2c(%rbp), %eax
je 0x12458
movl $0x1, %edi
leaq 0xdd066(%rip), %rsi     # 0xef4a7
leaq 0xdd08d(%rip), %rdx     # 0xef4d5
movb $0x0, %al
callq 0x1b030
movl $0xfffffffe, -0x4(%rbp) # imm = 0xFFFFFFFE
jmp 0x1245f
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0xc0, %rsp
popq %rbp
retq
nopl (%rax,%rax)