// File: /workspace/github_c_makefile_star2_O0/snej[P]zdelta/deflate.c
// Function: fill_ref_window
local void 
fill_ref_window(s, rw)
    deflate_state *s;
    int rw;
{
  uInt i;
  uInt wsize = s->w_size;
  uInt nb;


  /* zdelta: slide the window always by wsize  */
  zmemcpy((Bytef*) s->ref_window[rw], 
	  (Bytef*) (s->ref_window[rw]+wsize), 
	  (unsigned)wsize*sizeof(Bytef));
  nb = read_ref_buf(s->strm,s->ref_window[rw]+wsize, wsize, rw);
  
  /* zdelta: set the real ref_window_size      */
  s->ref_window_size[rw] = wsize+nb;
 
  /* zdelta: update reference window pointers  */
  /* if a given pointer is too far from the window, 
   * it will never be used again; stop updating it
   * TODO: needs better solution for this
   */ 
  if(s->rwptr[2*rw]  > (- ZD_UNREACHABLE)) s->rwptr[2*rw]   -=wsize;
  if(s->rwptr[2*rw+1]> (- ZD_UNREACHABLE)) s->rwptr[2*rw+1] -=wsize;
  
  /* zdelta: flush reference dictionary 	 */
  CLEAR_REF_HASH(s, rw);
  s->ref_h = s->ref_window[rw][0];
  /* zdelta: and rebuild the dictionary from the beginning
   * same speed if slided as the target trailing window
   * better compression since no hashes are lost
   */
  UPDATE_HASH(s, s->ref_h, s->ref_window[rw][1]);
  for(i = 0;i <= s->ref_window_size[rw] - MIN_MATCH; i++){
    INSERT_REF_STRING(s,i,rw);
  }
  s->stored_allowed[rw] = 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq -0x8(%rbp), %rax
movl 0x38(%rax), %eax
movl %eax, -0x14(%rbp)
movq -0x8(%rbp), %rax
movslq -0xc(%rbp), %rcx
movq 0x50(%rax,%rcx,8), %rdi
movq -0x8(%rbp), %rax
movslq -0xc(%rbp), %rcx
movq 0x50(%rax,%rcx,8), %rsi
movl -0x14(%rbp), %eax
addq %rax, %rsi
movl -0x14(%rbp), %eax
movl %eax, %edx
shlq $0x0, %rdx
callq 0x10d0
movq -0x8(%rbp), %rax
movq (%rax), %rdi
movq -0x8(%rbp), %rax
movslq -0xc(%rbp), %rcx
movq 0x50(%rax,%rcx,8), %rsi
movl -0x14(%rbp), %eax
addq %rax, %rsi
movl -0x14(%rbp), %edx
movl -0xc(%rbp), %ecx
callq 0x6720
movl %eax, -0x18(%rbp)
movl -0x14(%rbp), %eax
addl -0x18(%rbp), %eax
movl %eax, %eax
movl %eax, %edx
movq -0x8(%rbp), %rax
movslq -0xc(%rbp), %rcx
movq %rdx, 0x60(%rax,%rcx,8)
movq -0x8(%rbp), %rax
movl -0xc(%rbp), %ecx
shll %ecx
movslq %ecx, %rcx
cmpq $-0x8000, 0x1a78(%rax,%rcx,8) # imm = 0x8000
jle 0x6534
movl -0x14(%rbp), %eax
movl %eax, %esi
movq -0x8(%rbp), %rax
movl -0xc(%rbp), %ecx
shll %ecx
movslq %ecx, %rcx
movq 0x1a78(%rax,%rcx,8), %rdx
subq %rsi, %rdx
movq %rdx, 0x1a78(%rax,%rcx,8)
movq -0x8(%rbp), %rax
movl -0xc(%rbp), %ecx
shll %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
cmpq $-0x8000, 0x1a78(%rax,%rcx,8) # imm = 0x8000
jle 0x6578
movl -0x14(%rbp), %eax
movl %eax, %esi
movq -0x8(%rbp), %rax
movl -0xc(%rbp), %ecx
shll %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movq 0x1a78(%rax,%rcx,8), %rdx
subq %rsi, %rdx
movq %rdx, 0x1a78(%rax,%rcx,8)
movq -0x8(%rbp), %rax
movslq -0xc(%rbp), %rcx
movq 0x80(%rax,%rcx,8), %rax
movq -0x8(%rbp), %rcx
movl 0x90(%rcx), %ecx
subl $0x1, %ecx
movl %ecx, %ecx
movw $0x0, (%rax,%rcx,2)
movq -0x8(%rbp), %rax
movslq -0xc(%rbp), %rcx
movq 0x80(%rax,%rcx,8), %rdi
movq -0x8(%rbp), %rax
movl 0x90(%rax), %eax
subl $0x1, %eax
movl %eax, %eax
movl %eax, %edx
shlq %rdx
xorl %esi, %esi
callq 0x1080
movq -0x8(%rbp), %rax
movslq -0xc(%rbp), %rcx
movq 0x50(%rax,%rcx,8), %rax
movzbl (%rax), %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x8c(%rax)
movq -0x8(%rbp), %rax
movl 0x8c(%rax), %eax
movq -0x8(%rbp), %rcx
movl 0x9c(%rcx), %ecx
shll %cl, %eax
movl %eax, %ecx
movq -0x8(%rbp), %rax
movslq -0xc(%rbp), %rdx
movq 0x50(%rax,%rdx,8), %rax
movzbl 0x1(%rax), %eax
xorl %eax, %ecx
movq -0x8(%rbp), %rax
andl 0x98(%rax), %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x8c(%rax)
movl $0x0, -0x10(%rbp)
movl -0x10(%rbp), %eax
movq -0x8(%rbp), %rcx
movslq -0xc(%rbp), %rdx
movq 0x60(%rcx,%rdx,8), %rcx
subq $0x3, %rcx
cmpq %rcx, %rax
ja 0x66fc
movq -0x8(%rbp), %rax
movl 0x8c(%rax), %eax
movq -0x8(%rbp), %rcx
movl 0x9c(%rcx), %ecx
shll %cl, %eax
movl %eax, %ecx
movq -0x8(%rbp), %rax
movslq -0xc(%rbp), %rdx
movq 0x50(%rax,%rdx,8), %rax
movl -0x10(%rbp), %edx
addl $0x2, %edx
movl %edx, %edx
movzbl (%rax,%rdx), %eax
xorl %eax, %ecx
movq -0x8(%rbp), %rax
andl 0x98(%rax), %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x8c(%rax)
movq -0x8(%rbp), %rax
movslq -0xc(%rbp), %rcx
movq 0x80(%rax,%rcx,8), %rax
movq -0x8(%rbp), %rcx
movl 0x8c(%rcx), %ecx
movw (%rax,%rcx,2), %dx
movq -0x8(%rbp), %rax
movslq -0xc(%rbp), %rcx
movq 0x70(%rax,%rcx,8), %rax
movl -0x10(%rbp), %ecx
movzwl %cx, %ecx
movq -0x8(%rbp), %rsi
andl 0x44(%rsi), %ecx
movl %ecx, %ecx
movw %dx, (%rax,%rcx,2)
movl -0x10(%rbp), %eax
movw %ax, %dx
movq -0x8(%rbp), %rax
movslq -0xc(%rbp), %rcx
movq 0x80(%rax,%rcx,8), %rax
movq -0x8(%rbp), %rcx
movl 0x8c(%rcx), %ecx
movw %dx, (%rax,%rcx,2)
movl -0x10(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x10(%rbp)
jmp 0x6628
movq -0x8(%rbp), %rax
movslq -0xc(%rbp), %rcx
movb $0x0, 0x1aa8(%rax,%rcx)
addq $0x20, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)