// File: /workspace/github_c_makefile_star2_O0/madler[P]pigz/zopfli/src/zopfli/squeeze.c
// Function: GetBestLengths
static double GetBestLengths(ZopfliBlockState *s,
                             const unsigned char* in,
                             size_t instart, size_t inend,
                             CostModelFun* costmodel, void* costcontext,
                             unsigned short* length_array,
                             ZopfliHash* h, float* costs) {
  /* Best cost to get here so far. */
  size_t blocksize = inend - instart;
  size_t i = 0, k, kend;
  unsigned short leng;
  unsigned short dist;
  unsigned short sublen[259];
  size_t windowstart = instart > ZOPFLI_WINDOW_SIZE
      ? instart - ZOPFLI_WINDOW_SIZE : 0;
  double result;
  double mincost = GetCostModelMinCost(costmodel, costcontext);
  double mincostaddcostj;

  if (instart == inend) return 0;

  ZopfliResetHash(ZOPFLI_WINDOW_SIZE, h);
  ZopfliWarmupHash(in, windowstart, inend, h);
  for (i = windowstart; i < instart; i++) {
    ZopfliUpdateHash(in, i, inend, h);
  }

  for (i = 1; i < blocksize + 1; i++) costs[i] = ZOPFLI_LARGE_FLOAT;
  costs[0] = 0;  /* Because it's the start. */
  length_array[0] = 0;

  for (i = instart; i < inend; i++) {
    size_t j = i - instart;  /* Index in the costs array and length_array. */
    ZopfliUpdateHash(in, i, inend, h);

#ifdef ZOPFLI_SHORTCUT_LONG_REPETITIONS
    /* If we're in a long repetition of the same character and have more than
    ZOPFLI_MAX_MATCH characters before and after our position. */
    if (h->same[i & ZOPFLI_WINDOW_MASK] > ZOPFLI_MAX_MATCH * 2
        && i > instart + ZOPFLI_MAX_MATCH + 1
        && i + ZOPFLI_MAX_MATCH * 2 + 1 < inend
        && h->same[(i - ZOPFLI_MAX_MATCH) & ZOPFLI_WINDOW_MASK]
            > ZOPFLI_MAX_MATCH) {
      double symbolcost = costmodel(ZOPFLI_MAX_MATCH, 1, costcontext);
      /* Set the length to reach each one to ZOPFLI_MAX_MATCH, and the cost to
      the cost corresponding to that length. Doing this, we skip
      ZOPFLI_MAX_MATCH values to avoid calling ZopfliFindLongestMatch. */
      for (k = 0; k < ZOPFLI_MAX_MATCH; k++) {
        costs[j + ZOPFLI_MAX_MATCH] = costs[j] + symbolcost;
        length_array[j + ZOPFLI_MAX_MATCH] = ZOPFLI_MAX_MATCH;
        i++;
        j++;
        ZopfliUpdateHash(in, i, inend, h);
      }
    }
#endif

    ZopfliFindLongestMatch(s, h, in, i, inend, ZOPFLI_MAX_MATCH, sublen,
                           &dist, &leng);

    /* Literal. */
    if (i + 1 <= inend) {
      double newCost = costmodel(in[i], 0, costcontext) + costs[j];
      assert(newCost >= 0);
      if (newCost < costs[j + 1]) {
        costs[j + 1] = newCost;
        length_array[j + 1] = 1;
      }
    }
    /* Lengths. */
    kend = zopfli_min(leng, inend-i);
    mincostaddcostj = mincost + costs[j];
    for (k = 3; k <= kend; k++) {
      double newCost;

      /* Calling the cost model is expensive, avoid this if we are already at
      the minimum possible cost that it can return. */
     if (costs[j + k] <= mincostaddcostj) continue;

      newCost = costmodel(k, sublen[k], costcontext) + costs[j];
      assert(newCost >= 0);
      if (newCost < costs[j + k]) {
        assert(k <= ZOPFLI_MAX_MATCH);
        costs[j + k] = newCost;
        length_array[j + k] = k;
      }
    }
  }

  assert(costs[blocksize] >= 0);
  result = costs[blocksize];

  return result;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x2d0, %rsp            # imm = 0x2D0
movq 0x20(%rbp), %rax
movq 0x18(%rbp), %rax
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 -0x28(%rbp), %rax
subq -0x20(%rbp), %rax
movq %rax, -0x40(%rbp)
movq $0x0, -0x48(%rbp)
cmpq $0x8000, -0x20(%rbp)    # imm = 0x8000
jbe 0x1a570
movq -0x20(%rbp), %rax
subq $0x8000, %rax           # imm = 0x8000
movq %rax, -0x2b8(%rbp)
jmp 0x1a57b
xorl %eax, %eax
movq %rax, -0x2b8(%rbp)
jmp 0x1a57b
movq -0x2b8(%rbp), %rax
movq %rax, -0x278(%rbp)
movq -0x30(%rbp), %rdi
movq -0x38(%rbp), %rsi
callq 0x1afd0
movsd %xmm0, -0x288(%rbp)
movq -0x20(%rbp), %rax
cmpq -0x28(%rbp), %rax
jne 0x1a5b5
xorps %xmm0, %xmm0
movsd %xmm0, -0x8(%rbp)
jmp 0x1aae4
movq 0x18(%rbp), %rsi
movl $0x8000, %edi           # imm = 0x8000
callq 0x19350
movq -0x18(%rbp), %rdi
movq -0x278(%rbp), %rsi
movq -0x28(%rbp), %rdx
movq 0x18(%rbp), %rcx
callq 0x197f0
movq -0x278(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rax
cmpq -0x20(%rbp), %rax
jae 0x1a613
movq -0x18(%rbp), %rdi
movq -0x48(%rbp), %rsi
movq -0x28(%rbp), %rdx
movq 0x18(%rbp), %rcx
callq 0x19510
movq -0x48(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x48(%rbp)
jmp 0x1a5e6
movq $0x1, -0x48(%rbp)
movq -0x48(%rbp), %rax
movq -0x40(%rbp), %rcx
addq $0x1, %rcx
cmpq %rcx, %rax
jae 0x1a64f
movq 0x20(%rbp), %rax
movq -0x48(%rbp), %rcx
movss 0x43ec(%rip), %xmm0     # 0x1ea28
movss %xmm0, (%rax,%rcx,4)
movq -0x48(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x48(%rbp)
jmp 0x1a61b
movq 0x20(%rbp), %rax
xorps %xmm0, %xmm0
movss %xmm0, (%rax)
movq 0x10(%rbp), %rax
movw $0x0, (%rax)
movq -0x20(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rax
cmpq -0x28(%rbp), %rax
jae 0x1aa88
movq -0x48(%rbp), %rax
subq -0x20(%rbp), %rax
movq %rax, -0x298(%rbp)
movq -0x18(%rbp), %rdi
movq -0x48(%rbp), %rsi
movq -0x28(%rbp), %rdx
movq 0x18(%rbp), %rcx
callq 0x19510
movq 0x18(%rbp), %rax
movq 0x40(%rax), %rax
movq -0x48(%rbp), %rcx
andq $0x7fff, %rcx           # imm = 0x7FFF
movzwl (%rax,%rcx,2), %eax
cmpl $0x204, %eax            # imm = 0x204
jle 0x1a7dd
movq -0x48(%rbp), %rax
movq -0x20(%rbp), %rcx
addq $0x102, %rcx            # imm = 0x102
addq $0x1, %rcx
cmpq %rcx, %rax
jbe 0x1a7dd
movq -0x48(%rbp), %rax
addq $0x204, %rax            # imm = 0x204
addq $0x1, %rax
cmpq -0x28(%rbp), %rax
jae 0x1a7dd
movq 0x18(%rbp), %rax
movq 0x40(%rax), %rax
movq -0x48(%rbp), %rcx
subq $0x102, %rcx            # imm = 0x102
andq $0x7fff, %rcx           # imm = 0x7FFF
movzwl (%rax,%rcx,2), %eax
cmpl $0x102, %eax            # imm = 0x102
jle 0x1a7dd
movq -0x30(%rbp), %rax
movq -0x38(%rbp), %rdx
movl $0x102, %edi            # imm = 0x102
movl $0x1, %esi
callq *%rax
movsd %xmm0, -0x2a0(%rbp)
movq $0x0, -0x50(%rbp)
cmpq $0x102, -0x50(%rbp)     # imm = 0x102
jae 0x1a7db
movq 0x20(%rbp), %rax
movq -0x298(%rbp), %rcx
movss (%rax,%rcx,4), %xmm0
cvtss2sd %xmm0, %xmm0
addsd -0x2a0(%rbp), %xmm0
cvtsd2ss %xmm0, %xmm0
movq 0x20(%rbp), %rax
movq -0x298(%rbp), %rcx
movss %xmm0, 0x408(%rax,%rcx,4)
movq 0x10(%rbp), %rax
movq -0x298(%rbp), %rcx
movw $0x102, 0x204(%rax,%rcx,2) # imm = 0x102
movq -0x48(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x48(%rbp)
movq -0x298(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x298(%rbp)
movq -0x18(%rbp), %rdi
movq -0x48(%rbp), %rsi
movq -0x28(%rbp), %rdx
movq 0x18(%rbp), %rcx
callq 0x19510
movq -0x50(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x50(%rbp)
jmp 0x1a740
jmp 0x1a7dd
movq -0x10(%rbp), %rdi
movq 0x18(%rbp), %rsi
movq -0x18(%rbp), %rdx
movq -0x48(%rbp), %rcx
movq -0x28(%rbp), %r8
leaq -0x270(%rbp), %r11
movl $0x102, %r9d            # imm = 0x102
leaq -0x5c(%rbp), %r10
leaq -0x5a(%rbp), %rax
movq %r11, (%rsp)
movq %r10, 0x8(%rsp)
movq %rax, 0x10(%rsp)
callq 0x17cf0
movq -0x48(%rbp), %rax
addq $0x1, %rax
cmpq -0x28(%rbp), %rax
ja 0x1a8e9
movq -0x30(%rbp), %rax
movq -0x18(%rbp), %rcx
movq -0x48(%rbp), %rdx
movzbl (%rcx,%rdx), %edi
movq -0x38(%rbp), %rdx
xorl %esi, %esi
callq *%rax
movq 0x20(%rbp), %rax
movq -0x298(%rbp), %rcx
movss (%rax,%rcx,4), %xmm1
cvtss2sd %xmm1, %xmm1
addsd %xmm1, %xmm0
movsd %xmm0, -0x2a8(%rbp)
movsd -0x2a8(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jb 0x1a876
jmp 0x1a895
leaq 0x42bd(%rip), %rdi      # 0x1eb3a
leaq 0x41d8(%rip), %rsi      # 0x1ea5c
movl $0x117, %edx            # imm = 0x117
leaq 0x42b7(%rip), %rcx      # 0x1eb47
callq 0x3220
movsd -0x2a8(%rbp), %xmm1
movq 0x20(%rbp), %rax
movq -0x298(%rbp), %rcx
movss 0x4(%rax,%rcx,4), %xmm0
cvtss2sd %xmm0, %xmm0
ucomisd %xmm1, %xmm0
jbe 0x1a8e7
movsd -0x2a8(%rbp), %xmm0
cvtsd2ss %xmm0, %xmm0
movq 0x20(%rbp), %rax
movq -0x298(%rbp), %rcx
movss %xmm0, 0x4(%rax,%rcx,4)
movq 0x10(%rbp), %rax
movq -0x298(%rbp), %rcx
movw $0x1, 0x2(%rax,%rcx,2)
jmp 0x1a8e9
movzwl -0x5a(%rbp), %eax
movl %eax, %edi
movq -0x28(%rbp), %rsi
subq -0x48(%rbp), %rsi
callq 0x1b0e0
movq %rax, -0x58(%rbp)
movsd -0x288(%rbp), %xmm0
movq 0x20(%rbp), %rax
movq -0x298(%rbp), %rcx
movss (%rax,%rcx,4), %xmm1
cvtss2sd %xmm1, %xmm1
addsd %xmm1, %xmm0
movsd %xmm0, -0x290(%rbp)
movq $0x3, -0x50(%rbp)
movq -0x50(%rbp), %rax
cmpq -0x58(%rbp), %rax
ja 0x1aa75
movq 0x20(%rbp), %rax
movq -0x298(%rbp), %rcx
addq -0x50(%rbp), %rcx
movss (%rax,%rcx,4), %xmm0
cvtss2sd %xmm0, %xmm1
movsd -0x290(%rbp), %xmm0
ucomisd %xmm1, %xmm0
jb 0x1a969
jmp 0x1aa64
movq -0x30(%rbp), %rax
movq -0x50(%rbp), %rcx
movl %ecx, %edi
movq -0x50(%rbp), %rcx
movzwl -0x270(%rbp,%rcx,2), %esi
movq -0x38(%rbp), %rdx
callq *%rax
movq 0x20(%rbp), %rax
movq -0x298(%rbp), %rcx
movss (%rax,%rcx,4), %xmm1
cvtss2sd %xmm1, %xmm1
addsd %xmm1, %xmm0
movsd %xmm0, -0x2b0(%rbp)
movsd -0x2b0(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jb 0x1a9b8
jmp 0x1a9d7
leaq 0x417b(%rip), %rdi      # 0x1eb3a
leaq 0x4096(%rip), %rsi      # 0x1ea5c
movl $0x128, %edx            # imm = 0x128
leaq 0x4175(%rip), %rcx      # 0x1eb47
callq 0x3220
movsd -0x2b0(%rbp), %xmm1
movq 0x20(%rbp), %rax
movq -0x298(%rbp), %rcx
addq -0x50(%rbp), %rcx
movss (%rax,%rcx,4), %xmm0
cvtss2sd %xmm0, %xmm0
ucomisd %xmm1, %xmm0
jbe 0x1aa62
cmpq $0x102, -0x50(%rbp)     # imm = 0x102
ja 0x1aa09
jmp 0x1aa28
leaq 0x41c9(%rip), %rdi      # 0x1ebd9
leaq 0x4045(%rip), %rsi      # 0x1ea5c
movl $0x12a, %edx            # imm = 0x12A
leaq 0x4124(%rip), %rcx      # 0x1eb47
callq 0x3220
movsd -0x2b0(%rbp), %xmm0
cvtsd2ss %xmm0, %xmm0
movq 0x20(%rbp), %rax
movq -0x298(%rbp), %rcx
addq -0x50(%rbp), %rcx
movss %xmm0, (%rax,%rcx,4)
movq -0x50(%rbp), %rax
movw %ax, %dx
movq 0x10(%rbp), %rax
movq -0x298(%rbp), %rcx
addq -0x50(%rbp), %rcx
movw %dx, (%rax,%rcx,2)
jmp 0x1aa64
movq -0x50(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x50(%rbp)
jmp 0x1a930
jmp 0x1aa77
movq -0x48(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x48(%rbp)
jmp 0x1a66b
movq 0x20(%rbp), %rax
movq -0x40(%rbp), %rcx
movss (%rax,%rcx,4), %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jb 0x1aa9f
jmp 0x1aabe
leaq 0x4149(%rip), %rdi      # 0x1ebef
leaq 0x3faf(%rip), %rsi      # 0x1ea5c
movl $0x131, %edx            # imm = 0x131
leaq 0x408e(%rip), %rcx      # 0x1eb47
callq 0x3220
movq 0x20(%rbp), %rax
movq -0x40(%rbp), %rcx
movss (%rax,%rcx,4), %xmm0
cvtss2sd %xmm0, %xmm0
movsd %xmm0, -0x280(%rbp)
movsd -0x280(%rbp), %xmm0
movsd %xmm0, -0x8(%rbp)
movsd -0x8(%rbp), %xmm0
addq $0x2d0, %rsp            # imm = 0x2D0
popq %rbp
retq
nopw %cs:(%rax,%rax)