// File: /workspace/github_c_makefile_star2_O0/icebert[P]pblat/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) {
	fprintf(stderr, "zlib deflateInit2 error: %s\n", 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) {
	    fprintf(stderr, "Deflate produced larger output than expected. Abort\n"); 
	    return NULL;
	}
	err = deflate(&s, Z_NO_FLUSH);
	cdata_pos = cdata_alloc - s.avail_out;
	if (err != Z_OK) {
	    fprintf(stderr, "zlib deflate error: %s\n", s.msg);
	    break;
	}
    }
    if (deflate(&s, Z_FINISH) != Z_STREAM_END) {
	fprintf(stderr, "zlib deflate error: %s\n", s.msg);
    }
    *cdata_size = s.total_out;

    if (deflateEnd(&s) != Z_OK) {
	fprintf(stderr, "zlib deflate error: %s\n", 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 0x4a3ec(%rip), %xmm1    # 0xd6020
movq -0x18(%rbp), %xmm0
punpckldq %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
movapd 0x4a3eb(%rip), %xmm1    # 0xd6030
subpd %xmm1, %xmm0
movaps %xmm0, %xmm1
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
addsd %xmm1, %xmm0
movsd 0x50f14(%rip), %xmm1    # 0xdcb70
mulsd %xmm1, %xmm0
movsd 0x4c4b0(%rip), %xmm1    # 0xd8118
addsd %xmm1, %xmm0
cvttsd2si %xmm0, %eax
movl %eax, -0xa4(%rbp)
movslq %eax, %rdi
callq 0x69c0
movq %rax, -0xa0(%rbp)
cmpq $0x0, -0xa0(%rbp)
jne 0x8bc9c
movq $0x0, -0x8(%rbp)
jmp 0x8be9c
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 0x5697b(%rip), %rax     # 0xe26a1
movq %rax, (%rsp)
movl $0x70, 0x8(%rsp)
callq 0x60a0
movl %eax, -0xac(%rbp)
cmpl $0x0, -0xac(%rbp)
je 0x8bd6f
movq 0x79283(%rip), %rax     # 0x104fd0
movq (%rax), %rdi
movq -0x68(%rbp), %rdx
leaq 0x572d1(%rip), %rsi     # 0xe302c
movb $0x0, %al
callq 0x6a80
movq $0x0, -0x8(%rbp)
jmp 0x8be9c
jmp 0x8bd71
cmpl $0x0, -0x90(%rbp)
je 0x8be27
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 0x8bdd8
movq 0x79216(%rip), %rax     # 0x104fd0
movq (%rax), %rdi
leaq 0x57285(%rip), %rsi     # 0xe3049
movb $0x0, %al
callq 0x6a80
movq $0x0, -0x8(%rbp)
jmp 0x8be9c
leaq -0x98(%rbp), %rdi
xorl %esi, %esi
callq 0x6300
movl %eax, -0xac(%rbp)
movl -0xa4(%rbp), %eax
subl -0x78(%rbp), %eax
movl %eax, -0xa8(%rbp)
cmpl $0x0, -0xac(%rbp)
je 0x8be22
movq 0x791c5(%rip), %rax     # 0x104fd0
movq (%rax), %rdi
movq -0x68(%rbp), %rdx
leaq 0x57265(%rip), %rsi     # 0xe307e
movb $0x0, %al
callq 0x6a80
jmp 0x8be27
jmp 0x8bd71
leaq -0x98(%rbp), %rdi
movl $0x4, %esi
callq 0x6300
cmpl $0x1, %eax
je 0x8be59
movq 0x7918c(%rip), %rax     # 0x104fd0
movq (%rax), %rdi
movq -0x68(%rbp), %rdx
leaq 0x5722c(%rip), %rsi     # 0xe307e
movb $0x0, %al
callq 0x6a80
movq -0x70(%rbp), %rcx
movq -0x20(%rbp), %rax
movq %rcx, (%rax)
leaq -0x98(%rbp), %rdi
callq 0x6410
cmpl $0x0, %eax
je 0x8be91
movq 0x79154(%rip), %rax     # 0x104fd0
movq (%rax), %rdi
movq -0x68(%rbp), %rdx
leaq 0x571f4(%rip), %rsi     # 0xe307e
movb $0x0, %al
callq 0x6a80
movq -0xa0(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0xc0, %rsp
popq %rbp
retq
nopl (%rax)