// File: /workspace/github_cpp_makefile_star2_O1/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 %rdx, 0x10(%rsp)
testq %rdi, %rdi
je 0x8e0f1
movq %r8, %r14
movl %ecx, %r12d
movq %rsi, %r13
movq %rdi, %rbx
orb $0x40, 0x124(%rdi)
movl %r9d, 0x1c(%rsp)
testl %r9d, %r9d
jne 0x8d881
movq 0x10(%rsp), %rbp
movl %ebp, %r15d
movq %rbx, %rdi
movq %r15, %rsi
callq 0x92cb5
movq %rax, 0x390(%rbx)
testl %ebp, %ebp
jle 0x8d881
xorl %eax, %eax
movq 0x390(%rbx), %rcx
movb %al, (%rcx,%rax)
incq %rax
cmpq %rax, %r15
jne 0x8d86f
movq 0x10(%rsp), %rbp
cmpl %r12d, %ebp
movq %r13, 0x28(%rsp)
jle 0x8d9a9
movl %ebp, %r15d
movq %rbx, %rdi
movq %r15, %rsi
callq 0x92cb5
testq %r14, %r14
movl %r12d, 0x3c(%rsp)
movq %r15, 0x48(%rsp)
je 0x8d9b1
movq %rax, 0x438(%rbx)
testl %ebp, %ebp
jle 0x8d8d4
xorl %eax, %eax
movq 0x438(%rbx), %rcx
movb %al, (%rcx,%rax)
incq %rax
cmpq %rax, %r15
jne 0x8d8c2
cmpl $0x2, %r12d
movl $0x1, %eax
cmovgel %r12d, %eax
movq 0x10(%rsp), %rdx
leal -0x1(%rdx), %ecx
cmpl %eax, %edx
jle 0x8d936
movl %ecx, %ecx
decl %edx
movl $0x1, %edi
xorl %esi, %esi
movq 0x438(%rbx), %r9
movzbl (%r9,%rsi), %r8d
movzwl (%r14,%r8,2), %r11d
movzbl 0x1(%r9,%rsi), %r10d
cmpw (%r14,%r10,2), %r11w
jae 0x8d928
movb %r10b, (%r9,%rsi)
movq 0x438(%rbx), %rdi
movb %r8b, 0x1(%rdi,%rsi)
xorl %edi, %edi
incq %rsi
cmpq %rsi, %rcx
jne 0x8d8f8
decl %ecx
testl %edi, %edi
je 0x8d8e9
cmpl $0x0, 0x1c(%rsp)
je 0x8dd9f
testl %r12d, %r12d
movq 0x10(%rsp), %rbp
jle 0x8df4b
movl %r12d, %eax
xorl %ecx, %ecx
movq 0x438(%rbx), %rsi
movzbl (%rsi,%rcx), %edx
cmpl %r12d, %edx
jl 0x8d99c
movslq %ebp, %rdi
leaq (%rdi,%rdi,2), %rdx
addq %r13, %rdx
addq %rdi, %rsi
decq %rsi
addq $-0x3, %rdx
decl %ebp
leaq -0x1(%rsi), %rdi
cmpb %r12b, (%rsi)
movq %rdi, %rsi
jae 0x8d974
leaq (%rcx,%rcx,2), %rsi
movb 0x2(%rdx), %dil
movb %dil, 0x2(%r13,%rsi)
movzwl (%rdx), %edx
movw %dx, (%r13,%rsi)
incq %rcx
cmpq %rax, %rcx
jne 0x8d954
jmp 0x8df4b
movl %ebp, %r12d
jmp 0x8df65
movq %rax, 0x440(%rbx)
movq %rbx, %rdi
movq %r15, %rsi
callq 0x92cb5
movq %rax, 0x448(%rbx)
testl %ebp, %ebp
movq %rbp, %r14
jle 0x8d9ef
xorl %eax, %eax
movq 0x440(%rbx), %rcx
movb %al, (%rcx,%rax)
movq 0x448(%rbx), %rcx
movb %al, (%rcx,%rax)
incq %rax
cmpq %rax, %r15
jne 0x8d9d3
leaq 0x440(%rbx), %rbp
movl $0x1808, %esi           # imm = 0x1808
movq %rbx, %rdi
callq 0x92c97
movq %rax, %rsi
cmpl %r12d, %r14d
jle 0x8dd6d
cmpl $0x0, 0x1c(%rsp)
setne %al
testl %r14d, %r14d
setle %cl
orb %al, %cl
movb %cl, 0xf(%rsp)
leaq 0x5(%r13), %rax
movq %rax, 0x70(%rsp)
movl $0x60, %edi
movl $0x61, %eax
movq %rax, 0x60(%rsp)
xorl %eax, %eax
movq %rbp, 0x40(%rsp)
movq %rsi, 0x20(%rsp)
cmpl $0x2, %r14d
movl $0x1, %ecx
cmovgel %r14d, %ecx
decl %ecx
movq %rcx, 0x78(%rsp)
movl $0x2, %ecx
movq 0x70(%rsp), %rdx
movq %rdx, 0x68(%rsp)
xorl %edx, %edx
movl %edi, 0x30(%rsp)
movq %r14, 0x10(%rsp)
cmpq 0x78(%rsp), %rdx
je 0x8db9c
leaq 0x1(%rdx), %r8
movq %r8, 0x80(%rsp)
movq %rdx, 0x50(%rsp)
leaq (%rdx,%rdx,2), %r12
addq %r13, %r12
movq 0x68(%rsp), %r15
movl %ecx, 0x5c(%rsp)
movl %ecx, %ebp
movzbl (%r12), %edx
movzbl -0x2(%r15), %ecx
subl %ecx, %edx
movl %edx, %ecx
negl %ecx
cmovsl %edx, %ecx
movl $0xff, %r8d
andl %r8d, %ecx
movzbl 0x1(%r12), %r9d
movzbl -0x1(%r15), %edx
subl %edx, %r9d
movl %r9d, %edx
negl %edx
cmovsl %r9d, %edx
andl %r8d, %edx
addl %ecx, %edx
movzbl 0x2(%r12), %r9d
movzbl (%r15), %ecx
subl %ecx, %r9d
movl %r9d, %r14d
negl %r14d
cmovsl %r9d, %r14d
andl %r8d, %r14d
addl %edx, %r14d
movb $0x1, %r13b
cmpl %edi, %r14d
jbe 0x8db07
movq 0x10(%rsp), %r14
jmp 0x8db54
movl $0x10, %esi
movq %rbx, %rdi
callq 0x92d72
testq %rax, %rax
je 0x8db41
movl %r14d, %edx
movq 0x20(%rsp), %rsi
movq (%rsi,%rdx,8), %rcx
movq %rcx, (%rax)
movq 0x50(%rsp), %rcx
movb %cl, 0x8(%rax)
leal -0x1(%rbp), %ecx
movb %cl, 0x9(%rax)
movq %rax, (%rsi,%rdx,8)
movq 0x10(%rsp), %r14
jmp 0x8db50
xorl %eax, %eax
xorl %r13d, %r13d
movq 0x10(%rsp), %r14
movq 0x20(%rsp), %rsi
movl 0x30(%rsp), %edi
testb %r13b, %r13b
je 0x8db6b
leal 0x1(%rbp), %ecx
addq $0x3, %r15
cmpl %ebp, %r14d
movl %ecx, %ebp
jg 0x8daa3
movl 0x5c(%rsp), %ecx
incl %ecx
addq $0x3, 0x68(%rsp)
movq 0x80(%rsp), %rdx
testq %rax, %rax
movq 0x28(%rsp), %r13
movl 0x3c(%rsp), %r12d
movq 0x48(%rsp), %r15
movq 0x40(%rsp), %rbp
jne 0x8da75
testq %rax, %rax
je 0x8dd12
xorl %edx, %edx
movl %r14d, %edi
movq (%rsi,%rdx,8), %rcx
testq %rcx, %rcx
je 0x8dcfe
movq %rdx, 0x10(%rsp)
movq (%rbp), %r9
movzbl 0x8(%rcx), %edx
movzbl (%r9,%rdx), %esi
cmpl %esi, %edi
jle 0x8dcd6
movzbl 0x9(%rcx), %esi
movzbl (%r9,%rsi), %r8d
cmpl %r8d, %edi
jle 0x8dcd6
testb $0x1, %dil
movzbl %sil, %r8d
movzbl %dl, %r10d
movl %r10d, %edx
cmovel %r8d, %edx
leal -0x1(%rdi), %r14d
movzbl %dl, %esi
movzbl (%r9,%rsi), %r9d
leaq (%r9,%r9,2), %r9
leaq (%r14,%r14,2), %r11
movl %r12d, %r13d
movq 0x28(%rsp), %r12
movb 0x2(%r12,%r11), %bpl
movb %bpl, 0x2(%r12,%r9)
movq 0x40(%rsp), %rbp
movzwl (%r12,%r11), %r11d
movw %r11w, (%r12,%r9)
movl %r13d, %r12d
cmpb $0x0, 0xf(%rsp)
jne 0x8dc89
testb $0x1, %dil
cmovel %r10d, %r8d
movzbl %r8b, %edi
xorl %r8d, %r8d
movq 0x390(%rbx), %r9
movq 0x440(%rbx), %r10
movb (%r9,%r8), %r11b
cmpb (%r10,%rsi), %r11b
jne 0x8dc64
movb (%r10,%rdi), %r10b
movb %r10b, (%r9,%r8)
movq 0x390(%rbx), %r9
movzbl (%r9,%r8), %r10d
cmpl %r10d, %r14d
jne 0x8dc81
movq (%rbp), %r10
movb (%r10,%rsi), %r10b
movb %r10b, (%r9,%r8)
incq %r8
cmpq %r8, %r15
jne 0x8dc44
movq 0x440(%rbx), %rdi
movq 0x448(%rbx), %r8
movb (%rdi,%rsi), %r9b
movzbl (%r8,%r14), %r8d
movb %r9b, (%rdi,%r8)
movq 0x440(%rbx), %rdi
movq 0x448(%rbx), %r8
movb (%r8,%r14), %r9b
movzbl (%rdi,%rsi), %edi
movb %r9b, (%r8,%rdi)
movq 0x440(%rbx), %rdi
movb %r14b, (%rdi,%rsi)
movq 0x448(%rbx), %rsi
movb %dl, (%rsi,%r14)
jmp 0x8dcd9
movl %edi, %r14d
cmpl %r12d, %r14d
jle 0x8dced
movq (%rcx), %rcx
movl %r14d, %edi
testq %rcx, %rcx
jne 0x8dbbc
cmpl %r12d, %r14d
movq 0x20(%rsp), %rsi
movq 0x10(%rsp), %rdx
jg 0x8dd01
jmp 0x8dd12
movl %edi, %r14d
incq %rdx
movl %r14d, %edi
cmpq 0x60(%rsp), %rdx
jne 0x8dbaa
xorl %r15d, %r15d
movq (%rsi,%r15,8), %rsi
testq %rsi, %rsi
je 0x8dd34
movq (%rsi), %r13
movq %rbx, %rdi
callq 0x92d32
movq %r13, %rax
movq %r13, %rsi
testq %r13, %r13
jne 0x8dd1e
movq 0x20(%rsp), %rsi
movq $0x0, (%rsi,%r15,8)
incq %r15
cmpq $0x301, %r15            # imm = 0x301
jne 0x8dd15
movl 0x30(%rsp), %edi
addl $0x60, %edi
addq $0x60, 0x60(%rsp)
cmpl %r12d, %r14d
movq 0x48(%rsp), %r15
movq 0x28(%rsp), %r13
jg 0x8da47
movq %rbx, %rdi
callq 0x92d32
movq 0x448(%rbx), %rsi
movq %rbx, %rdi
callq 0x92d32
movq 0x440(%rbx), %rsi
movq %rbx, %rdi
callq 0x92d32
xorps %xmm0, %xmm0
movups %xmm0, (%rbp)
jmp 0x8df65
movl %r12d, %eax
testl %r12d, %r12d
movq 0x10(%rsp), %rbp
jle 0x8de41
xorl %ecx, %ecx
movl %ebp, %edx
movq 0x438(%rbx), %r8
movzbl (%r8,%rcx), %esi
cmpl %r12d, %esi
jl 0x8de35
movslq %edx, %rsi
leaq (%rsi,%rsi,2), %rdi
addq %r13, %rdi
movq %rsi, %r9
decq %rsi
decl %edx
addq $-0x3, %rdi
cmpb %r12b, -0x1(%r8,%r9)
jae 0x8ddcf
movb 0x2(%rdi), %r8b
movb %r8b, 0x1a(%rsp)
movzwl (%rdi), %r8d
movw %r8w, 0x18(%rsp)
leaq (%rcx,%rcx,2), %r8
movb 0x2(%r13,%r8), %r9b
movb %r9b, 0x2(%rdi)
movzwl (%r13,%r8), %r9d
movw %r9w, (%rdi)
movzwl 0x18(%rsp), %edi
movw %di, (%r13,%r8)
movb 0x1a(%rsp), %dil
movb %dil, 0x2(%r13,%r8)
movq 0x390(%rbx), %rdi
movb %cl, (%rdi,%rsi)
movq 0x390(%rbx), %rsi
movb %dl, (%rsi,%rcx)
incq %rcx
cmpq %rax, %rcx
jne 0x8ddb4
testl %ebp, %ebp
jle 0x8df4b
leaq 0x5(%r13), %rcx
xorl %edx, %edx
movq 0x390(%rbx), %rsi
movzbl (%rsi,%rdx), %r8d
cmpl %r12d, %r8d
jl 0x8df3f
xorl %edi, %edi
cmpl $0x2, %r12d
jl 0x8df3b
leaq (%r8,%r8,2), %r10
movzbl (%r13,%r10), %r8d
movzbl 0x1(%r13,%r10), %r9d
movzbl 0x1(%r13), %r11d
movl %r9d, %ebp
subl %r11d, %ebp
movl %ebp, %r11d
negl %r11d
cmovsl %ebp, %r11d
movzbl 0x2(%r13,%r10), %r10d
movzbl (%r13), %ebp
movl %r8d, %r14d
subl %ebp, %r14d
movl %r14d, %ebp
negl %ebp
cmovsl %r14d, %ebp
addl %r11d, %ebp
movzbl 0x2(%r13), %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 0x8ded3
movq 0x28(%rsp), %r13
movl 0x3c(%rsp), %r12d
movq 0x48(%rsp), %r15
movb %dil, (%rsi,%rdx)
incq %rdx
cmpq %r15, %rdx
jne 0x8de4f
movq 0x438(%rbx), %rsi
movq %rbx, %rdi
callq 0x92d32
movq $0x0, 0x438(%rbx)
cmpq $0x0, 0x238(%rbx)
movl 0x1c(%rsp), %eax
jne 0x8df7a
movq %r13, 0x238(%rbx)
movw %r12w, 0x240(%rbx)
testl %eax, %eax
je 0x8e0f1
movl $0x8000, %esi           # imm = 0x8000
movq %rbx, %rdi
callq 0x92c97
movq %rax, 0x388(%rbx)
movl $0x8000, %esi           # imm = 0x8000
movq %rbx, %rdi
callq 0x92cb5
movl $0x8000, %edx           # imm = 0x8000
movq %rax, 0x10(%rsp)
movq %rax, %rdi
movl $0xff, %esi
callq 0xe260
testl %r12d, %r12d
jle 0x8e0d3
movl %r12d, %eax
movq %rax, 0x40(%rsp)
xorl %ecx, %ecx
leaq (%rcx,%rcx,2), %rax
movzbl (%r13,%rax), %edx
shrl $0x3, %edx
movq %rdx, 0x50(%rsp)
movzbl 0x1(%r13,%rax), %esi
shrl $0x3, %esi
movzbl 0x2(%r13,%rax), %edi
shrl $0x3, %edi
movl %edi, %r8d
negl %r8d
xorl %r15d, %r15d
xorl %r9d, %r9d
movq 0x50(%rsp), %rdx
movl %edx, %eax
subl %r9d, %eax
movl %r9d, %r11d
subl %edx, %r11d
movq %r9, 0x30(%rsp)
cmpq %rdx, %r9
cmovbel %eax, %r11d
movq %r15, 0x20(%rsp)
xorl %r12d, %r12d
movl %esi, %eax
subl %r12d, %eax
movl %r12d, %r13d
subl %esi, %r13d
cmpq %rsi, %r12
cmovbel %eax, %r13d
leal (%r11,%r13), %ebp
cmpl %r13d, %r11d
cmovgl %r11d, %r13d
movq 0x10(%rsp), %rax
addq %r15, %rax
movl %edi, %edx
xorl %r9d, %r9d
leal (%r8,%r9), %r10d
cmpq %rdi, %r9
cmovbel %edx, %r10d
cmpl %r10d, %r13d
movl %r10d, %r14d
cmovgl %r13d, %r14d
addl %ebp, %r10d
addl %r14d, %r10d
movzbl (%rax,%r9), %r14d
cmpl %r14d, %r10d
jge 0x8e08a
movb %r10b, (%rax,%r9)
movq 0x388(%rbx), %r10
addq %r15, %r10
movb %cl, (%r9,%r10)
incq %r9
decl %edx
cmpq $0x20, %r9
jne 0x8e053
incq %r12
addq $0x20, %r15
cmpq $0x20, %r12
jne 0x8e029
movq 0x30(%rsp), %r9
incq %r9
movq 0x20(%rsp), %r15
addq $0x400, %r15            # imm = 0x400
cmpq $0x20, %r9
jne 0x8e005
incq %rcx
cmpq 0x40(%rsp), %rcx
movq 0x28(%rsp), %r13
jne 0x8dfd5
movq %rbx, %rdi
movq 0x10(%rsp), %rsi
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x92d32
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq