// File: /workspace/github_c_makefile_star2_O1/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, %r13
movq %r8, 0x8(%rsp)
movq %rcx, 0x18(%rsp)
movq %rdx, %r14
movq %rsi, 0x20(%rsp)
movq %rdi, %rbp
movq 0xa0(%rsp), %r12
xorl %ebx, %ebx
leaq 0x10(%rsp), %rax
movq %rbx, (%rax)
leaq 0x40(%rsp), %rax
movq %rbx, (%rax)
leaq 0x28(%rsp), %r15
movq %r15, %rdi
callq 0x6684
leaq 0x48(%rsp), %rdi
movq %rbp, (%rdi)
movq %r14, 0x10(%rdi)
movq 0x18(%rsp), %rcx
movq %rcx, 0x18(%rdi)
movq %rbx, 0x8(%rdi)
movq %rbx, (%r12)
movq %rbx, (%r13)
movq 0x20(%rsp), %rsi
movq %r14, %rdx
movq %r15, %r8
callq 0x70e6
movq (%r15), %rsi
movq 0x8(%r15), %rdx
movq 0x10(%r15), %rcx
leaq 0x40(%rsp), %rbx
movq %rbx, (%rsp)
movq %rbp, %rdi
movq 0x8(%rsp), %r8
leaq 0x10(%rsp), %r9
callq 0x14bc
movq (%rbx), %rdi
testq %rdi, %rdi
je 0x1bec
cmpq $0x0, 0x38(%rsp)
je 0x1bec
movq %r13, %r15
movq 0x10(%rsp), %r8
xorl %ebp, %ebp
movq %r8, 0x8(%rsp)
movq 0x30(%rsp), %rax
cmpw $0x0, (%rax,%rbp,2)
je 0x1b6d
movq 0x28(%rsp), %rax
movzwl (%rax,%rbp,2), %ebx
jmp 0x1b72
movl $0x1, %ebx
movq (%r12), %rsi
cmpq (%r8,%rsi,8), %rbp
jne 0x1bd5
leaq -0x1(%rsi), %rax
testq %rax, %rsi
jne 0x1bb6
movq %r12, %r13
movq %rdi, %r12
testq %rsi, %rsi
je 0x1b9e
movq (%r15), %rdi
shlq $0x4, %rsi
callq 0x1140
jmp 0x1ba8
movl $0x8, %edi
callq 0x1120
movq %rax, (%r15)
movq %r12, %rdi
movq %r13, %r12
movq 0x8(%rsp), %r8
movq (%r15), %rax
movq (%r12), %rcx
movq %r14, (%rax,%rcx,8)
movq (%r12), %rax
incq %rax
movq %rax, (%r12)
cmpq %rdi, %rax
jne 0x1bd5
xorl %eax, %eax
jmp 0x1bda
addq %rbx, %r14
movb $0x1, %al
testb %al, %al
je 0x1bec
incq %rbp
cmpq 0x38(%rsp), %rbp
jb 0x1b56
cmpq %rdi, (%r12)
jne 0x1c15
movq 0x10(%rsp), %rdi
callq 0x1030
leaq 0x28(%rsp), %rdi
callq 0x6693
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x84b4(%rip), %rdi      # 0xa0d0
leaq 0x83fb(%rip), %rsi      # 0xa01e
leaq 0x84be(%rip), %rcx      # 0xa0e8
movl $0x148, %edx            # imm = 0x148
callq 0x10b0