// File: /workspace/github_c_makefile_star2_O0/samtools[P]htslib/cram/cram_io.c
// Function: zlib_mem_deflate
static char *zlib_mem_deflate(char *data, size_t size, size_t *cdata_size,
                              int level, int strat) {
    z_stream s;
    unsigned char *cdata = NULL; /* Compressed output */
    int cdata_alloc = 0;
    int cdata_pos = 0;
    int err;

    cdata = malloc(cdata_alloc = size*1.05+100);
    if (!cdata)
        return NULL;
    cdata_pos = 0;

    /* Initialise zlib stream */
    s.zalloc = Z_NULL; /* use default allocation functions */
    s.zfree  = Z_NULL;
    s.opaque = Z_NULL;
    s.next_in  = (unsigned char *)data;
    s.avail_in = size;
    s.total_in = 0;
    s.next_out  = cdata;
    s.avail_out = cdata_alloc;
    s.total_out = 0;
    s.data_type = Z_BINARY;

    err = deflateInit2(&s, level, Z_DEFLATED, 15|16, 9, strat);
    if (err != Z_OK) {
        hts_log_error("Call to zlib deflateInit2 failed: %s", s.msg);
        return NULL;
    }

    /* Encode to 'cdata' array */
    for (;s.avail_in;) {
        s.next_out = &cdata[cdata_pos];
        s.avail_out = cdata_alloc - cdata_pos;
        if (cdata_alloc - cdata_pos <= 0) {
            hts_log_error("Deflate produced larger output than expected");
            return NULL;
        }
        err = deflate(&s, Z_NO_FLUSH);
        cdata_pos = cdata_alloc - s.avail_out;
        if (err != Z_OK) {
            hts_log_error("Call to zlib deflate failed: %s", s.msg);
            break;
        }
    }
    if (deflate(&s, Z_FINISH) != Z_STREAM_END) {
        hts_log_error("Call to zlib deflate failed: %s", s.msg);
    }
    *cdata_size = s.total_out;

    if (deflateEnd(&s) != Z_OK) {
        hts_log_error("Call to zlib deflate failed: %s", s.msg);
    }
    return (char *)cdata;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xc0, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movl %ecx, -0x24(%rbp)
movl %r8d, -0x28(%rbp)
movq $0x0, -0xa0(%rbp)
movl $0x0, -0xa4(%rbp)
movl $0x0, -0xa8(%rbp)
movaps 0x73efc(%rip), %xmm1    # 0xef900
movq -0x18(%rbp), %xmm0
punpckldq %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
movapd 0x73efb(%rip), %xmm1    # 0xef910
subpd %xmm1, %xmm0
movaps %xmm0, %xmm1
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
addsd %xmm1, %xmm0
movsd 0x79b54(%rip), %xmm1    # 0xf5580
mulsd %xmm1, %xmm0
movsd 0x72fa8(%rip), %xmm1    # 0xee9e0
addsd %xmm1, %xmm0
cvttsd2si %xmm0, %eax
movl %eax, -0xa4(%rbp)
movslq %eax, %rdi
callq 0x4650
movq %rax, -0xa0(%rbp)
cmpq $0x0, -0xa0(%rbp)
jne 0x7ba6c
movq $0x0, -0x8(%rbp)
jmp 0x7bc76
movl $0x0, -0xa8(%rbp)
movq $0x0, -0x58(%rbp)
movq $0x0, -0x50(%rbp)
movq $0x0, -0x48(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x98(%rbp)
movq -0x18(%rbp), %rax
movl %eax, -0x90(%rbp)
movq $0x0, -0x88(%rbp)
movq -0xa0(%rbp), %rax
movq %rax, -0x80(%rbp)
movl -0xa4(%rbp), %eax
movl %eax, -0x78(%rbp)
movq $0x0, -0x70(%rbp)
movl $0x0, -0x40(%rbp)
movl -0x24(%rbp), %esi
movl -0x28(%rbp), %r9d
leaq -0x98(%rbp), %rdi
movl $0x8, %edx
movl $0x1f, %ecx
movl $0x9, %r8d
leaq 0x7308f(%rip), %rax     # 0xeeb85
movq %rax, (%rsp)
movl $0x70, 0x8(%rsp)
callq 0x4080
movl %eax, -0xac(%rbp)
cmpl $0x0, -0xac(%rbp)
je 0x7bb41
movq -0x68(%rbp), %rcx
movl $0x1, %edi
leaq 0x7a197(%rip), %rsi     # 0xf5cbd
leaq 0x7a1a1(%rip), %rdx     # 0xf5cce
movb $0x0, %al
callq 0x1b030
movq $0x0, -0x8(%rbp)
jmp 0x7bc76
jmp 0x7bb43
cmpl $0x0, -0x90(%rbp)
je 0x7bbfd
movq -0xa0(%rbp), %rax
movslq -0xa8(%rbp), %rcx
addq %rcx, %rax
movq %rax, -0x80(%rbp)
movl -0xa4(%rbp), %eax
subl -0xa8(%rbp), %eax
movl %eax, -0x78(%rbp)
movl -0xa4(%rbp), %eax
subl -0xa8(%rbp), %eax
cmpl $0x0, %eax
jg 0x7bbac
movl $0x1, %edi
leaq 0x7a12c(%rip), %rsi     # 0xf5cbd
leaq 0x7a15b(%rip), %rdx     # 0xf5cf3
movb $0x0, %al
callq 0x1b030
movq $0x0, -0x8(%rbp)
jmp 0x7bc76
leaq -0x98(%rbp), %rdi
xorl %esi, %esi
callq 0x41e0
movl %eax, -0xac(%rbp)
movl -0xa4(%rbp), %eax
subl -0x78(%rbp), %eax
movl %eax, -0xa8(%rbp)
cmpl $0x0, -0xac(%rbp)
je 0x7bbf8
movq -0x68(%rbp), %rcx
movl $0x1, %edi
leaq 0x7a0d5(%rip), %rsi     # 0xf5cbd
leaq 0x7a131(%rip), %rdx     # 0xf5d20
movb $0x0, %al
callq 0x1b030
jmp 0x7bbfd
jmp 0x7bb43
leaq -0x98(%rbp), %rdi
movl $0x4, %esi
callq 0x41e0
cmpl $0x1, %eax
je 0x7bc31
movq -0x68(%rbp), %rcx
movl $0x1, %edi
leaq 0x7a09a(%rip), %rsi     # 0xf5cbd
leaq 0x7a0f6(%rip), %rdx     # 0xf5d20
movb $0x0, %al
callq 0x1b030
movq -0x70(%rbp), %rcx
movq -0x20(%rbp), %rax
movq %rcx, (%rax)
leaq -0x98(%rbp), %rdi
callq 0x4290
cmpl $0x0, %eax
je 0x7bc6b
movq -0x68(%rbp), %rcx
movl $0x1, %edi
leaq 0x7a060(%rip), %rsi     # 0xf5cbd
leaq 0x7a0bc(%rip), %rdx     # 0xf5d20
movb $0x0, %al
callq 0x1b030
movq -0xa0(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0xc0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)