// File: /workspace/github_cpp_makefile_star2_O2/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 0x8f0cf
movl (%rdi), %eax
leaq 0x1557e(%rip), %r8      # 0xa4440
movslq (%r8,%rcx,4), %r9
addq %r8, %r9
jmpq *%r9
btl $0x16, %edx
jb 0x8ef45
jmp 0x8f0cf
btl $0x16, %edx
jae 0x8f0cf
cmpb $0x4, 0x12(%rdi)
jne 0x8ef2e
cmpb $0x8, 0x11(%rdi)
jne 0x8efae
testb %dl, %dl
js 0x8f039
xorl %r8d, %r8d
pushq $0x3
popq %rcx
movq %rsi, %r9
cmpl %r8d, %eax
je 0x8f06b
movb 0x1(%rsi,%r8,4), %r10b
movb %r10b, (%r9)
movb 0x2(%rsi,%r8,4), %r10b
movb %r10b, 0x1(%r9)
movb 0x3(%rsi,%r8,4), %r10b
movb %r10b, 0x2(%r9)
addq $0x3, %r9
incq %r8
jmp 0x8ef02
cmpb $0x4, %cl
setne %cl
btl $0x16, %edx
setae %r8b
orb %cl, %r8b
jne 0x8f0cf
cmpb $0x2, 0x12(%rdi)
jne 0x8f0cf
cmpb $0x8, 0x11(%rdi)
jne 0x8ef7e
xorl %ecx, %ecx
testb %dl, %dl
js 0x8ef6d
cmpl %ecx, %eax
je 0x8efa8
movb 0x1(%rsi,%rcx,2), %r8b
movb %r8b, (%rsi,%rcx)
incq %rcx
jmp 0x8ef5b
cmpl %ecx, %eax
je 0x8efa8
movb (%rsi,%rcx,2), %r8b
movb %r8b, (%rsi,%rcx)
incq %rcx
jmp 0x8ef6d
testb %dl, %dl
js 0x8f006
xorl %ecx, %ecx
cmpl %ecx, %eax
je 0x8f024
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
jmp 0x8ef88
movb $0x8, 0x13(%rdi)
jmp 0x8f02a
testb %dl, %dl
js 0x8f070
xorl %r8d, %r8d
pushq $0x6
popq %rcx
movq %rsi, %r9
cmpl %r8d, %eax
je 0x8f0bd
movb 0x2(%rsi,%r8,8), %r10b
movb %r10b, (%r9)
movb 0x3(%rsi,%r8,8), %r10b
movb %r10b, 0x1(%r9)
movb 0x4(%rsi,%r8,8), %r10b
movb %r10b, 0x2(%r9)
movb 0x5(%rsi,%r8,8), %r10b
movb %r10b, 0x3(%r9)
movb 0x6(%rsi,%r8,8), %r10b
movb %r10b, 0x4(%r9)
movb 0x7(%rsi,%r8,8), %r10b
movb %r10b, 0x5(%r9)
addq $0x6, %r9
incq %r8
jmp 0x8efbf
pushq $0x1
popq %rcx
cmpl %eax, %ecx
jae 0x8f024
movb (%rsi,%rcx,4), %r8b
movb %r8b, (%rsi,%rcx,2)
movb 0x1(%rsi,%rcx,4), %r8b
movb %r8b, 0x1(%rsi,%rcx,2)
incq %rcx
jmp 0x8f009
movb $0x10, 0x13(%rdi)
addl %eax, %eax
movl %eax, %eax
movq %rax, 0x8(%rdi)
movb $0x1, 0x12(%rdi)
jmp 0x8f0cf
leaq 0x5(%rsi), %r8
pushq $0x1
popq %r9
pushq $0x3
popq %rcx
cmpl %eax, %r9d
jae 0x8f06b
movb (%rsi,%r9,4), %r10b
movb %r10b, -0x2(%r8)
movb 0x1(%rsi,%r9,4), %r10b
movb %r10b, -0x1(%r8)
movb 0x2(%rsi,%r9,4), %r10b
movb %r10b, (%r8)
addq $0x3, %r8
incq %r9
jmp 0x8f044
movb $0x18, %sil
jmp 0x8f0c0
leaq 0xb(%rsi), %r8
pushq $0x1
popq %r9
pushq $0x6
popq %rcx
cmpl %eax, %r9d
jae 0x8f0bd
movb (%rsi,%r9,8), %r10b
movb %r10b, -0x5(%r8)
movb 0x1(%rsi,%r9,8), %r10b
movb %r10b, -0x4(%r8)
movb 0x2(%rsi,%r9,8), %r10b
movb %r10b, -0x3(%r8)
movb 0x3(%rsi,%r9,8), %r10b
movb %r10b, -0x2(%r8)
movb 0x4(%rsi,%r9,8), %r10b
movb %r10b, -0x1(%r8)
movb 0x5(%rsi,%r9,8), %r10b
movb %r10b, (%r8)
addq $0x6, %r8
incq %r9
jmp 0x8f07b
movb $0x30, %sil
movb %sil, 0x13(%rdi)
imull %ecx, %eax
movq %rax, 0x8(%rdi)
movb $0x3, 0x12(%rdi)
btl $0x16, %edx
jae 0x8f0d9
andb $-0x5, 0x10(%rdi)
retq