// File: /workspace/github_c_makefile_star2_O2/snej[P]zdelta/zdelta.c
// Function: zd_uncompress1
int ZEXPORT zd_uncompress1(const Bytef *ref, uLong rsize,
			   Bytef **tar,  uLongf *tsize,
			   const Bytef *delta, uLong dsize)
{
  int rval;
  int f = ZD_SYNC_FLUSH;
  zd_mem_buffer tbuf;  
  zd_stream strm;
  
  /* zdelta: tsize must not be 0; try to guess a good output buffer size */
  if(!(*tsize)) *tsize = rsize*2+64; /* *tsize should not be 0*/

  /* init io buffers */
  strm.base[0]       = (Bytef*) ref;
  strm.base_avail[0] = rsize;
  strm.refnum        = 1;

  /* allocate initial size delta buffer */
  zd_alloc(&tbuf,*tsize);
  strm.avail_out = *tsize;
  strm.next_out  = tbuf.buffer;
  strm.total_out = 0;

  strm.avail_in = dsize;
  strm.next_in  = (Bytef*) delta;
  strm.total_in = 0;

  strm.zalloc = (alloc_func)0;
  strm.zfree  = (free_func)0;
  strm.opaque = (voidpf)0;
  rval = zd_inflateInit(&strm);
  if (rval != ZD_OK)
  {
    fprintf(stderr, "%s error: %d\n", "zd_InflateInit", rval);
    return rval;
  }

  while((rval = zd_inflate(&strm,f)) == ZD_OK){
    /* add more output memory */
    /*
    if(strm.avail_out!=0){
      rval = ZD_STREAM_END;
      break;
    } 
    */
    /* set correctly the mem_buffer internal pointer */
    tbuf.pos = strm.next_out; 

    /* allocate more memory */
    zd_realloc(&tbuf,tbuf.size);      

    /* restore zstream internal pointer */
    strm.next_out = tbuf.pos; 
    strm.avail_out = tbuf.size - strm.total_out;
  }

  /* set correctly the mem_buffer internal pointer */
  tbuf.pos = strm.next_out; 

  if(rval != ZD_STREAM_END){
    zd_free(&tbuf);
    if(strm.msg!=NULL) fprintf(stderr,"%s\n",strm.msg);
    zd_inflateEnd(&strm);
    return rval;
  }

  *tar   = tbuf.buffer;
  *tsize = strm.total_out;

  /* free memory */
  return zd_inflateEnd(&strm);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xa8, %rsp
movq %r9, %r12
movq %r8, %r15
movq %rcx, %rbx
movq %rdx, %r14
movq %rsi, %rax
movq (%rcx), %rsi
testq %rsi, %rsi
jne 0x1926
leaq 0x40(,%rax,2), %rsi
movq %rsi, (%rbx)
leaq 0x18(%rsp), %r13
movq %rdi, 0x30(%r13)
movq %rax, 0x40(%r13)
movl $0x1, 0x48(%r13)
movq %rsp, %rbp
movq %rbp, %rdi
callq 0x13f0
movl (%rbx), %eax
movl %eax, 0x20(%r13)
movq (%rbp), %rax
movq %rax, 0x18(%r13)
andq $0x0, 0x28(%r13)
movl %r12d, 0x8(%r13)
movq %r15, (%r13)
andq $0x0, 0x10(%r13)
xorps %xmm0, %xmm0
movups %xmm0, 0x60(%r13)
andq $0x0, 0x70(%r13)
leaq 0x7741(%rip), %rsi      # 0x90bb
movq %r13, %rdi
movl $0x90, %edx
callq 0x41da
testl %eax, %eax
jne 0x1a2c
leaq 0x18(%rsp), %r15
pushq $0x2
popq %r12
movq %rsp, %r13
movq %r15, %rdi
movl %r12d, %esi
callq 0x41e7
movl %eax, %ebp
movq 0x30(%rsp), %rax
movq %rax, 0x8(%rsp)
testl %ebp, %ebp
jne 0x19db
movq 0x10(%rsp), %rsi
movq %r13, %rdi
callq 0x1439
movq 0x8(%rsp), %rax
movq %rax, 0x30(%rsp)
movl 0x10(%rsp), %eax
subl 0x40(%rsp), %eax
movl %eax, 0x38(%rsp)
jmp 0x199b
cmpl $0x1, %ebp
jne 0x19fc
movq (%rsp), %rax
movq %rax, (%r14)
leaq 0x18(%rsp), %rdi
movq 0x28(%rdi), %rax
movq %rax, (%rbx)
callq 0x408c
movl %eax, %ebp
jmp 0x1a18
movq %rsp, %rdi
callq 0x149f
movq 0x68(%rsp), %rdx
testq %rdx, %rdx
jne 0x1a51
leaq 0x18(%rsp), %rdi
callq 0x408c
movl %ebp, %eax
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl %eax, %ebp
movq 0xc5bb(%rip), %rax      # 0xdff0
movq (%rax), %rdi
leaq 0x7682(%rip), %rsi      # 0x90c1
leaq 0x7695(%rip), %rdx      # 0x90db
movl %ebp, %ecx
xorl %eax, %eax
callq 0x10d0
jmp 0x1a18
movq 0xc598(%rip), %rax      # 0xdff0
movq (%rax), %rdi
leaq 0x7688(%rip), %rsi      # 0x90ea
xorl %eax, %eax
callq 0x10d0
jmp 0x1a0e
nop