// File: /workspace/github_cpp_makefile_star2_O2/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 0x83c7b
movl (%rdi), %eax
cmpl $0x4, %ecx
je 0x83c19
cmpl $0x2, %ecx
je 0x83bd0
cmpl $0x1, %ecx
jne 0x83c62
leal -0x1(%rax), %ecx
shrl $0x3, %ecx
addq %rsi, %rcx
movl %eax, %r9d
negl %r9d
andl $0x7, %r9d
xorl %edx, %edx
movq %rax, %r8
testl %r8d, %r8d
je 0x83c62
movzbl (%rcx), %r10d
btl %r9d, %r10d
setb -0x1(%rsi,%r8)
xorl %r10d, %r10d
cmpl $0x7, %r9d
leal 0x1(%r9), %r9d
cmovel %edx, %r9d
sete %r10b
subq %r10, %rcx
decq %r8
jmp 0x83b9e
leal -0x1(%rax), %edx
shrl $0x2, %edx
addq %rsi, %rdx
leal 0x6(,%rax,2), %ecx
notl %ecx
andl $0x6, %ecx
xorl %r8d, %r8d
movq %rax, %r9
testl %r9d, %r9d
je 0x83c62
movzbl (%rdx), %r10d
shrl %cl, %r10d
andb $0x3, %r10b
movb %r10b, -0x1(%rsi,%r9)
xorl %r10d, %r10d
cmpl $0x6, %ecx
leal 0x2(%rcx), %ecx
cmovel %r8d, %ecx
sete %r10b
subq %r10, %rdx
decq %r9
jmp 0x83beb
leal -0x1(%rax), %edx
shrl %edx
addq %rsi, %rdx
leal (,%rax,4), %ecx
andl $0x4, %ecx
movq %rax, %r8
testl %r8d, %r8d
je 0x83c62
movzbl (%rdx), %r9d
shrl %cl, %r9d
andb $0xf, %r9b
xorl %r10d, %r10d
xorl %r11d, %r11d
testl %ecx, %ecx
sete %r10b
movb %r9b, -0x1(%rsi,%r8)
setne %r11b
subq %r11, %rdx
shll $0x2, %r10d
decq %r8
movl %r10d, %ecx
jmp 0x83c2e
movb $0x8, 0x11(%rdi)
movzbl 0x12(%rdi), %ecx
leal (,%rcx,8), %edx
movb %dl, 0x13(%rdi)
imull %ecx, %eax
movq %rax, 0x8(%rdi)
retq