// File: /workspace/github_c_makefile_star2_O3/imaya[P]zopfli-for-emscripten/blocksplitter.c
// Function: ZopfliBlockSplit
void ZopfliBlockSplit(const ZopfliOptions* options,
                      const unsigned char* in, size_t instart, size_t inend,
                      size_t maxblocks, size_t** splitpoints, size_t* npoints) {
  size_t pos = 0;
  size_t i;
  ZopfliBlockState s;
  size_t* lz77splitpoints = 0;
  size_t nlz77points = 0;
  ZopfliLZ77Store store;

  ZopfliInitLZ77Store(&store);

  s.options = options;
  s.blockstart = instart;
  s.blockend = inend;
#ifdef ZOPFLI_LONGEST_MATCH_CACHE
  s.lmc = 0;
#endif

  *npoints = 0;
  *splitpoints = 0;

  /* Unintuitively, Using a simple LZ77 method here instead of ZopfliLZ77Optimal
  results in better blocks. */
  ZopfliLZ77Greedy(&s, in, instart, inend, &store);

  ZopfliBlockSplitLZ77(options,
                       store.litlens, store.dists, store.size, maxblocks,
                       &lz77splitpoints, &nlz77points);

  /* Convert LZ77 positions to positions in the uncompressed input. */
  pos = instart;
  if (nlz77points > 0) {
    for (i = 0; i < store.size; i++) {
      size_t length = store.dists[i] == 0 ? 1 : store.litlens[i];
      if (lz77splitpoints[*npoints] == i) {
        ZOPFLI_APPEND_DATA(pos, splitpoints, npoints);
        if (*npoints == nlz77points) break;
      }
      pos += length;
    }
  }
  assert(*npoints == nlz77points);

  free(lz77splitpoints);
  ZopfliCleanLZ77Store(&store);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movq %r9, %rbp
movq %r8, 0x8(%rsp)
movq %rcx, %r13
movq %rdx, %r14
movq %rsi, 0x20(%rsp)
movq %rdi, %r12
xorl %ebx, %ebx
leaq 0x10(%rsp), %rax
movq %rbx, (%rax)
leaq 0x28(%rsp), %rax
movq %rbx, (%rax)
leaq 0x30(%rsp), %r15
movq %r15, %rdi
callq 0x6824
leaq 0x48(%rsp), %rdi
movq %r12, (%rdi)
movq %r14, 0x10(%rdi)
movq %r13, 0x18(%rdi)
movq %rbx, 0x8(%rdi)
movq 0xa0(%rsp), %rax
movq %rbx, (%rax)
movq %rbp, 0x18(%rsp)
movq %rbx, (%rbp)
movq 0x20(%rsp), %rsi
movq %r14, %rdx
movq %r13, %rcx
movq %r15, %r8
callq 0x7215
movq (%r15), %rsi
movq 0x8(%r15), %rdx
movq 0x10(%r15), %rcx
leaq 0x28(%rsp), %rbx
movq %rbx, (%rsp)
movq %r12, %rdi
movq 0x8(%rsp), %r8
leaq 0x10(%rsp), %r9
callq 0x14cc
movq (%rbx), %rdi
testq %rdi, %rdi
setne %cl
movq 0x10(%r15), %rax
testq %rax, %rax
setne %dl
testb %dl, %cl
je 0x1bec
movq 0x10(%rsp), %r9
xorl %ebp, %ebp
movq 0x18(%rsp), %r13
movq 0xa0(%rsp), %r12
movq %r9, 0x8(%rsp)
movq 0x38(%rsp), %rcx
cmpw $0x0, (%rcx,%rbp,2)
je 0x1b71
movq 0x30(%rsp), %rcx
movzwl (%rcx,%rbp,2), %ebx
jmp 0x1b76
movl $0x1, %ebx
movq (%r12), %rsi
cmpq (%r9,%rsi,8), %rbp
jne 0x1bdb
leaq -0x1(%rsi), %rax
testq %rax, %rsi
jne 0x1ba4
movq %rdi, %r15
testq %rsi, %rsi
je 0x1baa
movq (%r13), %rdi
shlq $0x4, %rsi
callq 0x1150
movq (%r12), %rsi
jmp 0x1bb6
movq (%r13), %rax
jmp 0x1bc2
movl $0x8, %edi
callq 0x1130
xorl %esi, %esi
movq %rax, (%r13)
movq %r15, %rdi
movq 0x8(%rsp), %r9
movq %r14, (%rax,%rsi,8)
movq (%r12), %rsi
incq %rsi
movq %rsi, (%r12)
cmpq %rdi, %rsi
je 0x1bfc
movq 0x40(%rsp), %rax
addq %rbx, %r14
incq %rbp
cmpq %rax, %rbp
jb 0x1b5a
jmp 0x1bf7
movq 0xa0(%rsp), %rax
movq (%rax), %rsi
cmpq %rdi, %rsi
jne 0x1c1f
movq 0x10(%rsp), %rdi
callq 0x1030
leaq 0x30(%rsp), %rdi
callq 0x6833
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x84aa(%rip), %rdi      # 0xa0d0
leaq 0x83f1(%rip), %rsi      # 0xa01e
leaq 0x84b4(%rip), %rcx      # 0xa0e8
movl $0x148, %edx            # imm = 0x148
callq 0x10b0