// File: /workspace/github_c_makefile_star2_O3/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 0x5eb5
xorl %r8d, %r8d
leaq 0x424f(%rip), %rbx      # 0x9c00
movq 0x1a50(%rdi), %rax
movzbl (%rax,%r8), %r10d
movq 0x1a48(%rdi), %rax
movzwl (%rax,%r8,2), %r15d
cmpq $0x40, %r10
jne 0x5a5b
movl %r15d, %ecx
movzwl 0x2(%rdx,%rcx,4), %r10d
movl 0x1a74(%rdi), %eax
movl $0x10, %r14d
subl %r10d, %r14d
movzwl (%rdx,%rcx,4), %r11d
movl %r11d, %ebp
movl %eax, %ecx
shll %cl, %ebp
orw 0x1a70(%rdi), %bp
movw %bp, 0x1a70(%rdi)
cmpl %r14d, %eax
jle 0x5b13
movq 0x10(%rdi), %rax
movslq 0x28(%rdi), %rcx
leal 0x1(%rcx), %r14d
movl %r14d, 0x28(%rdi)
movb %bpl, (%rax,%rcx)
movb 0x1a71(%rdi), %al
movq 0x10(%rdi), %rcx
movslq 0x28(%rdi), %r14
leal 0x1(%r14), %ebp
movl %ebp, 0x28(%rdi)
movb %al, (%rcx,%r14)
movl 0x1a74(%rdi), %eax
movb $0x10, %cl
subb %al, %cl
shrl %cl, %r11d
movw %r11w, 0x1a70(%rdi)
addl %r10d, %eax
addl $-0x10, %eax
jmp 0x5e9b
movq 0x1a38(%rdi), %rax
movl %r15d, %ecx
shrl $0x7, %ecx
addq $0x100, %rcx            # imm = 0x100
cmpl $0x100, %r15d           # imm = 0x100
cmovbq %r15, %rcx
movzwl (%rax,%r8,2), %r13d
leaq 0x37da(%rip), %rax      # 0x9260
movzbl (%rcx,%rax), %r12d
movzwl 0x406(%rdx,%r12,4), %r14d
movl 0x1a74(%rdi), %eax
movl $0x10, %r9d
subl %r14d, %r9d
movzwl 0x404(%rdx,%r12,4), %r11d
movl %r11d, %ebp
movl %eax, %ecx
shll %cl, %ebp
orw 0x1a70(%rdi), %bp
movw %bp, 0x1a70(%rdi)
cmpl %r9d, %eax
jle 0x5b1b
movq 0x10(%rdi), %rax
movslq 0x28(%rdi), %rcx
leal 0x1(%rcx), %r9d
movl %r9d, 0x28(%rdi)
movb %bpl, (%rax,%rcx)
movb 0x1a71(%rdi), %al
movq 0x10(%rdi), %rcx
movslq 0x28(%rdi), %r9
leal 0x1(%r9), %ebp
movl %ebp, 0x28(%rdi)
movb %al, (%rcx,%r9)
movl 0x1a74(%rdi), %eax
movb $0x10, %cl
subb %al, %cl
shrl %cl, %r11d
movw %r11w, 0x1a70(%rdi)
addl %r14d, %eax
addl $-0x10, %eax
movl %r11d, %ebp
jmp 0x5b1e
addl %r10d, %eax
jmp 0x5e9b
addl %r14d, %eax
movl %eax, 0x1a74(%rdi)
cmpb $0x4, %r12b
jb 0x5bbd
leaq 0x428b(%rip), %rcx      # 0x9dc0
movl (%rcx,%r12,4), %r14d
leaq 0x4370(%rip), %rcx      # 0x9eb0
subl (%rcx,%r12,4), %r15d
movl $0x10, %r9d
movl %r15d, %r11d
movl %eax, %ecx
shll %cl, %r11d
subl %r14d, %r9d
orl %r11d, %ebp
movw %bp, 0x1a70(%rdi)
cmpl %r9d, %eax
jle 0x5bb1
movq 0x10(%rdi), %rax
movslq 0x28(%rdi), %rcx
leal 0x1(%rcx), %r9d
movl %r9d, 0x28(%rdi)
movb %bpl, (%rax,%rcx)
movb 0x1a71(%rdi), %al
movq 0x10(%rdi), %rcx
movslq 0x28(%rdi), %r9
leal 0x1(%r9), %r11d
movl %r11d, 0x28(%rdi)
movb %al, (%rcx,%r9)
movzwl %r15w, %ebp
movl 0x1a74(%rdi), %eax
movb $0x10, %cl
subb %al, %cl
shrl %cl, %ebp
movw %bp, 0x1a70(%rdi)
addl %r14d, %eax
addl $-0x10, %eax
jmp 0x5bb7
addl %eax, %r14d
movl %r14d, %eax
movl %eax, 0x1a74(%rdi)
cmpl $0xff, %r13d
ja 0x5bcb
movl %r13d, %ecx
jmp 0x5be7
movl $0x24, %r12d
cmpl $0xfff, %r13d           # imm = 0xFFF
je 0x5bf3
movl %r13d, %ecx
shrl $0x6, %ecx
addq $0x100, %rcx            # imm = 0x100
leaq 0x3872(%rip), %r9       # 0x9460
movzbl (%rcx,%r9), %r12d
movl (%rbx,%r12,4), %r15d
cmpl $0x20, %r10d
jne 0x5c81
movzwl 0x2(%rsi,%r12,4), %r10d
movl $0x10, %r9d
movzwl (%rsi,%r12,4), %r14d
movl %r14d, %r11d
movl %eax, %ecx
shll %cl, %r11d
subl %r10d, %r9d
orl %r11d, %ebp
movw %bp, 0x1a70(%rdi)
cmpl %r9d, %eax
jle 0x5d0b
movq 0x10(%rdi), %rax
movslq 0x28(%rdi), %rcx
leal 0x1(%rcx), %r9d
movl %r9d, 0x28(%rdi)
movb %bpl, (%rax,%rcx)
movb 0x1a71(%rdi), %al
movq 0x10(%rdi), %rcx
movslq 0x28(%rdi), %r9
leal 0x1(%r9), %r11d
movl %r11d, 0x28(%rdi)
movb %al, (%rcx,%r9)
movl 0x1a74(%rdi), %eax
movb $0x10, %cl
subb %al, %cl
shrl %cl, %r14d
movw %r14w, 0x1a70(%rdi)
addl %r10d, %eax
addl $-0x10, %eax
movl %r14d, %ebp
jmp 0x5d0e
testb %r10b, %r10b
movl $0x94, %ecx
movl $0x128, %r9d            # imm = 0x128
cmovnsl %r9d, %ecx
addq %rsi, %rcx
movzwl 0x2(%rcx,%r12,4), %r14d
movzwl (%rcx,%r12,4), %r11d
movl %r11d, %r9d
movl %eax, %ecx
shll %cl, %r9d
movl $0x10, %ecx
subl %r14d, %ecx
orl %r9d, %ebp
cmpl %ecx, %eax
jle 0x5d9f
movw %bp, 0x1a70(%rdi)
movq 0x10(%rdi), %rax
movslq 0x28(%rdi), %rcx
leal 0x1(%rcx), %r9d
movl %r9d, 0x28(%rdi)
movb %bpl, (%rax,%rcx)
movb 0x1a71(%rdi), %al
movq 0x10(%rdi), %rcx
movslq 0x28(%rdi), %r9
leal 0x1(%r9), %ebp
movl %ebp, 0x28(%rdi)
movb %al, (%rcx,%r9)
movl 0x1a74(%rdi), %eax
movb $0x10, %cl
subb %al, %cl
shrl %cl, %r11d
addl %r14d, %eax
addl $-0x10, %eax
movl %r11d, %ebp
jmp 0x5da2
addl %r10d, %eax
movl %eax, 0x1a74(%rdi)
testl %r15d, %r15d
je 0x5ea1
leaq 0x420c(%rip), %rcx      # 0x9f30
subl (%rcx,%r12,4), %r13d
movl $0x10, %r9d
movl %r13d, %r10d
movl %eax, %ecx
shll %cl, %r10d
subl %r15d, %r9d
orl %r10d, %ebp
movw %bp, 0x1a70(%rdi)
cmpl %r9d, %eax
jle 0x5e1c
movq 0x10(%rdi), %rax
movslq 0x28(%rdi), %rcx
leal 0x1(%rcx), %r9d
movl %r9d, 0x28(%rdi)
movb %bpl, (%rax,%rcx)
movb 0x1a71(%rdi), %al
movq 0x10(%rdi), %rcx
movslq 0x28(%rdi), %r9
leal 0x1(%r9), %r10d
movl %r10d, 0x28(%rdi)
movb %al, (%rcx,%r9)
movzwl %r13w, %eax
movl 0x1a74(%rdi), %r9d
movb $0x10, %cl
subb %r9b, %cl
shrl %cl, %eax
movw %ax, 0x1a70(%rdi)
leal (%r15,%r9), %eax
addl $-0x10, %eax
jmp 0x5e9b
addl %r14d, %eax
movl %eax, 0x1a74(%rdi)
testl %r15d, %r15d
je 0x5e2a
leaq 0x417c(%rip), %rcx      # 0x9f30
subl (%rcx,%r12,4), %r13d
movl %r13d, %r9d
movl %eax, %ecx
shll %cl, %r9d
movl $0x10, %ecx
subl %r15d, %ecx
orl %r9d, %ebp
cmpl %ecx, %eax
jle 0x5e21
movw %bp, 0x1a70(%rdi)
movq 0x10(%rdi), %rax
movslq 0x28(%rdi), %rcx
leal 0x1(%rcx), %r9d
movl %r9d, 0x28(%rdi)
movb %bpl, (%rax,%rcx)
movb 0x1a71(%rdi), %al
movq 0x10(%rdi), %rcx
movslq 0x28(%rdi), %r9
leal 0x1(%r9), %r11d
movl %r11d, 0x28(%rdi)
movb %al, (%rcx,%r9)
movzwl %r13w, %ebp
movl 0x1a74(%rdi), %eax
movb $0x10, %cl
subb %al, %cl
shrl %cl, %ebp
addl %r15d, %eax
addl $-0x10, %eax
jmp 0x5e24
addl %r15d, %eax
jmp 0x5e9b
addl %r15d, %eax
movl %eax, 0x1a74(%rdi)
andl $0x1f, %r10d
leaq 0x3db7(%rip), %rcx      # 0x9bec
movzwl (%rcx,%r10,4), %r10d
movl %r10d, %r9d
movl %eax, %ecx
shll %cl, %r9d
orl %r9d, %ebp
movw %bp, 0x1a70(%rdi)
cmpl $0x10, %eax
jl 0x5e99
movq 0x10(%rdi), %rax
movslq 0x28(%rdi), %rcx
leal 0x1(%rcx), %r9d
movl %r9d, 0x28(%rdi)
movb %bpl, (%rax,%rcx)
movb 0x1a71(%rdi), %al
movq 0x10(%rdi), %rcx
movslq 0x28(%rdi), %r9
leal 0x1(%r9), %r11d
movl %r11d, 0x28(%rdi)
movb %al, (%rcx,%r9)
movl 0x1a74(%rdi), %eax
movb $0x10, %cl
subb %al, %cl
shrl %cl, %r10d
movw %r10w, 0x1a70(%rdi)
addl $-0xf, %eax
jmp 0x5e9b
incl %eax
movl %eax, 0x1a74(%rdi)
incq %r8
movl 0x1a44(%rdi), %ecx
cmpq %rcx, %r8
jb 0x59b1
jmp 0x5ebb
movl 0x1a74(%rdi), %eax
movzwl 0x402(%rdx), %esi
movl $0x10, %r10d
subl %esi, %r10d
movzwl 0x400(%rdx), %r8d
movl %r8d, %r9d
movl %eax, %ecx
shll %cl, %r9d
orw 0x1a70(%rdi), %r9w
movw %r9w, 0x1a70(%rdi)
cmpl %r10d, %eax
jle 0x5f3a
movq 0x10(%rdi), %rax
movslq 0x28(%rdi), %rcx
leal 0x1(%rcx), %r10d
movl %r10d, 0x28(%rdi)
movb %r9b, (%rax,%rcx)
movb 0x1a71(%rdi), %al
movq 0x10(%rdi), %rcx
movslq 0x28(%rdi), %r9
leal 0x1(%r9), %r10d
movl %r10d, 0x28(%rdi)
movb %al, (%rcx,%r9)
movl 0x1a74(%rdi), %eax
movb $0x10, %cl
subb %al, %cl
shrl %cl, %r8d
movw %r8w, 0x1a70(%rdi)
addl %esi, %eax
addl $-0x10, %eax
jmp 0x5f3c
addl %esi, %eax
movl %eax, 0x1a74(%rdi)
movzwl 0x402(%rdx), %eax
movl %eax, 0x1a6c(%rdi)
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq