// File: /workspace/github_c_makefile_star2_O1/snej[P]zdelta/trees.c
// Function: compress_block
local void compress_block(s, ltree, dtree, zdtree)
    deflate_state *s;
    ct_data *ltree;  /* literal tree      */
    ct_data *dtree;  /* distance tree     */
    ct_data *zdtree; /* zdelta code tree  */
{
  unsigned dist;      /* distance of matched string */
  int lc;             /* match length or unmatched char (if dist == 0) */
  unsigned lx = 0;    /* running index in l_buf */
  unsigned code;      /* the code to send */
  int extra;          /* number of extra bits to send */

  unsigned zd;        /* zdelta pointer */
  
  if (s->last_lit != 0) do {
    zd   = s->z_buf[lx];
    dist = s->d_buf[lx];
    lc   = s->l_buf[lx++];
    if (zd == LITERAL) {
      send_code(s, dist, dtree); /* send a literal byte */
      TraceHuf( (stderr, "d:%u\n", dist) );
      Tracecv(isgraph(dist), (stderr," '%c' ", dist));
    } else {
      /* Here dist is the match distance */
      code = d_code(dist);
      Assert (code < D_CODES, "bad d_code");      
      send_code(s, LITERALS+1+code, dtree);       /* send the distance code */
      extra = extra_dbits[code];
      if (extra != 0) {
	dist -= base_dist[code];
	send_bits(s, dist, extra);          /* send the extra distance bits */
      }
      code = l_code(lc);        /* Here, lc is the match length - MIN_MATCH */
      extra = extra_lbits[code];
      if(zd == TARGET){                             /* target copy          */
	send_code(s, code, ltree);                  /* send the length code */ 
	if (extra != 0) {
	  lc -= base_length[code];
	  send_bits(s, lc, extra);            /* send the extra length bits */
	}
      }
      else{                                         /* reference copy       */
	send_code(s,code+OFFSET(zd),ltree);         /* send the length code */ 
         if (extra != 0) {
	  lc -= base_length[code];
	  send_bits(s, lc, extra);             /* send the extra length bits */
	}
	Assert ((zd & 0x1f) < Z_CODES, "bad zd_code");
	send_code(s, zd & 0x1f, zdtree);                 /* send zdelta code */
	TraceHuf( (stderr, "z:%u\n", zd) );
      }
    }

    /* Check that the overlay between pending_buf and d_buf+l_buf is ok: */
    Assert(((unsigned)s->pending) < s->lit_bufsize + 2*lx, 
	   "pendingBuf overflow");
  } while (lx < s->last_lit);

  send_code(s, END_BLOCK, dtree);
  s->last_eob_len = dtree[END_BLOCK].Len;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
cmpl $0x0, 0x1a44(%rdi)
je 0x5bad
xorl %eax, %eax
leaq 0x4513(%rip), %r14      # 0x9b4c
movq 0x1a50(%rdi), %rcx
movzbl (%rcx,%rax), %r13d
movq 0x1a48(%rdi), %rcx
movzwl (%rcx,%rax,2), %r9d
cmpq $0x40, %r13
jne 0x56db
movl %r9d, %r10d
movzwl 0x2(%rdx,%r10,4), %r9d
movl 0x1a74(%rdi), %ecx
movl $0x10, %ebp
subl %r9d, %ebp
movzwl (%rdx,%r10,4), %ebx
movl %ebx, %r10d
shll %cl, %r10d
cmpl %ebp, %ecx
jle 0x5b8a
orw 0x1a70(%rdi), %r10w
movw %r10w, 0x1a70(%rdi)
movq 0x10(%rdi), %rcx
movslq 0x28(%rdi), %r15
leal 0x1(%r15), %ebp
movl %ebp, 0x28(%rdi)
movb %r10b, (%rcx,%r15)
movb 0x1a71(%rdi), %cl
movq 0x10(%rdi), %r10
movslq 0x28(%rdi), %r15
leal 0x1(%r15), %ebp
movl %ebp, 0x28(%rdi)
movb %cl, (%r10,%r15)
movl 0x1a74(%rdi), %r10d
movb $0x10, %cl
subb %r10b, %cl
shrl %cl, %ebx
movw %bx, 0x1a70(%rdi)
jmp 0x5a4d
movq 0x1a38(%rdi), %rcx
movzwl (%rcx,%rax,2), %r12d
movl %r9d, %ecx
shrl $0x7, %ecx
addq $0x100, %rcx            # imm = 0x100
cmpl $0x100, %r9d            # imm = 0x100
cmovbq %r9, %rcx
leaq 0x3aba(%rip), %r8       # 0x91c0
movzbl (%rcx,%r8), %ebp
movzwl 0x406(%rdx,%rbp,4), %r15d
movl 0x1a74(%rdi), %ecx
movl $0x10, %r8d
subl %r15d, %r8d
movzwl 0x404(%rdx,%rbp,4), %r10d
movl %r10d, %ebx
shll %cl, %ebx
cmpl %r8d, %ecx
jle 0x5791
orw 0x1a70(%rdi), %bx
movw %bx, 0x1a70(%rdi)
movq 0x10(%rdi), %rcx
movslq 0x28(%rdi), %r8
leal 0x1(%r8), %r11d
movl %r11d, 0x28(%rdi)
movb %bl, (%rcx,%r8)
movb 0x1a71(%rdi), %cl
movq 0x10(%rdi), %r8
movslq 0x28(%rdi), %r11
leal 0x1(%r11), %ebx
movl %ebx, 0x28(%rdi)
movb %cl, (%r8,%r11)
movl 0x1a74(%rdi), %r8d
movb $0x10, %cl
subb %r8b, %cl
shrl %cl, %r10d
movw %r10w, 0x1a70(%rdi)
leal (%r15,%r8), %ecx
addl $-0x10, %ecx
jmp 0x579b
orw %bx, 0x1a70(%rdi)
addl %r15d, %ecx
movl %ecx, 0x1a74(%rdi)
cmpb $0x4, %bpl
jb 0x5849
leaq 0x456e(%rip), %r8       # 0x9d20
movl (%r8,%rbp,4), %r15d
leaq 0x4653(%rip), %r8       # 0x9e10
subl (%r8,%rbp,4), %r9d
movl $0x10, %r8d
subl %r15d, %r8d
movl %r9d, %r10d
shll %cl, %r10d
cmpl %r8d, %ecx
jle 0x5837
orw 0x1a70(%rdi), %r10w
movw %r10w, 0x1a70(%rdi)
movq 0x10(%rdi), %rcx
movslq 0x28(%rdi), %r8
leal 0x1(%r8), %r11d
movl %r11d, 0x28(%rdi)
movb %r10b, (%rcx,%r8)
movb 0x1a71(%rdi), %cl
movq 0x10(%rdi), %r8
movslq 0x28(%rdi), %r10
leal 0x1(%r10), %r11d
movl %r11d, 0x28(%rdi)
movb %cl, (%r8,%r10)
movzwl %r9w, %r8d
movl 0x1a74(%rdi), %r9d
movb $0x10, %cl
subb %r9b, %cl
shrl %cl, %r8d
movw %r8w, 0x1a70(%rdi)
addl %r9d, %r15d
addl $-0x10, %r15d
jmp 0x5842
orw %r10w, 0x1a70(%rdi)
addl %ecx, %r15d
movl %r15d, 0x1a74(%rdi)
cmpl $0xff, %r12d
ja 0x5857
movl %r12d, %ecx
jmp 0x5872
movl $0x24, %ebp
cmpl $0xfff, %r12d           # imm = 0xFFF
je 0x587e
movl %r12d, %ecx
shrl $0x6, %ecx
addq $0x100, %rcx            # imm = 0x100
leaq 0x3b47(%rip), %r8       # 0x93c0
movzbl (%rcx,%r8), %ebp
leaq 0x42db(%rip), %rcx      # 0x9b60
movl (%rcx,%rbp,4), %r9d
cmpl $0x20, %r13d
jne 0x591a
movzwl 0x2(%rsi,%rbp,4), %r15d
movl 0x1a74(%rdi), %ecx
movl $0x10, %r8d
subl %r15d, %r8d
movzwl (%rsi,%rbp,4), %ebx
movl %ebx, %r10d
shll %cl, %r10d
cmpl %r8d, %ecx
jle 0x59b7
orw 0x1a70(%rdi), %r10w
movw %r10w, 0x1a70(%rdi)
movq 0x10(%rdi), %rcx
movslq 0x28(%rdi), %r8
leal 0x1(%r8), %r11d
movl %r11d, 0x28(%rdi)
movb %r10b, (%rcx,%r8)
movb 0x1a71(%rdi), %cl
movq 0x10(%rdi), %r8
movslq 0x28(%rdi), %r10
leal 0x1(%r10), %r11d
movl %r11d, 0x28(%rdi)
movb %cl, (%r8,%r10)
movl 0x1a74(%rdi), %r8d
movb $0x10, %cl
subb %r8b, %cl
shrl %cl, %ebx
movw %bx, 0x1a70(%rdi)
leal (%r15,%r8), %ecx
addl $-0x10, %ecx
jmp 0x59c2
testb %r13b, %r13b
movl $0x94, %r8d
movl $0x128, %ecx            # imm = 0x128
cmovnsl %ecx, %r8d
addq %rsi, %r8
movzwl 0x2(%r8,%rbp,4), %r15d
movl 0x1a74(%rdi), %ecx
movl $0x10, %r11d
subl %r15d, %r11d
movzwl (%r8,%rbp,4), %ebx
movl %ebx, %r10d
shll %cl, %r10d
cmpl %r11d, %ecx
jle 0x5a59
orw 0x1a70(%rdi), %r10w
movw %r10w, 0x1a70(%rdi)
movq 0x10(%rdi), %rcx
movslq 0x28(%rdi), %r8
leal 0x1(%r8), %r11d
movl %r11d, 0x28(%rdi)
movb %r10b, (%rcx,%r8)
movb 0x1a71(%rdi), %cl
movq 0x10(%rdi), %r8
movslq 0x28(%rdi), %r10
leal 0x1(%r10), %r11d
movl %r11d, 0x28(%rdi)
movb %cl, (%r8,%r10)
movl 0x1a74(%rdi), %r8d
movb $0x10, %cl
subb %r8b, %cl
shrl %cl, %ebx
movw %bx, 0x1a70(%rdi)
leal (%r15,%r8), %ecx
addl $-0x10, %ecx
jmp 0x5a64
orw %r10w, 0x1a70(%rdi)
addl %r15d, %ecx
movl %ecx, 0x1a74(%rdi)
testl %r9d, %r9d
je 0x5b9b
leaq 0x44b8(%rip), %r8       # 0x9e90
subl (%r8,%rbp,4), %r12d
movl $0x10, %r8d
subl %r9d, %r8d
movl %r12d, %r10d
shll %cl, %r10d
cmpl %r8d, %ecx
jle 0x5b8a
orw 0x1a70(%rdi), %r10w
movw %r10w, 0x1a70(%rdi)
movq 0x10(%rdi), %rcx
movslq 0x28(%rdi), %r8
leal 0x1(%r8), %r11d
movl %r11d, 0x28(%rdi)
movb %r10b, (%rcx,%r8)
movb 0x1a71(%rdi), %cl
movq 0x10(%rdi), %r8
movslq 0x28(%rdi), %r10
leal 0x1(%r10), %r11d
movl %r11d, 0x28(%rdi)
movb %cl, (%r8,%r10)
movzwl %r12w, %r8d
movl 0x1a74(%rdi), %r10d
movb $0x10, %cl
subb %r10b, %cl
shrl %cl, %r8d
movw %r8w, 0x1a70(%rdi)
leal (%r9,%r10), %ecx
addl $-0x10, %ecx
jmp 0x5b95
orw %r10w, 0x1a70(%rdi)
addl %r15d, %ecx
movl %ecx, 0x1a74(%rdi)
testl %r9d, %r9d
je 0x5b05
leaq 0x4416(%rip), %r8       # 0x9e90
subl (%r8,%rbp,4), %r12d
movl $0x10, %r8d
subl %r9d, %r8d
movl %r12d, %r10d
shll %cl, %r10d
cmpl %r8d, %ecx
jle 0x5af4
orw 0x1a70(%rdi), %r10w
movw %r10w, 0x1a70(%rdi)
movq 0x10(%rdi), %rcx
movslq 0x28(%rdi), %r8
leal 0x1(%r8), %r11d
movl %r11d, 0x28(%rdi)
movb %r10b, (%rcx,%r8)
movb 0x1a71(%rdi), %cl
movq 0x10(%rdi), %r8
movslq 0x28(%rdi), %r10
leal 0x1(%r10), %r11d
movl %r11d, 0x28(%rdi)
movb %cl, (%r8,%r10)
movzwl %r12w, %r8d
movl 0x1a74(%rdi), %r10d
movb $0x10, %cl
subb %r10b, %cl
shrl %cl, %r8d
movw %r8w, 0x1a70(%rdi)
leal (%r9,%r10), %ecx
addl $-0x10, %ecx
jmp 0x5aff
orw %r10w, 0x1a70(%rdi)
addl %r9d, %ecx
movl %ecx, 0x1a74(%rdi)
andl $0x1f, %r13d
movzwl 0x2(%r14,%r13,4), %r9d
movl 0x1a74(%rdi), %ecx
movl $0x10, %r8d
subl %r9d, %r8d
movzwl (%r14,%r13,4), %ebx
movl %ebx, %r10d
shll %cl, %r10d
cmpl %r8d, %ecx
jle 0x5b8a
orw 0x1a70(%rdi), %r10w
movw %r10w, 0x1a70(%rdi)
movq 0x10(%rdi), %rcx
movslq 0x28(%rdi), %r8
leal 0x1(%r8), %r11d
movl %r11d, 0x28(%rdi)
movb %r10b, (%rcx,%r8)
movb 0x1a71(%rdi), %cl
movq 0x10(%rdi), %r8
movslq 0x28(%rdi), %r10
leal 0x1(%r10), %r11d
movl %r11d, 0x28(%rdi)
movb %cl, (%r8,%r10)
movl 0x1a74(%rdi), %r8d
movb $0x10, %cl
subb %r8b, %cl
shrl %cl, %ebx
movw %bx, 0x1a70(%rdi)
leal (%r9,%r8), %ecx
addl $-0x10, %ecx
jmp 0x5b95
orw %r10w, 0x1a70(%rdi)
addl %r9d, %ecx
movl %ecx, 0x1a74(%rdi)
incq %rax
movl 0x1a44(%rdi), %ecx
cmpq %rcx, %rax
jb 0x5639
movzwl 0x402(%rdx), %eax
movl 0x1a74(%rdi), %ecx
movl $0x10, %r9d
subl %eax, %r9d
movzwl 0x400(%rdx), %esi
movl %esi, %r8d
shll %cl, %r8d
orw 0x1a70(%rdi), %r8w
movw %r8w, 0x1a70(%rdi)
cmpl %r9d, %ecx
jle 0x5c31
movq 0x10(%rdi), %rcx
movslq 0x28(%rdi), %r9
leal 0x1(%r9), %r10d
movl %r10d, 0x28(%rdi)
movb %r8b, (%rcx,%r9)
movb 0x1a71(%rdi), %cl
movq 0x10(%rdi), %r8
movslq 0x28(%rdi), %r9
leal 0x1(%r9), %r10d
movl %r10d, 0x28(%rdi)
movb %cl, (%r8,%r9)
movl 0x1a74(%rdi), %r8d
movb $0x10, %cl
subb %r8b, %cl
shrl %cl, %esi
movw %si, 0x1a70(%rdi)
leal (%rax,%r8), %ecx
addl $-0x10, %ecx
jmp 0x5c33
addl %eax, %ecx
movl %ecx, 0x1a74(%rdi)
movzwl 0x402(%rdx), %eax
movl %eax, 0x1a6c(%rdi)
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq