// File: /workspace/github_c_makefile_star2_O0/imaya[P]zopfli-for-emscripten/deflate.c
// Function: DeflateSplittingLast
static void DeflateSplittingLast(const ZopfliOptions* options,
                                 int btype, int final,
                                 const unsigned char* in,
                                 size_t instart, size_t inend,
                                 unsigned char* bp,
                                 unsigned char** out, size_t* outsize) {
  size_t i;
  ZopfliBlockState s;
  ZopfliLZ77Store store;
  size_t* splitpoints = 0;
  size_t npoints = 0;

  if (btype == 0) {
    /* This function only supports LZ77 compression. DeflateSplittingFirst
       supports the special case of noncompressed data. Punt it to that one. */
    DeflateSplittingFirst(options, btype, final,
                          in, instart, inend,
                          bp, out, outsize);
  }
  assert(btype == 1 || btype == 2);

  ZopfliInitLZ77Store(&store);

  s.options = options;
  s.blockstart = instart;
  s.blockend = inend;
#ifdef ZOPFLI_LONGEST_MATCH_CACHE
  s.lmc = (ZopfliLongestMatchCache*)malloc(sizeof(ZopfliLongestMatchCache));
  ZopfliInitCache(inend - instart, s.lmc);
#endif

  if (btype == 2) {
    ZopfliLZ77Optimal(&s, in, instart, inend, &store);
  } else {
    assert (btype == 1);
    ZopfliLZ77OptimalFixed(&s, in, instart, inend, &store);
  }

  if (btype == 1) {
    /* If all blocks are fixed tree, splitting into separate blocks only
    increases the total size. Leave npoints at 0, this represents 1 block. */
  } else {
    ZopfliBlockSplitLZ77(options, store.litlens, store.dists, store.size,
                         options->blocksplittingmax, &splitpoints, &npoints);
  }

  for (i = 0; i <= npoints; i++) {
    size_t start = i == 0 ? 0 : splitpoints[i - 1];
    size_t end = i == npoints ? store.size : splitpoints[i];
    AddLZ77Block(options, btype, i == npoints && final,
                 store.litlens, store.dists, start, end, 0,
                 bp, out, outsize);
  }

#ifdef ZOPFLI_LONGEST_MATCH_CACHE
  ZopfliCleanCache(s.lmc);
  free(s.lmc);
#endif

  ZopfliCleanLZ77Store(&store);
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
subq $0xd0, %rsp
movq 0x100(%rsp), %rax
movq 0xf8(%rsp), %rax
movq 0xf0(%rsp), %rax
movq %rdi, 0xc8(%rsp)
movl %esi, 0xc4(%rsp)
movl %edx, 0xc0(%rsp)
movq %rcx, 0xb8(%rsp)
movq %r8, 0xb0(%rsp)
movq %r9, 0xa8(%rsp)
movq $0x0, 0x60(%rsp)
movq $0x0, 0x58(%rsp)
cmpl $0x0, 0xc4(%rsp)
jne 0x2ed6
movq 0xc8(%rsp), %rdi
movl 0xc4(%rsp), %esi
movl 0xc0(%rsp), %edx
movq 0xb8(%rsp), %rcx
movq 0xb0(%rsp), %r8
movq 0xa8(%rsp), %r9
movq 0xf0(%rsp), %r11
movq 0xf8(%rsp), %r10
movq 0x100(%rsp), %rax
movq %r11, (%rsp)
movq %r10, 0x8(%rsp)
movq %rax, 0x10(%rsp)
callq 0x31c0
cmpl $0x1, 0xc4(%rsp)
je 0x2eea
cmpl $0x2, 0xc4(%rsp)
jne 0x2eec
jmp 0x2f0b
leaq 0xa3ed(%rip), %rdi      # 0xd2e0
leaq 0xa3ff(%rip), %rsi      # 0xd2f9
movl $0x264, %edx            # imm = 0x264
leaq 0xa4fb(%rip), %rcx      # 0xd401
callq 0x10b0
leaq 0x68(%rsp), %rdi
callq 0x7820
movq 0xc8(%rsp), %rax
movq %rax, 0x80(%rsp)
movq 0xb0(%rsp), %rax
movq %rax, 0x90(%rsp)
movq 0xa8(%rsp), %rax
movq %rax, 0x98(%rsp)
movl $0x18, %edi
callq 0x1120
movq %rax, 0x88(%rsp)
movq 0xa8(%rsp), %rdi
subq 0xb0(%rsp), %rdi
movq 0x88(%rsp), %rsi
callq 0x22c0
cmpl $0x2, 0xc4(%rsp)
jne 0x2faa
movq 0xb8(%rsp), %rsi
movq 0xb0(%rsp), %rdx
movq 0xa8(%rsp), %rcx
leaq 0x80(%rsp), %rdi
leaq 0x68(%rsp), %r8
callq 0x92b0
jmp 0x2fff
cmpl $0x1, 0xc4(%rsp)
jne 0x2fb6
jmp 0x2fd5
leaq 0xa4d3(%rip), %rdi      # 0xd490
leaq 0xa335(%rip), %rsi      # 0xd2f9
movl $0x273, %edx            # imm = 0x273
leaq 0xa431(%rip), %rcx      # 0xd401
callq 0x10b0
movq 0xb8(%rsp), %rsi
movq 0xb0(%rsp), %rdx
movq 0xa8(%rsp), %rcx
leaq 0x80(%rsp), %rdi
leaq 0x68(%rsp), %r8
callq 0x9cd0
cmpl $0x1, 0xc4(%rsp)
jne 0x300b
jmp 0x3041
movq 0xc8(%rsp), %rdi
movq 0x68(%rsp), %rsi
movq 0x70(%rsp), %rdx
movq 0x78(%rsp), %rcx
movq 0xc8(%rsp), %rax
movslq 0x10(%rax), %r8
leaq 0x60(%rsp), %r9
leaq 0x58(%rsp), %rax
movq %rax, (%rsp)
callq 0x1290
movq $0x0, 0xa0(%rsp)
movq 0xa0(%rsp), %rax
cmpq 0x58(%rsp), %rax
ja 0x3189
cmpq $0x0, 0xa0(%rsp)
jne 0x3074
xorl %eax, %eax
movq %rax, 0x40(%rsp)
jmp 0x308e
movq 0x60(%rsp), %rax
movq 0xa0(%rsp), %rcx
subq $0x1, %rcx
movq (%rax,%rcx,8), %rax
movq %rax, 0x40(%rsp)
movq 0x40(%rsp), %rax
movq %rax, 0x50(%rsp)
movq 0xa0(%rsp), %rax
cmpq 0x58(%rsp), %rax
jne 0x30b3
movq 0x78(%rsp), %rax
movq %rax, 0x38(%rsp)
jmp 0x30c9
movq 0x60(%rsp), %rax
movq 0xa0(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, 0x38(%rsp)
movq 0x38(%rsp), %rax
movq %rax, 0x48(%rsp)
movq 0xc8(%rsp), %rax
movq %rax, 0x28(%rsp)
movl 0xc4(%rsp), %eax
movl %eax, 0x30(%rsp)
movq 0xa0(%rsp), %rcx
xorl %eax, %eax
cmpq 0x58(%rsp), %rcx
movb %al, 0x37(%rsp)
jne 0x310f
cmpl $0x0, 0xc0(%rsp)
setne %al
movb %al, 0x37(%rsp)
movl 0x30(%rsp), %esi
movq 0x28(%rsp), %rdi
movb 0x37(%rsp), %al
andb $0x1, %al
movzbl %al, %edx
movq 0x68(%rsp), %rcx
movq 0x70(%rsp), %r8
movq 0x50(%rsp), %r9
movq 0x48(%rsp), %rbx
movq 0xf0(%rsp), %r11
movq 0xf8(%rsp), %r10
movq 0x100(%rsp), %rax
xorl %ebp, %ebp
movq %rbx, (%rsp)
movq $0x0, 0x8(%rsp)
movq %r11, 0x10(%rsp)
movq %r10, 0x18(%rsp)
movq %rax, 0x20(%rsp)
callq 0x4940
movq 0xa0(%rsp), %rax
addq $0x1, %rax
movq %rax, 0xa0(%rsp)
jmp 0x304d
movq 0x88(%rsp), %rdi
callq 0x23c0
movq 0x88(%rsp), %rdi
callq 0x1030
leaq 0x68(%rsp), %rdi
callq 0x7850
addq $0xd0, %rsp
popq %rbx
popq %r14
popq %rbp
retq
nopl (%rax)