// File: /workspace/github_c_makefile_star2_O0/snej[P]zdelta/deflate.c
// Function: slide_ref_window
local void slide_ref_window(deflate_state *s, pointer_history *h, 
			    int rw, int len, int match_start){
  ulg ptr_val;
  h->sum_len[rw] += len;       /* cumm. copy length */
  ptr_val = (s->ref_window_size[rw] - match_start - MAX_MATCH) * len;
  h->sum_ptr[rw] += ptr_val;              /* pointer average */
  h->len_hist[rw][h->front_ptr[rw]] = len;
  h->ptr_hist[rw][h->front_ptr[rw]] = ptr_val;
  h->front_ptr[rw] = ZD_GET_NEXT_POS(h->front_ptr[rw]);
  
  if ((h->front_ptr[rw] == h->back_ptr[rw]) || (h->sum_len[rw] > 5000)){
    h->sum_len[rw] -= h->len_hist[rw][h->back_ptr[rw]];
    h->sum_ptr[rw] -= h->ptr_hist[rw][h->back_ptr[rw]];
    h->back_ptr[rw] = ZD_GET_NEXT_POS(h->back_ptr[rw]);
  }
  
  /* check if base window should be slided*/
  if((++(h->ch_flag[rw])) == ZD_TIME_TO_CHECK){
    h->ch_flag[rw] = 0;
    h->avg_pos = h->sum_ptr[rw] / h->sum_len[rw];
    
    if((h->avg_pos < 22000) && (h->sum_len[rw] > 2000) && 
       (s->rwptr[2*rw]>(int)s->w_size ||
	s->rwptr[2*rw+1]>(int)s->w_size)) 
    { 
      fill_ref_window(s, rw);         /* slide */
      h->sum_ptr[rw]   = 0;
      h->sum_len[rw]   = 0;
      h->front_ptr[rw] = 0;
      h->back_ptr[rw]  = 0;
    }
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movl %ecx, -0x18(%rbp)
movl %r8d, -0x1c(%rbp)
movslq -0x18(%rbp), %rdx
movq -0x10(%rbp), %rax
movslq -0x14(%rbp), %rcx
addq 0x3e80(%rax,%rcx,8), %rdx
movq %rdx, 0x3e80(%rax,%rcx,8)
movq -0x8(%rbp), %rax
movslq -0x14(%rbp), %rcx
movq 0x60(%rax,%rcx,8), %rax
movslq -0x1c(%rbp), %rcx
subq %rcx, %rax
subq $0x1002, %rax           # imm = 0x1002
movslq -0x18(%rbp), %rcx
imulq %rcx, %rax
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rdx
movq -0x10(%rbp), %rax
movslq -0x14(%rbp), %rcx
addq 0x3e88(%rax,%rcx,8), %rdx
movq %rdx, 0x3e88(%rax,%rcx,8)
movslq -0x18(%rbp), %rdx
movq -0x10(%rbp), %rax
movslq -0x14(%rbp), %rcx
imulq $0x1f40, %rcx, %rcx     # imm = 0x1F40
addq %rcx, %rax
movq -0x10(%rbp), %rcx
movslq -0x14(%rbp), %rsi
movslq 0x3e98(%rcx,%rsi,4), %rcx
movq %rdx, (%rax,%rcx,8)
movq -0x28(%rbp), %rdx
movq -0x10(%rbp), %rax
addq $0x1f40, %rax           # imm = 0x1F40
movslq -0x14(%rbp), %rcx
imulq $0x1f40, %rcx, %rcx     # imm = 0x1F40
addq %rcx, %rax
movq -0x10(%rbp), %rcx
movslq -0x14(%rbp), %rsi
movslq 0x3e98(%rcx,%rsi,4), %rcx
movq %rdx, (%rax,%rcx,8)
movq -0x10(%rbp), %rcx
movslq -0x14(%rbp), %rdx
movl 0x3e98(%rcx,%rdx,4), %eax
addl $0x1, %eax
movl %eax, 0x3e98(%rcx,%rdx,4)
cmpl $0x3e8, %eax            # imm = 0x3E8
jne 0x61f9
xorl %eax, %eax
movl %eax, -0x2c(%rbp)
jmp 0x620b
movq -0x10(%rbp), %rax
movslq -0x14(%rbp), %rcx
movl 0x3e98(%rax,%rcx,4), %eax
movl %eax, -0x2c(%rbp)
movl -0x2c(%rbp), %edx
movq -0x10(%rbp), %rax
movslq -0x14(%rbp), %rcx
movl %edx, 0x3e98(%rax,%rcx,4)
movq -0x10(%rbp), %rax
movslq -0x14(%rbp), %rcx
movl 0x3e98(%rax,%rcx,4), %eax
movq -0x10(%rbp), %rcx
movslq -0x14(%rbp), %rdx
cmpl 0x3e9c(%rcx,%rdx,4), %eax
je 0x6257
movq -0x10(%rbp), %rax
movslq -0x14(%rbp), %rcx
cmpq $0x1388, 0x3e80(%rax,%rcx,8) # imm = 0x1388
jbe 0x632a
movq -0x10(%rbp), %rax
movslq -0x14(%rbp), %rcx
imulq $0x1f40, %rcx, %rcx     # imm = 0x1F40
addq %rcx, %rax
movq -0x10(%rbp), %rcx
movslq -0x14(%rbp), %rdx
movslq 0x3e9c(%rcx,%rdx,4), %rcx
movq (%rax,%rcx,8), %rsi
movq -0x10(%rbp), %rax
movslq -0x14(%rbp), %rcx
movq 0x3e80(%rax,%rcx,8), %rdx
subq %rsi, %rdx
movq %rdx, 0x3e80(%rax,%rcx,8)
movq -0x10(%rbp), %rax
addq $0x1f40, %rax           # imm = 0x1F40
movslq -0x14(%rbp), %rcx
imulq $0x1f40, %rcx, %rcx     # imm = 0x1F40
addq %rcx, %rax
movq -0x10(%rbp), %rcx
movslq -0x14(%rbp), %rdx
movslq 0x3e9c(%rcx,%rdx,4), %rcx
movq (%rax,%rcx,8), %rsi
movq -0x10(%rbp), %rax
movslq -0x14(%rbp), %rcx
movq 0x3e88(%rax,%rcx,8), %rdx
subq %rsi, %rdx
movq %rdx, 0x3e88(%rax,%rcx,8)
movq -0x10(%rbp), %rcx
movslq -0x14(%rbp), %rdx
movl 0x3e9c(%rcx,%rdx,4), %eax
addl $0x1, %eax
movl %eax, 0x3e9c(%rcx,%rdx,4)
cmpl $0x3e8, %eax            # imm = 0x3E8
jne 0x6306
xorl %eax, %eax
movl %eax, -0x30(%rbp)
jmp 0x6318
movq -0x10(%rbp), %rax
movslq -0x14(%rbp), %rcx
movl 0x3e9c(%rax,%rcx,4), %eax
movl %eax, -0x30(%rbp)
movl -0x30(%rbp), %edx
movq -0x10(%rbp), %rax
movslq -0x14(%rbp), %rcx
movl %edx, 0x3e9c(%rax,%rcx,4)
movq -0x10(%rbp), %rcx
movslq -0x14(%rbp), %rdx
movl 0x3ea0(%rcx,%rdx,4), %eax
addl $0x1, %eax
movl %eax, 0x3ea0(%rcx,%rdx,4)
cmpl $0x2, %eax
jne 0x645f
movq -0x10(%rbp), %rax
movslq -0x14(%rbp), %rcx
movl $0x0, 0x3ea0(%rax,%rcx,4)
movq -0x10(%rbp), %rax
movslq -0x14(%rbp), %rcx
movq 0x3e88(%rax,%rcx,8), %rax
movq -0x10(%rbp), %rcx
movslq -0x14(%rbp), %rsi
xorl %edx, %edx
divq 0x3e80(%rcx,%rsi,8)
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x3e90(%rax)
movq -0x10(%rbp), %rax
cmpq $0x55f0, 0x3e90(%rax) # imm = 0x55F0
jae 0x645d
movq -0x10(%rbp), %rax
movslq -0x14(%rbp), %rcx
cmpq $0x7d0, 0x3e80(%rax,%rcx,8) # imm = 0x7D0
jbe 0x645d
movq -0x8(%rbp), %rax
movl -0x14(%rbp), %ecx
shll %ecx
movslq %ecx, %rcx
movq 0x1a78(%rax,%rcx,8), %rax
movq -0x8(%rbp), %rcx
movslq 0x38(%rcx), %rcx
cmpq %rcx, %rax
jg 0x6403
movq -0x8(%rbp), %rax
movl -0x14(%rbp), %ecx
shll %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movq 0x1a78(%rax,%rcx,8), %rax
movq -0x8(%rbp), %rcx
movslq 0x38(%rcx), %rcx
cmpq %rcx, %rax
jle 0x645d
movq -0x8(%rbp), %rdi
movl -0x14(%rbp), %esi
callq 0x6470
movq -0x10(%rbp), %rax
movslq -0x14(%rbp), %rcx
movq $0x0, 0x3e88(%rax,%rcx,8)
movq -0x10(%rbp), %rax
movslq -0x14(%rbp), %rcx
movq $0x0, 0x3e80(%rax,%rcx,8)
movq -0x10(%rbp), %rax
movslq -0x14(%rbp), %rcx
movl $0x0, 0x3e98(%rax,%rcx,4)
movq -0x10(%rbp), %rax
movslq -0x14(%rbp), %rcx
movl $0x0, 0x3e9c(%rax,%rcx,4)
jmp 0x645f
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)