// File: /workspace/github_cpp_makefile_star2_O1/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 0x9e16d
movl (%rdi), %eax
leaq 0x15813(%rip), %r8      # 0xb3740
movslq (%r8,%rcx,4), %r9
addq %r8, %r9
jmpq *%r9
btl $0x16, %edx
jae 0x9df9a
cmpb $0x4, 0x12(%rdi)
jne 0x9df9a
pushq %rbx
cmpb $0x8, 0x11(%rdi)
jne 0x9e019
movl $0x3, %ecx
movb $0x18, %r8b
testb %dl, %dl
js 0x9e0d0
testl %eax, %eax
je 0x9e15d
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 0x9df6c
jmp 0x9e15d
testl %ecx, %ecx
je 0x9dfb1
cmpl $0x4, %ecx
jne 0x9e16d
btl $0x16, %edx
jae 0x9e16d
cmpb $0x2, 0x12(%rdi)
jne 0x9e16d
cmpb $0x8, 0x11(%rdi)
jne 0x9dfe8
testb %dl, %dl
js 0x9e07d
testl %eax, %eax
je 0x9e092
xorl %ecx, %ecx
movb 0x1(%rsi,%rcx,2), %r8b
movb %r8b, (%rsi,%rcx)
incq %rcx
cmpl %ecx, %eax
jne 0x9dfd3
jmp 0x9e092
testb %dl, %dl
js 0x9e098
testl %eax, %eax
je 0x9e0bb
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 0x9dffa
jmp 0x9e0bb
movl $0x6, %ecx
movb $0x30, %r8b
testb %dl, %dl
js 0x9e10c
testl %eax, %eax
je 0x9e15d
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 0x9e037
jmp 0x9e15d
testl %eax, %eax
je 0x9e092
xorl %ecx, %ecx
movb (%rsi,%rcx,2), %r8b
movb %r8b, (%rsi,%rcx)
incq %rcx
cmpl %ecx, %eax
jne 0x9e083
movb $0x8, 0x13(%rdi)
jmp 0x9e0c1
cmpl $0x2, %eax
jb 0x9e0bb
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 0x9e0a2
movb $0x10, 0x13(%rdi)
addl %eax, %eax
movl %eax, %eax
movq %rax, 0x8(%rdi)
movb $0x1, 0x12(%rdi)
jmp 0x9e16d
cmpl $0x2, %eax
jb 0x9e15d
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 0x9e0e4
jmp 0x9e15d
cmpl $0x2, %eax
jb 0x9e15d
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 0x9e11c
movb %r8b, 0x13(%rdi)
imull %ecx, %eax
movq %rax, 0x8(%rdi)
movb $0x3, 0x12(%rdi)
popq %rbx
btl $0x16, %edx
jae 0x9e177
andb $-0x5, 0x10(%rdi)
retq