// File: /workspace/github_c_makefile_star2_O2/snej[P]zdelta/deflate.c
// Function: zd_deflateReset
int ZEXPORT zd_deflateReset (strm)
    zd_streamp strm;
{
  deflate_state *s;
  int rw;

  if (strm == ZD_NULL || strm->state == ZD_NULL || 
      strm->zalloc == ZD_NULL || strm->zfree == ZD_NULL ||
      strm->refnum < 0 || strm->refnum > REFNUM) return ZD_STREAM_ERROR;

  strm->total_in = strm->total_out = 0;
  for(rw=0;rw<strm->refnum;++rw) strm->base_out[rw] = 0;

  strm->msg = ZD_NULL; /* use zfree if we ever allocate msg dynamically */
  strm->data_type = Z_UNKNOWN;

  s = (deflate_state *)strm->state;
  s->pending = 0;
  s->pending_out = s->pending_buf;

  if (s->noheader < 0) {
    s->noheader = 0; /* was set to -1 by deflate(..., ZD_FINISH); */
  }
  s->status = s->noheader ? BUSY_STATE : INIT_STATE;
  strm->adler = 1;
  s->last_flush = Z_NO_FLUSH;

  zd_tr_init(s);
  lm_init(s); 

  /* zdelta: initialize the reference hash tables here
   *         the first ref_window_size bytes are inserted 
   *         into the reference dictionary 
   */
  for(rw=0;rw<strm->refnum;++rw){
    if(strm->base_avail[rw] >= MIN_MATCH)  init_ref_window(s,rw);
  }

  /* zdelta: initialize the target hash table here;
   *         this will save us sliding an empty hash table!
   *         no insertions are done
   */
  
  if (strm->avail_in >= MIN_MATCH) 
    init_window(s);
  
  return ZD_OK;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
pushq $-0x2
popq %rbp
testq %rdi, %rdi
je 0x1d32
movq %rdi, %r14
movq 0x58(%rdi), %rbx
testq %rbx, %rbx
je 0x1d32
cmpq $0x0, 0x60(%r14)
je 0x1d32
cmpq $0x0, 0x68(%r14)
je 0x1d32
movl 0x48(%r14), %eax
cmpq $0x1, %rax
ja 0x1d32
andq $0x0, 0x28(%r14)
andq $0x0, 0x10(%r14)
xorl %ecx, %ecx
cmpq %rcx, %rax
je 0x1ad3
andq $0x0, 0x38(%r14,%rcx,8)
incq %rcx
jmp 0x1ac3
andq $0x0, 0x50(%r14)
movl $0x2, 0x78(%r14)
andl $0x0, 0x28(%rbx)
movq 0x10(%rbx), %rax
movq %rax, 0x20(%rbx)
cmpl $0x0, 0x2c(%rbx)
js 0x1af8
je 0x1afc
pushq $0x71
jmp 0x1afe
andl $0x0, 0x2c(%rbx)
pushq $0x2a
popq %rax
movl %eax, 0x8(%rbx)
movq $0x1, 0x80(%r14)
andl $0x0, 0x34(%rbx)
movq %rbx, %rdi
callq 0x4574
movq (%rbx), %rax
movl 0x48(%rax), %eax
movl 0x38(%rbx), %ecx
addq %rcx, %rcx
movq %rcx, 0x58(%rbx)
andq $0x0, 0xa0(%rbx)
andl $0x0, 0xbc(%rbx)
movl $0x2, 0xa8(%rbx)
andq $0x0, 0xb0(%rbx)
andl $0x0, 0x88(%rbx)
andl $0x0, 0xe8(%rbx)
movabsq $0x200000000, %rdx      # imm = 0x200000000
movq %rdx, 0xe0(%rbx)
movslq 0xf4(%rbx), %rdx
shlq $0x4, %rdx
leaq 0xc1b5(%rip), %rsi      # 0xdd30
movzwl 0x2(%rdx,%rsi), %edi
movl %edi, 0xf0(%rbx)
movzwl (%rdx,%rsi), %edi
movl %edi, 0xfc(%rbx)
movzwl 0x6(%rdx,%rsi), %edi
movl %edi, 0xec(%rbx)
movzwl 0x4(%rdx,%rsi), %edx
movl %edx, 0x100(%rbx)
leal (%rax,%rax), %edx
xorl %esi, %esi
testl %edx, %edx
cmovlel %esi, %edx
jmp 0x1bd7
andq $0x0, 0x1a90(%rbx,%rsi,8)
andq $0x0, 0x1a78(%rbx,%rsi,8)
andl $0x0, 0x1aa0(%rbx,%rsi,4)
andl $0x0, 0x1a88(%rbx,%rsi,4)
incq %rsi
cmpq %rsi, %rdx
jne 0x1bb2
xorl %edx, %edx
testl %eax, %eax
cmovlel %edx, %eax
cmpq %rdx, %rax
je 0x1bfa
movb $0x1, 0x1aa8(%rbx,%rdx)
movq %rcx, 0x60(%rbx,%rdx,8)
incq %rdx
jmp 0x1be3
xorl %r15d, %r15d
movslq 0x48(%r14), %rax
cmpq %rax, %r15
jge 0x1cde
cmpq $0x3, 0x40(%r14,%r15,8)
jb 0x1cd6
movq (%rbx), %rdi
movq 0x50(%rbx,%r15,8), %rsi
movl 0x60(%rbx,%r15,8), %edx
movl %r15d, %ecx
callq 0x3fed
movl %eax, %r12d
movl %eax, %eax
movq %rax, 0x60(%rbx,%r15,8)
movq 0x80(%rbx,%r15,8), %rdi
movl 0x90(%rbx), %edx
decl %edx
andw $0x0, (%rdi,%rdx,2)
addq %rdx, %rdx
xorl %esi, %esi
callq 0x1090
movq 0x50(%rbx,%r15,8), %rax
movzbl (%rax), %esi
movl %esi, 0x8c(%rbx)
movl 0x98(%rbx), %edx
movl 0x9c(%rbx), %ecx
shll %cl, %esi
movzbl 0x1(%rax), %r10d
xorl %esi, %r10d
andl %edx, %r10d
movl %r10d, 0x8c(%rbx)
movq 0x70(%rbx,%r15,8), %rsi
movq 0x80(%rbx,%r15,8), %rdi
movzwl 0x44(%rbx), %r8d
addl $-0x2, %r12d
xorl %r9d, %r9d
cmpq %r9, %r12
je 0x1cd6
shll %cl, %r10d
leal 0x2(%r9), %r11d
movzbl (%rax,%r11), %r11d
xorl %r10d, %r11d
andl %edx, %r11d
movl %r11d, 0x8c(%rbx)
movzwl (%rdi,%r11,2), %r10d
movl %r8d, %r13d
andl %r9d, %r13d
movw %r10w, (%rsi,%r13,2)
movw %r9w, (%rdi,%r11,2)
incq %r9
movl %r11d, %r10d
jmp 0x1c9b
incq %r15
jmp 0x1bfd
xorl %ebp, %ebp
cmpl $0x3, 0x8(%r14)
jb 0x1d32
movq (%rbx), %rdi
movq 0x48(%rbx), %rsi
movl 0x58(%rbx), %edx
callq 0x364a
movl %eax, 0xbc(%rbx)
cmpl $0x3, %eax
jb 0x1d32
movq 0x48(%rbx), %rax
movl 0xb4(%rbx), %edx
movzbl (%rax,%rdx), %esi
movl %esi, 0x88(%rbx)
movb 0x9c(%rbx), %cl
shll %cl, %esi
leal 0x1(%rdx), %ecx
movzbl (%rax,%rcx), %eax
xorl %esi, %eax
andl 0x98(%rbx), %eax
movl %eax, 0x88(%rbx)
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq