// File: /workspace/github_c_makefile_star2_O3/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
movl $0xfffffffe, %ebp       # imm = 0xFFFFFFFE
testq %rdi, %rdi
je 0x1e52
movq %rdi, %r14
movq 0x58(%rdi), %rbx
testq %rbx, %rbx
je 0x1e52
cmpq $0x0, 0x60(%r14)
je 0x1e52
cmpq $0x0, 0x68(%r14)
je 0x1e52
movl 0x48(%r14), %eax
cmpl $0x1, %eax
ja 0x1e52
xorl %ecx, %ecx
movq %rcx, 0x28(%r14)
movq %rcx, 0x10(%r14)
cmpl $0x1, %eax
jne 0x1ba7
movq $0x0, 0x38(%r14)
movq $0x0, 0x50(%r14)
movl $0x2, 0x78(%r14)
movl $0x0, 0x28(%rbx)
movq 0x10(%rbx), %rax
movq %rax, 0x20(%rbx)
cmpl $0x0, 0x2c(%rbx)
js 0x1bd5
movl $0x71, %eax
jne 0x1be1
jmp 0x1bdc
movl $0x0, 0x2c(%rbx)
movl $0x2a, %eax
movl %eax, 0x8(%rbx)
movq $0x1, 0x80(%r14)
xorl %r15d, %r15d
movl %r15d, 0x34(%rbx)
movq %rbx, %rdi
callq 0x46cc
movq (%rbx), %rax
movslq 0x48(%rax), %rax
movl 0x38(%rbx), %ecx
addq %rcx, %rcx
movslq 0xf4(%rbx), %rdx
shlq $0x4, %rdx
movq %rcx, 0x58(%rbx)
movq %r15, 0xa0(%rbx)
movl %r15d, 0xbc(%rbx)
movl $0x2, 0xa8(%rbx)
movq %r15, 0xb0(%rbx)
movl %r15d, 0x88(%rbx)
movl %r15d, 0xe8(%rbx)
movabsq $0x200000000, %rsi      # imm = 0x200000000
movq %rsi, 0xe0(%rbx)
leaq 0xc0d1(%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)
testq %rax, %rax
jle 0x1cde
leal (%rax,%rax), %esi
cmpl $0x2, %esi
movl $0x1, %edx
cmovgel %esi, %edx
xorl %esi, %esi
movq %r15, 0x1a90(%rbx,%rsi,8)
movq %r15, 0x1a78(%rbx,%rsi,8)
movl %r15d, 0x1aa0(%rbx,%rsi,4)
movl %r15d, 0x1a88(%rbx,%rsi,4)
incq %rsi
cmpq %rsi, %rdx
jne 0x1c9f
xorl %edx, %edx
movb $0x1, 0x1aa8(%rbx,%rdx)
movq %rcx, 0x60(%rbx,%rdx,8)
incq %rdx
cmpq %rdx, %rax
jne 0x1cc9
movl 0x48(%r14), %eax
testl %eax, %eax
jle 0x1dfe
xorl %r12d, %r12d
cmpq $0x3, 0x40(%r14,%r12,8)
jb 0x1def
movq (%rbx), %rbp
movl 0x60(%rbx,%r12,8), %r13d
movq 0x40(%rbp,%r12,8), %rax
cmpl %r13d, %eax
cmovbl %eax, %r13d
testl %r13d, %r13d
je 0x1d3b
movq 0x50(%rbx,%r12,8), %rdi
movl %r13d, %r15d
subq %r15, %rax
movq %rax, 0x40(%rbp,%r12,8)
movq 0x30(%rbp,%r12,8), %rsi
movq %r15, %rdx
callq 0x10f0
addq %r15, 0x30(%rbp,%r12,8)
addq %r15, 0x38(%rbp,%r12,8)
jmp 0x1d3e
xorl %r15d, %r15d
movq %r15, 0x60(%rbx,%r12,8)
movq 0x80(%rbx,%r12,8), %rdi
movl 0x90(%rbx), %edx
decl %edx
movw $0x0, (%rdi,%rdx,2)
addq %rdx, %rdx
xorl %esi, %esi
callq 0x1090
movq 0x50(%rbx,%r12,8), %rax
movzbl (%rax), %esi
movl %esi, 0x8c(%rbx)
movl 0x98(%rbx), %edx
movl 0x9c(%rbx), %ecx
shll %cl, %esi
movzbl 0x1(%rax), %r9d
xorl %esi, %r9d
andl %edx, %r9d
movl %r9d, 0x8c(%rbx)
movq 0x70(%rbx,%r12,8), %rsi
movq 0x80(%rbx,%r12,8), %rdi
movzwl 0x44(%rbx), %r8d
leal -0x2(%r13), %r10d
cmpl $0x1, %r10d
adcl $-0x2, %r13d
xorl %r10d, %r10d
shll %cl, %r9d
leal 0x2(%r10), %r11d
movzbl (%rax,%r11), %r11d
xorl %r9d, %r11d
andl %edx, %r11d
movl %r11d, 0x8c(%rbx)
movzwl (%rdi,%r11,2), %r9d
movl %r8d, %r15d
andl %r10d, %r15d
movw %r9w, (%rsi,%r15,2)
movw %r10w, (%rdi,%r11,2)
incq %r10
movl %r11d, %r9d
cmpq %r10, %r13
jne 0x1db2
movl 0x48(%r14), %eax
incq %r12
movslq %eax, %rcx
cmpq %rcx, %r12
jl 0x1ced
xorl %ebp, %ebp
cmpl $0x3, 0x8(%r14)
jb 0x1e52
movq (%rbx), %rdi
movq 0x48(%rbx), %rsi
movl 0x58(%rbx), %edx
callq 0x3793
movl %eax, 0xbc(%rbx)
cmpl $0x3, %eax
jb 0x1e52
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