// File: /workspace/github_c_makefile_star2_O1/imaya[P]zopfli-for-emscripten/deflate.c
// Function: ZopfliCalculateBlockSize
double ZopfliCalculateBlockSize(const unsigned short* litlens,
                                const unsigned short* dists,
                                size_t lstart, size_t lend, int btype) {
  size_t ll_counts[288];
  size_t d_counts[32];

  unsigned ll_lengths[288];
  unsigned d_lengths[32];

  double result = 3; /*bfinal and btype bits*/

  assert(btype == 1 || btype == 2); /* This is not for uncompressed blocks. */

  if(btype == 1) {
    GetFixedTree(ll_lengths, d_lengths);
  } else {
    ZopfliLZ77Counts(litlens, dists, lstart, lend, ll_counts, d_counts);
    ZopfliCalculateBitLengths(ll_counts, 288, 15, ll_lengths);
    ZopfliCalculateBitLengths(d_counts, 32, 15, d_lengths);
    PatchDistanceCodesForBuggyDecoders(d_lengths);
    result += CalculateTreeSize(ll_lengths, d_lengths, ll_counts, d_counts);
  }

  result += CalculateBlockSymbolSize(
      ll_lengths, d_lengths, litlens, dists, lstart, lend);

  return result;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xf38, %rsp            # imm = 0xF38
leal -0x1(%r8), %eax
cmpl $0x2, %eax
jae 0x265e
movq %rcx, %rbx
movq %rdx, %r14
movq %rdi, %r12
movq %rsi, 0x8(%rsp)
cmpl $0x1, %r8d
jne 0x24af
leaq 0xb0(%rsp), %rdi
leaq 0x30(%rsp), %rsi
callq 0x267d
movsd 0x7edc(%rip), %xmm0     # 0xa380
movapd %xmm0, 0x10(%rsp)
jmp 0x2591
leaq 0x630(%rsp), %r13
leaq 0x530(%rsp), %rbp
movq %r12, %rdi
movq 0x8(%rsp), %rsi
movq %r14, %rdx
movq %rbx, %rcx
movq %r13, %r8
movq %rbp, %r9
callq 0x73d7
leaq 0xb0(%rsp), %r15
movl $0x120, %esi            # imm = 0x120
movq %r13, %rdi
movl $0xf, %edx
movq %r15, %rcx
callq 0x89c8
leaq 0x30(%rsp), %r13
movl $0x20, %esi
movq %rbp, %rdi
movl $0xf, %edx
movq %r13, %rcx
callq 0x89c8
movq %r13, %rdi
callq 0x26f8
xorl %eax, %eax
leaq 0x28(%rsp), %rbp
movq %rax, (%rbp)
leaq 0x20(%rsp), %r8
movq %rax, (%r8)
leaq 0x7(%rsp), %r13
movb $0x0, (%r13)
movq %r15, %rdi
leaq 0x30(%rsp), %rsi
movq %r13, %rdx
movq %rbp, %rcx
movq %r8, %r15
callq 0x2fb2
movq (%rbp), %rdi
callq 0x1030
movq (%r15), %rax
movzbl (%r13), %ecx
andl $0x7, %ecx
leaq (%rcx,%rax,8), %rax
movq %rax, %xmm0
punpckldq 0x7db1(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0x7db9(%rip), %xmm0     # 0xa330
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
addsd 0x7df5(%rip), %xmm1     # 0xa380
movapd %xmm1, 0x10(%rsp)
xorl %r13d, %r13d
cmpq %rbx, %r14
jae 0x2617
movq 0x8(%rsp), %rbp
cmpw $0x0, (%rbp,%r14,2)
movzwl (%r12,%r14,2), %edi
je 0x2605
callq 0x8a75
cltq
movl 0xb0(%rsp,%rax,4), %eax
addq %rax, %r13
movzwl (%rbp,%r14,2), %edi
callq 0x8a34
cltq
movl 0x30(%rsp,%rax,4), %ebp
movzwl (%r12,%r14,2), %edi
callq 0x8a59
movq %r12, %r15
movq %rbx, %r12
movslq %eax, %rbx
addq %rbp, %rbx
movq 0x8(%rsp), %rbp
addq %r13, %rbx
movzwl (%rbp,%r14,2), %edi
callq 0x89f4
movslq %eax, %r13
addq %rbx, %r13
movq %r12, %rbx
movq %r15, %r12
jmp 0x260f
movl 0xb0(%rsp,%rdi,4), %eax
addq %rax, %r13
incq %r14
cmpq %r14, %rbx
jne 0x259e
movl 0x4b0(%rsp), %eax
addq %r13, %rax
movq %rax, %xmm0
punpckldq 0x7cf2(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0x7cfa(%rip), %xmm0     # 0xa330
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
movapd 0x10(%rsp), %xmm0
addsd %xmm1, %xmm0
addq $0xf38, %rsp            # imm = 0xF38
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x7d23(%rip), %rdi      # 0xa388
leaq 0x7d35(%rip), %rsi      # 0xa3a1
leaq 0x7d38(%rip), %rcx      # 0xa3ab
movl $0x144, %edx            # imm = 0x144
callq 0x10b0