// File: /workspace/github_c_makefile_star2_O0/samtools[P]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) {
        hts_log_error("Call to zlib inflateInit failed: %s", 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) {
            hts_log_error("Call to zlib inflate failed: %s", s.msg);
            free(data);
            inflateEnd(&s);
            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);
            inflateEnd(&s);
            return NULL;
        }
        s.avail_out += alloc_inc;
    }
    inflateEnd(&s);

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

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xb0, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq $0x0, -0x98(%rbp)
movl $0x0, -0x9c(%rbp)
movaps 0x80dcd(%rip), %xmm1    # 0xef900
movq -0x18(%rbp), %xmm0
punpckldq %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
movapd 0x80dcc(%rip), %xmm1    # 0xef910
subpd %xmm1, %xmm0
movaps %xmm0, %xmm1
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
addsd %xmm1, %xmm0
movsd 0x869d5(%rip), %xmm1    # 0xf5530
mulsd %xmm1, %xmm0
movsd 0x7fe79(%rip), %xmm1    # 0xee9e0
addsd %xmm1, %xmm0
cvttsd2si %xmm0, %eax
movl %eax, -0x9c(%rbp)
movslq %eax, %rdi
callq 0x4650
movq %rax, -0x98(%rbp)
cmpq $0x0, -0x98(%rbp)
jne 0x6eb9b
movq $0x0, -0x8(%rbp)
jmp 0x6edd1
movq $0x0, -0x50(%rbp)
movq $0x0, -0x48(%rbp)
movq $0x0, -0x40(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x90(%rbp)
movq -0x18(%rbp), %rax
movl %eax, -0x88(%rbp)
movq $0x0, -0x80(%rbp)
movq -0x98(%rbp), %rax
movq %rax, -0x78(%rbp)
movl -0x9c(%rbp), %eax
movl %eax, -0x70(%rbp)
movq $0x0, -0x68(%rbp)
leaq -0x90(%rbp), %rdi
movl $0x2f, %esi
leaq 0x7ff86(%rip), %rdx     # 0xeeb85
movl $0x70, %ecx
callq 0x43d0
movl %eax, -0xa0(%rbp)
cmpl $0x0, -0xa0(%rbp)
je 0x6ec4f
movq -0x60(%rbp), %rcx
movl $0x1, %edi
leaq 0x86960(%rip), %rsi     # 0xf5588
leaq 0x8696a(%rip), %rdx     # 0xf5599
movb $0x0, %al
callq 0x1b030
movq -0x98(%rbp), %rdi
callq 0x45a0
movq $0x0, -0x8(%rbp)
jmp 0x6edd1
jmp 0x6ec51
cmpl $0x0, -0x88(%rbp)
je 0x6edaf
movq -0x98(%rbp), %rax
addq -0x68(%rbp), %rax
movq %rax, -0x78(%rbp)
leaq -0x90(%rbp), %rdi
xorl %esi, %esi
callq 0x4370
movl %eax, -0xa0(%rbp)
cmpl $0x1, -0xa0(%rbp)
jne 0x6ec8f
jmp 0x6edaf
cmpl $0x0, -0xa0(%rbp)
je 0x6ecdb
movq -0x60(%rbp), %rcx
movl $0x1, %edi
leaq 0x868e0(%rip), %rsi     # 0xf5588
leaq 0x8690e(%rip), %rdx     # 0xf55bd
movb $0x0, %al
callq 0x1b030
movq -0x98(%rbp), %rdi
callq 0x45a0
leaq -0x90(%rbp), %rdi
callq 0x44c0
movq $0x0, -0x8(%rbp)
jmp 0x6edd1
movl -0x88(%rbp), %eax
cvtsi2sd %rax, %xmm0
movq -0x80(%rbp), %xmm1
movaps 0x80c0e(%rip), %xmm3    # 0xef900
punpckldq %xmm3, %xmm1    # xmm1 = xmm1[0],xmm3[0],xmm1[1],xmm3[1]
movapd 0x80c12(%rip), %xmm2    # 0xef910
subpd %xmm2, %xmm1
movaps %xmm1, %xmm4
unpckhpd %xmm1, %xmm1            # xmm1 = xmm1[1,1]
addsd %xmm4, %xmm1
divsd %xmm1, %xmm0
movq -0x68(%rbp), %xmm1
punpckldq %xmm3, %xmm1    # xmm1 = xmm1[0],xmm3[0],xmm1[1],xmm3[1]
subpd %xmm2, %xmm1
movaps %xmm1, %xmm2
unpckhpd %xmm1, %xmm1            # xmm1 = xmm1[1,1]
addsd %xmm2, %xmm1
mulsd %xmm1, %xmm0
movsd 0x7fcab(%rip), %xmm1    # 0xee9e0
addsd %xmm1, %xmm0
cvttsd2si %xmm0, %eax
movl %eax, -0xac(%rbp)
movq -0x98(%rbp), %rdi
movq %rdi, -0xa8(%rbp)
movl -0xac(%rbp), %eax
addl -0x9c(%rbp), %eax
movl %eax, -0x9c(%rbp)
movslq %eax, %rsi
callq 0x4820
movq %rax, -0x98(%rbp)
cmpq $0x0, -0x98(%rbp)
jne 0x6ed9e
movq -0xa8(%rbp), %rdi
callq 0x45a0
leaq -0x90(%rbp), %rdi
callq 0x44c0
movq $0x0, -0x8(%rbp)
jmp 0x6edd1
movl -0xac(%rbp), %eax
addl -0x70(%rbp), %eax
movl %eax, -0x70(%rbp)
jmp 0x6ec51
leaq -0x90(%rbp), %rdi
callq 0x44c0
movq -0x68(%rbp), %rcx
movq -0x20(%rbp), %rax
movq %rcx, (%rax)
movq -0x98(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0xb0, %rsp
popq %rbp
retq
nop