// File: /workspace/github_cpp_makefile_star2_O3/tomfunkhouser[P]gaps/pkgs/png/pngrtran.c
// Function: png_do_unpack
void /* PRIVATE */
png_do_unpack(png_row_infop row_info, png_bytep row)
{
   png_debug(1, "in png_do_unpack");

   if (row_info->bit_depth < 8)
   {
      png_uint_32 i;
      png_uint_32 row_width=row_info->width;

      switch (row_info->bit_depth)
      {
         case 1:
         {
            png_bytep sp = row + (png_size_t)((row_width - 1) >> 3);
            png_bytep dp = row + (png_size_t)row_width - 1;
            png_uint_32 shift = 7 - (int)((row_width + 7) & 0x07);
            for (i = 0; i < row_width; i++)
            {
               *dp = (png_byte)((*sp >> shift) & 0x01);
               if (shift == 7)
               {
                  shift = 0;
                  sp--;
               }
               else
                  shift++;

               dp--;
            }
            break;
         }

         case 2:
         {

            png_bytep sp = row + (png_size_t)((row_width - 1) >> 2);
            png_bytep dp = row + (png_size_t)row_width - 1;
            png_uint_32 shift = (int)((3 - ((row_width + 3) & 0x03)) << 1);
            for (i = 0; i < row_width; i++)
            {
               *dp = (png_byte)((*sp >> shift) & 0x03);
               if (shift == 6)
               {
                  shift = 0;
                  sp--;
               }
               else
                  shift += 2;

               dp--;
            }
            break;
         }

         case 4:
         {
            png_bytep sp = row + (png_size_t)((row_width - 1) >> 1);
            png_bytep dp = row + (png_size_t)row_width - 1;
            png_uint_32 shift = (int)((1 - ((row_width + 1) & 0x01)) << 2);
            for (i = 0; i < row_width; i++)
            {
               *dp = (png_byte)((*sp >> shift) & 0x0f);
               if (shift == 4)
               {
                  shift = 0;
                  sp--;
               }
               else
                  shift = 4;

               dp--;
            }
            break;
         }
      }
      row_info->bit_depth = 8;
      row_info->pixel_depth = (png_byte)(8 * row_info->channels);
      row_info->rowbytes = row_width * row_info->channels;
   }
}

// Assembly:
movzbl 0x11(%rdi), %ecx
cmpl $0x7, %ecx
ja 0x91296
movl (%rdi), %eax
cmpl $0x4, %ecx
je 0x9122e
cmpl $0x2, %ecx
je 0x911d9
cmpl $0x1, %ecx
jne 0x9127d
testl %eax, %eax
je 0x9127d
movl %eax, %r9d
negl %r9d
andl $0x7, %r9d
leal -0x1(%rax), %ecx
shrl $0x3, %ecx
addq %rsi, %rcx
leaq (%rax,%rsi), %rdx
decq %rdx
xorl %esi, %esi
movl %eax, %r8d
movzbl (%rcx), %r10d
btl %r9d, %r10d
setb (%rdx)
xorl %r10d, %r10d
cmpl $0x7, %r9d
leal 0x1(%r9), %r9d
sete %r10b
cmovel %esi, %r9d
subq %r10, %rcx
decq %rdx
decl %r8d
jne 0x911ab
jmp 0x9127d
testl %eax, %eax
je 0x9127d
leal 0x6(,%rax,2), %ecx
notl %ecx
andl $0x6, %ecx
leal -0x1(%rax), %edx
shrl $0x2, %edx
addq %rsi, %rdx
addq %rax, %rsi
decq %rsi
xorl %r8d, %r8d
movl %eax, %r9d
movzbl (%rdx), %r10d
shrl %cl, %r10d
andb $0x3, %r10b
movb %r10b, (%rsi)
xorl %r10d, %r10d
cmpl $0x6, %ecx
leal 0x2(%rcx), %ecx
sete %r10b
cmovel %r8d, %ecx
subq %r10, %rdx
decq %rsi
decl %r9d
jne 0x91202
jmp 0x9127d
testl %eax, %eax
je 0x9127d
leal (,%rax,4), %ecx
andl $0x4, %ecx
leal -0x1(%rax), %edx
shrl %edx
addq %rsi, %rdx
addq %rax, %rsi
decq %rsi
movl %eax, %r8d
movzbl (%rdx), %r9d
shrl %cl, %r9d
andb $0xf, %r9b
xorl %r10d, %r10d
xorl %r11d, %r11d
testl %ecx, %ecx
sete %r10b
movb %r9b, (%rsi)
setne %r11b
subq %r11, %rdx
shll $0x2, %r10d
decq %rsi
movl %r10d, %ecx
decl %r8d
jne 0x9124d
movb $0x8, 0x11(%rdi)
movzbl 0x12(%rdi), %ecx
leal (,%rcx,8), %edx
movb %dl, 0x13(%rdi)
imull %ecx, %eax
movq %rax, 0x8(%rdi)
retq