// File: phillip-h[P]fractal-gen/lodepng.cpp
// Function: lodepng_get_color_profile(LodePNGColorProfile*, unsigned char const*, unsigned int, unsigned int, LodePNGColorMode const*)
unsigned lodepng_get_color_profile(LodePNGColorProfile* profile,
                                   const unsigned char* in, unsigned w, unsigned h,
                                   const LodePNGColorMode* mode)
{
  unsigned error = 0;
  size_t i;
  ColorTree tree;
  size_t numpixels = w * h;

  unsigned colored_done = lodepng_is_greyscale_type(mode) ? 1 : 0;
  unsigned alpha_done = lodepng_can_have_alpha(mode) ? 0 : 1;
  unsigned numcolors_done = 0;
  unsigned bpp = lodepng_get_bpp(mode);
  unsigned bits_done = bpp == 1 ? 1 : 0;
  unsigned maxnumcolors = 257;
  unsigned sixteen = 0;
  if(bpp <= 8) maxnumcolors = bpp == 1 ? 2 : (bpp == 2 ? 4 : (bpp == 4 ? 16 : 256));

  color_tree_init(&tree);

  /*Check if the 16-bit input is truly 16-bit*/
  if(mode->bitdepth == 16)
  {
    unsigned short r, g, b, a;
    for(i = 0; i != numpixels; ++i)
    {
      getPixelColorRGBA16(&r, &g, &b, &a, in, i, mode);
      if((r & 255) != ((r >> 8) & 255) || (g & 255) != ((g >> 8) & 255) ||
         (b & 255) != ((b >> 8) & 255) || (a & 255) != ((a >> 8) & 255)) /*first and second byte differ*/
      {
        sixteen = 1;
        break;
      }
    }
  }

  if(sixteen)
  {
    unsigned short r = 0, g = 0, b = 0, a = 0;
    profile->bits = 16;
    bits_done = numcolors_done = 1; /*counting colors no longer useful, palette doesn't support 16-bit*/

    for(i = 0; i != numpixels; ++i)
    {
      getPixelColorRGBA16(&r, &g, &b, &a, in, i, mode);

      if(!colored_done && (r != g || r != b))
      {
        profile->colored = 1;
        colored_done = 1;
      }

      if(!alpha_done)
      {
        unsigned matchkey = (r == profile->key_r && g == profile->key_g && b == profile->key_b);
        if(a != 65535 && (a != 0 || (profile->key && !matchkey)))
        {
          profile->alpha = 1;
          alpha_done = 1;
          if(profile->bits < 8) profile->bits = 8; /*PNG has no alphachannel modes with less than 8-bit per channel*/
        }
        else if(a == 0 && !profile->alpha && !profile->key)
        {
          profile->key = 1;
          profile->key_r = r;
          profile->key_g = g;
          profile->key_b = b;
        }
        else if(a == 65535 && profile->key && matchkey)
        {
          /* Color key cannot be used if an opaque pixel also has that RGB color. */
          profile->alpha = 1;
          alpha_done = 1;
        }
      }
      if(alpha_done && numcolors_done && colored_done && bits_done) break;
    }

    if(profile->key && !profile->alpha)
    {
      for(i = 0; i != numpixels; ++i)
      {
        getPixelColorRGBA16(&r, &g, &b, &a, in, i, mode);
        if(a != 0 && r == profile->key_r && g == profile->key_g && b == profile->key_b)
        {
          /* Color key cannot be used if an opaque pixel also has that RGB color. */
          profile->alpha = 1;
          alpha_done = 1;
        }
      }
    }
  }
  else /* < 16-bit */
  {
    unsigned char r = 0, g = 0, b = 0, a = 0;
    for(i = 0; i != numpixels; ++i)
    {
      getPixelColorRGBA8(&r, &g, &b, &a, in, i, mode);

      if(!bits_done && profile->bits < 8)
      {
        /*only r is checked, < 8 bits is only relevant for greyscale*/
        unsigned bits = getValueRequiredBits(r);
        if(bits > profile->bits) profile->bits = bits;
      }
      bits_done = (profile->bits >= bpp);

      if(!colored_done && (r != g || r != b))
      {
        profile->colored = 1;
        colored_done = 1;
        if(profile->bits < 8) profile->bits = 8; /*PNG has no colored modes with less than 8-bit per channel*/
      }

      if(!alpha_done)
      {
        unsigned matchkey = (r == profile->key_r && g == profile->key_g && b == profile->key_b);
        if(a != 255 && (a != 0 || (profile->key && !matchkey)))
        {
          profile->alpha = 1;
          alpha_done = 1;
          if(profile->bits < 8) profile->bits = 8; /*PNG has no alphachannel modes with less than 8-bit per channel*/
        }
        else if(a == 0 && !profile->alpha && !profile->key)
        {
          profile->key = 1;
          profile->key_r = r;
          profile->key_g = g;
          profile->key_b = b;
        }
        else if(a == 255 && profile->key && matchkey)
        {
          /* Color key cannot be used if an opaque pixel also has that RGB color. */
          profile->alpha = 1;
          alpha_done = 1;
          if(profile->bits < 8) profile->bits = 8; /*PNG has no alphachannel modes with less than 8-bit per channel*/
        }
      }

      if(!numcolors_done)
      {
        if(!color_tree_has(&tree, r, g, b, a))
        {
          color_tree_add(&tree, r, g, b, a, profile->numcolors);
          if(profile->numcolors < 256)
          {
            unsigned char* p = profile->palette;
            unsigned n = profile->numcolors;
            p[n * 4 + 0] = r;
            p[n * 4 + 1] = g;
            p[n * 4 + 2] = b;
            p[n * 4 + 3] = a;
          }
          ++profile->numcolors;
          numcolors_done = profile->numcolors >= maxnumcolors;
        }
      }

      if(alpha_done && numcolors_done && colored_done && bits_done) break;
    }

    if(profile->key && !profile->alpha)
    {
      for(i = 0; i != numpixels; ++i)
      {
        getPixelColorRGBA8(&r, &g, &b, &a, in, i, mode);
        if(a != 0 && r == profile->key_r && g == profile->key_g && b == profile->key_b)
        {
          /* Color key cannot be used if an opaque pixel also has that RGB color. */
          profile->alpha = 1;
          alpha_done = 1;
        }
      }
    }

    /*make the profile's key always 16-bit for consistency - repeat each byte twice*/
    profile->key_r += (profile->key_r << 8);
    profile->key_g += (profile->key_g << 8);
    profile->key_b += (profile->key_b << 8);
  }

  color_tree_cleanup(&tree);
  return error;
}

// Assembly:
subq $0x128, %rsp            # imm = 0x128
movq %rdi, 0x120(%rsp)
movq %rsi, 0x118(%rsp)
movl %edx, 0x114(%rsp)
movl %ecx, 0x110(%rsp)
movq %r8, 0x108(%rsp)
movl $0x0, 0x104(%rsp)
movl 0x114(%rsp), %eax
imull 0x110(%rsp), %eax
movl %eax, %eax
movq %rax, 0x68(%rsp)
movq 0x108(%rsp), %rdi
callq 0x8da0
movl %eax, %edx
xorl %eax, %eax
movl $0x1, %ecx
cmpl $0x0, %edx
cmovnel %ecx, %eax
movl %eax, 0x64(%rsp)
movq 0x108(%rsp), %rdi
callq 0x8e80
movl %eax, %edx
movl $0x1, %eax
xorl %ecx, %ecx
cmpl $0x0, %edx
cmovnel %ecx, %eax
movl %eax, 0x60(%rsp)
movl $0x0, 0x5c(%rsp)
movq 0x108(%rsp), %rdi
callq 0x8cd0
movl %eax, 0x58(%rsp)
movl 0x58(%rsp), %edx
xorl %eax, %eax
movl $0x1, %ecx
cmpl $0x1, %edx
cmovel %ecx, %eax
movl %eax, 0x54(%rsp)
movl $0x101, 0x50(%rsp)      # imm = 0x101
movl $0x0, 0x4c(%rsp)
cmpl $0x8, 0x58(%rsp)
ja 0xc02f
cmpl $0x1, 0x58(%rsp)
jne 0xbff5
movl $0x2, %eax
movl %eax, 0x18(%rsp)
jmp 0xc027
cmpl $0x2, 0x58(%rsp)
jne 0xc007
movl $0x4, %eax
movl %eax, 0x14(%rsp)
jmp 0xc01f
movl 0x58(%rsp), %edx
movl $0x100, %eax            # imm = 0x100
movl $0x10, %ecx
cmpl $0x4, %edx
cmovel %ecx, %eax
movl %eax, 0x14(%rsp)
movl 0x14(%rsp), %eax
movl %eax, 0x18(%rsp)
movl 0x18(%rsp), %eax
movl %eax, 0x50(%rsp)
leaq 0x70(%rsp), %rdi
callq 0xa240
movq 0x108(%rsp), %rax
cmpl $0x10, 0x4(%rax)
jne 0xc136
movq $0x0, 0xf8(%rsp)
movq 0xf8(%rsp), %rax
cmpq 0x68(%rsp), %rax
je 0xc134
movq 0x118(%rsp), %r8
movq 0xf8(%rsp), %r9
movq 0x108(%rsp), %rax
leaq 0x4a(%rsp), %rdi
leaq 0x48(%rsp), %rsi
leaq 0x46(%rsp), %rdx
leaq 0x44(%rsp), %rcx
movq %rax, (%rsp)
callq 0xa390
movzwl 0x4a(%rsp), %eax
andl $0xff, %eax
movzwl 0x4a(%rsp), %ecx
sarl $0x8, %ecx
andl $0xff, %ecx
cmpl %ecx, %eax
jne 0xc10f
movzwl 0x48(%rsp), %eax
andl $0xff, %eax
movzwl 0x48(%rsp), %ecx
sarl $0x8, %ecx
andl $0xff, %ecx
cmpl %ecx, %eax
jne 0xc10f
movzwl 0x46(%rsp), %eax
andl $0xff, %eax
movzwl 0x46(%rsp), %ecx
sarl $0x8, %ecx
andl $0xff, %ecx
cmpl %ecx, %eax
jne 0xc10f
movzwl 0x44(%rsp), %eax
andl $0xff, %eax
movzwl 0x44(%rsp), %ecx
sarl $0x8, %ecx
andl $0xff, %ecx
cmpl %ecx, %eax
je 0xc119
movl $0x1, 0x4c(%rsp)
jmp 0xc134
jmp 0xc11b
movq 0xf8(%rsp), %rax
addq $0x1, %rax
movq %rax, 0xf8(%rsp)
jmp 0xc057
jmp 0xc136
cmpl $0x0, 0x4c(%rsp)
je 0xc4b9
movw $0x0, 0x42(%rsp)
movw $0x0, 0x40(%rsp)
movw $0x0, 0x3e(%rsp)
movw $0x0, 0x3c(%rsp)
movq 0x120(%rsp), %rax
movl $0x10, 0x418(%rax)
movl $0x1, 0x5c(%rsp)
movl $0x1, 0x54(%rsp)
movq $0x0, 0xf8(%rsp)
movq 0xf8(%rsp), %rax
cmpq 0x68(%rsp), %rax
je 0xc3bf
movq 0x118(%rsp), %r8
movq 0xf8(%rsp), %r9
movq 0x108(%rsp), %rax
leaq 0x42(%rsp), %rdi
leaq 0x40(%rsp), %rsi
leaq 0x3e(%rsp), %rdx
leaq 0x3c(%rsp), %rcx
movq %rax, (%rsp)
callq 0xa390
cmpl $0x0, 0x64(%rsp)
jne 0xc20c
movzwl 0x42(%rsp), %eax
movzwl 0x40(%rsp), %ecx
cmpl %ecx, %eax
jne 0xc1f6
movzwl 0x42(%rsp), %eax
movzwl 0x3e(%rsp), %ecx
cmpl %ecx, %eax
je 0xc20c
movq 0x120(%rsp), %rax
movl $0x1, (%rax)
movl $0x1, 0x64(%rsp)
cmpl $0x0, 0x60(%rsp)
jne 0xc386
movzwl 0x42(%rsp), %ecx
movq 0x120(%rsp), %rax
movzwl 0x8(%rax), %edx
xorl %eax, %eax
cmpl %edx, %ecx
movb %al, 0x13(%rsp)
jne 0xc267
movzwl 0x40(%rsp), %ecx
movq 0x120(%rsp), %rax
movzwl 0xa(%rax), %edx
xorl %eax, %eax
cmpl %edx, %ecx
movb %al, 0x13(%rsp)
jne 0xc267
movzwl 0x3e(%rsp), %eax
movq 0x120(%rsp), %rcx
movzwl 0xc(%rcx), %ecx
cmpl %ecx, %eax
sete %al
movb %al, 0x13(%rsp)
movb 0x13(%rsp), %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, 0x38(%rsp)
movzwl 0x3c(%rsp), %eax
cmpl $0xffff, %eax           # imm = 0xFFFF
je 0xc2de
movzwl 0x3c(%rsp), %eax
cmpl $0x0, %eax
jne 0xc29f
movq 0x120(%rsp), %rax
cmpl $0x0, 0x4(%rax)
je 0xc2de
cmpl $0x0, 0x38(%rsp)
jne 0xc2de
movq 0x120(%rsp), %rax
movl $0x1, 0x10(%rax)
movl $0x1, 0x60(%rsp)
movq 0x120(%rsp), %rax
cmpl $0x8, 0x418(%rax)
jae 0xc2d9
movq 0x120(%rsp), %rax
movl $0x8, 0x418(%rax)
jmp 0xc384
movzwl 0x3c(%rsp), %eax
cmpl $0x0, %eax
jne 0xc348
movq 0x120(%rsp), %rax
cmpl $0x0, 0x10(%rax)
jne 0xc348
movq 0x120(%rsp), %rax
cmpl $0x0, 0x4(%rax)
jne 0xc348
movq 0x120(%rsp), %rax
movl $0x1, 0x4(%rax)
movw 0x42(%rsp), %cx
movq 0x120(%rsp), %rax
movw %cx, 0x8(%rax)
movw 0x40(%rsp), %cx
movq 0x120(%rsp), %rax
movw %cx, 0xa(%rax)
movw 0x3e(%rsp), %cx
movq 0x120(%rsp), %rax
movw %cx, 0xc(%rax)
jmp 0xc382
movzwl 0x3c(%rsp), %eax
cmpl $0xffff, %eax           # imm = 0xFFFF
jne 0xc380
movq 0x120(%rsp), %rax
cmpl $0x0, 0x4(%rax)
je 0xc380
cmpl $0x0, 0x38(%rsp)
je 0xc380
movq 0x120(%rsp), %rax
movl $0x1, 0x10(%rax)
movl $0x1, 0x60(%rsp)
jmp 0xc382
jmp 0xc384
jmp 0xc386
cmpl $0x0, 0x60(%rsp)
je 0xc3a4
cmpl $0x0, 0x5c(%rsp)
je 0xc3a4
cmpl $0x0, 0x64(%rsp)
je 0xc3a4
cmpl $0x0, 0x54(%rsp)
je 0xc3a4
jmp 0xc3bf
jmp 0xc3a6
movq 0xf8(%rsp), %rax
addq $0x1, %rax
movq %rax, 0xf8(%rsp)
jmp 0xc18b
movq 0x120(%rsp), %rax
cmpl $0x0, 0x4(%rax)
je 0xc4b4
movq 0x120(%rsp), %rax
cmpl $0x0, 0x10(%rax)
jne 0xc4b4
movq $0x0, 0xf8(%rsp)
movq 0xf8(%rsp), %rax
cmpq 0x68(%rsp), %rax
je 0xc4b2
movq 0x118(%rsp), %r8
movq 0xf8(%rsp), %r9
movq 0x108(%rsp), %rax
leaq 0x42(%rsp), %rdi
leaq 0x40(%rsp), %rsi
leaq 0x3e(%rsp), %rdx
leaq 0x3c(%rsp), %rcx
movq %rax, (%rsp)
callq 0xa390
movzwl 0x3c(%rsp), %eax
cmpl $0x0, %eax
je 0xc497
movzwl 0x42(%rsp), %eax
movq 0x120(%rsp), %rcx
movzwl 0x8(%rcx), %ecx
cmpl %ecx, %eax
jne 0xc497
movzwl 0x40(%rsp), %eax
movq 0x120(%rsp), %rcx
movzwl 0xa(%rcx), %ecx
cmpl %ecx, %eax
jne 0xc497
movzwl 0x3e(%rsp), %eax
movq 0x120(%rsp), %rcx
movzwl 0xc(%rcx), %ecx
cmpl %ecx, %eax
jne 0xc497
movq 0x120(%rsp), %rax
movl $0x1, 0x10(%rax)
movl $0x1, 0x60(%rsp)
jmp 0xc499
movq 0xf8(%rsp), %rax
addq $0x1, %rax
movq %rax, 0xf8(%rsp)
jmp 0xc3ef
jmp 0xc4b4
jmp 0xca55
movb $0x0, 0x37(%rsp)
movb $0x0, 0x36(%rsp)
movb $0x0, 0x35(%rsp)
movb $0x0, 0x34(%rsp)
movq $0x0, 0xf8(%rsp)
movq 0xf8(%rsp), %rax
cmpq 0x68(%rsp), %rax
je 0xc8fd
movq 0x118(%rsp), %r8
movq 0xf8(%rsp), %r9
movq 0x108(%rsp), %rax
leaq 0x37(%rsp), %rdi
leaq 0x36(%rsp), %rsi
leaq 0x35(%rsp), %rdx
leaq 0x34(%rsp), %rcx
movq %rax, (%rsp)
callq 0xb3e0
cmpl $0x0, 0x54(%rsp)
jne 0xc56f
movq 0x120(%rsp), %rax
cmpl $0x8, 0x418(%rax)
jae 0xc56f
movzbl 0x37(%rsp), %edi
callq 0xca70
movl %eax, 0x30(%rsp)
movl 0x30(%rsp), %eax
movq 0x120(%rsp), %rcx
cmpl 0x418(%rcx), %eax
jbe 0xc56d
movl 0x30(%rsp), %ecx
movq 0x120(%rsp), %rax
movl %ecx, 0x418(%rax)
jmp 0xc56f
movq 0x120(%rsp), %rax
movl 0x418(%rax), %eax
cmpl 0x58(%rsp), %eax
setae %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, 0x54(%rsp)
cmpl $0x0, 0x64(%rsp)
jne 0xc5eb
movzbl 0x37(%rsp), %eax
movzbl 0x36(%rsp), %ecx
cmpl %ecx, %eax
jne 0xc5b0
movzbl 0x37(%rsp), %eax
movzbl 0x35(%rsp), %ecx
cmpl %ecx, %eax
je 0xc5eb
movq 0x120(%rsp), %rax
movl $0x1, (%rax)
movl $0x1, 0x64(%rsp)
movq 0x120(%rsp), %rax
cmpl $0x8, 0x418(%rax)
jae 0xc5e9
movq 0x120(%rsp), %rax
movl $0x8, 0x418(%rax)
jmp 0xc5eb
cmpl $0x0, 0x60(%rsp)
jne 0xc793
movzbl 0x37(%rsp), %ecx
movq 0x120(%rsp), %rax
movzwl 0x8(%rax), %edx
xorl %eax, %eax
cmpl %edx, %ecx
movb %al, 0x12(%rsp)
jne 0xc646
movzbl 0x36(%rsp), %ecx
movq 0x120(%rsp), %rax
movzwl 0xa(%rax), %edx
xorl %eax, %eax
cmpl %edx, %ecx
movb %al, 0x12(%rsp)
jne 0xc646
movzbl 0x35(%rsp), %eax
movq 0x120(%rsp), %rcx
movzwl 0xc(%rcx), %ecx
cmpl %ecx, %eax
sete %al
movb %al, 0x12(%rsp)
movb 0x12(%rsp), %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, 0x2c(%rsp)
movzbl 0x34(%rsp), %eax
cmpl $0xff, %eax
je 0xc6bd
movzbl 0x34(%rsp), %eax
cmpl $0x0, %eax
jne 0xc67e
movq 0x120(%rsp), %rax
cmpl $0x0, 0x4(%rax)
je 0xc6bd
cmpl $0x0, 0x2c(%rsp)
jne 0xc6bd
movq 0x120(%rsp), %rax
movl $0x1, 0x10(%rax)
movl $0x1, 0x60(%rsp)
movq 0x120(%rsp), %rax
cmpl $0x8, 0x418(%rax)
jae 0xc6b8
movq 0x120(%rsp), %rax
movl $0x8, 0x418(%rax)
jmp 0xc791
movzbl 0x34(%rsp), %eax
cmpl $0x0, %eax
jne 0xc730
movq 0x120(%rsp), %rax
cmpl $0x0, 0x10(%rax)
jne 0xc730
movq 0x120(%rsp), %rax
cmpl $0x0, 0x4(%rax)
jne 0xc730
movq 0x120(%rsp), %rax
movl $0x1, 0x4(%rax)
movzbl 0x37(%rsp), %eax
movw %ax, %cx
movq 0x120(%rsp), %rax
movw %cx, 0x8(%rax)
movzbl 0x36(%rsp), %eax
movw %ax, %cx
movq 0x120(%rsp), %rax
movw %cx, 0xa(%rax)
movzbl 0x35(%rsp), %eax
movw %ax, %cx
movq 0x120(%rsp), %rax
movw %cx, 0xc(%rax)
jmp 0xc78f
movzbl 0x34(%rsp), %eax
cmpl $0xff, %eax
jne 0xc78d
movq 0x120(%rsp), %rax
cmpl $0x0, 0x4(%rax)
je 0xc78d
cmpl $0x0, 0x2c(%rsp)
je 0xc78d
movq 0x120(%rsp), %rax
movl $0x1, 0x10(%rax)
movl $0x1, 0x60(%rsp)
movq 0x120(%rsp), %rax
cmpl $0x8, 0x418(%rax)
jae 0xc78b
movq 0x120(%rsp), %rax
movl $0x8, 0x418(%rax)
jmp 0xc78d
jmp 0xc78f
jmp 0xc791
jmp 0xc793
cmpl $0x0, 0x5c(%rsp)
jne 0xc8c4
movb 0x37(%rsp), %dl
movb 0x36(%rsp), %cl
movb 0x35(%rsp), %al
leaq 0x70(%rsp), %rdi
movzbl %dl, %esi
movzbl %cl, %edx
movzbl %al, %ecx
movzbl 0x34(%rsp), %r8d
callq 0xcae0
cmpl $0x0, %eax
jne 0xc8c2
movb 0x37(%rsp), %sil
movb 0x36(%rsp), %dl
movb 0x35(%rsp), %cl
movb 0x34(%rsp), %al
movq 0x120(%rsp), %rdi
movl 0x14(%rdi), %r9d
leaq 0x70(%rsp), %rdi
movzbl %sil, %esi
movzbl %dl, %edx
movzbl %cl, %ecx
movzbl %al, %r8d
callq 0xa290
movq 0x120(%rsp), %rax
cmpl $0x100, 0x14(%rax)      # imm = 0x100
jae 0xc896
movq 0x120(%rsp), %rax
addq $0x18, %rax
movq %rax, 0x20(%rsp)
movq 0x120(%rsp), %rax
movl 0x14(%rax), %eax
movl %eax, 0x1c(%rsp)
movb 0x37(%rsp), %dl
movq 0x20(%rsp), %rax
movl 0x1c(%rsp), %ecx
shll $0x2, %ecx
addl $0x0, %ecx
movl %ecx, %ecx
movb %dl, (%rax,%rcx)
movb 0x36(%rsp), %dl
movq 0x20(%rsp), %rax
movl 0x1c(%rsp), %ecx
shll $0x2, %ecx
addl $0x1, %ecx
movl %ecx, %ecx
movb %dl, (%rax,%rcx)
movb 0x35(%rsp), %dl
movq 0x20(%rsp), %rax
movl 0x1c(%rsp), %ecx
shll $0x2, %ecx
addl $0x2, %ecx
movl %ecx, %ecx
movb %dl, (%rax,%rcx)
movb 0x34(%rsp), %dl
movq 0x20(%rsp), %rax
movl 0x1c(%rsp), %ecx
shll $0x2, %ecx
addl $0x3, %ecx
movl %ecx, %ecx
movb %dl, (%rax,%rcx)
movq 0x120(%rsp), %rax
movl 0x14(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x14(%rax)
movq 0x120(%rsp), %rax
movl 0x14(%rax), %eax
cmpl 0x50(%rsp), %eax
setae %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, 0x5c(%rsp)
jmp 0xc8c4
cmpl $0x0, 0x60(%rsp)
je 0xc8e2
cmpl $0x0, 0x5c(%rsp)
je 0xc8e2
cmpl $0x0, 0x64(%rsp)
je 0xc8e2
cmpl $0x0, 0x54(%rsp)
je 0xc8e2
jmp 0xc8fd
jmp 0xc8e4
movq 0xf8(%rsp), %rax
addq $0x1, %rax
movq %rax, 0xf8(%rsp)
jmp 0xc4d9
movq 0x120(%rsp), %rax
cmpl $0x0, 0x4(%rax)
je 0xc9f2
movq 0x120(%rsp), %rax
cmpl $0x0, 0x10(%rax)
jne 0xc9f2
movq $0x0, 0xf8(%rsp)
movq 0xf8(%rsp), %rax
cmpq 0x68(%rsp), %rax
je 0xc9f0
movq 0x118(%rsp), %r8
movq 0xf8(%rsp), %r9
movq 0x108(%rsp), %rax
leaq 0x37(%rsp), %rdi
leaq 0x36(%rsp), %rsi
leaq 0x35(%rsp), %rdx
leaq 0x34(%rsp), %rcx
movq %rax, (%rsp)
callq 0xb3e0
movzbl 0x34(%rsp), %eax
cmpl $0x0, %eax
je 0xc9d5
movzbl 0x37(%rsp), %eax
movq 0x120(%rsp), %rcx
movzwl 0x8(%rcx), %ecx
cmpl %ecx, %eax
jne 0xc9d5
movzbl 0x36(%rsp), %eax
movq 0x120(%rsp), %rcx
movzwl 0xa(%rcx), %ecx
cmpl %ecx, %eax
jne 0xc9d5
movzbl 0x35(%rsp), %eax
movq 0x120(%rsp), %rcx
movzwl 0xc(%rcx), %ecx
cmpl %ecx, %eax
jne 0xc9d5
movq 0x120(%rsp), %rax
movl $0x1, 0x10(%rax)
movl $0x1, 0x60(%rsp)
jmp 0xc9d7
movq 0xf8(%rsp), %rax
addq $0x1, %rax
movq %rax, 0xf8(%rsp)
jmp 0xc92d
jmp 0xc9f2
movq 0x120(%rsp), %rax
movzwl 0x8(%rax), %edx
shll $0x8, %edx
movq 0x120(%rsp), %rax
movzwl 0x8(%rax), %ecx
addl %edx, %ecx
movw %cx, 0x8(%rax)
movq 0x120(%rsp), %rax
movzwl 0xa(%rax), %edx
shll $0x8, %edx
movq 0x120(%rsp), %rax
movzwl 0xa(%rax), %ecx
addl %edx, %ecx
movw %cx, 0xa(%rax)
movq 0x120(%rsp), %rax
movzwl 0xc(%rax), %edx
shll $0x8, %edx
movq 0x120(%rsp), %rax
movzwl 0xc(%rax), %ecx
addl %edx, %ecx
movw %cx, 0xc(%rax)
leaq 0x70(%rsp), %rdi
callq 0xbe30
movl 0x104(%rsp), %eax
addq $0x128, %rsp            # imm = 0x128
retq
nop