// File: /workspace/github_c_makefile_star2_O3/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, 0x18(%rsp)
movq %rdx, 0x38(%rsp)
movq 0x10(%rsi), %r12
cmpq $0xa, %r12
jae 0x10dd7
addq $0x108, %rsp            # imm = 0x108
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rcx, %rbx
movq %rsi, %r14
movq %rdi, %r15
movl $0x1, %edi
movq %r12, %rsi
callq 0x3310
testq %rax, %rax
je 0x112ca
movq %rax, %rbp
movq %r15, 0x58(%rsp)
movq %rbx, 0x10(%rsp)
decq 0x38(%rsp)
movq %rax, 0x30(%rsp)
je 0x1117e
movl $0x1, %eax
movq %rax, 0x40(%rsp)
xorl %r15d, %r15d
cmpq %r12, %r15
jae 0x1128c
leaq 0x1(%r15), %rcx
movq %r12, %rax
subq %rcx, %rax
cmpq $0x3ff, %rax            # imm = 0x3FF
movq %r12, 0x28(%rsp)
movq %rcx, 0x48(%rsp)
movq %rcx, %r13
ja 0x10eba
movsd 0x6238(%rip), %xmm0     # 0x17088
cmpq %rcx, %r12
jbe 0x10fcc
movq 0x48(%rsp), %r13
movq %r13, %rbp
movsd 0x621f(%rip), %xmm1     # 0x17088
movsd %xmm1, 0x8(%rsp)
movq %r14, %rdi
movq %r15, %rsi
movq %rbp, %rdx
callq 0xf1ee
movsd %xmm0, 0x20(%rsp)
movq %r14, %rdi
movq %rbp, %rsi
movq %r12, %rdx
callq 0xf1ee
addsd 0x20(%rsp), %xmm0
movsd 0x8(%rsp), %xmm1
ucomisd %xmm0, %xmm1
cmovaq %rbp, %r13
minsd %xmm1, %xmm0
incq %rbp
movapd %xmm0, %xmm1
cmpq %rbp, %r12
jne 0x10e69
jmp 0x10fbe
movsd 0x61c6(%rip), %xmm2     # 0x17088
movq %rcx, %rsi
movq %r12, 0x50(%rsp)
movq %r13, 0x68(%rsp)
movsd %xmm2, 0x20(%rsp)
movabsq $-0x3333333333333333, %rcx # imm = 0xCCCCCCCCCCCCCCCD
mulq %rcx
movq %rdx, %rbp
shrq $0x3, %rbp
movq %rsi, 0x60(%rsp)
leaq (%rsi,%rbp), %r12
xorl %ebx, %ebx
leaq 0x1(%rbx), %r13
movq %r12, 0x70(%rsp,%rbx,8)
movq %r14, %rdi
movq %r15, %rsi
movq %r12, %rdx
callq 0xf1ee
movsd %xmm0, 0x8(%rsp)
movq %r14, %rdi
movq %r12, %rsi
movq 0x28(%rsp), %rdx
callq 0xf1ee
addsd 0x8(%rsp), %xmm0
movsd %xmm0, 0xc0(%rsp,%rbx,8)
addq %rbp, %r12
movq %r13, %rbx
cmpq $0x9, %r13
jne 0x10ef4
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 0x10f4c
movsd 0x20(%rsp), %xmm0
ucomisd %xmm0, %xmm2
movq 0x28(%rsp), %r12
movq 0x68(%rsp), %r13
movq 0x60(%rsp), %rsi
ja 0x10fbe
testq %rax, %rax
je 0x10f99
movq 0x68(%rsp,%rax,8), %rsi
cmpq $0x8, %rax
je 0x10fa3
movq 0x78(%rsp,%rax,8), %rcx
movq %rcx, 0x50(%rsp)
movq 0x70(%rsp,%rax,8), %r13
movq 0x50(%rsp), %rax
subq %rsi, %rax
movapd %xmm2, %xmm0
cmpq $0x9, %rax
ja 0x10eca
cmpq %r15, %r13
movq 0x30(%rsp), %rbp
jbe 0x112ab
movsd %xmm0, 0x20(%rsp)
cmpq %r12, %r13
jae 0x1126d
movq %r14, %rdi
movq %r15, %rsi
movq %r12, %rdx
callq 0xf1ee
movsd 0x20(%rsp), %xmm1
ucomisd %xmm0, %xmm1
ja 0x1102d
cmpq 0x48(%rsp), %r13
je 0x1102d
movq 0x18(%rsp), %rax
movq (%rax), %rsi
leaq -0x1(%rsi), %rax
testq %rax, %rsi
jne 0x1103d
testq %rsi, %rsi
je 0x11047
movq 0x10(%rsp), %rbx
movq (%rbx), %rdi
shlq $0x4, %rsi
callq 0x3440
movq 0x18(%rsp), %rcx
movq (%rcx), %rsi
jmp 0x11058
movb $0x1, (%rbp,%r15)
movq 0x10(%rsp), %rax
movq (%rax), %rax
jmp 0x110bc
movq 0x10(%rsp), %rax
movq (%rax), %rax
jmp 0x1105b
movl $0x8, %edi
callq 0x33e0
xorl %esi, %esi
movq 0x10(%rsp), %rbx
movq %rax, (%rbx)
movq %r13, (%rax,%rsi,8)
movq 0x18(%rsp), %rsi
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 0x110b7
leaq 0x1(%rdi), %rdx
cmpq %r13, 0x8(%rax,%rdi,8)
movq %rdx, %rdi
jbe 0x11088
jmp 0x110ae
movq -0x8(%rax,%rcx,8), %rsi
movq %rsi, (%rax,%rcx,8)
decq %rcx
cmpq %rdx, %rcx
ja 0x110a2
movq %r13, (%rax,%rdx,8)
incq 0x40(%rsp)
movq 0x10(%r14), %rcx
movq 0x18(%rsp), %rdx
movq (%rdx), %rdx
leaq -0x1(%rcx), %rsi
leaq 0x1(%rdx), %rdi
cmpq $0x1, %rdi
movq %rdx, %rdi
adcq $0x1, %rdi
negq %rdi
negq %rdx
movb $0x1, %r8b
xorl %r10d, %r10d
xorl %r9d, %r9d
incq %r9
cmpq $0x1, %r9
jne 0x110f8
xorl %r11d, %r11d
jmp 0x110fd
movq -0x10(%rax,%r9,8), %r11
leaq (%rdx,%r9), %r12
movq %rsi, %rbx
cmpq $0x1, %r12
je 0x1110f
movq -0x8(%rax,%r9,8), %rbx
cmpb $0x0, (%rbp,%r11)
jne 0x11122
movq %rbx, %r12
subq %r11, %r12
cmpq %r10, %r12
ja 0x11134
leaq (%rdi,%r9), %r11
incq %r11
incq %r9
cmpq $0x1, %r11
jne 0x110ed
jmp 0x1114c
xorl %r8d, %r8d
movq %rdi, %r13
movq %rbx, 0x28(%rsp)
movq %r11, %r15
movq %r12, %r10
addq %r9, %r13
jne 0x110ea
jmp 0x11160
testb $0x1, %r8b
movq 0x28(%rsp), %rbx
jne 0x11181
movq %rbx, %r12
subq %r15, %r12
movq %r15, %r11
cmpq $0xa, %r12
jb 0x11181
movq %r11, %r15
movq %rbx, %r12
movq 0x40(%rsp), %rax
cmpq %rax, 0x38(%rsp)
jae 0x10e20
jmp 0x11181
movq %r12, %rcx
movq 0x58(%rsp), %rax
cmpl $0x0, (%rax)
jne 0x111a4
movq %rbp, %rdi
addq $0x108, %rsp            # imm = 0x108
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x3050
movq 0x18(%rsp), %rax
movq (%rax), %r12
testq %r12, %r12
sete %al
testq %rcx, %rcx
sete %dl
xorl %ebx, %ebx
orb %al, %dl
movl $0x0, %eax
jne 0x11247
movq 0x10(%rsp), %rax
movq (%rax), %rdi
xorl %eax, %eax
xorl %r13d, %r13d
xorl %ebp, %ebp
xorl %ebx, %ebx
movq %rdi, 0x8(%rsp)
movq 0x8(%r14), %rdx
cmpw $0x0, (%rdx,%rbp,2)
je 0x111f2
movq (%r14), %rdx
movzwl (%rdx,%rbp,2), %r15d
jmp 0x111f8
movl $0x1, %r15d
cmpq (%rdi,%rbx,8), %rbp
jne 0x1123c
leaq -0x1(%rbx), %rcx
testq %rcx, %rbx
jne 0x1122c
testq %rbx, %rbx
je 0x1121d
movq %rbx, %rsi
shlq $0x4, %rsi
movq %rax, %rdi
callq 0x3440
jmp 0x11227
movl $0x8, %edi
callq 0x33e0
movq 0x8(%rsp), %rdi
movq %r13, (%rax,%rbx,8)
incq %rbx
cmpq %r12, %rbx
je 0x11250
movq 0x10(%r14), %rcx
addq %r15, %r13
incq %rbp
cmpq %rcx, %rbp
jb 0x111dd
cmpq %r12, %rbx
jne 0x112d4
xorl %edx, %edx
testq %r12, %r12
sete %dl
movq %rax, %rdi
movq %r12, %rsi
callq 0x381e
movq 0x30(%rsp), %rbp
jmp 0x1118b
leaq 0x5ec2(%rip), %rdi      # 0x17136
leaq 0x5e23(%rip), %rsi      # 0x1709e
leaq 0x5e3e(%rip), %rcx      # 0x170c0
movl $0xf7, %edx
callq 0x3220
leaq 0x5dfd(%rip), %rdi      # 0x17090
leaq 0x5e04(%rip), %rsi      # 0x1709e
leaq 0x5e1f(%rip), %rcx      # 0x170c0
movl $0xf3, %edx
callq 0x3220
leaq 0x5e75(%rip), %rdi      # 0x17127
leaq 0x5de5(%rip), %rsi      # 0x1709e
leaq 0x5e00(%rip), %rcx      # 0x170c0
movl $0xf6, %edx
callq 0x3220
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x3550
leaq 0x5e69(%rip), %rdi      # 0x17144
leaq 0x5dbc(%rip), %rsi      # 0x1709e
leaq 0x5ee3(%rip), %rcx      # 0x171cc
movl $0xa7, %edx
callq 0x3220