// File: /workspace/github_c_makefile_star2_O2/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x118, %rsp            # imm = 0x118
movq %r8, 0x18(%rsp)
movq %rdx, 0x30(%rsp)
movq 0x10(%rsi), %r12
cmpq $0xa, %r12
jae 0xffeb
addq $0x118, %rsp            # imm = 0x118
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rcx, %rbx
movq %rdi, %r14
movq %rsi, (%rsp)
movq %r12, %rdi
callq 0x33d0
testq %rax, %rax
je 0x1052b
movq %rax, %r13
xorl %eax, %eax
cmpq %rax, %r12
je 0x1001b
movb $0x0, (%r13,%rax)
incq %rax
jmp 0x1000b
movq %r14, 0x48(%rsp)
movq %rbx, 0x10(%rsp)
decq 0x30(%rsp)
pushq $0x1
popq %rax
movq $0x0, 0x20(%rsp)
leaq 0x68(%rsp), %r15
movq %r12, %r14
movq %rax, 0x38(%rsp)
movq %r13, 0x28(%rsp)
movq (%rsp), %rax
movq 0x38(%rsp), %rcx
cmpq %rcx, 0x30(%rsp)
jb 0x1032e
movq %rax, 0x68(%rsp)
movq 0x20(%rsp), %rax
movq %rax, 0x70(%rsp)
movq %r14, 0x78(%rsp)
cmpq %r14, %rax
jae 0x1050c
leaq 0x1(%rax), %r12
movq %r14, %rax
subq %r12, %rax
cmpq $0x3ff, %rax            # imm = 0x3FF
movq %r12, 0x50(%rsp)
ja 0x100d2
movsd 0x5ff0(%rip), %xmm0     # 0x16088
movsd %xmm0, 0x8(%rsp)
movq %r12, %r13
cmpq %r12, %r14
je 0x101c0
movq %r12, %rdi
movq %r15, %rsi
callq 0x10552
movsd 0x8(%rsp), %xmm1
ucomisd %xmm0, %xmm1
cmovaq %r12, %r13
minsd %xmm1, %xmm0
incq %r12
movsd %xmm0, 0x8(%rsp)
jmp 0x100a1
movq %r14, 0x40(%rsp)
movq %r12, %rsi
movsd 0x5fa6(%rip), %xmm0     # 0x16088
movsd %xmm0, 0x8(%rsp)
movq %r12, %r13
movq 0x40(%rsp), %rax
subq %rsi, %rax
cmpq $0xa, %rax
jb 0x101c0
movq %r13, 0x60(%rsp)
movq %r14, %r13
xorl %edx, %edx
pushq $0xa
popq %rcx
divq %rcx
movq %rax, %r12
movq %rsi, 0x58(%rsp)
leaq (%rsi,%rax), %r14
xorl %ebp, %ebp
cmpq $0x9, %rbp
je 0x10149
leaq 0x1(%rbp), %rbx
movq %r14, 0x80(%rsp,%rbp,8)
movq %r14, %rdi
movq %r15, %rsi
callq 0x10552
movsd %xmm0, 0xd0(%rsp,%rbp,8)
addq %r12, %r14
movq %rbx, %rbp
jmp 0x1011b
movsd 0xd0(%rsp), %xmm0
pushq $0x1
popq %rcx
xorl %eax, %eax
movq %r13, %r14
movq 0x60(%rsp), %r13
movq 0x58(%rsp), %rsi
cmpq $0x9, %rcx
je 0x10188
movsd 0xd0(%rsp,%rcx,8), %xmm1
ucomisd %xmm1, %xmm0
cmovaq %rcx, %rax
minsd %xmm0, %xmm1
incq %rcx
movapd %xmm1, %xmm0
jmp 0x10164
ucomisd 0x8(%rsp), %xmm0
ja 0x101c0
testq %rax, %rax
je 0x101a0
movq 0x78(%rsp,%rax,8), %rsi
cmpq $0x8, %rax
je 0x101ad
movq 0x88(%rsp,%rax,8), %rcx
movq %rcx, 0x40(%rsp)
movq 0x80(%rsp,%rax,8), %r13
movsd %xmm0, 0x8(%rsp)
jmp 0x100eb
movq 0x20(%rsp), %rsi
cmpq %rsi, %r13
movq (%rsp), %rdi
jbe 0x104ce
cmpq %r14, %r13
jae 0x104ed
movq %r14, %rdx
callq 0xe4ef
movsd 0x8(%rsp), %xmm1
ucomisd %xmm0, %xmm1
ja 0x10227
cmpq 0x50(%rsp), %r13
je 0x10227
movq 0x18(%rsp), %rax
movq (%rax), %rsi
leaq -0x1(%rsi), %rax
testq %rax, %rsi
jne 0x10241
testq %rsi, %rsi
je 0x1024b
movq 0x10(%rsp), %rbx
movq (%rbx), %rdi
shlq $0x4, %rsi
callq 0x3430
movq 0x18(%rsp), %rcx
movq (%rcx), %rsi
jmp 0x1025a
movq 0x28(%rsp), %r13
movq 0x20(%rsp), %rax
movb $0x1, (%r13,%rax)
movq 0x10(%rsp), %rax
movq (%rax), %rax
jmp 0x102ab
movq 0x10(%rsp), %rax
movq (%rax), %rax
jmp 0x1025d
pushq $0x8
popq %rdi
callq 0x33d0
xorl %esi, %esi
movq 0x10(%rsp), %rbx
movq %rax, (%rbx)
movq %r13, (%rax,%rsi,8)
movq 0x18(%rsp), %rdx
movq (%rdx), %rcx
leaq 0x1(%rcx), %rsi
movq %rsi, (%rdx)
pushq $-0x1
popq %rdi
leaq 0x2(%rdi), %rdx
cmpq %rsi, %rdx
jae 0x102a1
leaq 0x1(%rdi), %rdx
cmpq %r13, 0x8(%rax,%rdi,8)
movq %rdx, %rdi
jbe 0x10273
jmp 0x10298
movq -0x8(%rax,%rcx,8), %rsi
movq %rsi, (%rax,%rcx,8)
decq %rcx
cmpq %rdx, %rcx
ja 0x1028c
movq %r13, (%rax,%rdx,8)
incq 0x38(%rsp)
movq 0x28(%rsp), %r13
movq (%rsp), %rcx
movq 0x10(%rcx), %r12
movq 0x18(%rsp), %rcx
movq (%rcx), %rcx
leaq -0x1(%r12), %rdx
leaq 0x1(%rcx), %rsi
xorl %edi, %edi
xorl %r8d, %r8d
xorl %r9d, %r9d
cmpq %rdi, %rsi
je 0x10313
testq %rdi, %rdi
je 0x102dd
movq -0x8(%rax,%rdi,8), %r10
jmp 0x102e0
xorl %r10d, %r10d
movq %rdx, %r11
cmpq %rdi, %rcx
je 0x102ec
movq (%rax,%rdi,8), %r11
cmpb $0x0, (%r13,%r10)
jne 0x1030e
movq %r11, %rbx
subq %r10, %rbx
cmpq %r9, %rbx
jbe 0x1030e
movq %r10, 0x20(%rsp)
movq %r11, %r14
pushq $0x1
popq %r8
movq %rbx, %r9
incq %rdi
jmp 0x102cc
testl %r8d, %r8d
je 0x1032a
movq %r14, %rax
subq 0x20(%rsp), %rax
cmpq $0xa, %rax
jae 0x10048
movq (%rsp), %rax
movq 0x48(%rsp), %rcx
cmpl $0x0, (%rcx)
jne 0x10351
movq %r13, %rdi
addq $0x118, %rsp            # imm = 0x118
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x3050
movq 0x18(%rsp), %rcx
movq (%rcx), %rbp
xorl %r14d, %r14d
movl $0x0, %edi
testq %rbp, %rbp
je 0x1040d
movq %rbp, 0x8(%rsp)
movq 0x10(%rsp), %rcx
movq (%rcx), %rbx
xorl %r14d, %r14d
pushq $0x1
popq %rdx
xorl %ebp, %ebp
xorl %r13d, %r13d
xorl %edi, %edi
cmpq %r12, %rbp
jae 0x10403
movq %rax, %rcx
movq 0x8(%rax), %rax
cmpw $0x0, (%rax,%rbp,2)
movq %rdx, %r15
je 0x103a2
movq (%rcx), %rax
movzwl (%rax,%rbp,2), %r15d
cmpq (%rbx,%r14,8), %rbp
jne 0x103c7
leaq -0x1(%r14), %rax
testq %rax, %r14
jne 0x103cd
movq %rdx, %r12
testq %r14, %r14
je 0x103d3
movq %r14, %rsi
shlq $0x4, %rsi
callq 0x3430
jmp 0x103db
movq (%rsp), %rax
jmp 0x103fb
movq (%rsp), %rax
jmp 0x103e5
pushq $0x8
popq %rdi
callq 0x33d0
movq %rax, %rdi
movq (%rsp), %rax
movq %r12, %rdx
movq %r13, (%rdi,%r14,8)
incq %r14
cmpq 0x8(%rsp), %r14
je 0x104bc
movq 0x10(%rax), %r12
addq %r15, %r13
incq %rbp
jmp 0x10384
movq 0x28(%rsp), %r13
movq 0x8(%rsp), %rbp
movq %rdi, %r12
cmpq %rbp, %r14
jne 0x10533
movq 0xbbd0(%rip), %rbx      # 0x1bff0
movq (%rbx), %rcx
leaq 0x5dee(%rip), %rdi      # 0x16218
pushq $0x14
popq %rsi
pushq $0x1
popq %rdx
callq 0x3550
leaq 0x5df1(%rip), %r14      # 0x1622d
xorl %r15d, %r15d
movq (%rbx), %rcx
cmpq %r15, %rbp
je 0x1045d
movl (%r12,%r15,8), %edx
movq %rcx, %rdi
movq %r14, %rsi
xorl %eax, %eax
callq 0x3340
incq %r15
jmp 0x1043f
leaq 0x5dcd(%rip), %rdi      # 0x16231
pushq $0x5
popq %rsi
pushq $0x1
popq %rdx
callq 0x3550
leaq 0x5dc1(%rip), %r14      # 0x16237
xorl %r15d, %r15d
movq (%rbx), %rcx
cmpq %r15, %rbp
movq %r12, %rax
je 0x1049a
movl (%rax,%r15,8), %edx
movq %rcx, %rdi
movq %r14, %rsi
xorl %eax, %eax
callq 0x3340
incq %r15
jmp 0x10479
movq %rax, %rbx
leaq 0x5a5b(%rip), %rdi      # 0x15eff
pushq $0x2
popq %rsi
pushq $0x1
popq %rdx
callq 0x3550
movq %rbx, %rdi
callq 0x3050
jmp 0x10338
movq %rdi, %r12
movq 0x28(%rsp), %r13
movq 0x8(%rsp), %rbp
jmp 0x10419
leaq 0x5c52(%rip), %rdi      # 0x16127
leaq 0x5bc2(%rip), %rsi      # 0x1609e
leaq 0x5bdd(%rip), %rcx      # 0x160c0
movl $0xf6, %edx
callq 0x3220
leaq 0x5c42(%rip), %rdi      # 0x16136
leaq 0x5ba3(%rip), %rsi      # 0x1609e
leaq 0x5bbe(%rip), %rcx      # 0x160c0
movl $0xf7, %edx
callq 0x3220
leaq 0x5b7d(%rip), %rdi      # 0x16090
leaq 0x5b84(%rip), %rsi      # 0x1609e
leaq 0x5b9f(%rip), %rcx      # 0x160c0
movl $0xf3, %edx
callq 0x3220
pushq $-0x1
popq %rdi
callq 0x3540
leaq 0x5c0a(%rip), %rdi      # 0x16144
leaq 0x5b5d(%rip), %rsi      # 0x1609e
leaq 0x5c84(%rip), %rcx      # 0x161cc
movl $0xa7, %edx
callq 0x3220