// File: /workspace/github_c_makefile_star2_O2/icebert[P]pblat/htslib/cram/cram_io.c
// Function: zlib_mem_inflate
char *zlib_mem_inflate(char *cdata, size_t csize, size_t *size) {
    z_stream s;
    unsigned char *data = NULL; /* Uncompressed output */
    int data_alloc = 0;
    int err;

    /* Starting point at uncompressed size, and scale after that */
    data = malloc(data_alloc = csize*1.2+100);
    if (!data)
	return NULL;

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

    //err = inflateInit(&s);
    err = inflateInit2(&s, 15 + 32);
    if (err != Z_OK) {
	fprintf(stderr, "zlib inflateInit error: %s\n", s.msg);
	free(data);
	return NULL;
    }

    /* Decode to 'data' array */
    for (;s.avail_in;) {
	unsigned char *data_tmp;
	int alloc_inc;

	s.next_out = &data[s.total_out];
	err = inflate(&s, Z_NO_FLUSH);
	if (err == Z_STREAM_END)
	    break;

	if (err != Z_OK) {
	    fprintf(stderr, "zlib inflate error: %s\n", s.msg);
	    if (data)
		free(data);
	    return NULL;
	}

	/* More to come, so realloc based on growth so far */
	alloc_inc = (double)s.avail_in/s.total_in * s.total_out + 100;
	data = realloc((data_tmp = data), data_alloc += alloc_inc);
	if (!data) {
	    free(data_tmp);
	    return NULL;
	}
	s.avail_out += alloc_inc;
    }
    inflateEnd(&s);

    *size = s.total_out;
    return (char *)data;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movq %rsi, %r15
movq %rsi, %xmm0
punpckldq 0x2d63f(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0x2d647(%rip), %xmm0    # 0x7b020
movq %rdx, %r14
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
mulsd 0x3a1e0(%rip), %xmm1    # 0x87bd0
addsd 0x2f7c8(%rip), %xmm1    # 0x7d1c0
movq %rdi, %r12
cvttsd2si %xmm1, %ebp
movslq %ebp, %rdi
callq 0x69d0
testq %rax, %rax
je 0x4db62
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
andq $0x0, 0x50(%rdi)
xorpd %xmm0, %xmm0
movupd %xmm0, 0x40(%rdi)
movq %r12, (%rdi)
movl %r15d, 0x8(%rdi)
andq $0x0, 0x10(%rdi)
movq %rax, 0x18(%rdi)
movl %ebp, 0x20(%rdi)
andq $0x0, 0x28(%rdi)
leaq 0x39d45(%rip), %rdx     # 0x8778a
pushq $0x2f
popq %rsi
pushq $0x70
popq %rcx
callq 0x65d0
testl %eax, %eax
jne 0x4db25
leaq 0x8(%rsp), %r15
movl 0x8(%r15), %r12d
testl %r12d, %r12d
je 0x4db0f
movq 0x30(%rsp), %rax
addq %rbx, %rax
movq %rax, 0x20(%rsp)
movq %r15, %rdi
xorl %esi, %esi
callq 0x6540
testl %eax, %eax
jne 0x4db0a
movl 0x10(%rsp), %r12d
cvtsi2sd %r12, %xmm0
movsd 0x18(%rsp), %xmm1
movsd 0x2d56f(%rip), %xmm3    # 0x7b010
unpcklps %xmm3, %xmm1            # xmm1 = xmm1[0],xmm3[0],xmm1[1],xmm3[1]
movapd 0x2d574(%rip), %xmm4    # 0x7b020
subpd %xmm4, %xmm1
movapd %xmm1, %xmm2
unpckhpd %xmm1, %xmm2            # xmm2 = xmm2[1],xmm1[1]
addsd %xmm1, %xmm2
divsd %xmm2, %xmm0
movsd 0x30(%rsp), %xmm1
unpcklps %xmm3, %xmm1            # xmm1 = xmm1[0],xmm3[0],xmm1[1],xmm3[1]
subpd %xmm4, %xmm1
movapd %xmm1, %xmm2
unpckhpd %xmm1, %xmm2            # xmm2 = xmm2[1],xmm1[1]
addsd %xmm1, %xmm2
mulsd %xmm0, %xmm2
addsd 0x2f6db(%rip), %xmm2    # 0x7d1c0
cvttsd2si %xmm2, %r13d
addl %r13d, %ebp
movslq %ebp, %rsi
movq %rbx, %rdi
callq 0x6c80
testq %rax, %rax
je 0x4db5a
addl %r13d, 0x28(%rsp)
movq %rax, %rbx
jmp 0x4da61
cmpl $0x1, %eax
jne 0x4db3d
leaq 0x8(%rsp), %r15
movq %r15, %rdi
callq 0x6730
movq 0x28(%r15), %rax
movq %rax, (%r14)
jmp 0x4db64
movq 0x654ac(%rip), %rax     # 0xb2fd8
movq (%rax), %rdi
movq 0x38(%rsp), %rdx
leaq 0x3a0cd(%rip), %rsi     # 0x87c08
jmp 0x4db53
movq 0x65494(%rip), %rax     # 0xb2fd8
movq (%rax), %rdi
movq 0x38(%rsp), %rdx
leaq 0x3a0d1(%rip), %rsi     # 0x87c24
xorl %eax, %eax
callq 0x6a90
movq %rbx, %rdi
callq 0x68a0
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq