// File: /workspace/github_c_makefile_star2_O0/madler[P]pigz/zopfli/src/zopfli/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;
  ZopfliHash hash;
  ZopfliHash* h = &hash;

  ZopfliInitLZ77Store(in, &store);
  ZopfliInitBlockState(options, instart, inend, 0, &s);
  ZopfliAllocHash(ZOPFLI_WINDOW_SIZE, h);

  *npoints = 0;
  *splitpoints = 0;

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

  ZopfliBlockSplitLZ77(options,
                       &store, 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);
  ZopfliCleanBlockState(&s);
  ZopfliCleanLZ77Store(&store);
  ZopfliCleanHash(h);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x120, %rsp            # imm = 0x120
movq 0x10(%rbp), %rax
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movq %r9, -0x30(%rbp)
movq $0x0, -0x38(%rbp)
movq $0x0, -0x68(%rbp)
movq $0x0, -0x70(%rbp)
leaq -0x100(%rbp), %rax
movq %rax, -0x108(%rbp)
movq -0x10(%rbp), %rdi
leaq -0xb8(%rbp), %rsi
callq 0x16b40
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rdx
xorl %ecx, %ecx
leaq -0x60(%rbp), %r8
callq 0x17b20
movq -0x108(%rbp), %rsi
movl $0x8000, %edi           # imm = 0x8000
callq 0x19290
movq 0x10(%rbp), %rax
movq $0x0, (%rax)
movq -0x30(%rbp), %rax
movq $0x0, (%rax)
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
movq -0x20(%rbp), %rcx
movq -0x108(%rbp), %r9
leaq -0x60(%rbp), %rdi
leaq -0xb8(%rbp), %r8
callq 0x189b0
movq -0x8(%rbp), %rdi
movq -0x28(%rbp), %rdx
leaq -0xb8(%rbp), %rsi
leaq -0x68(%rbp), %rcx
leaq -0x70(%rbp), %r8
callq 0x159a0
movq -0x18(%rbp), %rax
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x70(%rbp)
jbe 0x165f2
movq $0x0, -0x40(%rbp)
movq -0x40(%rbp), %rax
cmpq -0xa8(%rbp), %rax
jae 0x165f0
movq -0xb0(%rbp), %rax
movq -0x40(%rbp), %rcx
movzwl (%rax,%rcx,2), %eax
cmpl $0x0, %eax
jne 0x164f7
movl $0x1, %eax
movl %eax, -0x114(%rbp)
jmp 0x1650c
movq -0xb8(%rbp), %rax
movq -0x40(%rbp), %rcx
movzwl (%rax,%rcx,2), %eax
movl %eax, -0x114(%rbp)
movl -0x114(%rbp), %eax
cltq
movq %rax, -0x110(%rbp)
movq -0x68(%rbp), %rax
movq 0x10(%rbp), %rcx
movq (%rcx), %rcx
movq (%rax,%rcx,8), %rax
cmpq -0x40(%rbp), %rax
jne 0x165d0
movq 0x10(%rbp), %rax
movq (%rax), %rax
movq 0x10(%rbp), %rcx
movq (%rcx), %rcx
subq $0x1, %rcx
andq %rcx, %rax
cmpq $0x0, %rax
jne 0x1659b
movq 0x10(%rbp), %rax
cmpq $0x0, (%rax)
jne 0x1656c
movl $0x8, %edi
callq 0x33d0
movq %rax, -0x120(%rbp)
jmp 0x1658d
movq -0x30(%rbp), %rax
movq (%rax), %rdi
movq 0x10(%rbp), %rax
movq (%rax), %rsi
shlq %rsi
shlq $0x3, %rsi
callq 0x3430
movq %rax, -0x120(%rbp)
movq -0x120(%rbp), %rcx
movq -0x30(%rbp), %rax
movq %rcx, (%rax)
movq -0x38(%rbp), %rdx
movq -0x30(%rbp), %rax
movq (%rax), %rax
movq 0x10(%rbp), %rcx
movq (%rcx), %rcx
movq %rdx, (%rax,%rcx,8)
movq 0x10(%rbp), %rax
movq (%rax), %rcx
addq $0x1, %rcx
movq %rcx, (%rax)
movq 0x10(%rbp), %rax
movq (%rax), %rax
cmpq -0x70(%rbp), %rax
jne 0x165ce
jmp 0x165f0
jmp 0x165d0
movq -0x110(%rbp), %rax
addq -0x38(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x40(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x40(%rbp)
jmp 0x164c5
jmp 0x165f2
movq 0x10(%rbp), %rax
movq (%rax), %rax
cmpq -0x70(%rbp), %rax
jne 0x16601
jmp 0x16620
leaq 0x7c03(%rip), %rdi      # 0x1e20b
leaq 0x7b57(%rip), %rsi      # 0x1e166
movl $0x13a, %edx            # imm = 0x13A
leaq 0x7c08(%rip), %rcx      # 0x1e223
callq 0x3220
movq -0x68(%rbp), %rdi
callq 0x3050
leaq -0x60(%rbp), %rdi
callq 0x17bb0
leaq -0xb8(%rbp), %rdi
callq 0x16bc0
movq -0x108(%rbp), %rdi
callq 0x194a0
addq $0x120, %rsp            # imm = 0x120
popq %rbp
retq
nopw %cs:(%rax,%rax)