// File: /workspace/github_c_makefile_star2_O2/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, %rbx
movq %r8, 0x8(%rsp)
movq %rcx, %rbp
movq %rdx, %r14
movq %rsi, 0x20(%rsp)
movq %rdi, %r13
leaq 0x10(%rsp), %rax
andq $0x0, (%rax)
leaq 0x40(%rsp), %r12
andq $0x0, (%r12)
leaq 0x28(%rsp), %r15
movq %r15, %rdi
callq 0x439c
leaq 0x48(%rsp), %rdi
movq %r13, (%rdi)
movq %r14, 0x10(%rdi)
movq %rbp, 0x18(%rdi)
andq $0x0, 0x8(%rdi)
movq 0xa0(%rsp), %rax
andq $0x0, (%rax)
movq %rbx, 0x18(%rsp)
andq $0x0, (%rbx)
movq 0x20(%rsp), %rsi
movq %r14, %rdx
movq %rbp, %rcx
movq %r15, %r8
callq 0x4d4c
movq (%r15), %rsi
movq 0x8(%r15), %rdx
movq 0x10(%r15), %rcx
movq %r12, (%rsp)
movq %r13, %rdi
movq 0x8(%rsp), %r8
leaq 0x10(%rsp), %r9
callq 0x128c
movq 0xa0(%rsp), %rdx
movq (%r12), %rcx
testq %rcx, %rcx
je 0x19fe
movq 0x10(%rsp), %rbp
xorl %r15d, %r15d
pushq $0x1
popq %rdi
movq %rcx, 0x8(%rsp)
movq 0x18(%rsp), %r13
cmpq 0x38(%rsp), %r15
jae 0x19fe
movq 0x30(%rsp), %rax
cmpw $0x0, (%rax,%r15,2)
movq %rdi, %rbx
je 0x198d
movq 0x28(%rsp), %rax
movzwl (%rax,%r15,2), %ebx
movq (%rdx), %rsi
cmpq (%rbp,%rsi,8), %r15
jne 0x19f3
leaq -0x1(%rsi), %rax
testq %rax, %rsi
jne 0x19be
movq %rdx, %r12
testq %rsi, %rsi
je 0x19c8
movq (%r13), %rdi
shlq $0x4, %rsi
callq 0x1140
movq %r12, %rdx
movq (%r12), %rsi
jmp 0x19d5
movq 0x18(%rsp), %rax
movq (%rax), %rax
jmp 0x19e1
pushq $0x8
popq %rdi
callq 0x1120
xorl %esi, %esi
movq %r12, %rdx
movq %rax, (%r13)
movq 0x8(%rsp), %rcx
pushq $0x1
popq %rdi
movq %r14, (%rax,%rsi,8)
movq (%rdx), %rax
incq %rax
movq %rax, (%rdx)
cmpq %rcx, %rax
je 0x19fe
addq %rbx, %r14
incq %r15
jmp 0x1968
cmpq %rcx, (%rdx)
jne 0x1a26
movq 0x10(%rsp), %rdi
callq 0x1030
leaq 0x28(%rsp), %rdi
callq 0x43a8
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x56a3(%rip), %rdi      # 0x70d0
leaq 0x55ea(%rip), %rsi      # 0x701e
leaq 0x56ad(%rip), %rcx      # 0x70e8
movl $0x148, %edx            # imm = 0x148
callq 0x10b0