// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0xf0, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq %r8, -0x30(%rbp)
movq %r9, -0x38(%rbp)
movl $0x2, -0x40(%rbp)
movq -0x28(%rbp), %rax
cmpq $0x0, (%rax)
jne 0x1d36
movq -0x18(%rbp), %rcx
shlq %rcx
addq $0x40, %rcx
movq -0x28(%rbp), %rax
movq %rcx, (%rax)
movq -0x10(%rbp), %rax
movq %rax, -0xb8(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0xa8(%rbp)
movl $0x1, -0xa0(%rbp)
movq -0x28(%rbp), %rax
movq (%rax), %rsi
leaq -0x58(%rbp), %rdi
callq 0x1490
movq -0x28(%rbp), %rax
movq (%rax), %rax
movl %eax, -0xc8(%rbp)
movq -0x58(%rbp), %rax
movq %rax, -0xd0(%rbp)
movq $0x0, -0xc0(%rbp)
movq -0x38(%rbp), %rax
movl %eax, -0xe0(%rbp)
movq -0x30(%rbp), %rax
movq %rax, -0xe8(%rbp)
movq $0x0, -0xd8(%rbp)
movq $0x0, -0x88(%rbp)
movq $0x0, -0x80(%rbp)
movq $0x0, -0x78(%rbp)
leaq -0xe8(%rbp), %rdi
leaq 0xe2f9(%rip), %rsi      # 0x100cb
movl $0x90, %edx
callq 0x6af0
movl %eax, -0x3c(%rbp)
cmpl $0x0, -0x3c(%rbp)
je 0x1e12
movq 0x1220c(%rip), %rax     # 0x13ff8
movq (%rax), %rdi
movl -0x3c(%rbp), %ecx
leaq 0xe2d8(%rip), %rsi      # 0x100d1
leaq 0xe2eb(%rip), %rdx      # 0x100eb
movb $0x0, %al
callq 0x10b0
movl -0x3c(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x1ee0
jmp 0x1e14
movl -0x40(%rbp), %esi
leaq -0xe8(%rbp), %rdi
callq 0x6b20
movl %eax, -0x3c(%rbp)
cmpl $0x0, %eax
jne 0x1e61
movq -0xd0(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x48(%rbp), %rsi
leaq -0x58(%rbp), %rdi
callq 0x1520
movq -0x50(%rbp), %rax
movq %rax, -0xd0(%rbp)
movq -0x48(%rbp), %rax
subq -0xc0(%rbp), %rax
movl %eax, -0xc8(%rbp)
jmp 0x1e14
movq -0xd0(%rbp), %rax
movq %rax, -0x50(%rbp)
cmpl $0x1, -0x3c(%rbp)
je 0x1eb8
leaq -0x58(%rbp), %rdi
callq 0x15e0
cmpq $0x0, -0x98(%rbp)
je 0x1ea4
movq 0x1216c(%rip), %rax     # 0x13ff8
movq (%rax), %rdi
movq -0x98(%rbp), %rdx
leaq 0xe25d(%rip), %rsi      # 0x100fa
movb $0x0, %al
callq 0x10b0
leaq -0xe8(%rbp), %rdi
callq 0x6890
movl -0x3c(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x1ee0
movq -0x58(%rbp), %rcx
movq -0x20(%rbp), %rax
movq %rcx, (%rax)
movq -0xc0(%rbp), %rcx
movq -0x28(%rbp), %rax
movq %rcx, (%rax)
leaq -0xe8(%rbp), %rdi
callq 0x6890
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0xf0, %rsp
popq %rbp
retq
nopl (%rax)