// File: /workspace/github_c_makefile_star2_O0/madler[P]pigz/zopfli/src/zopfli/deflate.c
// Function: TryOptimizeHuffmanForRle
static double TryOptimizeHuffmanForRle(
    const ZopfliLZ77Store* lz77, size_t lstart, size_t lend,
    const size_t* ll_counts, const size_t* d_counts,
    unsigned* ll_lengths, unsigned* d_lengths) {
  size_t ll_counts2[ZOPFLI_NUM_LL];
  size_t d_counts2[ZOPFLI_NUM_D];
  unsigned ll_lengths2[ZOPFLI_NUM_LL];
  unsigned d_lengths2[ZOPFLI_NUM_D];
  double treesize;
  double datasize;
  double treesize2;
  double datasize2;

  treesize = CalculateTreeSize(ll_lengths, d_lengths);
  datasize = CalculateBlockSymbolSizeGivenCounts(ll_counts, d_counts,
      ll_lengths, d_lengths, lz77, lstart, lend);

  memcpy(ll_counts2, ll_counts, sizeof(ll_counts2));
  memcpy(d_counts2, d_counts, sizeof(d_counts2));
  OptimizeHuffmanForRle(ZOPFLI_NUM_LL, ll_counts2);
  OptimizeHuffmanForRle(ZOPFLI_NUM_D, d_counts2);
  ZopfliCalculateBitLengths(ll_counts2, ZOPFLI_NUM_LL, 15, ll_lengths2);
  ZopfliCalculateBitLengths(d_counts2, ZOPFLI_NUM_D, 15, d_lengths2);
  PatchDistanceCodesForBuggyDecoders(d_lengths2);

  treesize2 = CalculateTreeSize(ll_lengths2, d_lengths2);
  datasize2 = CalculateBlockSymbolSizeGivenCounts(ll_counts, d_counts,
      ll_lengths2, d_lengths2, lz77, lstart, lend);

  if (treesize2 + datasize2 < treesize + datasize) {
    memcpy(ll_lengths, ll_lengths2, sizeof(ll_lengths2));
    memcpy(d_lengths, d_lengths2, sizeof(d_lengths2));
    return treesize2 + datasize2;
  }
  return treesize + datasize;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xfb0, %rsp            # imm = 0xFB0
movq 0x10(%rbp), %rax
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq %r8, -0x30(%rbp)
movq %r9, -0x38(%rbp)
movq -0x38(%rbp), %rdi
movq 0x10(%rbp), %rsi
callq 0x145f0
movq %rax, %xmm0
movaps 0x7e50(%rip), %xmm1     # 0x1c1d0
movaps %xmm1, -0xf80(%rbp)
punpckldq %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
movapd 0x7e4d(%rip), %xmm1     # 0x1c1e0
movaps %xmm1, -0xf70(%rbp)
subpd %xmm1, %xmm0
movaps %xmm0, %xmm1
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
addsd %xmm1, %xmm0
movsd %xmm0, -0xf48(%rbp)
movq -0x28(%rbp), %rdi
movq -0x30(%rbp), %rsi
movq -0x38(%rbp), %rdx
movq 0x10(%rbp), %rcx
movq -0x10(%rbp), %r8
movq -0x18(%rbp), %r9
movq -0x20(%rbp), %r10
movq %rsp, %rax
movq %r10, (%rax)
callq 0x14120
movaps -0xf80(%rbp), %xmm2
movaps -0xf70(%rbp), %xmm1
movq %rax, %xmm0
punpckldq %xmm2, %xmm0    # xmm0 = xmm0[0],xmm2[0],xmm0[1],xmm2[1]
subpd %xmm1, %xmm0
movaps %xmm0, %xmm1
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
addsd %xmm1, %xmm0
movsd %xmm0, -0xf50(%rbp)
movq -0x28(%rbp), %rsi
leaq -0x940(%rbp), %rdi
movq %rdi, -0xfa8(%rbp)
movl $0x900, %edx            # imm = 0x900
callq 0x3360
movq -0x30(%rbp), %rsi
leaq -0xa40(%rbp), %rdi
movq %rdi, -0xfa0(%rbp)
movl $0x100, %edx            # imm = 0x100
callq 0x3360
movq -0xfa8(%rbp), %rsi
movl $0x120, %edi            # imm = 0x120
callq 0x12510
movq -0xfa0(%rbp), %rsi
movl $0x20, %edi
callq 0x12510
movq -0xfa8(%rbp), %rdi
movl $0x120, %esi            # imm = 0x120
movl $0xf, %edx
movl %edx, -0xf94(%rbp)
leaq -0xec0(%rbp), %rcx
movq %rcx, -0xf90(%rbp)
callq 0x16ae0
movq -0xfa0(%rbp), %rdi
movl -0xf94(%rbp), %edx
movl $0x20, %esi
leaq -0xf40(%rbp), %rcx
movq %rcx, -0xf88(%rbp)
callq 0x16ae0
movq -0xf88(%rbp), %rdi
callq 0x142b0
movq -0xf90(%rbp), %rdi
movq -0xf88(%rbp), %rsi
callq 0x145f0
movq -0xf90(%rbp), %rdx
movq -0xf88(%rbp), %rcx
movaps -0xf80(%rbp), %xmm2
movaps -0xf70(%rbp), %xmm1
movq %rax, %xmm0
punpckldq %xmm2, %xmm0    # xmm0 = xmm0[0],xmm2[0],xmm0[1],xmm2[1]
subpd %xmm1, %xmm0
movaps %xmm0, %xmm1
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
addsd %xmm1, %xmm0
movsd %xmm0, -0xf58(%rbp)
movq -0x28(%rbp), %rdi
movq -0x30(%rbp), %rsi
movq -0x10(%rbp), %r8
movq -0x18(%rbp), %r9
movq -0x20(%rbp), %r10
movq %rsp, %rax
movq %r10, (%rax)
callq 0x14120
movaps -0xf80(%rbp), %xmm2
movaps -0xf70(%rbp), %xmm1
movq %rax, %xmm0
punpckldq %xmm2, %xmm0    # xmm0 = xmm0[0],xmm2[0],xmm0[1],xmm2[1]
subpd %xmm1, %xmm0
movaps %xmm0, %xmm1
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
addsd %xmm1, %xmm0
movsd %xmm0, -0xf60(%rbp)
movsd -0xf58(%rbp), %xmm1
addsd -0xf60(%rbp), %xmm1
movsd -0xf48(%rbp), %xmm0
addsd -0xf50(%rbp), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x145be
movq -0x38(%rbp), %rdi
leaq -0xec0(%rbp), %rsi
movl $0x480, %edx            # imm = 0x480
callq 0x3360
movq 0x10(%rbp), %rdi
leaq -0xf40(%rbp), %rsi
movl $0x80, %edx
callq 0x3360
movsd -0xf58(%rbp), %xmm0
addsd -0xf60(%rbp), %xmm0
movsd %xmm0, -0x8(%rbp)
jmp 0x145d3
movsd -0xf48(%rbp), %xmm0
addsd -0xf50(%rbp), %xmm0
movsd %xmm0, -0x8(%rbp)
movsd -0x8(%rbp), %xmm0
addq $0xfb0, %rsp            # imm = 0xFB0
popq %rbp
retq
nopw %cs:(%rax,%rax)