// File: /workspace/github_c_makefile_star2_O0/imaya[P]zopfli-for-emscripten/deflate.c
// Function: DeflateDynamicBlock
static void DeflateDynamicBlock(const ZopfliOptions* options, int final,
                                const unsigned char* in,
                                size_t instart, size_t inend,
                                unsigned char* bp,
                                unsigned char** out, size_t* outsize) {
  ZopfliBlockState s;
  size_t blocksize = inend - instart;
  ZopfliLZ77Store store;
  int 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(blocksize, s.lmc);
#endif

  ZopfliLZ77Optimal(&s, in, instart, inend, &store);

  /* For small block, encoding with fixed tree can be smaller. For large block,
  don't bother doing this expensive test, dynamic tree will be better.*/
  if (store.size < 1000) {
    double dyncost, fixedcost;
    ZopfliLZ77Store fixedstore;
    ZopfliInitLZ77Store(&fixedstore);
    ZopfliLZ77OptimalFixed(&s, in, instart, inend, &fixedstore);
    dyncost = ZopfliCalculateBlockSize(store.litlens, store.dists,
        0, store.size, 2);
    fixedcost = ZopfliCalculateBlockSize(fixedstore.litlens, fixedstore.dists,
        0, fixedstore.size, 1);
    if (fixedcost < dyncost) {
      btype = 1;
      ZopfliCleanLZ77Store(&store);
      store = fixedstore;
    } else {
      ZopfliCleanLZ77Store(&fixedstore);
    }
  }

  AddLZ77Block(s.options, btype, final,
               store.litlens, store.dists, 0, store.size,
               blocksize, bp, out, outsize);

#ifdef ZOPFLI_LONGEST_MATCH_CACHE
  ZopfliCleanCache(s.lmc);
  free(s.lmc);
#endif
  ZopfliCleanLZ77Store(&store);
}

// Assembly:
pushq %r14
pushq %rbx
subq $0xc8, %rsp
movq 0xe8(%rsp), %rax
movq 0xe0(%rsp), %rax
movq %rdi, 0xc0(%rsp)
movl %esi, 0xbc(%rsp)
movq %rdx, 0xb0(%rsp)
movq %rcx, 0xa8(%rsp)
movq %r8, 0xa0(%rsp)
movq %r9, 0x98(%rsp)
movq 0xa0(%rsp), %rax
subq 0xa8(%rsp), %rax
movq %rax, 0x70(%rsp)
movl $0x2, 0x54(%rsp)
leaq 0x58(%rsp), %rdi
callq 0x7820
movq 0xc0(%rsp), %rax
movq %rax, 0x78(%rsp)
movq 0xa8(%rsp), %rax
movq %rax, 0x88(%rsp)
movq 0xa0(%rsp), %rax
movq %rax, 0x90(%rsp)
movl $0x18, %edi
callq 0x1120
movq %rax, 0x80(%rsp)
movq 0x70(%rsp), %rdi
movq 0x80(%rsp), %rsi
callq 0x22c0
movq 0xb0(%rsp), %rsi
movq 0xa8(%rsp), %rdx
movq 0xa0(%rsp), %rcx
leaq 0x78(%rsp), %rdi
leaq 0x58(%rsp), %r8
callq 0x92b0
cmpq $0x3e8, 0x68(%rsp)      # imm = 0x3E8
jae 0x59b0
leaq 0x28(%rsp), %rdi
callq 0x7820
movq 0xb0(%rsp), %rsi
movq 0xa8(%rsp), %rdx
movq 0xa0(%rsp), %rcx
leaq 0x78(%rsp), %rdi
leaq 0x28(%rsp), %r8
callq 0x9cd0
movq 0x58(%rsp), %rdi
movq 0x60(%rsp), %rsi
movq 0x68(%rsp), %rcx
xorl %eax, %eax
movl %eax, %edx
movl $0x2, %r8d
callq 0x2780
movsd %xmm0, 0x48(%rsp)
movq 0x28(%rsp), %rdi
movq 0x30(%rsp), %rsi
movq 0x38(%rsp), %rcx
xorl %eax, %eax
movl %eax, %edx
movl $0x1, %r8d
callq 0x2780
movsd %xmm0, 0x40(%rsp)
movsd 0x40(%rsp), %xmm1
movsd 0x48(%rsp), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x59a4
movl $0x1, 0x54(%rsp)
leaq 0x58(%rsp), %rdi
callq 0x7850
movq 0x28(%rsp), %rax
movq %rax, 0x58(%rsp)
movq 0x30(%rsp), %rax
movq %rax, 0x60(%rsp)
movq 0x38(%rsp), %rax
movq %rax, 0x68(%rsp)
jmp 0x59ae
leaq 0x28(%rsp), %rdi
callq 0x7850
jmp 0x59b0
movq 0x78(%rsp), %rdi
movl 0x54(%rsp), %esi
movl 0xbc(%rsp), %edx
movq 0x58(%rsp), %rcx
movq 0x60(%rsp), %r8
movq 0x68(%rsp), %r14
movq 0x70(%rsp), %rbx
movq 0x98(%rsp), %r11
movq 0xe0(%rsp), %r10
movq 0xe8(%rsp), %rax
xorl %r9d, %r9d
movq %r14, (%rsp)
movq %rbx, 0x8(%rsp)
movq %r11, 0x10(%rsp)
movq %r10, 0x18(%rsp)
movq %rax, 0x20(%rsp)
callq 0x4940
movq 0x80(%rsp), %rdi
callq 0x23c0
movq 0x80(%rsp), %rdi
callq 0x1030
leaq 0x58(%rsp), %rdi
callq 0x7850
addq $0xc8, %rsp
popq %rbx
popq %r14
retq
nopl (%rax,%rax)