// File: /workspace/github_c_makefile_star2_O0/madler[P]pigz/zopfli/src/zopfli/blocksplitter.c
// Function: ZopfliBlockSplitLZ77
void ZopfliBlockSplitLZ77(const ZopfliOptions* options,
                          const ZopfliLZ77Store* lz77, size_t maxblocks,
                          size_t** splitpoints, size_t* npoints) {
  size_t lstart, lend;
  size_t i;
  size_t llpos = 0;
  size_t numblocks = 1;
  unsigned char* done;
  double splitcost, origcost;

  if (lz77->size < 10) return;  /* This code fails on tiny files. */

  done = (unsigned char*)malloc(lz77->size);
  if (!done) exit(-1); /* Allocation failed. */
  for (i = 0; i < lz77->size; i++) done[i] = 0;

  lstart = 0;
  lend = lz77->size;
  for (;;) {
    SplitCostContext c;

    if (maxblocks > 0 && numblocks >= maxblocks) {
      break;
    }

    c.lz77 = lz77;
    c.start = lstart;
    c.end = lend;
    assert(lstart < lend);
    llpos = FindMinimum(SplitCost, &c, lstart + 1, lend, &splitcost);

    assert(llpos > lstart);
    assert(llpos < lend);

    origcost = EstimateCost(lz77, lstart, lend);

    if (splitcost > origcost || llpos == lstart + 1 || llpos == lend) {
      done[lstart] = 1;
    } else {
      AddSorted(llpos, splitpoints, npoints);
      numblocks++;
    }

    if (!FindLargestSplittableBlock(
        lz77->size, done, *splitpoints, *npoints, &lstart, &lend)) {
      break;  /* No further split will probably reduce compression. */
    }

    if (lend - lstart < 10) {
      break;
    }
  }

  if (options->verbose) {
    PrintBlockSplitPoints(lz77, *splitpoints, *npoints);
  }

  free(done);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x80, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movq $0x0, -0x48(%rbp)
movq $0x1, -0x50(%rbp)
movq -0x10(%rbp), %rax
cmpq $0xa, 0x10(%rax)
jae 0x159df
jmp 0x15bec
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0x33d0
movq %rax, -0x58(%rbp)
cmpq $0x0, -0x58(%rbp)
jne 0x15a01
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x3540
movq $0x0, -0x40(%rbp)
movq -0x40(%rbp), %rax
movq -0x10(%rbp), %rcx
cmpq 0x10(%rcx), %rax
jae 0x15a31
movq -0x58(%rbp), %rax
movq -0x40(%rbp), %rcx
movb $0x0, (%rax,%rcx)
movq -0x40(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x40(%rbp)
jmp 0x15a09
movq $0x0, -0x30(%rbp)
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x18(%rbp)
jbe 0x15a5b
movq -0x50(%rbp), %rax
cmpq -0x18(%rbp), %rax
jb 0x15a5b
jmp 0x15bc3
movq -0x10(%rbp), %rax
movq %rax, -0x80(%rbp)
movq -0x30(%rbp), %rax
movq %rax, -0x78(%rbp)
movq -0x38(%rbp), %rax
movq %rax, -0x70(%rbp)
movq -0x30(%rbp), %rax
cmpq -0x38(%rbp), %rax
jae 0x15a7f
jmp 0x15a9e
leaq 0x86d2(%rip), %rdi      # 0x1e158
leaq 0x86d9(%rip), %rsi      # 0x1e166
movl $0xf3, %edx
leaq 0x86ef(%rip), %rcx      # 0x1e188
callq 0x3220
movq -0x30(%rbp), %rdx
addq $0x1, %rdx
movq -0x38(%rbp), %rcx
leaq 0x40f(%rip), %rdi       # 0x15ec0
leaq -0x80(%rbp), %rsi
leaq -0x60(%rbp), %r8
callq 0x15c00
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rax
cmpq -0x30(%rbp), %rax
jbe 0x15ace
jmp 0x15aed
leaq 0x871a(%rip), %rdi      # 0x1e1ef
leaq 0x868a(%rip), %rsi      # 0x1e166
movl $0xf6, %edx
leaq 0x86a0(%rip), %rcx      # 0x1e188
callq 0x3220
movq -0x48(%rbp), %rax
cmpq -0x38(%rbp), %rax
jae 0x15af9
jmp 0x15b18
leaq 0x86fe(%rip), %rdi      # 0x1e1fe
leaq 0x865f(%rip), %rsi      # 0x1e166
movl $0xf7, %edx
leaq 0x8675(%rip), %rcx      # 0x1e188
callq 0x3220
movq -0x10(%rbp), %rdi
movq -0x30(%rbp), %rsi
movq -0x38(%rbp), %rdx
callq 0x15f20
movsd %xmm0, -0x68(%rbp)
movsd -0x60(%rbp), %xmm0
ucomisd -0x68(%rbp), %xmm0
ja 0x15b55
movq -0x48(%rbp), %rax
movq -0x30(%rbp), %rcx
addq $0x1, %rcx
cmpq %rcx, %rax
je 0x15b55
movq -0x48(%rbp), %rax
cmpq -0x38(%rbp), %rax
jne 0x15b63
movq -0x58(%rbp), %rax
movq -0x30(%rbp), %rcx
movb $0x1, (%rax,%rcx)
jmp 0x15b80
movq -0x48(%rbp), %rdi
movq -0x20(%rbp), %rsi
movq -0x28(%rbp), %rdx
callq 0x15f50
movq -0x50(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x50(%rbp)
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rdi
movq -0x58(%rbp), %rsi
movq -0x20(%rbp), %rax
movq (%rax), %rdx
movq -0x28(%rbp), %rax
movq (%rax), %rcx
leaq -0x30(%rbp), %r8
leaq -0x38(%rbp), %r9
callq 0x16090
cmpl $0x0, %eax
jne 0x15bae
jmp 0x15bc3
movq -0x38(%rbp), %rax
subq -0x30(%rbp), %rax
cmpq $0xa, %rax
jae 0x15bbe
jmp 0x15bc3
jmp 0x15a45
movq -0x8(%rbp), %rax
cmpl $0x0, (%rax)
je 0x15be3
movq -0x10(%rbp), %rdi
movq -0x20(%rbp), %rax
movq (%rax), %rsi
movq -0x28(%rbp), %rax
movq (%rax), %rdx
callq 0x16190
movq -0x58(%rbp), %rdi
callq 0x3050
addq $0x80, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)