// File: /workspace/github_cpp_makefile_star2_O3/tomfunkhouser[P]gaps/pkgs/png/pngrtran.c
// Function: png_do_gray_to_rgb
void /* PRIVATE */
png_do_gray_to_rgb(png_row_infop row_info, png_bytep row)
{
   png_uint_32 i;
   png_uint_32 row_width = row_info->width;

   png_debug(1, "in png_do_gray_to_rgb");

   if (row_info->bit_depth >= 8 &&
      !(row_info->color_type & PNG_COLOR_MASK_COLOR))
   {
      if (row_info->color_type == PNG_COLOR_TYPE_GRAY)
      {
         if (row_info->bit_depth == 8)
         {
            png_bytep sp = row + (png_size_t)row_width - 1;
            png_bytep dp = sp  + (png_size_t)row_width * 2;
            for (i = 0; i < row_width; i++)
            {
               *(dp--) = *sp;
               *(dp--) = *sp;
               *(dp--) = *(sp--);
            }
         }
         else
         {
            png_bytep sp = row + (png_size_t)row_width * 2 - 1;
            png_bytep dp = sp  + (png_size_t)row_width * 4;
            for (i = 0; i < row_width; i++)
            {
               *(dp--) = *sp;
               *(dp--) = *(sp - 1);
               *(dp--) = *sp;
               *(dp--) = *(sp - 1);
               *(dp--) = *(sp--);
               *(dp--) = *(sp--);
            }
         }
      }
      else if (row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
      {
         if (row_info->bit_depth == 8)
         {
            png_bytep sp = row + (png_size_t)row_width * 2 - 1;
            png_bytep dp = sp  + (png_size_t)row_width * 2;
            for (i = 0; i < row_width; i++)
            {
               *(dp--) = *(sp--);
               *(dp--) = *sp;
               *(dp--) = *sp;
               *(dp--) = *(sp--);
            }
         }
         else
         {
            png_bytep sp = row + (png_size_t)row_width * 4 - 1;
            png_bytep dp = sp  + (png_size_t)row_width * 4;
            for (i = 0; i < row_width; i++)
            {
               *(dp--) = *(sp--);
               *(dp--) = *(sp--);
               *(dp--) = *sp;
               *(dp--) = *(sp - 1);
               *(dp--) = *sp;
               *(dp--) = *(sp - 1);
               *(dp--) = *(sp--);
               *(dp--) = *(sp--);
            }
         }
      }
      row_info->channels += (png_byte)2;
      row_info->color_type |= PNG_COLOR_MASK_COLOR;
      row_info->pixel_depth = (png_byte)(row_info->channels *
         row_info->bit_depth);
      row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth, row_width);
   }
}

// Assembly:
movb 0x11(%rdi), %al
cmpb $0x8, %al
jb 0x8fc09
movzbl 0x10(%rdi), %edx
testb $0x2, %dl
jne 0x8fc09
movl (%rdi), %ecx
cmpl $0x4, %edx
je 0x8faf2
testl %edx, %edx
jne 0x8fbd1
cmpb $0x8, %al
jne 0x8fb2d
testl %ecx, %ecx
je 0x8fbd1
leaq (%rsi,%rcx), %rax
decq %rax
addq %rcx, %rsi
leaq (%rsi,%rcx,2), %rdx
decq %rdx
movl %ecx, %esi
movb (%rax), %r8b
movb %r8b, (%rdx)
movb %r8b, -0x1(%rdx)
movb (%rax), %r8b
decq %rax
movb %r8b, -0x2(%rdx)
addq $-0x3, %rdx
decl %esi
jne 0x8fad1
jmp 0x8fbd1
cmpb $0x8, %al
jne 0x8fb83
testl %ecx, %ecx
je 0x8fbd1
movq %rcx, %rax
movb -0x1(%rsi,%rax,2), %dl
movb %dl, -0x1(%rsi,%rax,4)
movb -0x2(%rsi,%rax,2), %dl
movb %dl, -0x2(%rsi,%rax,4)
movb %dl, -0x3(%rsi,%rax,4)
movb -0x2(%rsi,%rax,2), %dl
movb %dl, -0x4(%rsi,%rax,4)
decq %rax
testl %eax, %eax
jne 0x8fb05
jmp 0x8fbd1
testl %ecx, %ecx
je 0x8fbd1
leaq (%rsi,%rcx,2), %rdx
leaq (%rsi,%rcx,2), %rax
decq %rax
leaq (%rdx,%rcx,4), %rdx
decq %rdx
movl %ecx, %esi
movb (%rax), %r8b
movb %r8b, (%rdx)
movb -0x1(%rax), %r8b
movb %r8b, -0x1(%rdx)
movb (%rax), %r8b
movb %r8b, -0x2(%rdx)
movb -0x1(%rax), %r8b
movb %r8b, -0x3(%rdx)
movb (%rax), %r8b
movb %r8b, -0x4(%rdx)
movb -0x1(%rax), %r8b
movb %r8b, -0x5(%rdx)
addq $-0x6, %rdx
addq $-0x2, %rax
decl %esi
jne 0x8fb49
jmp 0x8fbd1
testl %ecx, %ecx
je 0x8fbd1
movq %rcx, %rax
movb -0x1(%rsi,%rax,4), %dl
movb %dl, -0x1(%rsi,%rax,8)
movb -0x2(%rsi,%rax,4), %dl
movb %dl, -0x2(%rsi,%rax,8)
movb -0x3(%rsi,%rax,4), %dl
movb %dl, -0x3(%rsi,%rax,8)
movb -0x4(%rsi,%rax,4), %dl
movb %dl, -0x4(%rsi,%rax,8)
movb -0x3(%rsi,%rax,4), %dl
movb %dl, -0x5(%rsi,%rax,8)
movb -0x4(%rsi,%rax,4), %dl
movb %dl, -0x6(%rsi,%rax,8)
movb -0x3(%rsi,%rax,4), %dl
movb %dl, -0x7(%rsi,%rax,8)
movb -0x4(%rsi,%rax,4), %dl
movb %dl, -0x8(%rsi,%rax,8)
decq %rax
testl %eax, %eax
jne 0x8fb8a
movb 0x11(%rdi), %al
movb 0x12(%rdi), %dl
addb $0x2, %dl
movb %dl, 0x12(%rdi)
orb $0x2, 0x10(%rdi)
mulb %dl
movb %al, 0x13(%rdi)
cmpb $0x8, %al
jb 0x8fbf6
shrb $0x3, %al
movzbl %al, %eax
imulq %rcx, %rax
jmp 0x8fc05
movzbl %al, %eax
imulq %rcx, %rax
addq $0x7, %rax
shrq $0x3, %rax
movq %rax, 0x8(%rdi)
retq