// File: /workspace/github_c_makefile_star2_O0/imaya[P]zopfli-for-emscripten/deflate.c
// Function: AddLZ77Data
static void AddLZ77Data(const unsigned short* litlens,
                        const unsigned short* dists,
                        size_t lstart, size_t lend,
                        size_t expected_data_size,
                        const unsigned* ll_symbols, const unsigned* ll_lengths,
                        const unsigned* d_symbols, const unsigned* d_lengths,
                        unsigned char* bp,
                        unsigned char** out, size_t* outsize) {
  size_t testlength = 0;
  size_t i;

  for (i = lstart; i < lend; i++) {
    unsigned dist = dists[i];
    unsigned litlen = litlens[i];
    if (dist == 0) {
      assert(litlen < 256);
      assert(ll_lengths[litlen] > 0);
      AddHuffmanBits(ll_symbols[litlen], ll_lengths[litlen], bp, out, outsize);
      testlength++;
    } else {
      unsigned lls = ZopfliGetLengthSymbol(litlen);
      unsigned ds = ZopfliGetDistSymbol(dist);
      assert(litlen >= 3 && litlen <= 288);
      assert(ll_lengths[lls] > 0);
      assert(d_lengths[ds] > 0);
      AddHuffmanBits(ll_symbols[lls], ll_lengths[lls], bp, out, outsize);
      AddBits(ZopfliGetLengthExtraBitsValue(litlen),
              ZopfliGetLengthExtraBits(litlen),
              bp, out, outsize);
      AddHuffmanBits(d_symbols[ds], d_lengths[ds], bp, out, outsize);
      AddBits(ZopfliGetDistExtraBitsValue(dist),
              ZopfliGetDistExtraBits(dist),
              bp, out, outsize);
      testlength += litlen;
    }
  }
  assert(expected_data_size == 0 || testlength == expected_data_size);
}

// Assembly:
subq $0x58, %rsp
movq 0x88(%rsp), %rax
movq 0x80(%rsp), %rax
movq 0x78(%rsp), %rax
movq 0x70(%rsp), %rax
movq 0x68(%rsp), %rax
movq 0x60(%rsp), %rax
movq %rdi, 0x50(%rsp)
movq %rsi, 0x48(%rsp)
movq %rdx, 0x40(%rsp)
movq %rcx, 0x38(%rsp)
movq %r8, 0x30(%rsp)
movq %r9, 0x28(%rsp)
movq $0x0, 0x20(%rsp)
movq 0x40(%rsp), %rax
movq %rax, 0x18(%rsp)
movq 0x18(%rsp), %rax
cmpq 0x38(%rsp), %rax
jae 0x51e5
movq 0x48(%rsp), %rax
movq 0x18(%rsp), %rcx
movzwl (%rax,%rcx,2), %eax
movl %eax, 0x14(%rsp)
movq 0x50(%rsp), %rax
movq 0x18(%rsp), %rcx
movzwl (%rax,%rcx,2), %eax
movl %eax, 0x10(%rsp)
cmpl $0x0, 0x14(%rsp)
jne 0x5048
cmpl $0x100, 0x10(%rsp)      # imm = 0x100
jae 0x4fb4
jmp 0x4fd3
leaq 0x860d(%rip), %rdi      # 0xd5c8
leaq 0x8337(%rip), %rsi      # 0xd2f9
movl $0x100, %edx            # imm = 0x100
leaq 0x8607(%rip), %rcx      # 0xd5d5
callq 0x10b0
movq 0x60(%rsp), %rax
movl 0x10(%rsp), %ecx
cmpl $0x0, (%rax,%rcx,4)
jbe 0x4fe4
jmp 0x5003
leaq 0x86c8(%rip), %rdi      # 0xd6b3
leaq 0x8307(%rip), %rsi      # 0xd2f9
movl $0x101, %edx            # imm = 0x101
leaq 0x85d7(%rip), %rcx      # 0xd5d5
callq 0x10b0
movq 0x28(%rsp), %rax
movl 0x10(%rsp), %ecx
movl (%rax,%rcx,4), %edi
movq 0x60(%rsp), %rax
movl 0x10(%rsp), %ecx
movl (%rax,%rcx,4), %esi
movq 0x78(%rsp), %rdx
movq 0x80(%rsp), %rcx
movq 0x88(%rsp), %r8
callq 0x4800
movq 0x20(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x20(%rsp)
jmp 0x51d0
movl 0x10(%rsp), %edi
callq 0xb4a0
movl %eax, 0xc(%rsp)
movl 0x14(%rsp), %edi
callq 0xb400
movl %eax, 0x8(%rsp)
cmpl $0x3, 0x10(%rsp)
jb 0x5075
cmpl $0x120, 0x10(%rsp)      # imm = 0x120
ja 0x5075
jmp 0x5094
leaq 0x864e(%rip), %rdi      # 0xd6ca
leaq 0x8276(%rip), %rsi      # 0xd2f9
movl $0x107, %edx            # imm = 0x107
leaq 0x8546(%rip), %rcx      # 0xd5d5
callq 0x10b0
movq 0x60(%rsp), %rax
movl 0xc(%rsp), %ecx
cmpl $0x0, (%rax,%rcx,4)
jbe 0x50a5
jmp 0x50c4
leaq 0x863b(%rip), %rdi      # 0xd6e7
leaq 0x8246(%rip), %rsi      # 0xd2f9
movl $0x108, %edx            # imm = 0x108
leaq 0x8516(%rip), %rcx      # 0xd5d5
callq 0x10b0
movq 0x70(%rsp), %rax
movl 0x8(%rsp), %ecx
cmpl $0x0, (%rax,%rcx,4)
jbe 0x50d5
jmp 0x50f4
leaq 0x861f(%rip), %rdi      # 0xd6fb
leaq 0x8216(%rip), %rsi      # 0xd2f9
movl $0x109, %edx            # imm = 0x109
leaq 0x84e6(%rip), %rcx      # 0xd5d5
callq 0x10b0
movq 0x28(%rsp), %rax
movl 0xc(%rsp), %ecx
movl (%rax,%rcx,4), %edi
movq 0x60(%rsp), %rax
movl 0xc(%rsp), %ecx
movl (%rax,%rcx,4), %esi
movq 0x78(%rsp), %rdx
movq 0x80(%rsp), %rcx
movq 0x88(%rsp), %r8
callq 0x4800
movl 0x10(%rsp), %edi
callq 0xb480
movl %eax, (%rsp)
movl 0x10(%rsp), %edi
callq 0xb460
movl (%rsp), %edi
movl %eax, %esi
movq 0x78(%rsp), %rdx
movq 0x80(%rsp), %rcx
movq 0x88(%rsp), %r8
callq 0x46d0
movq 0x68(%rsp), %rax
movl 0x8(%rsp), %ecx
movl (%rax,%rcx,4), %edi
movq 0x70(%rsp), %rax
movl 0x8(%rsp), %ecx
movl (%rax,%rcx,4), %esi
movq 0x78(%rsp), %rdx
movq 0x80(%rsp), %rcx
movq 0x88(%rsp), %r8
callq 0x4800
movl 0x14(%rsp), %edi
callq 0xb3a0
movl %eax, 0x4(%rsp)
movl 0x14(%rsp), %edi
callq 0xb360
movl 0x4(%rsp), %edi
movl %eax, %esi
movq 0x78(%rsp), %rdx
movq 0x80(%rsp), %rcx
movq 0x88(%rsp), %r8
callq 0x46d0
movl 0x10(%rsp), %eax
addq 0x20(%rsp), %rax
movq %rax, 0x20(%rsp)
jmp 0x51d2
movq 0x18(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x18(%rsp)
jmp 0x4f69
cmpq $0x0, 0x30(%rsp)
je 0x51f9
movq 0x20(%rsp), %rax
cmpq 0x30(%rsp), %rax
jne 0x51fb
jmp 0x521a
leaq 0x850b(%rip), %rdi      # 0xd70d
leaq 0x80f0(%rip), %rsi      # 0xd2f9
movl $0x115, %edx            # imm = 0x115
leaq 0x83c0(%rip), %rcx      # 0xd5d5
callq 0x10b0
addq $0x58, %rsp
retq
nop