// File: /workspace/github_cpp_makefile_star2_O3/tomfunkhouser[P]gaps/pkgs/png/pngrtran.c
// Function: png_set_quantize
void PNGAPI
png_set_quantize(png_structp png_ptr, png_colorp palette,
   int num_palette, int maximum_colors, png_uint_16p histogram,
   int full_quantize)
{
   png_debug(1, "in png_set_quantize");

   if (png_ptr == NULL)
      return;
   png_ptr->transformations |= PNG_QUANTIZE;

   if (!full_quantize)
   {
      int i;

      png_ptr->quantize_index = (png_bytep)png_malloc(png_ptr,
         (png_uint_32)(num_palette * png_sizeof(png_byte)));
      for (i = 0; i < num_palette; i++)
         png_ptr->quantize_index[i] = (png_byte)i;
   }

   if (num_palette > maximum_colors)
   {
      if (histogram != NULL)
      {
         /* This is easy enough, just throw out the least used colors.
          * Perhaps not the best solution, but good enough.
          */

         int i;

         /* Initialize an array to sort colors */
         png_ptr->quantize_sort = (png_bytep)png_malloc(png_ptr,
            (png_uint_32)(num_palette * png_sizeof(png_byte)));

         /* Initialize the quantize_sort array */
         for (i = 0; i < num_palette; i++)
            png_ptr->quantize_sort[i] = (png_byte)i;

         /* Find the least used palette entries by starting a
          * bubble sort, and running it until we have sorted
          * out enough colors.  Note that we don't care about
          * sorting all the colors, just finding which are
          * least used.
          */

         for (i = num_palette - 1; i >= maximum_colors; i--)
         {
            int done; /* To stop early if the list is pre-sorted */
            int j;

            done = 1;
            for (j = 0; j < i; j++)
            {
               if (histogram[png_ptr->quantize_sort[j]]
                   < histogram[png_ptr->quantize_sort[j + 1]])
               {
                  png_byte t;

                  t = png_ptr->quantize_sort[j];
                  png_ptr->quantize_sort[j] = png_ptr->quantize_sort[j + 1];
                  png_ptr->quantize_sort[j + 1] = t;
                  done = 0;
               }
            }
            if (done)
               break;
         }

         /* Swap the palette around, and set up a table, if necessary */
         if (full_quantize)
         {
            int j = num_palette;

            /* Put all the useful colors within the max, but don't
             * move the others.
             */
            for (i = 0; i < maximum_colors; i++)
            {
               if ((int)png_ptr->quantize_sort[i] >= maximum_colors)
               {
                  do
                     j--;
                  while ((int)png_ptr->quantize_sort[j] >= maximum_colors);
                  palette[i] = palette[j];
               }
            }
         }
         else
         {
            int j = num_palette;

            /* Move all the used colors inside the max limit, and
             * develop a translation table.
             */
            for (i = 0; i < maximum_colors; i++)
            {
               /* Only move the colors we need to */
               if ((int)png_ptr->quantize_sort[i] >= maximum_colors)
               {
                  png_color tmp_color;

                  do
                     j--;
                  while ((int)png_ptr->quantize_sort[j] >= maximum_colors);

                  tmp_color = palette[j];
                  palette[j] = palette[i];
                  palette[i] = tmp_color;
                  /* Indicate where the color went */
                  png_ptr->quantize_index[j] = (png_byte)i;
                  png_ptr->quantize_index[i] = (png_byte)j;
               }
            }

            /* Find closest color for those colors we are not using */
            for (i = 0; i < num_palette; i++)
            {
               if ((int)png_ptr->quantize_index[i] >= maximum_colors)
               {
                  int min_d, k, min_k, d_index;

                  /* Find the closest color to one we threw out */
                  d_index = png_ptr->quantize_index[i];
                  min_d = PNG_COLOR_DIST(palette[d_index], palette[0]);
                  for (k = 1, min_k = 0; k < maximum_colors; k++)
                  {
                     int d;

                     d = PNG_COLOR_DIST(palette[d_index], palette[k]);

                     if (d < min_d)
                     {
                        min_d = d;
                        min_k = k;
                     }
                  }
                  /* Point to closest color */
                  png_ptr->quantize_index[i] = (png_byte)min_k;
               }
            }
         }
         png_free(png_ptr, png_ptr->quantize_sort);
         png_ptr->quantize_sort = NULL;
      }
      else
      {
         /* This is much harder to do simply (and quickly).  Perhaps
          * we need to go through a median cut routine, but those
          * don't always behave themselves with only a few colors
          * as input.  So we will just find the closest two colors,
          * and throw out one of them (chosen somewhat randomly).
          * [We don't understand this at all, so if someone wants to
          *  work on improving it, be our guest - AED, GRP]
          */
         int i;
         int max_d;
         int num_new_palette;
         png_dsortp t;
         png_dsortpp hash;

         t = NULL;

         /* Initialize palette index arrays */
         png_ptr->index_to_palette = (png_bytep)png_malloc(png_ptr,
            (png_uint_32)(num_palette * png_sizeof(png_byte)));
         png_ptr->palette_to_index = (png_bytep)png_malloc(png_ptr,
            (png_uint_32)(num_palette * png_sizeof(png_byte)));

         /* Initialize the sort array */
         for (i = 0; i < num_palette; i++)
         {
            png_ptr->index_to_palette[i] = (png_byte)i;
            png_ptr->palette_to_index[i] = (png_byte)i;
         }

         hash = (png_dsortpp)png_calloc(png_ptr, (png_uint_32)(769 *
            png_sizeof(png_dsortp)));

         num_new_palette = num_palette;

         /* Initial wild guess at how far apart the farthest pixel
          * pair we will be eliminating will be.  Larger
          * numbers mean more areas will be allocated, Smaller
          * numbers run the risk of not saving enough data, and
          * having to do this all over again.
          *
          * I have not done extensive checking on this number.
          */
         max_d = 96;

         while (num_new_palette > maximum_colors)
         {
            for (i = 0; i < num_new_palette - 1; i++)
            {
               int j;

               for (j = i + 1; j < num_new_palette; j++)
               {
                  int d;

                  d = PNG_COLOR_DIST(palette[i], palette[j]);

                  if (d <= max_d)
                  {

                     t = (png_dsortp)png_malloc_warn(png_ptr,
                         (png_uint_32)(png_sizeof(png_dsort)));
                     if (t == NULL)
                         break;
                     t->next = hash[d];
                     t->left = (png_byte)i;
                     t->right = (png_byte)j;
                     hash[d] = t;
                  }
               }
               if (t == NULL)
                  break;
            }

            if (t != NULL)
            for (i = 0; i <= max_d; i++)
            {
               if (hash[i] != NULL)
               {
                  png_dsortp p;

                  for (p = hash[i]; p; p = p->next)
                  {
                     if ((int)png_ptr->index_to_palette[p->left]
                        < num_new_palette &&
                        (int)png_ptr->index_to_palette[p->right]
                        < num_new_palette)
                     {
                        int j, next_j;

                        if (num_new_palette & 0x01)
                        {
                           j = p->left;
                           next_j = p->right;
                        }
                        else
                        {
                           j = p->right;
                           next_j = p->left;
                        }

                        num_new_palette--;
                        palette[png_ptr->index_to_palette[j]]
                          = palette[num_new_palette];
                        if (!full_quantize)
                        {
                           int k;

                           for (k = 0; k < num_palette; k++)
                           {
                              if (png_ptr->quantize_index[k] ==
                                 png_ptr->index_to_palette[j])
                                 png_ptr->quantize_index[k] =
                                    png_ptr->index_to_palette[next_j];
                              if ((int)png_ptr->quantize_index[k] ==
                                 num_new_palette)
                                 png_ptr->quantize_index[k] =
                                    png_ptr->index_to_palette[j];
                           }
                        }

                        png_ptr->index_to_palette[png_ptr->palette_to_index
                           [num_new_palette]] = png_ptr->index_to_palette[j];
                        png_ptr->palette_to_index[png_ptr->index_to_palette[j]]
                           = png_ptr->palette_to_index[num_new_palette];

                        png_ptr->index_to_palette[j] =
                            (png_byte)num_new_palette;
                        png_ptr->palette_to_index[num_new_palette] =
                            (png_byte)j;
                     }
                     if (num_new_palette <= maximum_colors)
                        break;
                  }
                  if (num_new_palette <= maximum_colors)
                     break;
               }
            }

            for (i = 0; i < 769; i++)
            {
               if (hash[i] != NULL)
               {
                  png_dsortp p = hash[i];
                  while (p)
                  {
                     t = p->next;
                     png_free(png_ptr, p);
                     p = t;
                  }
               }
               hash[i] = 0;
            }
            max_d += 96;
         }
         png_free(png_ptr, hash);
         png_free(png_ptr, png_ptr->palette_to_index);
         png_free(png_ptr, png_ptr->index_to_palette);
         png_ptr->palette_to_index = NULL;
         png_ptr->index_to_palette = NULL;
      }
      num_palette = maximum_colors;
   }
   if (png_ptr->palette == NULL)
   {
      png_ptr->palette = palette;
   }
   png_ptr->num_palette = (png_uint_16)num_palette;

   if (full_quantize)
   {
      int i;
      png_bytep distance;
      int total_bits = PNG_QUANTIZE_RED_BITS + PNG_QUANTIZE_GREEN_BITS +
         PNG_QUANTIZE_BLUE_BITS;
      int num_red = (1 << PNG_QUANTIZE_RED_BITS);
      int num_green = (1 << PNG_QUANTIZE_GREEN_BITS);
      int num_blue = (1 << PNG_QUANTIZE_BLUE_BITS);
      png_size_t num_entries = ((png_size_t)1 << total_bits);

      png_ptr->palette_lookup = (png_bytep )png_calloc(png_ptr,
         (png_uint_32)(num_entries * png_sizeof(png_byte)));

      distance = (png_bytep)png_malloc(png_ptr, (png_uint_32)(num_entries *
         png_sizeof(png_byte)));
      png_memset(distance, 0xff, num_entries * png_sizeof(png_byte));

      for (i = 0; i < num_palette; i++)
      {
         int ir, ig, ib;
         int r = (palette[i].red >> (8 - PNG_QUANTIZE_RED_BITS));
         int g = (palette[i].green >> (8 - PNG_QUANTIZE_GREEN_BITS));
         int b = (palette[i].blue >> (8 - PNG_QUANTIZE_BLUE_BITS));

         for (ir = 0; ir < num_red; ir++)
         {
            /* int dr = abs(ir - r); */
            int dr = ((ir > r) ? ir - r : r - ir);
            int index_r = (ir << (PNG_QUANTIZE_BLUE_BITS +
                PNG_QUANTIZE_GREEN_BITS));

            for (ig = 0; ig < num_green; ig++)
            {
               /* int dg = abs(ig - g); */
               int dg = ((ig > g) ? ig - g : g - ig);
               int dt = dr + dg;
               int dm = ((dr > dg) ? dr : dg);
               int index_g = index_r | (ig << PNG_QUANTIZE_BLUE_BITS);

               for (ib = 0; ib < num_blue; ib++)
               {
                  int d_index = index_g | ib;
                  /* int db = abs(ib - b); */
                  int db = ((ib > b) ? ib - b : b - ib);
                  int dmax = ((dm > db) ? dm : db);
                  int d = dmax + dt + db;

                  if (d < (int)distance[d_index])
                  {
                     distance[d_index] = (png_byte)d;
                     png_ptr->palette_lookup[d_index] = (png_byte)i;
                  }
               }
            }
         }
      }

      png_free(png_ptr, distance);
   }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x88, %rsp
movq %rsi, 0x10(%rsp)
testq %rdi, %rdi
je 0x8d345
movl %r9d, %ebp
movq %r8, %r15
movl %ecx, %r13d
movl %edx, %r14d
movq %rdi, %rbx
orb $0x40, 0x124(%rdi)
testl %r9d, %r9d
jne 0x8cad3
movl %r14d, %r12d
movq %rbx, %rdi
movq %r12, %rsi
callq 0x91fa8
movq %rax, 0x390(%rbx)
testl %r14d, %r14d
jle 0x8cad3
xorl %eax, %eax
movq 0x390(%rbx), %rcx
movb %al, (%rcx,%rax)
incq %rax
cmpq %rax, %r12
jne 0x8cac1
cmpl %r13d, %r14d
jle 0x8cbf4
movl %r14d, %r12d
movq %rbx, %rdi
movq %r12, %rsi
callq 0x91fa8
testq %r15, %r15
movl %r13d, 0x18(%rsp)
movl %ebp, 0x44(%rsp)
movq %r12, 0x48(%rsp)
je 0x8cbfc
movq %rax, 0x438(%rbx)
testl %r14d, %r14d
jle 0x8cb21
xorl %eax, %eax
movq 0x438(%rbx), %rcx
movb %al, (%rcx,%rax)
incq %rax
cmpq %rax, %r12
jne 0x8cb0f
cmpl $0x2, %r13d
movl $0x1, %eax
cmovgel %r13d, %eax
leal -0x1(%r14), %ecx
movl %r14d, %edx
cmpl %eax, %edx
jle 0x8cb82
movl %ecx, %ecx
decl %edx
movl $0x1, %edi
xorl %esi, %esi
movq 0x438(%rbx), %r9
movzbl (%r9,%rsi), %r8d
movzwl (%r15,%r8,2), %r11d
movzbl 0x1(%r9,%rsi), %r10d
cmpw (%r15,%r10,2), %r11w
jae 0x8cb74
movb %r10b, (%r9,%rsi)
movq 0x438(%rbx), %rdi
movb %r8b, 0x1(%rdi,%rsi)
xorl %edi, %edi
incq %rsi
cmpq %rsi, %rcx
jne 0x8cb44
decl %ecx
testl %edi, %edi
je 0x8cb35
testl %ebp, %ebp
je 0x8cff7
testl %r13d, %r13d
jle 0x8d1ac
movl %r13d, %eax
xorl %ecx, %ecx
movq 0x10(%rsp), %r8
movq 0x438(%rbx), %rsi
movzbl (%rsi,%rcx), %edx
cmpl %r13d, %edx
jl 0x8cbe7
movslq %r14d, %rdi
leaq (%rdi,%rdi,2), %rdx
addq 0x10(%rsp), %rdx
addq %rdi, %rsi
decq %rsi
decl %r14d
addq $-0x3, %rdx
leaq -0x1(%rsi), %rdi
cmpb %r13b, (%rsi)
movq %rdi, %rsi
jae 0x8cbbf
leaq (%rcx,%rcx,2), %rsi
movb 0x2(%rdx), %dil
movb %dil, 0x2(%r8,%rsi)
movzwl (%rdx), %edx
movw %dx, (%r8,%rsi)
incq %rcx
cmpq %rax, %rcx
jne 0x8cb9d
jmp 0x8d1ac
movl %r14d, %r13d
jmp 0x8d1c6
movq %rax, 0x440(%rbx)
movq %rbx, %rdi
movq %r12, %rsi
callq 0x91fa8
movq %rax, 0x448(%rbx)
testl %r14d, %r14d
jle 0x8cc38
xorl %eax, %eax
movq 0x440(%rbx), %rcx
movb %al, (%rcx,%rax)
movq 0x448(%rbx), %rcx
movb %al, (%rcx,%rax)
incq %rax
cmpq %rax, %r12
jne 0x8cc1c
leaq 0x440(%rbx), %rax
movq %rax, 0x30(%rsp)
testl %ebp, %ebp
setne %bpl
movl $0x1808, %esi           # imm = 0x1808
movq %rbx, %rdi
callq 0x91f8a
movq %rax, %r8
testl %r14d, %r14d
setle %al
orb %bpl, %al
movb %al, 0xf(%rsp)
movq 0x10(%rsp), %rax
addq $0x5, %rax
movq %rax, 0x60(%rsp)
movl $0x60, 0x38(%rsp)
movl $0x61, %eax
movq %rax, 0x58(%rsp)
xorl %eax, %eax
movq %r8, 0x20(%rsp)
movl %r14d, %r10d
cmpl $0x2, %r14d
movl $0x1, %ecx
cmovgel %r14d, %ecx
decl %ecx
movl $0x1, %r15d
movq 0x60(%rsp), %rdx
xorl %r13d, %r13d
movq %r14, 0x70(%rsp)
movq %rcx, 0x68(%rsp)
movq %r10, 0x28(%rsp)
cmpq %rcx, %r13
je 0x8ce21
leaq 0x1(%r13), %rcx
movq %rcx, 0x78(%rsp)
leaq (,%r13,2), %r12
addq %r13, %r12
addq 0x10(%rsp), %r12
movq %rdx, 0x80(%rsp)
movq %rdx, %r14
movq %r15, 0x50(%rsp)
movzbl (%r12), %ecx
movzbl -0x2(%r14), %edx
subl %edx, %ecx
movl %ecx, %edx
negl %edx
cmovsl %ecx, %edx
movl $0xff, %edi
andl %edi, %edx
movzbl 0x1(%r12), %ecx
movzbl -0x1(%r14), %esi
subl %esi, %ecx
movl %ecx, %esi
negl %esi
cmovsl %ecx, %esi
andl %edi, %esi
addl %edx, %esi
movzbl 0x2(%r12), %ecx
movzbl (%r14), %edx
subl %edx, %ecx
movl %ecx, %ebp
negl %ebp
cmovsl %ecx, %ebp
andl %edi, %ebp
addl %esi, %ebp
cmpl 0x38(%rsp), %ebp
ja 0x8cd6f
movl $0x10, %esi
movq %rbx, %rdi
callq 0x92056
testq %rax, %rax
je 0x8cdb5
movl %ebp, %ecx
movq 0x20(%rsp), %r8
movq (%r8,%rcx,8), %rdx
movq %rdx, (%rax)
movb %r13b, 0x8(%rax)
movb %r15b, 0x9(%rax)
movq %rax, (%r8,%rcx,8)
movq 0x28(%rsp), %r10
incq %r15
addq $0x3, %r14
cmpq %r15, %r10
jne 0x8ccef
movq 0x50(%rsp), %r15
incq %r15
movq 0x80(%rsp), %rdx
addq $0x3, %rdx
movq 0x78(%rsp), %r13
testq %rax, %rax
movq 0x48(%rsp), %r12
movq 0x70(%rsp), %r14
movq 0x68(%rsp), %rcx
jne 0x8ccbd
jmp 0x8cfa3
xorl %eax, %eax
movq 0x28(%rsp), %rbp
movl 0x18(%rsp), %r13d
movq 0x48(%rsp), %r12
movq 0x20(%rsp), %r8
xorl %r14d, %r14d
movq (%r8,%r14,8), %rsi
testq %rsi, %rsi
je 0x8cdf1
movq (%rsi), %r15
movq %rbx, %rdi
callq 0x92016
movq %r15, %rsi
testq %r15, %r15
jne 0x8cdd7
xorl %eax, %eax
movq 0x20(%rsp), %r8
movq $0x0, (%r8,%r14,8)
incq %r14
cmpq $0x301, %r14            # imm = 0x301
jne 0x8cdce
addl $0x60, 0x38(%rsp)
addq $0x60, 0x58(%rsp)
movq %rbp, %r14
cmpl %r13d, %r14d
jg 0x8cc8e
jmp 0x8cfba
testq %rax, %rax
je 0x8cfa3
xorl %ecx, %ecx
movl 0x18(%rsp), %r13d
movq %rcx, 0x28(%rsp)
movq (%r8,%rcx,8), %rdx
testq %rdx, %rdx
je 0x8cf83
movl %r14d, %r8d
movq 0x30(%rsp), %rcx
movq (%rcx), %r10
movzbl 0x8(%rdx), %esi
movzbl (%r10,%rsi), %edi
cmpl %edi, %r8d
jle 0x8cf6c
movzbl 0x9(%rdx), %edi
movzbl (%r10,%rdi), %r9d
cmpl %r9d, %r8d
jbe 0x8cf6c
testb $0x1, %r8b
movzbl %dil, %r9d
movzbl %sil, %r11d
movl %r11d, %esi
cmovel %r9d, %esi
leal -0x1(%r8), %r14d
movzbl %sil, %edi
movzbl (%r10,%rdi), %r10d
leaq (%r10,%r10,2), %r10
movq %r14, %rcx
leaq (%r14,%r14,2), %r14
movq 0x10(%rsp), %r15
movb 0x2(%r15,%r14), %bpl
movb %bpl, 0x2(%r15,%r10)
movzwl (%r15,%r14), %ebp
movw %bp, (%r15,%r10)
cmpb $0x0, 0xf(%rsp)
jne 0x8cf1b
testb $0x1, %r8b
cmovel %r11d, %r9d
movzbl %r9b, %r8d
xorl %r9d, %r9d
movq 0x390(%rbx), %r10
movq 0x440(%rbx), %r14
movb (%r10,%r9), %r11b
cmpb (%r14,%rdi), %r11b
jne 0x8cef7
movb (%r14,%r8), %r11b
movb %r11b, (%r10,%r9)
movq 0x390(%rbx), %r10
movb (%r10,%r9), %r11b
movzbl %r11b, %r11d
movq %rcx, %r14
cmpl %r11d, %r14d
jne 0x8cf13
movq 0x30(%rsp), %r11
movq (%r11), %r11
movb (%r11,%rdi), %r11b
movb %r11b, (%r10,%r9)
incq %r9
cmpq %r9, %r12
jne 0x8cecc
movq 0x440(%rbx), %r8
movq 0x448(%rbx), %r9
movb (%r8,%rdi), %r10b
movq %rcx, %r14
movzbl (%r9,%rcx), %r9d
movb %r10b, (%r8,%r9)
movq 0x440(%rbx), %r8
movq 0x448(%rbx), %r9
movb (%r9,%rcx), %r10b
movzbl (%r8,%rdi), %r8d
movb %r10b, (%r9,%r8)
movq 0x440(%rbx), %r8
movb %r14b, (%r8,%rdi)
movq 0x448(%rbx), %rdi
movb %sil, (%rdi,%rcx)
jmp 0x8cf6f
movl %r8d, %r14d
cmpl %r13d, %r14d
jle 0x8cfb2
movq (%rdx), %rdx
movl %r14d, %r8d
testq %rdx, %rdx
jne 0x8ce46
movq 0x28(%rsp), %rcx
incq %rcx
cmpq 0x58(%rsp), %rcx
movq 0x20(%rsp), %r8
jne 0x8ce31
movq %r14, %rbp
jmp 0x8cdcb
xorl %eax, %eax
movl %r10d, %ebp
movl 0x18(%rsp), %r13d
jmp 0x8cdcb
movq %r14, %rbp
jmp 0x8cdc6
movq %rbx, %rdi
movq %r8, %rsi
callq 0x92016
movq 0x448(%rbx), %rsi
movq %rbx, %rdi
callq 0x92016
movq 0x440(%rbx), %rsi
movq %rbx, %rdi
callq 0x92016
xorps %xmm0, %xmm0
movq 0x30(%rsp), %rax
movups %xmm0, (%rax)
movl 0x44(%rsp), %ebp
jmp 0x8d1c6
movl %r13d, %eax
testl %r13d, %r13d
jle 0x8d09a
xorl %ecx, %ecx
movl %r14d, %edx
movq 0x10(%rsp), %r10
movq 0x438(%rbx), %r8
movzbl (%r8,%rcx), %esi
cmpl %r13d, %esi
jl 0x8d08e
movslq %edx, %rsi
leaq (%rsi,%rsi,2), %rdi
addq 0x10(%rsp), %rdi
movq %rsi, %r9
decq %rsi
decl %edx
addq $-0x3, %rdi
cmpb %r13b, -0x1(%r8,%r9)
jae 0x8d02a
movb 0x2(%rdi), %r8b
movb %r8b, 0x1e(%rsp)
movzwl (%rdi), %r8d
movw %r8w, 0x1c(%rsp)
leaq (%rcx,%rcx,2), %r8
movb 0x2(%r10,%r8), %r9b
movb %r9b, 0x2(%rdi)
movzwl (%r10,%r8), %r9d
movw %r9w, (%rdi)
movzwl 0x1c(%rsp), %edi
movw %di, (%r10,%r8)
movb 0x1e(%rsp), %dil
movb %dil, 0x2(%r10,%r8)
movq 0x390(%rbx), %rdi
movb %cl, (%rdi,%rsi)
movq 0x390(%rbx), %rsi
movb %dl, (%rsi,%rcx)
incq %rcx
cmpq %rax, %rcx
jne 0x8d00d
testl %r14d, %r14d
jle 0x8d1ac
movq 0x10(%rsp), %rcx
addq $0x5, %rcx
xorl %edx, %edx
movq 0x390(%rbx), %rsi
movzbl (%rsi,%rdx), %r8d
cmpl %r13d, %r8d
jl 0x8d1a0
xorl %edi, %edi
cmpl $0x2, %r13d
jl 0x8d19c
leaq (%r8,%r8,2), %r10
movq 0x10(%rsp), %r15
movzbl (%r15,%r10), %r8d
movzbl 0x1(%r15,%r10), %r9d
movzbl 0x1(%r15), %r11d
movl %r9d, %ebp
subl %r11d, %ebp
movl %ebp, %r11d
negl %r11d
cmovsl %ebp, %r11d
movzbl 0x2(%r15,%r10), %r10d
movzbl (%r15), %ebp
movl %r8d, %r14d
subl %ebp, %r14d
movl %r14d, %ebp
negl %ebp
cmovsl %r14d, %ebp
addl %r11d, %ebp
movzbl 0x2(%r15), %r11d
movl %r10d, %r14d
subl %r11d, %r14d
movl %r14d, %r11d
negl %r11d
cmovsl %r14d, %r11d
addl %ebp, %r11d
movl $0x1, %r14d
movq %rcx, %r15
movzbl -0x2(%r15), %ebp
movl %r8d, %r12d
subl %ebp, %r12d
movl %r12d, %ebp
negl %ebp
cmovsl %r12d, %ebp
movzbl -0x1(%r15), %r12d
movl %r9d, %r13d
subl %r12d, %r13d
movl %r13d, %r12d
negl %r12d
cmovsl %r13d, %r12d
addl %ebp, %r12d
movzbl (%r15), %ebp
movl %r10d, %r13d
subl %ebp, %r13d
movl %r13d, %ebp
negl %ebp
cmovsl %r13d, %ebp
addl %r12d, %ebp
cmpl %r11d, %ebp
cmovll %r14d, %edi
cmovll %ebp, %r11d
incq %r14
addq $0x3, %r15
cmpq %r14, %rax
jne 0x8d135
movl 0x18(%rsp), %r13d
movl 0x44(%rsp), %ebp
movq 0x48(%rsp), %r12
movb %dil, (%rsi,%rdx)
incq %rdx
cmpq %r12, %rdx
jne 0x8d0ae
movq 0x438(%rbx), %rsi
movq %rbx, %rdi
callq 0x92016
movq $0x0, 0x438(%rbx)
cmpq $0x0, 0x238(%rbx)
jne 0x8d1dc
movq 0x10(%rsp), %rax
movq %rax, 0x238(%rbx)
movw %r13w, 0x240(%rbx)
testl %ebp, %ebp
je 0x8d345
movl $0x8000, %esi           # imm = 0x8000
movq %rbx, %rdi
callq 0x91f8a
movq %rax, 0x388(%rbx)
movl $0x8000, %esi           # imm = 0x8000
movq %rbx, %rdi
callq 0x91fa8
movl $0x8000, %edx           # imm = 0x8000
movq %rax, 0x38(%rsp)
movq %rax, %rdi
movl $0xff, %esi
callq 0xe260
testl %r13d, %r13d
jle 0x8d327
movl %r13d, %eax
movq %rax, 0x50(%rsp)
xorl %ecx, %ecx
leaq (%rcx,%rcx,2), %rax
movq 0x10(%rsp), %rdx
movzbl (%rdx,%rax), %esi
shrl $0x3, %esi
movq %rsi, 0x30(%rsp)
movzbl 0x1(%rdx,%rax), %esi
shrl $0x3, %esi
movzbl 0x2(%rdx,%rax), %edi
shrl $0x3, %edi
movl %edi, %r8d
negl %r8d
xorl %r14d, %r14d
xorl %edx, %edx
movl %edx, %eax
movq 0x30(%rsp), %r11
subl %r11d, %eax
movq %rdx, 0x28(%rsp)
subq %rdx, %r11
cmovbl %eax, %r11d
movq %r14, 0x20(%rsp)
xorl %r12d, %r12d
movl %r12d, %eax
subl %esi, %eax
movq %rsi, %r13
subq %r12, %r13
cmovbl %eax, %r13d
leal (%r11,%r13), %ebp
cmpl %r13d, %r11d
cmovgl %r11d, %r13d
movq 0x38(%rsp), %rax
addq %r14, %rax
movl %edi, %edx
xorl %r9d, %r9d
leal (%r8,%r9), %r10d
cmpq %rdi, %r9
cmovbel %edx, %r10d
cmpl %r10d, %r13d
movl %r10d, %r15d
cmovgl %r13d, %r15d
addl %ebp, %r10d
addl %r15d, %r10d
movzbl (%rax,%r9), %r15d
cmpl %r15d, %r10d
jge 0x8d2e3
movb %r10b, (%rax,%r9)
movq 0x388(%rbx), %r10
addq %r14, %r10
movb %cl, (%r9,%r10)
incq %r9
decl %edx
cmpq $0x20, %r9
jne 0x8d2ac
incq %r12
addq $0x20, %r14
cmpq $0x20, %r12
jne 0x8d285
movq 0x28(%rsp), %rdx
incq %rdx
movq 0x20(%rsp), %r14
addq $0x400, %r14            # imm = 0x400
cmpq $0x20, %rdx
jne 0x8d267
incq %rcx
cmpq 0x50(%rsp), %rcx
jne 0x8d237
movq %rbx, %rdi
movq 0x38(%rsp), %rsi
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x92016
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq