// File: Lut99[P]RayTracer/src/lib/LodePNG.cpp
// Function: lodepng_compute_color_stats(LodePNGColorStats*, unsigned char const*, unsigned int, unsigned int, LodePNGColorMode const*)
void lodepng_compute_color_stats(LodePNGColorStats* stats,
                                 const unsigned char* in, unsigned w, unsigned h,
                                 const LodePNGColorMode* mode_in) {
  size_t i;
  ColorTree tree;
  size_t numpixels = (size_t)w * (size_t)h;

  /* mark things as done already if it would be impossible to have a more expensive case */
  unsigned colored_done = lodepng_is_greyscale_type(mode_in) ? 1 : 0;
  unsigned alpha_done = lodepng_can_have_alpha(mode_in) ? 0 : 1;
  unsigned numcolors_done = 0;
  unsigned bpp = lodepng_get_bpp(mode_in);
  unsigned bits_done = (stats->bits == 1 && bpp == 1) ? 1 : 0;
  unsigned sixteen = 0; /* whether the input image is 16 bit */
  unsigned maxnumcolors = 257;
  if(bpp <= 8) maxnumcolors = LODEPNG_MIN(257, stats->numcolors + (1u << bpp));

  stats->numpixels += numpixels;

  /*if palette not allowed, no need to compute numcolors*/
  if(!stats->allow_palette) numcolors_done = 1;

  color_tree_init(&tree);

  /*If the stats was already filled in from previous data, fill its palette in tree
  and mark things as done already if we know they are the most expensive case already*/
  if(stats->alpha) alpha_done = 1;
  if(stats->colored) colored_done = 1;
  if(stats->bits == 16) numcolors_done = 1;
  if(stats->bits >= bpp) bits_done = 1;
  if(stats->numcolors >= maxnumcolors) numcolors_done = 1;

  if(!numcolors_done) {
    for(i = 0; i < stats->numcolors; i++) {
      const unsigned char* color = &stats->palette[i * 4];
      color_tree_add(&tree, color[0], color[1], color[2], color[3], (unsigned int) i);
    }
  }

  /*Check if the 16-bit input is truly 16-bit*/
  if(mode_in->bitdepth == 16 && !sixteen) {
    unsigned short r, g, b, a;
    for(i = 0; i != numpixels; ++i) {
      getPixelColorRGBA16(&r, &g, &b, &a, in, i, mode_in);
      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*/ {
        stats->bits = 16;
        sixteen = 1;
        bits_done = 1;
        numcolors_done = 1; /*counting colors no longer useful, palette doesn't support 16-bit*/
        break;
      }
    }
  }

  if(sixteen) {
    unsigned short r = 0, g = 0, b = 0, a = 0;

    for(i = 0; i != numpixels; ++i) {
      getPixelColorRGBA16(&r, &g, &b, &a, in, i, mode_in);

      if(!colored_done && (r != g || r != b)) {
        stats->colored = 1;
        colored_done = 1;
      }

      if(!alpha_done) {
        unsigned matchkey = (r == stats->key_r && g == stats->key_g && b == stats->key_b);
        if(a != 65535 && (a != 0 || (stats->key && !matchkey))) {
          stats->alpha = 1;
          stats->key = 0;
          alpha_done = 1;
        } else if(a == 0 && !stats->alpha && !stats->key) {
          stats->key = 1;
          stats->key_r = r;
          stats->key_g = g;
          stats->key_b = b;
        } else if(a == 65535 && stats->key && matchkey) {
          /* Color key cannot be used if an opaque pixel also has that RGB color. */
          stats->alpha = 1;
          stats->key = 0;
          alpha_done = 1;
        }
      }
      if(alpha_done && numcolors_done && colored_done && bits_done) break;
    }

    if(stats->key && !stats->alpha) {
      for(i = 0; i != numpixels; ++i) {
        getPixelColorRGBA16(&r, &g, &b, &a, in, i, mode_in);
        if(a != 0 && r == stats->key_r && g == stats->key_g && b == stats->key_b) {
          /* Color key cannot be used if an opaque pixel also has that RGB color. */
          stats->alpha = 1;
          stats->key = 0;
          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_in);

      if(!bits_done && stats->bits < 8) {
        /*only r is checked, < 8 bits is only relevant for grayscale*/
        unsigned bits = getValueRequiredBits(r);
        if(bits > stats->bits) stats->bits = bits;
      }
      bits_done = (stats->bits >= bpp);

      if(!colored_done && (r != g || r != b)) {
        stats->colored = 1;
        colored_done = 1;
        if(stats->bits < 8) stats->bits = 8; /*PNG has no colored modes with less than 8-bit per channel*/
      }

      if(!alpha_done) {
        unsigned matchkey = (r == stats->key_r && g == stats->key_g && b == stats->key_b);
        if(a != 255 && (a != 0 || (stats->key && !matchkey))) {
          stats->alpha = 1;
          stats->key = 0;
          alpha_done = 1;
          if(stats->bits < 8) stats->bits = 8; /*PNG has no alphachannel modes with less than 8-bit per channel*/
        } else if(a == 0 && !stats->alpha && !stats->key) {
          stats->key = 1;
          stats->key_r = r;
          stats->key_g = g;
          stats->key_b = b;
        } else if(a == 255 && stats->key && matchkey) {
          /* Color key cannot be used if an opaque pixel also has that RGB color. */
          stats->alpha = 1;
          stats->key = 0;
          alpha_done = 1;
          if(stats->bits < 8) stats->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, stats->numcolors);
          if(stats->numcolors < 256) {
            unsigned char* p = stats->palette;
            unsigned n = stats->numcolors;
            p[n * 4 + 0] = r;
            p[n * 4 + 1] = g;
            p[n * 4 + 2] = b;
            p[n * 4 + 3] = a;
          }
          ++stats->numcolors;
          numcolors_done = stats->numcolors >= maxnumcolors;
        }
      }

      if(alpha_done && numcolors_done && colored_done && bits_done) break;
    }

    if(stats->key && !stats->alpha) {
      for(i = 0; i != numpixels; ++i) {
        getPixelColorRGBA8(&r, &g, &b, &a, in, i, mode_in);
        if(a != 0 && r == stats->key_r && g == stats->key_g && b == stats->key_b) {
          /* Color key cannot be used if an opaque pixel also has that RGB color. */
          stats->alpha = 1;
          stats->key = 0;
          alpha_done = 1;
          if(stats->bits < 8) stats->bits = 8; /*PNG has no alphachannel modes with less than 8-bit per channel*/
        }
      }
    }

    /*make the stats's key always 16-bit for consistency - repeat each byte twice*/
    stats->key_r += (stats->key_r << 8);
    stats->key_g += (stats->key_g << 8);
    stats->key_b += (stats->key_b << 8);
  }

  color_tree_cleanup(&tree);
}

// 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 0x114(%rsp), %eax
movl 0x110(%rsp), %ecx
imulq %rcx, %rax
movq %rax, 0x70(%rsp)
movq 0x108(%rsp), %rdi
callq 0x13fc20
movl %eax, %edx
xorl %eax, %eax
movl $0x1, %ecx
cmpl $0x0, %edx
cmovnel %ecx, %eax
movl %eax, 0x6c(%rsp)
movq 0x108(%rsp), %rdi
callq 0x13fd00
movl %eax, %edx
movl $0x1, %eax
xorl %ecx, %ecx
cmpl $0x0, %edx
cmovnel %ecx, %eax
movl %eax, 0x68(%rsp)
movl $0x0, 0x64(%rsp)
movq 0x108(%rsp), %rdi
callq 0x13fb50
movl %eax, 0x60(%rsp)
movq 0x120(%rsp), %rcx
xorl %eax, %eax
cmpl $0x1, 0x418(%rcx)
movb %al, 0x1b(%rsp)
jne 0x1437a0
cmpl $0x1, 0x60(%rsp)
sete %al
movb %al, 0x1b(%rsp)
movb 0x1b(%rsp), %dl
xorl %eax, %eax
movl $0x1, %ecx
testb $0x1, %dl
cmovnel %ecx, %eax
movl %eax, 0x5c(%rsp)
movl $0x0, 0x58(%rsp)
movl $0x101, 0x54(%rsp)      # imm = 0x101
cmpl $0x8, 0x60(%rsp)
ja 0x143826
movq 0x120(%rsp), %rax
movl 0x14(%rax), %eax
movl %eax, 0x14(%rsp)
movl 0x60(%rsp), %ecx
movl $0x1, %eax
shll %cl, %eax
movl 0x14(%rsp), %ecx
addl %eax, %ecx
movl $0x101, %eax            # imm = 0x101
cmpl %ecx, %eax
jae 0x143800
movl $0x101, %eax            # imm = 0x101
movl %eax, 0x10(%rsp)
jmp 0x14381e
movq 0x120(%rsp), %rax
movl 0x14(%rax), %eax
movl 0x60(%rsp), %ecx
movl $0x1, %edx
shll %cl, %edx
movl %edx, %ecx
addl %ecx, %eax
movl %eax, 0x10(%rsp)
movl 0x10(%rsp), %eax
movl %eax, 0x54(%rsp)
movq 0x70(%rsp), %rcx
movq 0x120(%rsp), %rax
addq 0x420(%rax), %rcx
movq %rcx, 0x420(%rax)
movq 0x120(%rsp), %rax
cmpl $0x0, 0x428(%rax)
jne 0x14385a
movl $0x1, 0x64(%rsp)
leaq 0x78(%rsp), %rdi
callq 0x1412b0
movq 0x120(%rsp), %rax
cmpl $0x0, 0x10(%rax)
je 0x14387a
movl $0x1, 0x68(%rsp)
movq 0x120(%rsp), %rax
cmpl $0x0, (%rax)
je 0x14388f
movl $0x1, 0x6c(%rsp)
movq 0x120(%rsp), %rax
cmpl $0x10, 0x418(%rax)
jne 0x1438a8
movl $0x1, 0x64(%rsp)
movq 0x120(%rsp), %rax
movl 0x418(%rax), %eax
cmpl 0x60(%rsp), %eax
jb 0x1438c4
movl $0x1, 0x5c(%rsp)
movq 0x120(%rsp), %rax
movl 0x14(%rax), %eax
cmpl 0x54(%rsp), %eax
jb 0x1438dd
movl $0x1, 0x64(%rsp)
cmpl $0x0, 0x64(%rsp)
jne 0x14398a
movq $0x0, 0x100(%rsp)
movq 0x100(%rsp), %rax
movq 0x120(%rsp), %rcx
movl 0x14(%rcx), %ecx
cmpq %rcx, %rax
jae 0x143988
movq 0x120(%rsp), %rax
addq $0x18, %rax
movq 0x100(%rsp), %rcx
shlq $0x2, %rcx
addq %rcx, %rax
movq %rax, 0x48(%rsp)
movq 0x48(%rsp), %rax
movb (%rax), %sil
movq 0x48(%rsp), %rax
movb 0x1(%rax), %dl
movq 0x48(%rsp), %rax
movb 0x2(%rax), %cl
movq 0x48(%rsp), %rax
movb 0x3(%rax), %al
movq 0x100(%rsp), %rdi
movl %edi, %r9d
leaq 0x78(%rsp), %rdi
movzbl %sil, %esi
movzbl %dl, %edx
movzbl %cl, %ecx
movzbl %al, %r8d
callq 0x141300
movq 0x100(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x100(%rsp)
jmp 0x1438f4
jmp 0x14398a
movq 0x108(%rsp), %rax
cmpl $0x10, 0x4(%rax)
jne 0x143ab4
cmpl $0x0, 0x58(%rsp)
jne 0x143ab4
movq $0x0, 0x100(%rsp)
movq 0x100(%rsp), %rax
cmpq 0x70(%rsp), %rax
je 0x143ab2
movq 0x118(%rsp), %r8
movq 0x100(%rsp), %r9
movq 0x108(%rsp), %rax
leaq 0x46(%rsp), %rdi
leaq 0x44(%rsp), %rsi
leaq 0x42(%rsp), %rdx
leaq 0x40(%rsp), %rcx
movq %rax, (%rsp)
callq 0x141400
movzwl 0x46(%rsp), %eax
andl $0xff, %eax
movzwl 0x46(%rsp), %ecx
sarl $0x8, %ecx
andl $0xff, %ecx
cmpl %ecx, %eax
jne 0x143a6b
movzwl 0x44(%rsp), %eax
andl $0xff, %eax
movzwl 0x44(%rsp), %ecx
sarl $0x8, %ecx
andl $0xff, %ecx
cmpl %ecx, %eax
jne 0x143a6b
movzwl 0x42(%rsp), %eax
andl $0xff, %eax
movzwl 0x42(%rsp), %ecx
sarl $0x8, %ecx
andl $0xff, %ecx
cmpl %ecx, %eax
jne 0x143a6b
movzwl 0x40(%rsp), %eax
andl $0xff, %eax
movzwl 0x40(%rsp), %ecx
sarl $0x8, %ecx
andl $0xff, %ecx
cmpl %ecx, %eax
je 0x143a97
movq 0x120(%rsp), %rax
movl $0x10, 0x418(%rax)
movl $0x1, 0x58(%rsp)
movl $0x1, 0x5c(%rsp)
movl $0x1, 0x64(%rsp)
jmp 0x143ab2
jmp 0x143a99
movq 0x100(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x100(%rsp)
jmp 0x1439b3
jmp 0x143ab4
cmpl $0x0, 0x58(%rsp)
je 0x143e1f
movw $0x0, 0x3e(%rsp)
movw $0x0, 0x3c(%rsp)
movw $0x0, 0x3a(%rsp)
movw $0x0, 0x38(%rsp)
movq $0x0, 0x100(%rsp)
movq 0x100(%rsp), %rax
cmpq 0x70(%rsp), %rax
je 0x143d16
movq 0x118(%rsp), %r8
movq 0x100(%rsp), %r9
movq 0x108(%rsp), %rax
leaq 0x3e(%rsp), %rdi
leaq 0x3c(%rsp), %rsi
leaq 0x3a(%rsp), %rdx
leaq 0x38(%rsp), %rcx
movq %rax, (%rsp)
callq 0x141400
cmpl $0x0, 0x6c(%rsp)
jne 0x143b68
movzwl 0x3e(%rsp), %eax
movzwl 0x3c(%rsp), %ecx
cmpl %ecx, %eax
jne 0x143b52
movzwl 0x3e(%rsp), %eax
movzwl 0x3a(%rsp), %ecx
cmpl %ecx, %eax
je 0x143b68
movq 0x120(%rsp), %rax
movl $0x1, (%rax)
movl $0x1, 0x6c(%rsp)
cmpl $0x0, 0x68(%rsp)
jne 0x143cdd
movzwl 0x3e(%rsp), %ecx
movq 0x120(%rsp), %rax
movzwl 0x8(%rax), %edx
xorl %eax, %eax
cmpl %edx, %ecx
movb %al, 0xf(%rsp)
jne 0x143bc3
movzwl 0x3c(%rsp), %ecx
movq 0x120(%rsp), %rax
movzwl 0xa(%rax), %edx
xorl %eax, %eax
cmpl %edx, %ecx
movb %al, 0xf(%rsp)
jne 0x143bc3
movzwl 0x3a(%rsp), %eax
movq 0x120(%rsp), %rcx
movzwl 0xc(%rcx), %ecx
cmpl %ecx, %eax
sete %al
movb %al, 0xf(%rsp)
movb 0xf(%rsp), %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, 0x34(%rsp)
movzwl 0x38(%rsp), %eax
cmpl $0xffff, %eax           # imm = 0xFFFF
je 0x143c26
movzwl 0x38(%rsp), %eax
cmpl $0x0, %eax
jne 0x143bfb
movq 0x120(%rsp), %rax
cmpl $0x0, 0x4(%rax)
je 0x143c26
cmpl $0x0, 0x34(%rsp)
jne 0x143c26
movq 0x120(%rsp), %rax
movl $0x1, 0x10(%rax)
movq 0x120(%rsp), %rax
movl $0x0, 0x4(%rax)
movl $0x1, 0x68(%rsp)
jmp 0x143cdb
movzwl 0x38(%rsp), %eax
cmpl $0x0, %eax
jne 0x143c90
movq 0x120(%rsp), %rax
cmpl $0x0, 0x10(%rax)
jne 0x143c90
movq 0x120(%rsp), %rax
cmpl $0x0, 0x4(%rax)
jne 0x143c90
movq 0x120(%rsp), %rax
movl $0x1, 0x4(%rax)
movw 0x3e(%rsp), %cx
movq 0x120(%rsp), %rax
movw %cx, 0x8(%rax)
movw 0x3c(%rsp), %cx
movq 0x120(%rsp), %rax
movw %cx, 0xa(%rax)
movw 0x3a(%rsp), %cx
movq 0x120(%rsp), %rax
movw %cx, 0xc(%rax)
jmp 0x143cd9
movzwl 0x38(%rsp), %eax
cmpl $0xffff, %eax           # imm = 0xFFFF
jne 0x143cd7
movq 0x120(%rsp), %rax
cmpl $0x0, 0x4(%rax)
je 0x143cd7
cmpl $0x0, 0x34(%rsp)
je 0x143cd7
movq 0x120(%rsp), %rax
movl $0x1, 0x10(%rax)
movq 0x120(%rsp), %rax
movl $0x0, 0x4(%rax)
movl $0x1, 0x68(%rsp)
jmp 0x143cd9
jmp 0x143cdb
jmp 0x143cdd
cmpl $0x0, 0x68(%rsp)
je 0x143cfb
cmpl $0x0, 0x64(%rsp)
je 0x143cfb
cmpl $0x0, 0x6c(%rsp)
je 0x143cfb
cmpl $0x0, 0x5c(%rsp)
je 0x143cfb
jmp 0x143d16
jmp 0x143cfd
movq 0x100(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x100(%rsp)
jmp 0x143ae7
movq 0x120(%rsp), %rax
cmpl $0x0, 0x4(%rax)
je 0x143e1a
movq 0x120(%rsp), %rax
cmpl $0x0, 0x10(%rax)
jne 0x143e1a
movq $0x0, 0x100(%rsp)
movq 0x100(%rsp), %rax
cmpq 0x70(%rsp), %rax
je 0x143e18
movq 0x118(%rsp), %r8
movq 0x100(%rsp), %r9
movq 0x108(%rsp), %rax
leaq 0x3e(%rsp), %rdi
leaq 0x3c(%rsp), %rsi
leaq 0x3a(%rsp), %rdx
leaq 0x38(%rsp), %rcx
movq %rax, (%rsp)
callq 0x141400
movzwl 0x38(%rsp), %eax
cmpl $0x0, %eax
je 0x143dfd
movzwl 0x3e(%rsp), %eax
movq 0x120(%rsp), %rcx
movzwl 0x8(%rcx), %ecx
cmpl %ecx, %eax
jne 0x143dfd
movzwl 0x3c(%rsp), %eax
movq 0x120(%rsp), %rcx
movzwl 0xa(%rcx), %ecx
cmpl %ecx, %eax
jne 0x143dfd
movzwl 0x3a(%rsp), %eax
movq 0x120(%rsp), %rcx
movzwl 0xc(%rcx), %ecx
cmpl %ecx, %eax
jne 0x143dfd
movq 0x120(%rsp), %rax
movl $0x1, 0x10(%rax)
movq 0x120(%rsp), %rax
movl $0x0, 0x4(%rax)
movl $0x1, 0x68(%rsp)
jmp 0x143dff
movq 0x100(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x100(%rsp)
jmp 0x143d46
jmp 0x143e1a
jmp 0x144411
movb $0x0, 0x33(%rsp)
movb $0x0, 0x32(%rsp)
movb $0x0, 0x31(%rsp)
movb $0x0, 0x30(%rsp)
movq $0x0, 0x100(%rsp)
movq 0x100(%rsp), %rax
cmpq 0x70(%rsp), %rax
je 0x144281
movq 0x118(%rsp), %r8
movq 0x100(%rsp), %r9
movq 0x108(%rsp), %rax
leaq 0x33(%rsp), %rdi
leaq 0x32(%rsp), %rsi
leaq 0x31(%rsp), %rdx
leaq 0x30(%rsp), %rcx
movq %rax, (%rsp)
callq 0x142880
cmpl $0x0, 0x5c(%rsp)
jne 0x143ed5
movq 0x120(%rsp), %rax
cmpl $0x8, 0x418(%rax)
jae 0x143ed5
movzbl 0x33(%rsp), %edi
callq 0x144430
movl %eax, 0x2c(%rsp)
movl 0x2c(%rsp), %eax
movq 0x120(%rsp), %rcx
cmpl 0x418(%rcx), %eax
jbe 0x143ed3
movl 0x2c(%rsp), %ecx
movq 0x120(%rsp), %rax
movl %ecx, 0x418(%rax)
jmp 0x143ed5
movq 0x120(%rsp), %rax
movl 0x418(%rax), %eax
cmpl 0x60(%rsp), %eax
setae %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, 0x5c(%rsp)
cmpl $0x0, 0x6c(%rsp)
jne 0x143f51
movzbl 0x33(%rsp), %eax
movzbl 0x32(%rsp), %ecx
cmpl %ecx, %eax
jne 0x143f16
movzbl 0x33(%rsp), %eax
movzbl 0x31(%rsp), %ecx
cmpl %ecx, %eax
je 0x143f51
movq 0x120(%rsp), %rax
movl $0x1, (%rax)
movl $0x1, 0x6c(%rsp)
movq 0x120(%rsp), %rax
cmpl $0x8, 0x418(%rax)
jae 0x143f4f
movq 0x120(%rsp), %rax
movl $0x8, 0x418(%rax)
jmp 0x143f51
cmpl $0x0, 0x68(%rsp)
jne 0x144117
movzbl 0x33(%rsp), %ecx
movq 0x120(%rsp), %rax
movzwl 0x8(%rax), %edx
xorl %eax, %eax
cmpl %edx, %ecx
movb %al, 0xe(%rsp)
jne 0x143fac
movzbl 0x32(%rsp), %ecx
movq 0x120(%rsp), %rax
movzwl 0xa(%rax), %edx
xorl %eax, %eax
cmpl %edx, %ecx
movb %al, 0xe(%rsp)
jne 0x143fac
movzbl 0x31(%rsp), %eax
movq 0x120(%rsp), %rcx
movzwl 0xc(%rcx), %ecx
cmpl %ecx, %eax
sete %al
movb %al, 0xe(%rsp)
movb 0xe(%rsp), %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, 0x28(%rsp)
movzbl 0x30(%rsp), %eax
cmpl $0xff, %eax
je 0x144032
movzbl 0x30(%rsp), %eax
cmpl $0x0, %eax
jne 0x143fe4
movq 0x120(%rsp), %rax
cmpl $0x0, 0x4(%rax)
je 0x144032
cmpl $0x0, 0x28(%rsp)
jne 0x144032
movq 0x120(%rsp), %rax
movl $0x1, 0x10(%rax)
movq 0x120(%rsp), %rax
movl $0x0, 0x4(%rax)
movl $0x1, 0x68(%rsp)
movq 0x120(%rsp), %rax
cmpl $0x8, 0x418(%rax)
jae 0x14402d
movq 0x120(%rsp), %rax
movl $0x8, 0x418(%rax)
jmp 0x144115
movzbl 0x30(%rsp), %eax
cmpl $0x0, %eax
jne 0x1440a5
movq 0x120(%rsp), %rax
cmpl $0x0, 0x10(%rax)
jne 0x1440a5
movq 0x120(%rsp), %rax
cmpl $0x0, 0x4(%rax)
jne 0x1440a5
movq 0x120(%rsp), %rax
movl $0x1, 0x4(%rax)
movzbl 0x33(%rsp), %eax
movw %ax, %cx
movq 0x120(%rsp), %rax
movw %cx, 0x8(%rax)
movzbl 0x32(%rsp), %eax
movw %ax, %cx
movq 0x120(%rsp), %rax
movw %cx, 0xa(%rax)
movzbl 0x31(%rsp), %eax
movw %ax, %cx
movq 0x120(%rsp), %rax
movw %cx, 0xc(%rax)
jmp 0x144113
movzbl 0x30(%rsp), %eax
cmpl $0xff, %eax
jne 0x144111
movq 0x120(%rsp), %rax
cmpl $0x0, 0x4(%rax)
je 0x144111
cmpl $0x0, 0x28(%rsp)
je 0x144111
movq 0x120(%rsp), %rax
movl $0x1, 0x10(%rax)
movq 0x120(%rsp), %rax
movl $0x0, 0x4(%rax)
movl $0x1, 0x68(%rsp)
movq 0x120(%rsp), %rax
cmpl $0x8, 0x418(%rax)
jae 0x14410f
movq 0x120(%rsp), %rax
movl $0x8, 0x418(%rax)
jmp 0x144111
jmp 0x144113
jmp 0x144115
jmp 0x144117
cmpl $0x0, 0x64(%rsp)
jne 0x144248
movb 0x33(%rsp), %dl
movb 0x32(%rsp), %cl
movb 0x31(%rsp), %al
leaq 0x78(%rsp), %rdi
movzbl %dl, %esi
movzbl %cl, %edx
movzbl %al, %ecx
movzbl 0x30(%rsp), %r8d
callq 0x1444a0
cmpl $0x0, %eax
jne 0x144246
movb 0x33(%rsp), %sil
movb 0x32(%rsp), %dl
movb 0x31(%rsp), %cl
movb 0x30(%rsp), %al
movq 0x120(%rsp), %rdi
movl 0x14(%rdi), %r9d
leaq 0x78(%rsp), %rdi
movzbl %sil, %esi
movzbl %dl, %edx
movzbl %cl, %ecx
movzbl %al, %r8d
callq 0x141300
movq 0x120(%rsp), %rax
cmpl $0x100, 0x14(%rax)      # imm = 0x100
jae 0x14421a
movq 0x120(%rsp), %rax
addq $0x18, %rax
movq %rax, 0x20(%rsp)
movq 0x120(%rsp), %rax
movl 0x14(%rax), %eax
movl %eax, 0x1c(%rsp)
movb 0x33(%rsp), %dl
movq 0x20(%rsp), %rax
movl 0x1c(%rsp), %ecx
shll $0x2, %ecx
addl $0x0, %ecx
movl %ecx, %ecx
movb %dl, (%rax,%rcx)
movb 0x32(%rsp), %dl
movq 0x20(%rsp), %rax
movl 0x1c(%rsp), %ecx
shll $0x2, %ecx
addl $0x1, %ecx
movl %ecx, %ecx
movb %dl, (%rax,%rcx)
movb 0x31(%rsp), %dl
movq 0x20(%rsp), %rax
movl 0x1c(%rsp), %ecx
shll $0x2, %ecx
addl $0x2, %ecx
movl %ecx, %ecx
movb %dl, (%rax,%rcx)
movb 0x30(%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 0x54(%rsp), %eax
setae %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, 0x64(%rsp)
jmp 0x144248
cmpl $0x0, 0x68(%rsp)
je 0x144266
cmpl $0x0, 0x64(%rsp)
je 0x144266
cmpl $0x0, 0x6c(%rsp)
je 0x144266
cmpl $0x0, 0x5c(%rsp)
je 0x144266
jmp 0x144281
jmp 0x144268
movq 0x100(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x100(%rsp)
jmp 0x143e3f
movq 0x120(%rsp), %rax
cmpl $0x0, 0x4(%rax)
je 0x1443ae
movq 0x120(%rsp), %rax
cmpl $0x0, 0x10(%rax)
jne 0x1443ae
movq $0x0, 0x100(%rsp)
movq 0x100(%rsp), %rax
cmpq 0x70(%rsp), %rax
je 0x1443ac
movq 0x118(%rsp), %r8
movq 0x100(%rsp), %r9
movq 0x108(%rsp), %rax
leaq 0x33(%rsp), %rdi
leaq 0x32(%rsp), %rsi
leaq 0x31(%rsp), %rdx
leaq 0x30(%rsp), %rcx
movq %rax, (%rsp)
callq 0x142880
movzbl 0x30(%rsp), %eax
cmpl $0x0, %eax
je 0x144391
movzbl 0x33(%rsp), %eax
movq 0x120(%rsp), %rcx
movzwl 0x8(%rcx), %ecx
cmpl %ecx, %eax
jne 0x144391
movzbl 0x32(%rsp), %eax
movq 0x120(%rsp), %rcx
movzwl 0xa(%rcx), %ecx
cmpl %ecx, %eax
jne 0x144391
movzbl 0x31(%rsp), %eax
movq 0x120(%rsp), %rcx
movzwl 0xc(%rcx), %ecx
cmpl %ecx, %eax
jne 0x144391
movq 0x120(%rsp), %rax
movl $0x1, 0x10(%rax)
movq 0x120(%rsp), %rax
movl $0x0, 0x4(%rax)
movl $0x1, 0x68(%rsp)
movq 0x120(%rsp), %rax
cmpl $0x8, 0x418(%rax)
jae 0x14438f
movq 0x120(%rsp), %rax
movl $0x8, 0x418(%rax)
jmp 0x144391
jmp 0x144393
movq 0x100(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x100(%rsp)
jmp 0x1442b1
jmp 0x1443ae
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 0x78(%rsp), %rdi
callq 0x1432a0
addq $0x128, %rsp            # imm = 0x128
retq
nopw %cs:(%rax,%rax)