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

   {
      png_bytep sp=row;
      png_bytep dp=row;
      png_uint_32 row_width=row_info->width;
      png_uint_32 i;

      if ((row_info->color_type == PNG_COLOR_TYPE_RGB ||
          (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA &&
          (flags & PNG_FLAG_STRIP_ALPHA))) &&
          row_info->channels == 4)
      {
         if (row_info->bit_depth == 8)
         {
            /* This converts from RGBX or RGBA to RGB */
            if (flags & PNG_FLAG_FILLER_AFTER)
            {
               dp+=3; sp+=4;
               for (i = 1; i < row_width; i++)
               {
                  *dp++ = *sp++;
                  *dp++ = *sp++;
                  *dp++ = *sp++;
                  sp++;
               }
            }
            /* This converts from XRGB or ARGB to RGB */
            else
            {
               for (i = 0; i < row_width; i++)
               {
                  sp++;
                  *dp++ = *sp++;
                  *dp++ = *sp++;
                  *dp++ = *sp++;
               }
            }
            row_info->pixel_depth = 24;
            row_info->rowbytes = row_width * 3;
         }
         else /* if (row_info->bit_depth == 16) */
         {
            if (flags & PNG_FLAG_FILLER_AFTER)
            {
               /* This converts from RRGGBBXX or RRGGBBAA to RRGGBB */
               sp += 8; dp += 6;
               for (i = 1; i < row_width; i++)
               {
                  /* This could be (although png_memcpy is probably slower):
                  png_memcpy(dp, sp, 6);
                  sp += 8;
                  dp += 6;
                  */

                  *dp++ = *sp++;
                  *dp++ = *sp++;
                  *dp++ = *sp++;
                  *dp++ = *sp++;
                  *dp++ = *sp++;
                  *dp++ = *sp++;
                  sp += 2;
               }
            }
            else
            {
               /* This converts from XXRRGGBB or AARRGGBB to RRGGBB */
               for (i = 0; i < row_width; i++)
               {
                  /* This could be (although png_memcpy is probably slower):
                  png_memcpy(dp, sp, 6);
                  sp += 8;
                  dp += 6;
                  */

                  sp+=2;
                  *dp++ = *sp++;
                  *dp++ = *sp++;
                  *dp++ = *sp++;
                  *dp++ = *sp++;
                  *dp++ = *sp++;
                  *dp++ = *sp++;
               }
            }
            row_info->pixel_depth = 48;
            row_info->rowbytes = row_width * 6;
         }
         row_info->channels = 3;
      }
      else if ((row_info->color_type == PNG_COLOR_TYPE_GRAY ||
         (row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA &&
         (flags & PNG_FLAG_STRIP_ALPHA))) &&
          row_info->channels == 2)
      {
         if (row_info->bit_depth == 8)
         {
            /* This converts from GX or GA to G */
            if (flags & PNG_FLAG_FILLER_AFTER)
            {
               for (i = 0; i < row_width; i++)
               {
                  *dp++ = *sp++;
                  sp++;
               }
            }
            /* This converts from XG or AG to G */
            else
            {
               for (i = 0; i < row_width; i++)
               {
                  sp++;
                  *dp++ = *sp++;
               }
            }
            row_info->pixel_depth = 8;
            row_info->rowbytes = row_width;
         }
         else /* if (row_info->bit_depth == 16) */
         {
            if (flags & PNG_FLAG_FILLER_AFTER)
            {
               /* This converts from GGXX or GGAA to GG */
               sp += 4; dp += 2;
               for (i = 1; i < row_width; i++)
               {
                  *dp++ = *sp++;
                  *dp++ = *sp++;
                  sp += 2;
               }
            }
            else
            {
               /* This converts from XXGG or AAGG to GG */
               for (i = 0; i < row_width; i++)
               {
                  sp += 2;
                  *dp++ = *sp++;
                  *dp++ = *sp++;
               }
            }
            row_info->pixel_depth = 16;
            row_info->rowbytes = row_width * 2;
         }
         row_info->channels = 1;
      }
      if (flags & PNG_FLAG_STRIP_ALPHA)
        row_info->color_type &= ~PNG_COLOR_MASK_ALPHA;
   }
}

// Assembly:
movzbl 0x10(%rdi), %ecx
cmpq $0x6, %rcx
ja 0x9d77a
movl (%rdi), %eax
leaq 0x16269(%rip), %r8      # 0xb3790
movslq (%r8,%rcx,4), %r9
addq %r8, %r9
jmpq *%r9
btl $0x16, %edx
jb 0x9d5be
jmp 0x9d77a
btl $0x16, %edx
jae 0x9d77a
cmpb $0x4, 0x12(%rdi)
jne 0x9d5a7
pushq %rbx
cmpb $0x8, 0x11(%rdi)
jne 0x9d626
movl $0x3, %ecx
movb $0x18, %r8b
testb %dl, %dl
js 0x9d6dd
testl %eax, %eax
je 0x9d76a
xorl %r9d, %r9d
xorl %r10d, %r10d
movb 0x1(%rsi,%r10,4), %r11b
movb %r11b, (%rsi,%r9)
movb 0x2(%rsi,%r10,4), %r11b
movb %r11b, 0x1(%rsi,%r9)
movb 0x3(%rsi,%r10,4), %r11b
movb %r11b, 0x2(%rsi,%r9)
incq %r10
addq $0x3, %r9
cmpl %r10d, %eax
jne 0x9d579
jmp 0x9d76a
cmpb $0x4, %cl
setne %cl
btl $0x16, %edx
setae %r8b
orb %cl, %r8b
jne 0x9d77a
cmpb $0x2, 0x12(%rdi)
jne 0x9d77a
cmpb $0x8, 0x11(%rdi)
jne 0x9d5f5
testb %dl, %dl
js 0x9d68a
testl %eax, %eax
je 0x9d69f
xorl %ecx, %ecx
movb 0x1(%rsi,%rcx,2), %r8b
movb %r8b, (%rsi,%rcx)
incq %rcx
cmpl %ecx, %eax
jne 0x9d5e0
jmp 0x9d69f
testb %dl, %dl
js 0x9d6a5
testl %eax, %eax
je 0x9d6c8
xorl %ecx, %ecx
movb 0x2(%rsi,%rcx,4), %r8b
movb %r8b, (%rsi,%rcx,2)
movb 0x3(%rsi,%rcx,4), %r8b
movb %r8b, 0x1(%rsi,%rcx,2)
incq %rcx
cmpl %ecx, %eax
jne 0x9d607
jmp 0x9d6c8
movl $0x6, %ecx
movb $0x30, %r8b
testb %dl, %dl
js 0x9d719
testl %eax, %eax
je 0x9d76a
xorl %r9d, %r9d
movq %rsi, %r10
movb 0x2(%rsi,%r9,8), %r11b
movb %r11b, (%r10)
movb 0x3(%rsi,%r9,8), %r11b
movb %r11b, 0x1(%r10)
movb 0x4(%rsi,%r9,8), %r11b
movb %r11b, 0x2(%r10)
movb 0x5(%rsi,%r9,8), %r11b
movb %r11b, 0x3(%r10)
movb 0x6(%rsi,%r9,8), %r11b
movb %r11b, 0x4(%r10)
movb 0x7(%rsi,%r9,8), %r11b
movb %r11b, 0x5(%r10)
incq %r9
addq $0x6, %r10
cmpl %r9d, %eax
jne 0x9d644
jmp 0x9d76a
testl %eax, %eax
je 0x9d69f
xorl %ecx, %ecx
movb (%rsi,%rcx,2), %r8b
movb %r8b, (%rsi,%rcx)
incq %rcx
cmpl %ecx, %eax
jne 0x9d690
movb $0x8, 0x13(%rdi)
jmp 0x9d6ce
cmpl $0x2, %eax
jb 0x9d6c8
movl $0x1, %ecx
movb (%rsi,%rcx,4), %r8b
movb %r8b, (%rsi,%rcx,2)
movb 0x1(%rsi,%rcx,4), %r8b
movb %r8b, 0x1(%rsi,%rcx,2)
incq %rcx
cmpl %ecx, %eax
jne 0x9d6af
movb $0x10, 0x13(%rdi)
addl %eax, %eax
movl %eax, %eax
movq %rax, 0x8(%rdi)
movb $0x1, 0x12(%rdi)
jmp 0x9d77a
cmpl $0x2, %eax
jb 0x9d76a
leal -0x1(%rax), %r9d
leaq 0x5(%rsi), %r10
xorl %r11d, %r11d
movb 0x4(%rsi,%r11,4), %bl
movb %bl, -0x2(%r10)
movb 0x5(%rsi,%r11,4), %bl
movb %bl, -0x1(%r10)
movb 0x6(%rsi,%r11,4), %bl
movb %bl, (%r10)
incq %r11
addq $0x3, %r10
cmpl %r11d, %r9d
jne 0x9d6f1
jmp 0x9d76a
cmpl $0x2, %eax
jb 0x9d76a
leal -0x1(%rax), %r9d
leaq 0xb(%rsi), %r10
xorl %r11d, %r11d
movb 0x8(%rsi,%r11,8), %bl
movb %bl, -0x5(%r10)
movb 0x9(%rsi,%r11,8), %bl
movb %bl, -0x4(%r10)
movb 0xa(%rsi,%r11,8), %bl
movb %bl, -0x3(%r10)
movb 0xb(%rsi,%r11,8), %bl
movb %bl, -0x2(%r10)
movb 0xc(%rsi,%r11,8), %bl
movb %bl, -0x1(%r10)
movb 0xd(%rsi,%r11,8), %bl
movb %bl, (%r10)
incq %r11
addq $0x6, %r10
cmpl %r11d, %r9d
jne 0x9d729
movb %r8b, 0x13(%rdi)
imull %ecx, %eax
movq %rax, 0x8(%rdi)
movb $0x3, 0x12(%rdi)
popq %rbx
btl $0x16, %edx
jae 0x9d784
andb $-0x5, 0x10(%rdi)
retq