// File: /workspace/github_cpp_makefile_star2_O2/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 $0x78, %rsp
movq %rsi, 0x8(%rsp)
testq %rdi, %rdi
je 0x8001a
movq %r8, %r15
movl %edx, %r12d
movq %rdi, %r14
orb $0x40, 0x124(%rdi)
movl %edx, %r13d
movl %r9d, 0x14(%rsp)
testl %r9d, %r9d
movq %rcx, %rsi
movq %rcx, (%rsp)
je 0x7f7f1
cmpl %esi, %r12d
jle 0x7f7e9
movq %r14, %rdi
movq %r13, %rsi
callq 0x848bb
testq %r15, %r15
je 0x7f8f7
movq %rax, 0x438(%r14)
xorl %ecx, %ecx
testl %r12d, %r12d
movl $0x0, %eax
cmovgl %r12d, %eax
movq (%rsp), %rsi
cmpq %rcx, %rax
je 0x7f829
movq 0x438(%r14), %rdx
movb %cl, (%rdx,%rcx)
incq %rcx
jmp 0x7f7d5
movl %r12d, %ebx
jmp 0x7fe9f
movq %r14, %rdi
movq %r13, %rsi
callq 0x848bb
movq (%rsp), %rsi
movq %rax, 0x390(%r14)
xorl %eax, %eax
testl %r12d, %r12d
movl $0x0, %ecx
cmovgl %r12d, %ecx
cmpq %rax, %rcx
je 0x7f7a3
movq 0x390(%r14), %rdx
movb %al, (%rdx,%rax)
incq %rax
jmp 0x7f815
movslq %r12d, %rdx
movslq %esi, %rcx
cmpq %rcx, %rdx
jle 0x7f87c
decq %rdx
xorl %esi, %esi
xorl %edi, %edi
cmpq %rdx, %rsi
jge 0x7f876
movq 0x438(%r14), %r9
movzbl (%r9,%rsi), %r8d
movzwl (%r15,%r8,2), %r11d
movzbl 0x1(%r9,%rsi), %r10d
incq %rsi
cmpw (%r15,%r10,2), %r11w
jae 0x7f83b
movb %r10b, -0x1(%r9,%rsi)
movq 0x438(%r14), %rdi
movb %r8b, (%rdi,%rsi)
movb $0x1, %dil
jmp 0x7f83b
testb $0x1, %dil
jne 0x7f82f
cmpl $0x0, 0x14(%rsp)
je 0x7fcc2
xorl %eax, %eax
movq (%rsp), %rdx
testl %edx, %edx
movl $0x0, %ecx
cmovgl %edx, %ecx
cmpq %rcx, %rax
je 0x7fe84
movq 0x438(%r14), %rsi
movzbl (%rsi,%rax), %edx
cmpl (%rsp), %edx
jl 0x7f8f2
movslq %r12d, %rdi
leaq (%rdi,%rdi,2), %rdx
addq 0x8(%rsp), %rdx
addq %rdi, %rsi
decq %rsi
movq (%rsp), %r8
movzbl (%rsi), %edi
decl %r12d
addq $-0x3, %rdx
decq %rsi
cmpl %r8d, %edi
jge 0x7f8c6
leaq (%rax,%rax,2), %rsi
movb 0x2(%rdx), %dil
movq 0x8(%rsp), %r8
movb %dil, 0x2(%r8,%rsi)
movzwl (%rdx), %edx
movw %dx, (%r8,%rsi)
incq %rax
jmp 0x7f897
leaq 0x440(%r14), %rbp
movq %rax, 0x440(%r14)
movq %r14, %rdi
movq %r13, %rsi
callq 0x848bb
movq %rax, 0x448(%r14)
xorl %eax, %eax
testl %r12d, %r12d
movl $0x0, %ecx
cmovgl %r12d, %ecx
movq %rcx, 0x50(%rsp)
cmpq %rax, 0x50(%rsp)
je 0x7f94a
movq 0x440(%r14), %rcx
movb %al, (%rcx,%rax)
movq 0x448(%r14), %rcx
movb %al, (%rcx,%rax)
incq %rax
jmp 0x7f92a
movl $0x1808, %esi           # imm = 0x1808
movq %r14, %rdi
callq 0x8489d
movq %rax, %r13
movq 0x8(%rsp), %rax
addq $0x5, %rax
movq %rax, 0x60(%rsp)
pushq $0x60
popq %rax
movl %eax, 0x18(%rsp)
pushq $0x61
popq %rax
movq %rax, 0x40(%rsp)
xorl %r15d, %r15d
movq %r13, 0x20(%rsp)
movq %rbp, 0x48(%rsp)
movq (%rsp), %rsi
cmpl %esi, %r12d
jle 0x7fc89
cmpl $0x2, %r12d
pushq $0x1
popq %rax
movl %eax, %ecx
cmovgel %r12d, %ecx
decl %ecx
movq 0x60(%rsp), %rdx
movq %rdx, 0x58(%rsp)
movl %eax, 0x2c(%rsp)
xorl %ebx, %ebx
movq %r12, 0x30(%rsp)
movq %rcx, 0x68(%rsp)
cmpq %rcx, %rbx
je 0x7fb09
leaq 0x1(%rbx), %rax
movq %rax, 0x70(%rsp)
leaq (%rbx,%rbx,2), %r9
addq 0x8(%rsp), %r9
movq 0x58(%rsp), %r13
movl 0x2c(%rsp), %ebp
movq %r9, 0x38(%rsp)
cmpl %ebp, %r12d
jle 0x7fa86
movzbl (%r9), %eax
movzbl -0x2(%r13), %ecx
subl %ecx, %eax
movl %eax, %ecx
negl %ecx
cmovsl %eax, %ecx
movl $0xff, %edi
andl %edi, %ecx
movzbl 0x1(%r9), %eax
movzbl -0x1(%r13), %edx
subl %edx, %eax
movl %eax, %edx
negl %edx
cmovsl %eax, %edx
andl %edi, %edx
addl %ecx, %edx
movzbl 0x2(%r9), %eax
movzbl (%r13), %ecx
subl %ecx, %eax
movl %eax, %r12d
negl %r12d
cmovsl %eax, %r12d
andl %edi, %r12d
addl %edx, %r12d
cmpl 0x18(%rsp), %r12d
ja 0x7fa76
movq %r14, %rdi
pushq $0x10
popq %rsi
callq 0x84960
testq %rax, %rax
je 0x7fab2
movq %rax, %r15
movl %r12d, %eax
movq 0x20(%rsp), %rdx
movq (%rdx,%rax,8), %rcx
movq %rcx, (%r15)
movb %bl, 0x8(%r15)
movb %bpl, 0x9(%r15)
movq %r15, (%rdx,%rax,8)
movq (%rsp), %rsi
movq 0x38(%rsp), %r9
incl %ebp
addq $0x3, %r13
movq 0x30(%rsp), %r12
jmp 0x7f9e3
incl 0x2c(%rsp)
addq $0x3, 0x58(%rsp)
movq 0x70(%rsp), %rbx
testq %r15, %r15
movq 0x48(%rsp), %rbp
movq 0x20(%rsp), %r13
movq 0x68(%rsp), %rcx
jne 0x7f9ba
jmp 0x7fc81
xorl %r15d, %r15d
movq 0x30(%rsp), %r12
movq 0x48(%rsp), %rbp
movq 0x20(%rsp), %r13
xorl %ebx, %ebx
cmpq $0x301, %rbx            # imm = 0x301
je 0x7faf9
movq (%r13,%rbx,8), %rsi
testq %rsi, %rsi
jne 0x7fae9
jmp 0x7faee
movq (%rsi), %r15
movq %r14, %rdi
callq 0x84923
movq %r15, %rsi
testq %rsi, %rsi
jne 0x7fadb
andq $0x0, (%r13,%rbx,8)
incq %rbx
jmp 0x7fac6
addl $0x60, 0x18(%rsp)
addq $0x60, 0x40(%rsp)
jmp 0x7f984
testq %r15, %r15
je 0x7fc81
xorl %eax, %eax
cmpq 0x40(%rsp), %rax
je 0x7fac4
movq (%r13,%rax,8), %rcx
testq %rcx, %rcx
je 0x7fc79
testq %rcx, %rcx
je 0x7fc70
movq (%rbp), %r9
movzbl 0x8(%rcx), %edx
movzbl (%r9,%rdx), %esi
cmpl %esi, %r12d
jle 0x7fbfe
movzbl 0x9(%rcx), %esi
movzbl (%r9,%rsi), %edi
cmpl %edi, %r12d
jbe 0x7fbfe
testb $0x1, %r12b
movzbl %sil, %r8d
movzbl %dl, %r10d
movl %r10d, %esi
cmovel %r8d, %esi
leal -0x1(%r12), %edx
movzbl %sil, %edi
movzbl (%r9,%rdi), %r9d
leaq (%r9,%r9,2), %r9
leaq (%rdx,%rdx,2), %r11
movq %r12, %r13
movq 0x8(%rsp), %r12
movb 0x2(%r12,%r11), %bl
movb %bl, 0x2(%r12,%r9)
movzwl (%r12,%r11), %r11d
movw %r11w, (%r12,%r9)
cmpl $0x0, 0x14(%rsp)
movq 0x50(%rsp), %r12
je 0x7fc14
movq 0x440(%r14), %r8
movq 0x448(%r14), %r9
movb (%r8,%rdi), %r10b
movzbl (%r9,%rdx), %r9d
movb %r10b, (%r8,%r9)
movq 0x440(%r14), %r8
movq 0x448(%r14), %r9
movb (%r9,%rdx), %r10b
movzbl (%r8,%rdi), %r8d
movb %r10b, (%r9,%r8)
movq 0x440(%r14), %r8
movb %dl, (%r8,%rdi)
movq 0x448(%r14), %rdi
movb %sil, (%rdi,%rdx)
movq 0x20(%rsp), %r13
jmp 0x7fc01
movl %r12d, %edx
movq (%rsp), %rsi
cmpl %esi, %edx
jle 0x7fc6d
movq (%rcx), %rcx
movl %edx, %r12d
jmp 0x7fb29
testb $0x1, %r13b
cmovel %r10d, %r8d
movzbl %r8b, %r8d
xorl %r9d, %r9d
cmpq %r9, %r12
je 0x7fbab
movq 0x390(%r14), %r10
movq 0x440(%r14), %rbx
movb (%r10,%r9), %r11b
cmpb (%rbx,%rdi), %r11b
jne 0x7fc53
movb (%rbx,%r8), %r11b
movb %r11b, (%r10,%r9)
movq 0x390(%r14), %r10
movb (%r10,%r9), %r11b
movzbl %r11b, %r11d
cmpl %r11d, %edx
jne 0x7fc68
movq (%rbp), %r11
movb (%r11,%rdi), %r11b
movb %r11b, (%r10,%r9)
incq %r9
jmp 0x7fc23
movl %edx, %r12d
cmpl %esi, %r12d
jle 0x7fac4
incq %rax
jmp 0x7fb14
xorl %r15d, %r15d
jmp 0x7fac4
movq %r14, %rdi
movq %r13, %rsi
callq 0x84923
movq 0x448(%r14), %rsi
movq %r14, %rdi
callq 0x84923
movq 0x440(%r14), %rsi
movq %r14, %rdi
callq 0x84923
movq (%rsp), %rbx
xorps %xmm0, %xmm0
movups %xmm0, (%rbp)
jmp 0x7fe9f
xorl %edx, %edx
movq (%rsp), %rdi
testl %edi, %edi
movl $0x0, %esi
cmovgl %edi, %esi
cmpq %rsi, %rdx
je 0x7fd72
movq 0x438(%r14), %r9
movzbl (%r9,%rdx), %edi
cmpl (%rsp), %edi
jl 0x7fd6a
movslq %r12d, %rdi
leaq (%rdi,%rdi,2), %r8
addq 0x8(%rsp), %r8
movq (%rsp), %r11
movzbl -0x1(%r9,%rdi), %r10d
decq %rdi
decl %r12d
addq $-0x3, %r8
cmpl %r11d, %r10d
jge 0x7fcfc
movb 0x2(%r8), %r9b
movb %r9b, 0x12(%rsp)
movzwl (%r8), %r9d
movw %r9w, 0x10(%rsp)
leaq (%rdx,%rdx,2), %r9
movq 0x8(%rsp), %r11
movb 0x2(%r11,%r9), %r10b
movb %r10b, 0x2(%r8)
movzwl (%r11,%r9), %r10d
movw %r10w, (%r8)
movzwl 0x10(%rsp), %r8d
movw %r8w, (%r11,%r9)
movb 0x12(%rsp), %r8b
movb %r8b, 0x2(%r11,%r9)
movq 0x390(%r14), %r8
movb %dl, (%r8,%rdi)
movq 0x390(%r14), %rdi
movb %r12b, (%rdi,%rdx)
incq %rdx
jmp 0x7fcd2
movq 0x8(%rsp), %rdx
addq $0x5, %rdx
movq %rdx, 0x18(%rsp)
xorl %esi, %esi
cmpq %rax, %rsi
je 0x7fe84
movq 0x390(%r14), %r9
movzbl (%r9,%rsi), %r10d
cmpl (%rsp), %r10d
jl 0x7fe7c
leaq (%r10,%r10,2), %rbx
movq 0x8(%rsp), %r8
movzbl (%r8,%rbx), %edx
movzbl (%r8), %r11d
movl %edx, %ebp
subl %r11d, %ebp
movl %ebp, %r15d
negl %r15d
cmovsl %ebp, %r15d
movl $0xff, %r10d
andl %r10d, %r15d
movzbl 0x1(%r8,%rbx), %edi
movzbl 0x1(%r8), %ebp
movl %edi, %r12d
subl %ebp, %r12d
movl %r12d, %r13d
negl %r13d
cmovsl %r12d, %r13d
andl %r10d, %r13d
addl %r15d, %r13d
movzbl 0x2(%r8,%rbx), %ebx
movzbl 0x2(%r8), %ebp
movl %ebx, %r15d
subl %ebp, %r15d
movl %r15d, %ebp
negl %ebp
cmovsl %r15d, %ebp
andl %r10d, %ebp
addl %r13d, %ebp
xorl %r15d, %r15d
movq 0x18(%rsp), %r12
pushq $0x1
popq %r13
cmpq %rcx, %r13
jge 0x7fe78
movzbl -0x2(%r12), %r8d
movl %edx, %r10d
subl %r8d, %r10d
movl %r10d, %r8d
negl %r8d
cmovsl %r10d, %r8d
movzbl -0x1(%r12), %r10d
movl %edi, %r11d
subl %r10d, %r11d
movl %r11d, %r10d
negl %r10d
cmovsl %r11d, %r10d
addl %r8d, %r10d
movzbl (%r12), %r8d
movl %ebx, %r11d
subl %r8d, %r11d
movl %r11d, %r8d
negl %r8d
cmovsl %r11d, %r8d
addl %r10d, %r8d
cmpl %ebp, %r8d
cmovll %r13d, %r15d
cmovll %r8d, %ebp
incq %r13
addq $0x3, %r12
jmp 0x7fe18
movb %r15b, (%r9,%rsi)
incq %rsi
jmp 0x7fd82
movq 0x438(%r14), %rsi
movq %r14, %rdi
callq 0x84923
andq $0x0, 0x438(%r14)
movq (%rsp), %rbx
cmpq $0x0, 0x238(%r14)
movl 0x14(%rsp), %eax
jne 0x7febd
movq 0x8(%rsp), %rax
movq %rax, 0x238(%r14)
movl 0x14(%rsp), %eax
movw %bx, 0x240(%r14)
testl %eax, %eax
je 0x8001a
movl $0x8000, %esi           # imm = 0x8000
movq %r14, %rdi
callq 0x8489d
movq %rax, 0x388(%r14)
movl $0x8000, %esi           # imm = 0x8000
movq %r14, %rdi
callq 0x848bb
movl $0x8000, %edx           # imm = 0x8000
movq %rax, 0x18(%rsp)
movq %rax, %rdi
movl $0xff, %esi
callq 0xe270
xorl %eax, %eax
testl %ebx, %ebx
cmovlel %eax, %ebx
movq %rbx, (%rsp)
cmpq %rbx, %rax
je 0x80029
leaq (%rax,%rax,2), %rcx
movq 0x8(%rsp), %rsi
movzbl (%rsi,%rcx), %edx
shrl $0x3, %edx
movq %rdx, 0x38(%rsp)
movzbl 0x1(%rsi,%rcx), %edx
shrl $0x3, %edx
movzbl 0x2(%rsi,%rcx), %esi
shrl $0x3, %esi
movl %esi, %edi
negl %edi
xorl %r11d, %r11d
xorl %r9d, %r9d
cmpq $0x20, %r9
je 0x8000e
movq 0x38(%rsp), %r8
movl %r8d, %ecx
subl %r9d, %ecx
movl %r9d, %r10d
subl %r8d, %r10d
movq %r9, 0x20(%rsp)
cmpq %r8, %r9
cmovbel %ecx, %r10d
movq %r11, 0x30(%rsp)
xorl %ebx, %ebx
cmpq $0x20, %rbx
je 0x7fff5
movl %edx, %ecx
subl %ebx, %ecx
movl %ebx, %r12d
subl %edx, %r12d
cmpq %rdx, %rbx
cmovbel %ecx, %r12d
leal (%r12,%r10), %ebp
cmpl %r12d, %r10d
cmovgl %r10d, %r12d
movq 0x18(%rsp), %rcx
leaq (%rcx,%r11), %r13
movl %esi, %ecx
xorl %r8d, %r8d
cmpq $0x20, %r8
je 0x7ffec
leal (%rdi,%r8), %r9d
cmpq %rsi, %r8
cmovbel %ecx, %r9d
cmpl %r9d, %r12d
movl %r9d, %r15d
cmovgl %r12d, %r15d
addl %ebp, %r9d
addl %r15d, %r9d
movzbl (%r13,%r8), %r15d
cmpl %r15d, %r9d
jge 0x7ffe5
movb %r9b, (%r13,%r8)
movq 0x388(%r14), %r9
addq %r11, %r9
movb %al, (%r8,%r9)
incq %r8
decl %ecx
jmp 0x7ffa6
incq %rbx
addq $0x20, %r11
jmp 0x7ff76
movq 0x20(%rsp), %r9
incq %r9
movq 0x30(%rsp), %r11
addq $0x400, %r11            # imm = 0x400
jmp 0x7ff48
incq %rax
movq (%rsp), %rbx
jmp 0x7ff10
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r14, %rdi
movq 0x18(%rsp), %rsi
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x84923