// File: /workspace/github_c_makefile_star2_O2/snej[P]zdelta/zdelta.c
// Function: zd_compress1
int ZEXPORT zd_compress1(const Bytef *ref, uLong rsize,
			 const Bytef *tar, uLong tsize,
			 Bytef **delta, uLongf *dsize)
{
  int rval;
  zd_stream strm;
  zd_mem_buffer dbuf;

  /* the zstream output buffer should have size greater than zero try to
   * guess buffer size, such that no memory realocation will be needed 
   */ 
  if(!(*dsize)) *dsize = tsize/EXPECTED_RATIO + 64; /* *dsize should not be 0*/

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

  strm.next_in  = (Bytef*) tar;
  strm.total_in = 0;
  strm.avail_in = tsize;

  /* allocate the output buffer */
  zd_alloc(&dbuf, *dsize);	
  
  strm.next_out  = dbuf.pos;
  strm.total_out = 0;
  strm.avail_out = *dsize; 

  strm.zalloc = (alloc_func)0;
  strm.zfree = (free_func)0;
  strm.opaque = (voidpf)0;

  /* init huffman coder */
  rval = zd_deflateInit(&strm, ZD_DEFAULT_COMPRESSION);
  if (rval != ZD_OK)
  {
    fprintf(stderr, "%s error: %d\n", "deflateInit", rval);
    return rval;
  }

  /* compress the data */
  while((rval = zd_deflate(&strm,ZD_FINISH)) == ZD_OK){

    /* set correctly the mem_buffef internal pointer */
    dbuf.pos = strm.next_out; 

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

    /* restore zstream internal pointer */
    strm.next_out = (uch*)dbuf.pos;
    strm.avail_out = dbuf.size - strm.total_out;
  }

  /* set correcty the mem_buffer pointers */
  dbuf.pos = strm.next_out; 

  if(rval != ZD_STREAM_END){
    fprintf(stderr, "%s error: %d\n", "deflateInit", rval);
    zd_free(&dbuf);
    zd_deflateEnd(&strm);
    return rval;
  }

  *delta = dbuf.buffer;
  *dsize = (uLong) strm.total_out;

  /* release memory */
  return zd_deflateEnd(&strm);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xa8, %rsp
movq %r9, %rbx
movq %r8, %r14
movq %rsi, %rax
movq (%r9), %rsi
testq %rsi, %rsi
jne 0x16e9
movq %rcx, %rsi
shrq $0x2, %rsi
addq $0x40, %rsi
movq %rsi, (%rbx)
leaq 0x18(%rsp), %r15
movq %rdi, 0x30(%r15)
movq %rax, 0x40(%r15)
andq $0x0, 0x38(%r15)
movl $0x1, 0x48(%r15)
movq %rdx, (%r15)
andq $0x0, 0x10(%r15)
movl %ecx, 0x8(%r15)
movq %rsp, %r12
movq %r12, %rdi
callq 0x13f0
movq 0x8(%r12), %rax
movq %rax, 0x18(%r15)
andq $0x0, 0x28(%r15)
movl (%rbx), %eax
movl %eax, 0x20(%r15)
xorps %xmm0, %xmm0
movups %xmm0, 0x60(%r15)
andq $0x0, 0x70(%r15)
leaq 0x7979(%rip), %rdx      # 0x90bb
pushq $-0x1
popq %rsi
movq %r15, %rdi
movl $0x90, %ecx
callq 0x206b
testl %eax, %eax
jne 0x17d5
leaq 0x18(%rsp), %r15
pushq $0x4
popq %r12
movq %rsp, %r13
movq %r15, %rdi
movl %r12d, %esi
callq 0x1e1a
movl %eax, %ebp
movq 0x30(%rsp), %rax
movq %rax, 0x8(%rsp)
testl %ebp, %ebp
jne 0x17a2
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 0x1762
cmpl $0x1, %ebp
jne 0x17fa
movq (%rsp), %rax
movq %rax, (%r14)
leaq 0x18(%rsp), %rdi
movq 0x28(%rdi), %rax
movq %rax, (%rbx)
callq 0x23be
movl %eax, %ebp
movl %ebp, %eax
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl %eax, %ebp
movq 0xc812(%rip), %rax      # 0xdff0
movq (%rax), %rdi
leaq 0x78d9(%rip), %rsi      # 0x90c1
leaq 0x78e0(%rip), %rdx      # 0x90cf
movl %ebp, %ecx
xorl %eax, %eax
callq 0x10d0
jmp 0x17c1
movq 0xc7ef(%rip), %rax      # 0xdff0
movq (%rax), %rdi
leaq 0x78b6(%rip), %rsi      # 0x90c1
leaq 0x78bd(%rip), %rdx      # 0x90cf
movl %ebp, %ecx
xorl %eax, %eax
callq 0x10d0
movq %rsp, %rdi
callq 0x149f
leaq 0x18(%rsp), %rdi
callq 0x23be
jmp 0x17c1