// File: /workspace/github_c_makefile_star2_O3/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 0x178d
movq %rcx, %rsi
shrq $0x2, %rsi
addq $0x40, %rsi
movq %rsi, (%rbx)
leaq 0x18(%rsp), %r15
movq %rdi, 0x30(%r15)
movq %rax, 0x40(%r15)
xorl %r13d, %r13d
movq %r13, 0x38(%r15)
movl $0x1, 0x48(%r15)
movq %rdx, (%r15)
movq %r13, 0x10(%r15)
movl %ecx, 0x8(%r15)
movq %rsp, %r12
movq %r12, %rdi
callq 0x1474
movq 0x8(%r12), %rax
movq %rax, 0x18(%r15)
movq %r13, 0x28(%r15)
movl (%rbx), %eax
movl %eax, 0x20(%r15)
xorps %xmm0, %xmm0
movups %xmm0, 0x60(%r15)
movq %r13, 0x70(%r15)
leaq 0x78d6(%rip), %rdx      # 0x90bb
movq %r15, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
movl $0x90, %ecx
callq 0x2213
testl %eax, %eax
jne 0x1897
leaq 0x18(%rsp), %rdi
movl $0x4, %esi
callq 0x1f40
testl %eax, %eax
jne 0x1858
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 $0x4, %esi
callq 0x1f40
testl %eax, %eax
je 0x181a
movl %eax, %ebp
movq 0x30(%rsp), %rax
movq %rax, 0x8(%rsp)
cmpl $0x1, %ebp
jne 0x18bc
movq (%rsp), %rax
movq %rax, (%r14)
leaq 0x18(%rsp), %rdi
movq 0x28(%rdi), %rax
movq %rax, (%rbx)
callq 0x253b
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 0xc750(%rip), %rax      # 0xdff0
movq (%rax), %rdi
leaq 0x7817(%rip), %rsi      # 0x90c1
leaq 0x781e(%rip), %rdx      # 0x90cf
movl %ebp, %ecx
xorl %eax, %eax
callq 0x10d0
jmp 0x1883
movq 0xc72d(%rip), %rax      # 0xdff0
movq (%rax), %rdi
leaq 0x77f4(%rip), %rsi      # 0x90c1
leaq 0x77fb(%rip), %rdx      # 0x90cf
movl %ebp, %ecx
xorl %eax, %eax
callq 0x10d0
movq %rsp, %rdi
callq 0x1526
leaq 0x18(%rsp), %rdi
callq 0x253b
jmp 0x1883