// File: /workspace/github_c_makefile_star2_O0/Joy-Division[P]tools-mgs/lodepng/lodepng.c
// Function: writeLZ77data
static void writeLZ77data(size_t* bp, ucvector* out, const uivector* lz77_encoded,
                          const HuffmanTree* tree_ll, const HuffmanTree* tree_d)
{
  size_t i = 0;
  for(i = 0; i != lz77_encoded->size; ++i)
  {
    unsigned val = lz77_encoded->data[i];
    addHuffmanSymbol(bp, out, HuffmanTree_getCode(tree_ll, val), HuffmanTree_getLength(tree_ll, val));
    if(val > 256) /*for a length code, 3 more things have to be added*/
    {
      unsigned length_index = val - FIRST_LENGTH_CODE_INDEX;
      unsigned n_length_extra_bits = LENGTHEXTRA[length_index];
      unsigned length_extra_bits = lz77_encoded->data[++i];

      unsigned distance_code = lz77_encoded->data[++i];

      unsigned distance_index = distance_code;
      unsigned n_distance_extra_bits = DISTANCEEXTRA[distance_index];
      unsigned distance_extra_bits = lz77_encoded->data[++i];

      addBitsToStream(bp, out, length_extra_bits, n_length_extra_bits);
      addHuffmanSymbol(bp, out, HuffmanTree_getCode(tree_d, distance_code),
                       HuffmanTree_getLength(tree_d, distance_code));
      addBitsToStream(bp, out, distance_extra_bits, n_distance_extra_bits);
    }
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x80, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movq $0x0, -0x30(%rbp)
movq $0x0, -0x30(%rbp)
movq -0x30(%rbp), %rax
movq -0x18(%rbp), %rcx
cmpq 0x8(%rcx), %rax
je 0xd7f2
movq -0x18(%rbp), %rax
movq (%rax), %rax
movq -0x30(%rbp), %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0x34(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x68(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x60(%rbp)
movq -0x20(%rbp), %rdi
movl -0x34(%rbp), %esi
callq 0xd840
movl %eax, -0x54(%rbp)
movq -0x20(%rbp), %rdi
movl -0x34(%rbp), %esi
callq 0xd860
movq -0x68(%rbp), %rdi
movq -0x60(%rbp), %rsi
movl -0x54(%rbp), %edx
movl %eax, %ecx
callq 0xd800
cmpl $0x100, -0x34(%rbp)     # imm = 0x100
jbe 0xd7df
movl -0x34(%rbp), %eax
subl $0x101, %eax            # imm = 0x101
movl %eax, -0x38(%rbp)
movl -0x38(%rbp), %eax
movl %eax, %ecx
leaq 0x6bbd(%rip), %rax      # 0x142c0
movl (%rax,%rcx,4), %eax
movl %eax, -0x3c(%rbp)
movq -0x18(%rbp), %rax
movq (%rax), %rax
movq -0x30(%rbp), %rcx
movq %rcx, %rdx
addq $0x1, %rdx
movq %rdx, -0x30(%rbp)
movl 0x4(%rax,%rcx,4), %eax
movl %eax, -0x40(%rbp)
movq -0x18(%rbp), %rax
movq (%rax), %rax
movq -0x30(%rbp), %rcx
movq %rcx, %rdx
addq $0x1, %rdx
movq %rdx, -0x30(%rbp)
movl 0x4(%rax,%rcx,4), %eax
movl %eax, -0x44(%rbp)
movl -0x44(%rbp), %eax
movl %eax, -0x48(%rbp)
movl -0x48(%rbp), %eax
movl %eax, %ecx
leaq 0x6c6b(%rip), %rax      # 0x143c0
movl (%rax,%rcx,4), %eax
movl %eax, -0x4c(%rbp)
movq -0x18(%rbp), %rax
movq (%rax), %rax
movq -0x30(%rbp), %rcx
movq %rcx, %rdx
addq $0x1, %rdx
movq %rdx, -0x30(%rbp)
movl 0x4(%rax,%rcx,4), %eax
movl %eax, -0x50(%rbp)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movl -0x40(%rbp), %edx
movl -0x3c(%rbp), %eax
movl %eax, %ecx
callq 0xdc90
movq -0x8(%rbp), %rax
movq %rax, -0x80(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x78(%rbp)
movq -0x28(%rbp), %rdi
movl -0x44(%rbp), %esi
callq 0xd840
movl %eax, -0x6c(%rbp)
movq -0x28(%rbp), %rdi
movl -0x44(%rbp), %esi
callq 0xd860
movq -0x80(%rbp), %rdi
movq -0x78(%rbp), %rsi
movl -0x6c(%rbp), %edx
movl %eax, %ecx
callq 0xd800
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movl -0x50(%rbp), %edx
movl -0x4c(%rbp), %eax
movl %eax, %ecx
callq 0xdc90
jmp 0xd7e1
movq -0x30(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x30(%rbp)
jmp 0xd67f
addq $0x80, %rsp
popq %rbp
retq
nopl (%rax,%rax)