// File: /workspace/github_c_makefile_star2_O1/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 $0x108, %rsp            # imm = 0x108
movq %r8, 0x10(%rsp)
movq 0x10(%rsi), %rbp
cmpq $0xa, %rbp
jae 0x108d6
addq $0x108, %rsp            # imm = 0x108
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rcx, %r13
movq %rsi, %r14
movq %rdi, 0x50(%rsp)
movq %rdx, %rbx
movq %rbp, %rdi
callq 0x33d0
testq %rax, %rax
je 0x10d99
movq %rax, %r12
xorl %r15d, %r15d
movq %rax, %rdi
xorl %esi, %esi
movq %rbp, %rdx
callq 0x3260
movq %rbx, %rcx
decq %rcx
movl $0x1, %edx
movq %r12, 0x38(%rsp)
movq %r13, 0x58(%rsp)
movq %rcx, 0x30(%rsp)
cmpq %rdx, %rcx
jae 0x1092e
xorl %eax, %eax
jmp 0x10c49
cmpq %rbp, %r15
jae 0x10d3c
movq %rdx, 0x18(%rsp)
leaq 0x1(%r15), %rcx
movq %rbp, %rax
subq %rcx, %rax
cmpq $0x3ff, %rax            # imm = 0x3FF
movq %rcx, 0x40(%rsp)
ja 0x109c8
movsd 0x66ed(%rip), %xmm0     # 0x17048
movq %rcx, %rbx
cmpq %rcx, %rbp
jbe 0x10ad8
movq 0x40(%rsp), %rbx
movq %rbx, %r13
movsd 0x66d1(%rip), %xmm1     # 0x17048
movsd %xmm1, 0x8(%rsp)
movq %r14, %rdi
movq %r15, %rsi
movq %r13, %rdx
callq 0xedab
movsd %xmm0, 0x28(%rsp)
movq %r14, %rdi
movq %r13, %rsi
movq %rbp, %rdx
callq 0xedab
addsd 0x28(%rsp), %xmm0
movsd 0x8(%rsp), %xmm1
ucomisd %xmm0, %xmm1
cmovaq %r13, %rbx
minsd %xmm1, %xmm0
incq %r13
movapd %xmm0, %xmm1
cmpq %r13, %rbp
jne 0x10977
jmp 0x10ad8
movq %rcx, %rbx
movsd 0x6675(%rip), %xmm2     # 0x17048
movq %rcx, %rsi
movq %rbp, 0x48(%rsp)
movq %rbx, 0x68(%rsp)
movsd %xmm2, 0x20(%rsp)
movabsq $-0x3333333333333333, %rcx # imm = 0xCCCCCCCCCCCCCCCD
mulq %rcx
shrq $0x3, %rdx
movq %rsi, 0x60(%rsp)
movq %rdx, 0x28(%rsp)
leaq (%rsi,%rdx), %r12
xorl %ebx, %ebx
movq %r15, %r13
movq %rbp, %r15
leaq 0x1(%rbx), %rbp
movq %r12, 0x70(%rsp,%rbx,8)
movq %r14, %rdi
movq %r13, %rsi
movq %r12, %rdx
callq 0xedab
movsd %xmm0, 0x8(%rsp)
movq %r14, %rdi
movq %r12, %rsi
movq %r15, %rdx
callq 0xedab
addsd 0x8(%rsp), %xmm0
movsd %xmm0, 0xc0(%rsp,%rbx,8)
addq 0x28(%rsp), %r12
movq %rbp, %rbx
cmpq $0x9, %rbp
jne 0x10a0d
movl $0x1, %ecx
movsd 0xc0(%rsp), %xmm2
xorl %eax, %eax
movapd %xmm2, %xmm1
movsd 0xc0(%rsp,%rcx,8), %xmm2
ucomisd %xmm2, %xmm1
cmovaq %rcx, %rax
minsd %xmm1, %xmm2
incq %rcx
cmpq $0x9, %rcx
jne 0x10a65
movsd 0x20(%rsp), %xmm0
ucomisd %xmm0, %xmm2
movq %r15, %rbp
movq %r13, %r15
movq 0x68(%rsp), %rbx
movq 0x60(%rsp), %rsi
ja 0x10ad8
testq %rax, %rax
je 0x10aad
movq 0x68(%rsp,%rax,8), %rsi
cmpq $0x8, %rax
je 0x10abd
movq 0x78(%rsp,%rax,8), %rcx
movq %rcx, 0x48(%rsp)
movq 0x70(%rsp,%rax,8), %rbx
movq 0x48(%rsp), %rax
subq %rsi, %rax
movapd %xmm2, %xmm0
cmpq $0x9, %rax
ja 0x109db
cmpq %r15, %rbx
jbe 0x10d7a
movsd %xmm0, 0x20(%rsp)
cmpq %rbp, %rbx
movq 0x38(%rsp), %r12
movq 0x58(%rsp), %r13
jae 0x10d5b
movq %r14, %rdi
movq %r15, %rsi
movq %rbp, %rdx
callq 0xedab
movsd 0x20(%rsp), %xmm1
ucomisd %xmm0, %xmm1
ja 0x10b40
cmpq 0x40(%rsp), %rbx
je 0x10b40
movq 0x10(%rsp), %rax
movq (%rax), %rsi
leaq -0x1(%rsi), %rax
testq %rax, %rsi
jne 0x10b55
testq %rsi, %rsi
je 0x10b47
movq (%r13), %rdi
shlq $0x4, %rsi
callq 0x3430
jmp 0x10b51
movb $0x1, (%r12,%r15)
jmp 0x10bbd
movl $0x8, %edi
callq 0x33d0
movq %rax, (%r13)
movq (%r13), %rax
movq 0x10(%rsp), %rsi
movq (%rsi), %rcx
movq %rbx, (%rax,%rcx,8)
movq (%rsi), %rcx
leaq 0x1(%rcx), %rdx
cmpq $0x1, %rdx
movq %rcx, %rdi
adcq $0x1, %rdi
movq %rdx, (%rsi)
movl $0x1, %esi
subq %rdi, %rsi
movq $-0x1, %rdi
leaq (%rsi,%rdi), %rdx
cmpq $-0x1, %rdx
je 0x10bb8
leaq 0x1(%rdi), %rdx
cmpq %rbx, 0x8(%rax,%rdi,8)
movq %rdx, %rdi
jbe 0x10b89
jmp 0x10baf
movq -0x8(%rax,%rcx,8), %rsi
movq %rsi, (%rax,%rcx,8)
decq %rcx
cmpq %rdx, %rcx
ja 0x10ba3
movq %rbx, (%rax,%rdx,8)
incq 0x18(%rsp)
movq 0x10(%r14), %rax
movq 0x10(%rsp), %rcx
movq (%rcx), %rcx
decq %rax
leaq 0x1(%rcx), %rdx
cmpq $0x1, %rdx
movq %rcx, %rdx
adcq $0x1, %rdx
movq (%r13), %rsi
xorl %r8d, %r8d
xorl %edi, %edi
xorl %r9d, %r9d
testq %r9, %r9
je 0x10bf3
movq -0x8(%rsi,%r9,8), %r10
jmp 0x10bf6
xorl %r10d, %r10d
movq %rax, %r11
cmpq %r9, %rcx
je 0x10c02
movq (%rsi,%r9,8), %r11
cmpb $0x0, (%r12,%r10)
jne 0x10c22
movq %r11, %rbx
subq %r10, %rbx
cmpq %r8, %rbx
jbe 0x10c22
movl $0x1, %edi
movq %r11, %rbp
movq %r10, %r15
movq %rbx, %r8
incq %r9
cmpq %r9, %rdx
jne 0x10be7
testl %edi, %edi
je 0x10c3d
movq %rbp, %rax
subq %r15, %rax
cmpq $0xa, %rax
setae %al
jmp 0x10c3f
xorl %eax, %eax
movq 0x30(%rsp), %rcx
movq 0x18(%rsp), %rdx
testb %al, %al
jne 0x10922
movq 0x50(%rsp), %rax
cmpl $0x0, (%rax)
jne 0x10c74
movq %r12, %rdi
addq $0x108, %rsp            # imm = 0x108
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x3050
movq 0x10(%rsp), %rax
movq (%rax), %r12
xorl %r15d, %r15d
movl $0x0, %eax
testq %r12, %r12
je 0x10d22
xorl %r15d, %r15d
cmpq $0x0, 0x10(%r14)
movl $0x0, %eax
je 0x10d22
movq (%r13), %rsi
xorl %eax, %eax
xorl %r13d, %r13d
xorl %ebp, %ebp
xorl %r15d, %r15d
movq %rsi, 0x8(%rsp)
movq 0x8(%r14), %rcx
cmpw $0x0, (%rcx,%rbp,2)
je 0x10cc7
movq (%r14), %rcx
movzwl (%rcx,%rbp,2), %ebx
jmp 0x10ccc
movl $0x1, %ebx
cmpq (%rsi,%r15,8), %rbp
jne 0x10d10
leaq -0x1(%r15), %rcx
testq %rcx, %r15
jne 0x10d00
testq %r15, %r15
je 0x10cf1
movq %r15, %rsi
shlq $0x4, %rsi
movq %rax, %rdi
callq 0x3430
jmp 0x10cfb
movl $0x8, %edi
callq 0x33d0
movq 0x8(%rsp), %rsi
movq %r13, (%rax,%r15,8)
incq %r15
cmpq %r12, %r15
jne 0x10d10
xorl %ecx, %ecx
jmp 0x10d15
addq %rbx, %r13
movb $0x1, %cl
testb %cl, %cl
je 0x10d22
incq %rbp
cmpq 0x10(%r14), %rbp
jb 0x10cb3
cmpq %r12, %r15
jne 0x10da3
movq %r15, %rdi
movq %rax, %rsi
callq 0x37e3
movq 0x38(%rsp), %r12
jmp 0x10c5b
leaq 0x630d(%rip), %rdi      # 0x17050
leaq 0x6314(%rip), %rsi      # 0x1705e
leaq 0x632f(%rip), %rcx      # 0x17080
movl $0xf3, %edx
callq 0x3220
leaq 0x6394(%rip), %rdi      # 0x170f6
leaq 0x62f5(%rip), %rsi      # 0x1705e
leaq 0x6310(%rip), %rcx      # 0x17080
movl $0xf7, %edx
callq 0x3220
leaq 0x6366(%rip), %rdi      # 0x170e7
leaq 0x62d6(%rip), %rsi      # 0x1705e
leaq 0x62f1(%rip), %rcx      # 0x17080
movl $0xf6, %edx
callq 0x3220
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x3540
leaq 0x635a(%rip), %rdi      # 0x17104
leaq 0x62ad(%rip), %rsi      # 0x1705e
leaq 0x63d4(%rip), %rcx      # 0x1718c
movl $0xa7, %edx
callq 0x3220