// File: /workspace/github_c_makefile_star2_O0/icebert[P]pblat/htslib/bgzf.c
// Function: bgzf_compress
int bgzf_compress(void *_dst, size_t *dlen, const void *src, size_t slen, int level)
{
    uint32_t crc;
    z_stream zs;
    uint8_t *dst = (uint8_t*)_dst;

    // compress the body
    zs.zalloc = NULL; zs.zfree = NULL;
    zs.next_in  = (Bytef*)src;
    zs.avail_in = slen;
    zs.next_out = dst + BLOCK_HEADER_LENGTH;
    zs.avail_out = *dlen - BLOCK_HEADER_LENGTH - BLOCK_FOOTER_LENGTH;
    if (deflateInit2(&zs, level, Z_DEFLATED, -15, 8, Z_DEFAULT_STRATEGY) != Z_OK) return -1; // -15 to disable zlib header/footer
    if (deflate(&zs, Z_FINISH) != Z_STREAM_END) return -1;
    if (deflateEnd(&zs) != Z_OK) return -1;
    *dlen = zs.total_out + BLOCK_HEADER_LENGTH + BLOCK_FOOTER_LENGTH;
    // write the header
    memcpy(dst, g_magic, BLOCK_HEADER_LENGTH); // the last two bytes are a place holder for the length of the block
    packInt16(&dst[16], *dlen - 1); // write the compressed length; -1 to fit 2 bytes
    // write the footer
    crc = crc32(crc32(0L, NULL, 0L), (Bytef*)src, slen);
    packInt32((uint8_t*)&dst[*dlen - 8], crc);
    packInt32((uint8_t*)&dst[*dlen - 4], slen);
    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)
movq -0x10(%rbp), %rax
movq %rax, -0xa8(%rbp)
movq $0x0, -0x60(%rbp)
movq $0x0, -0x58(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0xa0(%rbp)
movq -0x28(%rbp), %rax
movl %eax, -0x98(%rbp)
movq -0xa8(%rbp), %rax
addq $0x12, %rax
movq %rax, -0x88(%rbp)
movq -0x18(%rbp), %rax
movq (%rax), %rax
subq $0x12, %rax
subq $0x8, %rax
movl %eax, -0x80(%rbp)
movl -0x2c(%rbp), %esi
leaq -0xa0(%rbp), %rdi
movl $0x8, %r8d
movl $0xfffffff1, %ecx       # imm = 0xFFFFFFF1
xorl %r9d, %r9d
leaq 0x46ebf(%rip), %rax     # 0xe26a1
movl %r8d, %edx
movq %rax, (%rsp)
movl $0x70, 0x8(%rsp)
callq 0x60a0
cmpl $0x0, %eax
je 0x9b807
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x9b905
leaq -0xa0(%rbp), %rdi
movl $0x4, %esi
callq 0x6300
cmpl $0x1, %eax
je 0x9b829
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x9b905
leaq -0xa0(%rbp), %rdi
callq 0x6410
cmpl $0x0, %eax
je 0x9b846
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x9b905
movq -0x78(%rbp), %rcx
addq $0x12, %rcx
addq $0x8, %rcx
movq -0x18(%rbp), %rax
movq %rcx, (%rax)
movq -0xa8(%rbp), %rax
movq 0x48479(%rip), %rcx     # 0xe3ce0
movq %rcx, (%rax)
movq 0x48477(%rip), %rcx     # 0xe3ce8
movq %rcx, 0x8(%rax)
movw 0x48474(%rip), %cx      # 0xe3cf0
movw %cx, 0x10(%rax)
movq -0xa8(%rbp), %rdi
addq $0x10, %rdi
movq -0x18(%rbp), %rax
movq (%rax), %rax
subq $0x1, %rax
movzwl %ax, %esi
callq 0x9b920
xorl %eax, %eax
movl %eax, %esi
xorl %edx, %edx
movq %rsi, %rdi
callq 0x64a0
movq %rax, %rdi
movq -0x20(%rbp), %rsi
movq -0x28(%rbp), %rax
movl %eax, %edx
callq 0x64a0
movl %eax, -0x30(%rbp)
movq -0xa8(%rbp), %rdi
movq -0x18(%rbp), %rax
movq (%rax), %rax
subq $0x8, %rax
addq %rax, %rdi
movl -0x30(%rbp), %esi
callq 0x9b950
movq -0xa8(%rbp), %rdi
movq -0x18(%rbp), %rax
movq (%rax), %rax
subq $0x4, %rax
addq %rax, %rdi
movq -0x28(%rbp), %rax
movl %eax, %esi
callq 0x9b950
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0xc0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)