// File: /workspace/github_c_makefile_star2_O0/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:
subq $0xa8, %rsp
movq 0xb0(%rsp), %rax
movq %rdi, 0xa0(%rsp)
movq %rsi, 0x98(%rsp)
movq %rdx, 0x90(%rsp)
movq %rcx, 0x88(%rsp)
movq %r8, 0x80(%rsp)
movq %r9, 0x78(%rsp)
movq $0x0, 0x70(%rsp)
movq $0x0, 0x40(%rsp)
movq $0x0, 0x38(%rsp)
leaq 0x20(%rsp), %rdi
callq 0x7820
movq 0xa0(%rsp), %rax
movq %rax, 0x48(%rsp)
movq 0x90(%rsp), %rax
movq %rax, 0x58(%rsp)
movq 0x88(%rsp), %rax
movq %rax, 0x60(%rsp)
movq $0x0, 0x50(%rsp)
movq 0xb0(%rsp), %rax
movq $0x0, (%rax)
movq 0x78(%rsp), %rax
movq $0x0, (%rax)
movq 0x98(%rsp), %rsi
movq 0x90(%rsp), %rdx
movq 0x88(%rsp), %rcx
leaq 0x48(%rsp), %rdi
leaq 0x20(%rsp), %r8
callq 0x8bb0
movq 0xa0(%rsp), %rdi
movq 0x20(%rsp), %rsi
movq 0x28(%rsp), %rdx
movq 0x30(%rsp), %rcx
movq 0x80(%rsp), %r8
leaq 0x40(%rsp), %r9
leaq 0x38(%rsp), %rax
movq %rax, (%rsp)
callq 0x1290
movq 0x90(%rsp), %rax
movq %rax, 0x70(%rsp)
cmpq $0x0, 0x38(%rsp)
jbe 0x217c
movq $0x0, 0x68(%rsp)
movq 0x68(%rsp), %rax
cmpq 0x30(%rsp), %rax
jae 0x217a
movq 0x28(%rsp), %rax
movq 0x68(%rsp), %rcx
movzwl (%rax,%rcx,2), %eax
cmpl $0x0, %eax
jne 0x2065
movl $0x1, %eax
movl %eax, 0x14(%rsp)
jmp 0x2077
movq 0x20(%rsp), %rax
movq 0x68(%rsp), %rcx
movzwl (%rax,%rcx,2), %eax
movl %eax, 0x14(%rsp)
movl 0x14(%rsp), %eax
cltq
movq %rax, 0x18(%rsp)
movq 0x40(%rsp), %rax
movq 0xb0(%rsp), %rcx
movq (%rcx), %rcx
movq (%rax,%rcx,8), %rax
cmpq 0x68(%rsp), %rax
jne 0x2158
movq 0xb0(%rsp), %rax
movq (%rax), %rax
movq 0xb0(%rsp), %rcx
movq (%rcx), %rcx
subq $0x1, %rcx
andq %rcx, %rax
cmpq $0x0, %rax
jne 0x2114
movq 0xb0(%rsp), %rax
cmpq $0x0, (%rax)
jne 0x20e3
movl $0x8, %edi
callq 0x1120
movq %rax, 0x8(%rsp)
jmp 0x2107
movq 0x78(%rsp), %rax
movq (%rax), %rdi
movq 0xb0(%rsp), %rax
movq (%rax), %rsi
shlq %rsi
shlq $0x3, %rsi
callq 0x1140
movq %rax, 0x8(%rsp)
movq 0x8(%rsp), %rcx
movq 0x78(%rsp), %rax
movq %rcx, (%rax)
movq 0x70(%rsp), %rdx
movq 0x78(%rsp), %rax
movq (%rax), %rax
movq 0xb0(%rsp), %rcx
movq (%rcx), %rcx
movq %rdx, (%rax,%rcx,8)
movq 0xb0(%rsp), %rax
movq (%rax), %rcx
addq $0x1, %rcx
movq %rcx, (%rax)
movq 0xb0(%rsp), %rax
movq (%rax), %rax
cmpq 0x38(%rsp), %rax
jne 0x2156
jmp 0x217a
jmp 0x2158
movq 0x18(%rsp), %rax
addq 0x70(%rsp), %rax
movq %rax, 0x70(%rsp)
movq 0x68(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x68(%rsp)
jmp 0x2037
jmp 0x217c
movq 0xb0(%rsp), %rax
movq (%rax), %rax
cmpq 0x38(%rsp), %rax
jne 0x2190
jmp 0x21af
leaq 0xaf39(%rip), %rdi      # 0xd0d0
leaq 0xae80(%rip), %rsi      # 0xd01e
movl $0x148, %edx            # imm = 0x148
leaq 0xaf3e(%rip), %rcx      # 0xd0e8
callq 0x10b0
movq 0x40(%rsp), %rdi
callq 0x1030
leaq 0x20(%rsp), %rdi
callq 0x7850
addq $0xa8, %rsp
retq
nopl (%rax,%rax)