// File: /workspace/github_c_makefile_star2_O0/tditlu[P]shadetabler/src/lodepng/lodepng.c
// Function: deflateDynamic
static unsigned deflateDynamic(LodePNGBitWriter* writer, Hash* hash,
                               const unsigned char* data, size_t datapos, size_t dataend,
                               const LodePNGCompressSettings* settings, unsigned final) {
  unsigned error = 0;

  /*
  A block is compressed as follows: The PNG data is lz77 encoded, resulting in
  literal bytes and length/distance pairs. This is then huffman compressed with
  two huffman trees. One huffman tree is used for the lit and len values ("ll"),
  another huffman tree is used for the dist values ("d"). These two trees are
  stored using their code lengths, and to compress even more these code lengths
  are also run-length encoded and huffman compressed. This gives a huffman tree
  of code lengths "cl". The code lengths used to describe this third tree are
  the code length code lengths ("clcl").
  */

  /*The lz77 encoded data, represented with integers since there will also be length and distance codes in it*/
  uivector lz77_encoded;
  HuffmanTree tree_ll; /*tree for lit,len values*/
  HuffmanTree tree_d; /*tree for distance codes*/
  HuffmanTree tree_cl; /*tree for encoding the code lengths representing tree_ll and tree_d*/
  unsigned* frequencies_ll = 0; /*frequency of lit,len codes*/
  unsigned* frequencies_d = 0; /*frequency of dist codes*/
  unsigned* frequencies_cl = 0; /*frequency of code length codes*/
  unsigned* bitlen_lld = 0; /*lit,len,dist code lengths (int bits), literally (without repeat codes).*/
  unsigned* bitlen_lld_e = 0; /*bitlen_lld encoded with repeat codes (this is a rudimentary run length compression)*/
  size_t datasize = dataend - datapos;

  /*
  If we could call "bitlen_cl" the the code length code lengths ("clcl"), that is the bit lengths of codes to represent
  tree_cl in CLCL_ORDER, then due to the huffman compression of huffman tree representations ("two levels"), there are
  some analogies:
  bitlen_lld is to tree_cl what data is to tree_ll and tree_d.
  bitlen_lld_e is to bitlen_lld what lz77_encoded is to data.
  bitlen_cl is to bitlen_lld_e what bitlen_lld is to lz77_encoded.
  */

  unsigned BFINAL = final;
  size_t i;
  size_t numcodes_ll, numcodes_d, numcodes_lld, numcodes_lld_e, numcodes_cl;
  unsigned HLIT, HDIST, HCLEN;

  uivector_init(&lz77_encoded);
  HuffmanTree_init(&tree_ll);
  HuffmanTree_init(&tree_d);
  HuffmanTree_init(&tree_cl);
  /* could fit on stack, but >1KB is on the larger side so allocate instead */
  frequencies_ll = (unsigned*)lodepng_malloc(286 * sizeof(*frequencies_ll));
  frequencies_d = (unsigned*)lodepng_malloc(30 * sizeof(*frequencies_d));
  frequencies_cl = (unsigned*)lodepng_malloc(NUM_CODE_LENGTH_CODES * sizeof(*frequencies_cl));

  if(!frequencies_ll || !frequencies_d || !frequencies_cl) error = 83; /*alloc fail*/

  /*This while loop never loops due to a break at the end, it is here to
  allow breaking out of it to the cleanup phase on error conditions.*/
  while(!error) {
    lodepng_memset(frequencies_ll, 0, 286 * sizeof(*frequencies_ll));
    lodepng_memset(frequencies_d, 0, 30 * sizeof(*frequencies_d));
    lodepng_memset(frequencies_cl, 0, NUM_CODE_LENGTH_CODES * sizeof(*frequencies_cl));

    if(settings->use_lz77) {
      error = encodeLZ77(&lz77_encoded, hash, data, datapos, dataend, settings->windowsize,
                         settings->minmatch, settings->nicematch, settings->lazymatching);
      if(error) break;
    } else {
      if(!uivector_resize(&lz77_encoded, datasize)) ERROR_BREAK(83 /*alloc fail*/);
      for(i = datapos; i < dataend; ++i) lz77_encoded.data[i - datapos] = data[i]; /*no LZ77, but still will be Huffman compressed*/
    }

    /*Count the frequencies of lit, len and dist codes*/
    for(i = 0; i != lz77_encoded.size; ++i) {
      unsigned symbol = lz77_encoded.data[i];
      ++frequencies_ll[symbol];
      if(symbol > 256) {
        unsigned dist = lz77_encoded.data[i + 2];
        ++frequencies_d[dist];
        i += 3;
      }
    }
    frequencies_ll[256] = 1; /*there will be exactly 1 end code, at the end of the block*/

    /*Make both huffman trees, one for the lit and len codes, one for the dist codes*/
    error = HuffmanTree_makeFromFrequencies(&tree_ll, frequencies_ll, 257, 286, 15);
    if(error) break;
    /*2, not 1, is chosen for mincodes: some buggy PNG decoders require at least 2 symbols in the dist tree*/
    error = HuffmanTree_makeFromFrequencies(&tree_d, frequencies_d, 2, 30, 15);
    if(error) break;

    numcodes_ll = LODEPNG_MIN(tree_ll.numcodes, 286);
    numcodes_d = LODEPNG_MIN(tree_d.numcodes, 30);
    /*store the code lengths of both generated trees in bitlen_lld*/
    numcodes_lld = numcodes_ll + numcodes_d;
    bitlen_lld = (unsigned*)lodepng_malloc(numcodes_lld * sizeof(*bitlen_lld));
    /*numcodes_lld_e never needs more size than bitlen_lld*/
    bitlen_lld_e = (unsigned*)lodepng_malloc(numcodes_lld * sizeof(*bitlen_lld_e));
    if(!bitlen_lld || !bitlen_lld_e) ERROR_BREAK(83); /*alloc fail*/
    numcodes_lld_e = 0;

    for(i = 0; i != numcodes_ll; ++i) bitlen_lld[i] = tree_ll.lengths[i];
    for(i = 0; i != numcodes_d; ++i) bitlen_lld[numcodes_ll + i] = tree_d.lengths[i];

    /*run-length compress bitlen_ldd into bitlen_lld_e by using repeat codes 16 (copy length 3-6 times),
    17 (3-10 zeroes), 18 (11-138 zeroes)*/
    for(i = 0; i != numcodes_lld; ++i) {
      unsigned j = 0; /*amount of repetitions*/
      while(i + j + 1 < numcodes_lld && bitlen_lld[i + j + 1] == bitlen_lld[i]) ++j;

      if(bitlen_lld[i] == 0 && j >= 2) /*repeat code for zeroes*/ {
        ++j; /*include the first zero*/
        if(j <= 10) /*repeat code 17 supports max 10 zeroes*/ {
          bitlen_lld_e[numcodes_lld_e++] = 17;
          bitlen_lld_e[numcodes_lld_e++] = j - 3;
        } else /*repeat code 18 supports max 138 zeroes*/ {
          if(j > 138) j = 138;
          bitlen_lld_e[numcodes_lld_e++] = 18;
          bitlen_lld_e[numcodes_lld_e++] = j - 11;
        }
        i += (j - 1);
      } else if(j >= 3) /*repeat code for value other than zero*/ {
        size_t k;
        unsigned num = j / 6u, rest = j % 6u;
        bitlen_lld_e[numcodes_lld_e++] = bitlen_lld[i];
        for(k = 0; k < num; ++k) {
          bitlen_lld_e[numcodes_lld_e++] = 16;
          bitlen_lld_e[numcodes_lld_e++] = 6 - 3;
        }
        if(rest >= 3) {
          bitlen_lld_e[numcodes_lld_e++] = 16;
          bitlen_lld_e[numcodes_lld_e++] = rest - 3;
        }
        else j -= rest;
        i += j;
      } else /*too short to benefit from repeat code*/ {
        bitlen_lld_e[numcodes_lld_e++] = bitlen_lld[i];
      }
    }

    /*generate tree_cl, the huffmantree of huffmantrees*/
    for(i = 0; i != numcodes_lld_e; ++i) {
      ++frequencies_cl[bitlen_lld_e[i]];
      /*after a repeat code come the bits that specify the number of repetitions,
      those don't need to be in the frequencies_cl calculation*/
      if(bitlen_lld_e[i] >= 16) ++i;
    }

    error = HuffmanTree_makeFromFrequencies(&tree_cl, frequencies_cl,
                                            NUM_CODE_LENGTH_CODES, NUM_CODE_LENGTH_CODES, 7);
    if(error) break;

    /*compute amount of code-length-code-lengths to output*/
    numcodes_cl = NUM_CODE_LENGTH_CODES;
    /*trim zeros at the end (using CLCL_ORDER), but minimum size must be 4 (see HCLEN below)*/
    while(numcodes_cl > 4u && tree_cl.lengths[CLCL_ORDER[numcodes_cl - 1u]] == 0) {
      numcodes_cl--;
    }

    /*
    Write everything into the output

    After the BFINAL and BTYPE, the dynamic block consists out of the following:
    - 5 bits HLIT, 5 bits HDIST, 4 bits HCLEN
    - (HCLEN+4)*3 bits code lengths of code length alphabet
    - HLIT + 257 code lengths of lit/length alphabet (encoded using the code length
      alphabet, + possible repetition codes 16, 17, 18)
    - HDIST + 1 code lengths of distance alphabet (encoded using the code length
      alphabet, + possible repetition codes 16, 17, 18)
    - compressed data
    - 256 (end code)
    */

    /*Write block type*/
    writeBits(writer, BFINAL, 1);
    writeBits(writer, 0, 1); /*first bit of BTYPE "dynamic"*/
    writeBits(writer, 1, 1); /*second bit of BTYPE "dynamic"*/

    /*write the HLIT, HDIST and HCLEN values*/
    /*all three sizes take trimmed ending zeroes into account, done either by HuffmanTree_makeFromFrequencies
    or in the loop for numcodes_cl above, which saves space. */
    HLIT = (unsigned)(numcodes_ll - 257);
    HDIST = (unsigned)(numcodes_d - 1);
    HCLEN = (unsigned)(numcodes_cl - 4);
    writeBits(writer, HLIT, 5);
    writeBits(writer, HDIST, 5);
    writeBits(writer, HCLEN, 4);

    /*write the code lengths of the code length alphabet ("bitlen_cl")*/
    for(i = 0; i != numcodes_cl; ++i) writeBits(writer, tree_cl.lengths[CLCL_ORDER[i]], 3);

    /*write the lengths of the lit/len AND the dist alphabet*/
    for(i = 0; i != numcodes_lld_e; ++i) {
      writeBitsReversed(writer, tree_cl.codes[bitlen_lld_e[i]], tree_cl.lengths[bitlen_lld_e[i]]);
      /*extra bits of repeat codes*/
      if(bitlen_lld_e[i] == 16) writeBits(writer, bitlen_lld_e[++i], 2);
      else if(bitlen_lld_e[i] == 17) writeBits(writer, bitlen_lld_e[++i], 3);
      else if(bitlen_lld_e[i] == 18) writeBits(writer, bitlen_lld_e[++i], 7);
    }

    /*write the compressed data symbols*/
    writeLZ77data(writer, &lz77_encoded, &tree_ll, &tree_d);
    /*error: the length of the end code 256 must be larger than 0*/
    if(tree_ll.lengths[256] == 0) ERROR_BREAK(64);

    /*write the end code*/
    writeBitsReversed(writer, tree_ll.codes[256], tree_ll.lengths[256]);

    break; /*end of error-while*/
  }

  /*cleanup*/
  uivector_cleanup(&lz77_encoded);
  HuffmanTree_cleanup(&tree_ll);
  HuffmanTree_cleanup(&tree_d);
  HuffmanTree_cleanup(&tree_cl);
  lodepng_free(frequencies_ll);
  lodepng_free(frequencies_d);
  lodepng_free(frequencies_cl);
  lodepng_free(bitlen_lld);
  lodepng_free(bitlen_lld_e);

  return error;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x180, %rsp            # imm = 0x180
movl 0x10(%rbp), %eax
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movq %r9, -0x30(%rbp)
movl $0x0, -0x34(%rbp)
movq $0x0, -0xd0(%rbp)
movq $0x0, -0xd8(%rbp)
movq $0x0, -0xe0(%rbp)
movq $0x0, -0xe8(%rbp)
movq $0x0, -0xf0(%rbp)
movq -0x28(%rbp), %rax
subq -0x20(%rbp), %rax
movq %rax, -0xf8(%rbp)
movl 0x10(%rbp), %eax
movl %eax, -0xfc(%rbp)
leaq -0x50(%rbp), %rdi
callq 0x13010
leaq -0x78(%rbp), %rdi
callq 0x10b50
leaq -0xa0(%rbp), %rdi
callq 0x10b50
leaq -0xc8(%rbp), %rdi
callq 0x10b50
movl $0x478, %edi            # imm = 0x478
callq 0x3de0
movq %rax, -0xd0(%rbp)
movl $0x78, %edi
callq 0x3de0
movq %rax, -0xd8(%rbp)
movl $0x4c, %edi
callq 0x3de0
movq %rax, -0xe0(%rbp)
cmpq $0x0, -0xd0(%rbp)
je 0x12307
cmpq $0x0, -0xd8(%rbp)
je 0x12307
cmpq $0x0, -0xe0(%rbp)
jne 0x1230e
movl $0x53, -0x34(%rbp)
jmp 0x12310
cmpl $0x0, -0x34(%rbp)
setne %al
xorb $-0x1, %al
testb $0x1, %al
jne 0x12322
jmp 0x12daf
movq -0xd0(%rbp), %rdi
xorl %esi, %esi
movl $0x478, %edx            # imm = 0x478
callq 0x4a10
movq -0xd8(%rbp), %rdi
xorl %esi, %esi
movl $0x78, %edx
callq 0x4a10
movq -0xe0(%rbp), %rdi
xorl %esi, %esi
movl $0x4c, %edx
callq 0x4a10
movq -0x30(%rbp), %rax
cmpl $0x0, 0x4(%rax)
je 0x123ba
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
movq -0x20(%rbp), %rcx
movq -0x28(%rbp), %r8
movq -0x30(%rbp), %rax
movl 0x8(%rax), %r9d
movq -0x30(%rbp), %rax
movl 0xc(%rax), %r11d
movq -0x30(%rbp), %rax
movl 0x10(%rax), %r10d
movq -0x30(%rbp), %rax
movl 0x14(%rax), %eax
leaq -0x50(%rbp), %rdi
movl %r11d, (%rsp)
movl %r10d, 0x8(%rsp)
movl %eax, 0x10(%rsp)
callq 0x13040
movl %eax, -0x34(%rbp)
cmpl $0x0, -0x34(%rbp)
je 0x123b8
jmp 0x12daf
jmp 0x1242a
movq -0xf8(%rbp), %rsi
leaq -0x50(%rbp), %rdi
callq 0x13da0
cmpl $0x0, %eax
jne 0x123db
movl $0x53, -0x34(%rbp)
jmp 0x12daf
movq -0x20(%rbp), %rax
movq %rax, -0x108(%rbp)
movq -0x108(%rbp), %rax
cmpq -0x28(%rbp), %rax
jae 0x12428
movq -0x18(%rbp), %rax
movq -0x108(%rbp), %rcx
movzbl (%rax,%rcx), %edx
movq -0x50(%rbp), %rax
movq -0x108(%rbp), %rcx
subq -0x20(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
movq -0x108(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x108(%rbp)
jmp 0x123e6
jmp 0x1242a
movq $0x0, -0x108(%rbp)
movq -0x108(%rbp), %rax
cmpq -0x48(%rbp), %rax
je 0x124d2
movq -0x50(%rbp), %rax
movq -0x108(%rbp), %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0x140(%rbp)
movq -0xd0(%rbp), %rax
movl -0x140(%rbp), %ecx
movl (%rax,%rcx,4), %edx
addl $0x1, %edx
movl %edx, (%rax,%rcx,4)
cmpl $0x100, -0x140(%rbp)    # imm = 0x100
jbe 0x124b9
movq -0x50(%rbp), %rax
movq -0x108(%rbp), %rcx
movl 0x8(%rax,%rcx,4), %eax
movl %eax, -0x144(%rbp)
movq -0xd8(%rbp), %rax
movl -0x144(%rbp), %ecx
movl (%rax,%rcx,4), %edx
addl $0x1, %edx
movl %edx, (%rax,%rcx,4)
movq -0x108(%rbp), %rax
addq $0x3, %rax
movq %rax, -0x108(%rbp)
jmp 0x124bb
movq -0x108(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x108(%rbp)
jmp 0x12435
movq -0xd0(%rbp), %rax
movl $0x1, 0x400(%rax)
movq -0xd0(%rbp), %rsi
leaq -0x78(%rbp), %rdi
movl $0x101, %edx            # imm = 0x101
movl $0x11e, %ecx            # imm = 0x11E
movl $0xf, %r8d
callq 0x13ee0
movl %eax, -0x34(%rbp)
cmpl $0x0, -0x34(%rbp)
je 0x12511
jmp 0x12daf
movq -0xd8(%rbp), %rsi
leaq -0xa0(%rbp), %rdi
movl $0x2, %edx
movl $0x1e, %ecx
movl $0xf, %r8d
callq 0x13ee0
movl %eax, -0x34(%rbp)
cmpl $0x0, -0x34(%rbp)
je 0x12542
jmp 0x12daf
cmpl $0x11e, -0x64(%rbp)     # imm = 0x11E
jae 0x12556
movl -0x64(%rbp), %eax
movl %eax, -0x15c(%rbp)
jmp 0x12563
movl $0x11e, %eax            # imm = 0x11E
movl %eax, -0x15c(%rbp)
jmp 0x12563
movl -0x15c(%rbp), %eax
movl %eax, %eax
movq %rax, -0x110(%rbp)
cmpl $0x1e, -0x8c(%rbp)
jae 0x12589
movl -0x8c(%rbp), %eax
movl %eax, -0x160(%rbp)
jmp 0x12596
movl $0x1e, %eax
movl %eax, -0x160(%rbp)
jmp 0x12596
movl -0x160(%rbp), %eax
movl %eax, %eax
movq %rax, -0x118(%rbp)
movq -0x110(%rbp), %rax
addq -0x118(%rbp), %rax
movq %rax, -0x120(%rbp)
movq -0x120(%rbp), %rdi
shlq $0x2, %rdi
callq 0x3de0
movq %rax, -0xe8(%rbp)
movq -0x120(%rbp), %rdi
shlq $0x2, %rdi
callq 0x3de0
movq %rax, -0xf0(%rbp)
cmpq $0x0, -0xe8(%rbp)
je 0x125fc
cmpq $0x0, -0xf0(%rbp)
jne 0x12608
movl $0x53, -0x34(%rbp)
jmp 0x12daf
movq $0x0, -0x128(%rbp)
movq $0x0, -0x108(%rbp)
movq -0x108(%rbp), %rax
cmpq -0x110(%rbp), %rax
je 0x12661
movq -0x70(%rbp), %rax
movq -0x108(%rbp), %rcx
movl (%rax,%rcx,4), %edx
movq -0xe8(%rbp), %rax
movq -0x108(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
movq -0x108(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x108(%rbp)
jmp 0x1261e
movq $0x0, -0x108(%rbp)
movq -0x108(%rbp), %rax
cmpq -0x118(%rbp), %rax
je 0x126b9
movq -0x98(%rbp), %rax
movq -0x108(%rbp), %rcx
movl (%rax,%rcx,4), %edx
movq -0xe8(%rbp), %rax
movq -0x110(%rbp), %rcx
addq -0x108(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
movq -0x108(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x108(%rbp)
jmp 0x1266c
movq $0x0, -0x108(%rbp)
movq -0x108(%rbp), %rax
cmpq -0x120(%rbp), %rax
je 0x12a0b
movl $0x0, -0x148(%rbp)
movq -0x108(%rbp), %rcx
movl -0x148(%rbp), %eax
addq %rax, %rcx
addq $0x1, %rcx
xorl %eax, %eax
cmpq -0x120(%rbp), %rcx
movb %al, -0x161(%rbp)
jae 0x1273c
movq -0xe8(%rbp), %rax
movq -0x108(%rbp), %rcx
movl -0x148(%rbp), %edx
addq %rdx, %rcx
movl 0x4(%rax,%rcx,4), %eax
movq -0xe8(%rbp), %rcx
movq -0x108(%rbp), %rdx
cmpl (%rcx,%rdx,4), %eax
sete %al
movb %al, -0x161(%rbp)
movb -0x161(%rbp), %al
testb $0x1, %al
jne 0x12748
jmp 0x12759
movl -0x148(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x148(%rbp)
jmp 0x126e2
movq -0xe8(%rbp), %rax
movq -0x108(%rbp), %rcx
cmpl $0x0, (%rax,%rcx,4)
jne 0x12862
cmpl $0x2, -0x148(%rbp)
jb 0x12862
movl -0x148(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x148(%rbp)
cmpl $0xa, -0x148(%rbp)
ja 0x127e3
movq -0xf0(%rbp), %rax
movq -0x128(%rbp), %rcx
movq %rcx, %rdx
addq $0x1, %rdx
movq %rdx, -0x128(%rbp)
movl $0x11, (%rax,%rcx,4)
movl -0x148(%rbp), %edx
subl $0x3, %edx
movq -0xf0(%rbp), %rax
movq -0x128(%rbp), %rcx
movq %rcx, %rsi
addq $0x1, %rsi
movq %rsi, -0x128(%rbp)
movl %edx, (%rax,%rcx,4)
jmp 0x12844
cmpl $0x8a, -0x148(%rbp)
jbe 0x127f9
movl $0x8a, -0x148(%rbp)
movq -0xf0(%rbp), %rax
movq -0x128(%rbp), %rcx
movq %rcx, %rdx
addq $0x1, %rdx
movq %rdx, -0x128(%rbp)
movl $0x12, (%rax,%rcx,4)
movl -0x148(%rbp), %edx
subl $0xb, %edx
movq -0xf0(%rbp), %rax
movq -0x128(%rbp), %rcx
movq %rcx, %rsi
addq $0x1, %rsi
movq %rsi, -0x128(%rbp)
movl %edx, (%rax,%rcx,4)
movl -0x148(%rbp), %eax
subl $0x1, %eax
movl %eax, %eax
addq -0x108(%rbp), %rax
movq %rax, -0x108(%rbp)
jmp 0x129f2
cmpl $0x3, -0x148(%rbp)
jb 0x129c0
movl -0x148(%rbp), %eax
movl $0x6, %ecx
xorl %edx, %edx
divl %ecx
movl %eax, -0x154(%rbp)
movl -0x148(%rbp), %eax
movl $0x6, %ecx
xorl %edx, %edx
divl %ecx
movl %edx, -0x158(%rbp)
movq -0xe8(%rbp), %rax
movq -0x108(%rbp), %rcx
movl (%rax,%rcx,4), %edx
movq -0xf0(%rbp), %rax
movq -0x128(%rbp), %rcx
movq %rcx, %rsi
addq $0x1, %rsi
movq %rsi, -0x128(%rbp)
movl %edx, (%rax,%rcx,4)
movq $0x0, -0x150(%rbp)
movq -0x150(%rbp), %rax
movl -0x154(%rbp), %ecx
cmpq %rcx, %rax
jae 0x12940
movq -0xf0(%rbp), %rax
movq -0x128(%rbp), %rcx
movq %rcx, %rdx
addq $0x1, %rdx
movq %rdx, -0x128(%rbp)
movl $0x10, (%rax,%rcx,4)
movq -0xf0(%rbp), %rax
movq -0x128(%rbp), %rcx
movq %rcx, %rdx
addq $0x1, %rdx
movq %rdx, -0x128(%rbp)
movl $0x3, (%rax,%rcx,4)
movq -0x150(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x150(%rbp)
jmp 0x128d4
cmpl $0x3, -0x158(%rbp)
jb 0x12996
movq -0xf0(%rbp), %rax
movq -0x128(%rbp), %rcx
movq %rcx, %rdx
addq $0x1, %rdx
movq %rdx, -0x128(%rbp)
movl $0x10, (%rax,%rcx,4)
movl -0x158(%rbp), %edx
subl $0x3, %edx
movq -0xf0(%rbp), %rax
movq -0x128(%rbp), %rcx
movq %rcx, %rsi
addq $0x1, %rsi
movq %rsi, -0x128(%rbp)
movl %edx, (%rax,%rcx,4)
jmp 0x129aa
movl -0x158(%rbp), %ecx
movl -0x148(%rbp), %eax
subl %ecx, %eax
movl %eax, -0x148(%rbp)
movl -0x148(%rbp), %eax
addq -0x108(%rbp), %rax
movq %rax, -0x108(%rbp)
jmp 0x129f0
movq -0xe8(%rbp), %rax
movq -0x108(%rbp), %rcx
movl (%rax,%rcx,4), %edx
movq -0xf0(%rbp), %rax
movq -0x128(%rbp), %rcx
movq %rcx, %rsi
addq $0x1, %rsi
movq %rsi, -0x128(%rbp)
movl %edx, (%rax,%rcx,4)
jmp 0x129f2
jmp 0x129f4
movq -0x108(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x108(%rbp)
jmp 0x126c4
movq $0x0, -0x108(%rbp)
movq -0x108(%rbp), %rax
cmpq -0x128(%rbp), %rax
je 0x12a83
movq -0xe0(%rbp), %rax
movq -0xf0(%rbp), %rcx
movq -0x108(%rbp), %rdx
movl (%rcx,%rdx,4), %ecx
movl (%rax,%rcx,4), %edx
addl $0x1, %edx
movl %edx, (%rax,%rcx,4)
movq -0xf0(%rbp), %rax
movq -0x108(%rbp), %rcx
cmpl $0x10, (%rax,%rcx,4)
jb 0x12a6d
movq -0x108(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x108(%rbp)
jmp 0x12a6f
movq -0x108(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x108(%rbp)
jmp 0x12a16
movq -0xe0(%rbp), %rsi
leaq -0xc8(%rbp), %rdi
movl $0x13, %ecx
movl $0x7, %r8d
movq %rcx, %rdx
callq 0x13ee0
movl %eax, -0x34(%rbp)
cmpl $0x0, -0x34(%rbp)
je 0x12ab2
jmp 0x12daf
movq $0x13, -0x130(%rbp)
xorl %eax, %eax
cmpq $0x4, -0x130(%rbp)
movb %al, -0x162(%rbp)
jbe 0x12af8
movq -0xc0(%rbp), %rax
movq -0x130(%rbp), %rdx
subq $0x1, %rdx
leaq 0x89c8(%rip), %rcx      # 0x1b4b0
movl (%rcx,%rdx,4), %ecx
cmpl $0x0, (%rax,%rcx,4)
sete %al
movb %al, -0x162(%rbp)
movb -0x162(%rbp), %al
testb $0x1, %al
jne 0x12b04
jmp 0x12b18
movq -0x130(%rbp), %rax
addq $-0x1, %rax
movq %rax, -0x130(%rbp)
jmp 0x12abd
movq -0x8(%rbp), %rdi
movl -0xfc(%rbp), %esi
movl $0x1, %edx
callq 0x12e90
movq -0x8(%rbp), %rdi
xorl %esi, %esi
movl $0x1, %edx
callq 0x12e90
movq -0x8(%rbp), %rdi
movl $0x1, %esi
movl $0x1, %edx
callq 0x12e90
movq -0x110(%rbp), %rax
subq $0x101, %rax            # imm = 0x101
movl %eax, -0x134(%rbp)
movq -0x118(%rbp), %rax
subq $0x1, %rax
movl %eax, -0x138(%rbp)
movq -0x130(%rbp), %rax
subq $0x4, %rax
movl %eax, -0x13c(%rbp)
movq -0x8(%rbp), %rdi
movl -0x134(%rbp), %esi
movl $0x5, %edx
callq 0x12e90
movq -0x8(%rbp), %rdi
movl -0x138(%rbp), %esi
movl $0x5, %edx
callq 0x12e90
movq -0x8(%rbp), %rdi
movl -0x13c(%rbp), %esi
movl $0x4, %edx
callq 0x12e90
movq $0x0, -0x108(%rbp)
movq -0x108(%rbp), %rax
cmpq -0x130(%rbp), %rax
je 0x12c18
movq -0x8(%rbp), %rdi
movq -0xc0(%rbp), %rax
movq -0x108(%rbp), %rdx
leaq 0x88bc(%rip), %rcx      # 0x1b4b0
movl (%rcx,%rdx,4), %ecx
movl (%rax,%rcx,4), %esi
movl $0x3, %edx
callq 0x12e90
movq -0x108(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x108(%rbp)
jmp 0x12bcb
movq $0x0, -0x108(%rbp)
movq -0x108(%rbp), %rax
cmpq -0x128(%rbp), %rax
je 0x12d62
movq -0x8(%rbp), %rdi
movq -0xc8(%rbp), %rax
movq -0xf0(%rbp), %rcx
movq -0x108(%rbp), %rdx
movl (%rcx,%rdx,4), %ecx
movl (%rax,%rcx,4), %esi
movq -0xc0(%rbp), %rax
movq -0xf0(%rbp), %rcx
movq -0x108(%rbp), %rdx
movl (%rcx,%rdx,4), %ecx
movl (%rax,%rcx,4), %eax
movl %eax, %edx
callq 0x13900
movq -0xf0(%rbp), %rax
movq -0x108(%rbp), %rcx
cmpl $0x10, (%rax,%rcx,4)
jne 0x12cbf
movq -0x8(%rbp), %rdi
movq -0xf0(%rbp), %rax
movq -0x108(%rbp), %rcx
movq %rcx, %rdx
addq $0x1, %rdx
movq %rdx, -0x108(%rbp)
movl 0x4(%rax,%rcx,4), %esi
movl $0x2, %edx
callq 0x12e90
jmp 0x12d49
movq -0xf0(%rbp), %rax
movq -0x108(%rbp), %rcx
cmpl $0x11, (%rax,%rcx,4)
jne 0x12d03
movq -0x8(%rbp), %rdi
movq -0xf0(%rbp), %rax
movq -0x108(%rbp), %rcx
movq %rcx, %rdx
addq $0x1, %rdx
movq %rdx, -0x108(%rbp)
movl 0x4(%rax,%rcx,4), %esi
movl $0x3, %edx
callq 0x12e90
jmp 0x12d47
movq -0xf0(%rbp), %rax
movq -0x108(%rbp), %rcx
cmpl $0x12, (%rax,%rcx,4)
jne 0x12d45
movq -0x8(%rbp), %rdi
movq -0xf0(%rbp), %rax
movq -0x108(%rbp), %rcx
movq %rcx, %rdx
addq $0x1, %rdx
movq %rdx, -0x108(%rbp)
movl 0x4(%rax,%rcx,4), %esi
movl $0x7, %edx
callq 0x12e90
jmp 0x12d47
jmp 0x12d49
jmp 0x12d4b
movq -0x108(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x108(%rbp)
jmp 0x12c23
movq -0x8(%rbp), %rdi
leaq -0x50(%rbp), %rsi
leaq -0x78(%rbp), %rdx
leaq -0xa0(%rbp), %rcx
callq 0x13740
movq -0x70(%rbp), %rax
cmpl $0x0, 0x400(%rax)
jne 0x12d90
movl $0x40, -0x34(%rbp)
jmp 0x12daf
movq -0x8(%rbp), %rdi
movq -0x78(%rbp), %rax
movl 0x400(%rax), %esi
movq -0x70(%rbp), %rax
movl 0x400(%rax), %eax
movl %eax, %edx
callq 0x13900
leaq -0x50(%rbp), %rdi
callq 0x138b0
leaq -0x78(%rbp), %rdi
callq 0x111f0
leaq -0xa0(%rbp), %rdi
callq 0x111f0
leaq -0xc8(%rbp), %rdi
callq 0x111f0
movq -0xd0(%rbp), %rdi
callq 0x5060
movq -0xd8(%rbp), %rdi
callq 0x5060
movq -0xe0(%rbp), %rdi
callq 0x5060
movq -0xe8(%rbp), %rdi
callq 0x5060
movq -0xf0(%rbp), %rdi
callq 0x5060
movl -0x34(%rbp), %eax
addq $0x180, %rsp            # imm = 0x180
popq %rbp
retq
nopw %cs:(%rax,%rax)