// File: /workspace/github_c_makefile_star2_O1/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
cmpq $0x0, (%rcx)
jne 0x19d4
leaq 0x40(,%rsi,2), %rax
movq %rax, (%rbx)
leaq 0x18(%rsp), %r13
movq %rdi, 0x30(%r13)
movq %rsi, 0x40(%r13)
movl $0x1, 0x48(%r13)
movq (%rbx), %rsi
movq %rsp, %rbp
movq %rbp, %rdi
callq 0x1474
movl (%rbx), %eax
movl %eax, 0x20(%r13)
movq (%rbp), %rax
movq %rax, 0x18(%r13)
xorl %eax, %eax
movq %rax, 0x28(%r13)
movl %r12d, 0x8(%r13)
movq %r15, (%r13)
movq %rax, 0x10(%r13)
movq %rax, 0x70(%r13)
xorps %xmm0, %xmm0
movups %xmm0, 0x60(%r13)
leaq 0x7691(%rip), %rsi      # 0x90bb
movq %r13, %rdi
movl $0x90, %edx
callq 0x43af
testl %eax, %eax
jne 0x1af5
leaq 0x18(%rsp), %rdi
movl $0x2, %esi
callq 0x43be
testl %eax, %eax
jne 0x1a98
movq %rsp, %r15
leaq 0x18(%rsp), %r12
movq 0x30(%rsp), %rax
movq %rax, 0x8(%rsp)
movq 0x10(%rsp), %rsi
movq %r15, %rdi
callq 0x14c0
movq 0x8(%rsp), %rax
movq %rax, 0x30(%rsp)
movl 0x10(%rsp), %eax
subl 0x40(%rsp), %eax
movl %eax, 0x38(%rsp)
movq %r12, %rdi
movl $0x2, %esi
callq 0x43be
testl %eax, %eax
je 0x1a5a
movl %eax, %ebp
movq 0x30(%rsp), %rax
movq %rax, 0x8(%rsp)
cmpl $0x1, %ebp
jne 0x1ac5
movq (%rsp), %rax
movq %rax, (%r14)
leaq 0x18(%rsp), %rdi
movq 0x28(%rdi), %rax
movq %rax, (%rbx)
callq 0x425d
movl %eax, %ebp
jmp 0x1ae1
movq %rsp, %rdi
callq 0x1526
movq 0x68(%rsp), %rdx
testq %rdx, %rdx
jne 0x1b1a
leaq 0x18(%rsp), %rdi
callq 0x425d
movl %ebp, %eax
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl %eax, %ebp
movq 0xc4f2(%rip), %rax      # 0xdff0
movq (%rax), %rdi
leaq 0x75b9(%rip), %rsi      # 0x90c1
leaq 0x75cc(%rip), %rdx      # 0x90db
movl %ebp, %ecx
xorl %eax, %eax
callq 0x10d0
jmp 0x1ae1
movq 0xc4cf(%rip), %rax      # 0xdff0
movq (%rax), %rdi
leaq 0x75bf(%rip), %rsi      # 0x90ea
xorl %eax, %eax
callq 0x10d0
jmp 0x1ad7