// File: /workspace/github_cpp_makefile_star2_O3/tomfunkhouser[P]gaps/pkgs/png/pngrutil.c
// Function: png_do_read_interlace
void /* PRIVATE */
png_do_read_interlace(png_structp png_ptr)
{
   png_row_infop row_info = &(png_ptr->row_info);
   png_bytep row = png_ptr->row_buf + 1;
   int pass = png_ptr->pass;
   png_uint_32 transformations = png_ptr->transformations;
   /* Arrays to facilitate easy interlacing - use pass (0 - 6) as index */
   /* Offset to next interlace block */
   PNG_CONST int png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1};

   png_debug(1, "in png_do_read_interlace");
   if (row != NULL && row_info != NULL)
   {
      png_uint_32 final_width;

      final_width = row_info->width * png_pass_inc[pass];

      switch (row_info->pixel_depth)
      {
         case 1:
         {
            png_bytep sp = row + (png_size_t)((row_info->width - 1) >> 3);
            png_bytep dp = row + (png_size_t)((final_width - 1) >> 3);
            int sshift, dshift;
            int s_start, s_end, s_inc;
            int jstop = png_pass_inc[pass];
            png_byte v;
            png_uint_32 i;
            int j;

#ifdef PNG_READ_PACKSWAP_SUPPORTED
            if (transformations & PNG_PACKSWAP)
            {
                sshift = (int)((row_info->width + 7) & 0x07);
                dshift = (int)((final_width + 7) & 0x07);
                s_start = 7;
                s_end = 0;
                s_inc = -1;
            }
            else
#endif
            {
                sshift = 7 - (int)((row_info->width + 7) & 0x07);
                dshift = 7 - (int)((final_width + 7) & 0x07);
                s_start = 0;
                s_end = 7;
                s_inc = 1;
            }

            for (i = 0; i < row_info->width; i++)
            {
               v = (png_byte)((*sp >> sshift) & 0x01);
               for (j = 0; j < jstop; j++)
               {
                  *dp &= (png_byte)((0x7f7f >> (7 - dshift)) & 0xff);
                  *dp |= (png_byte)(v << dshift);
                  if (dshift == s_end)
                  {
                     dshift = s_start;
                     dp--;
                  }
                  else
                     dshift += s_inc;
               }
               if (sshift == s_end)
               {
                  sshift = s_start;
                  sp--;
               }
               else
                  sshift += s_inc;
            }
            break;
         }
         case 2:
         {
            png_bytep sp = row + (png_uint_32)((row_info->width - 1) >> 2);
            png_bytep dp = row + (png_uint_32)((final_width - 1) >> 2);
            int sshift, dshift;
            int s_start, s_end, s_inc;
            int jstop = png_pass_inc[pass];
            png_uint_32 i;

#ifdef PNG_READ_PACKSWAP_SUPPORTED
            if (transformations & PNG_PACKSWAP)
            {
               sshift = (int)(((row_info->width + 3) & 0x03) << 1);
               dshift = (int)(((final_width + 3) & 0x03) << 1);
               s_start = 6;
               s_end = 0;
               s_inc = -2;
            }
            else
#endif
            {
               sshift = (int)((3 - ((row_info->width + 3) & 0x03)) << 1);
               dshift = (int)((3 - ((final_width + 3) & 0x03)) << 1);
               s_start = 0;
               s_end = 6;
               s_inc = 2;
            }

            for (i = 0; i < row_info->width; i++)
            {
               png_byte v;
               int j;

               v = (png_byte)((*sp >> sshift) & 0x03);
               for (j = 0; j < jstop; j++)
               {
                  *dp &= (png_byte)((0x3f3f >> (6 - dshift)) & 0xff);
                  *dp |= (png_byte)(v << dshift);
                  if (dshift == s_end)
                  {
                     dshift = s_start;
                     dp--;
                  }
                  else
                     dshift += s_inc;
               }
               if (sshift == s_end)
               {
                  sshift = s_start;
                  sp--;
               }
               else
                  sshift += s_inc;
            }
            break;
         }
         case 4:
         {
            png_bytep sp = row + (png_size_t)((row_info->width - 1) >> 1);
            png_bytep dp = row + (png_size_t)((final_width - 1) >> 1);
            int sshift, dshift;
            int s_start, s_end, s_inc;
            png_uint_32 i;
            int jstop = png_pass_inc[pass];

#ifdef PNG_READ_PACKSWAP_SUPPORTED
            if (transformations & PNG_PACKSWAP)
            {
               sshift = (int)(((row_info->width + 1) & 0x01) << 2);
               dshift = (int)(((final_width + 1) & 0x01) << 2);
               s_start = 4;
               s_end = 0;
               s_inc = -4;
            }
            else
#endif
            {
               sshift = (int)((1 - ((row_info->width + 1) & 0x01)) << 2);
               dshift = (int)((1 - ((final_width + 1) & 0x01)) << 2);
               s_start = 0;
               s_end = 4;
               s_inc = 4;
            }

            for (i = 0; i < row_info->width; i++)
            {
               png_byte v = (png_byte)((*sp >> sshift) & 0xf);
               int j;

               for (j = 0; j < jstop; j++)
               {
                  *dp &= (png_byte)((0xf0f >> (4 - dshift)) & 0xff);
                  *dp |= (png_byte)(v << dshift);
                  if (dshift == s_end)
                  {
                     dshift = s_start;
                     dp--;
                  }
                  else
                     dshift += s_inc;
               }
               if (sshift == s_end)
               {
                  sshift = s_start;
                  sp--;
               }
               else
                  sshift += s_inc;
            }
            break;
         }
         default:
         {
            png_size_t pixel_bytes = (row_info->pixel_depth >> 3);
            png_bytep sp = row + (png_size_t)(row_info->width - 1)
                * pixel_bytes;
            png_bytep dp = row + (png_size_t)(final_width - 1) * pixel_bytes;

            int jstop = png_pass_inc[pass];
            png_uint_32 i;

            for (i = 0; i < row_info->width; i++)
            {
               png_byte v[8];
               int j;

               png_memcpy(v, sp, pixel_bytes);
               for (j = 0; j < jstop; j++)
               {
                  png_memcpy(dp, v, pixel_bytes);
                  dp -= pixel_bytes;
               }
               sp -= pixel_bytes;
            }
            break;
         }
      }
      row_info->width = final_width;
      row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth, final_width);
   }
#ifndef PNG_READ_PACKSWAP_SUPPORTED
   transformations = transformations; /* Silence compiler warning */
#endif
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq 0x1f0(%rdi), %rbx
incq %rbx
movl 0x124(%rdi), %r9d
movzbl 0x24c(%rdi), %eax
movl 0x218(%rdi), %esi
leaq 0x16047(%rip), %rcx     # 0xb2830
movl (%rcx,%rax,4), %ecx
movl %ecx, %r10d
imull %esi, %r10d
movzbl 0x22b(%rdi), %ebp
cmpl $0x4, %ebp
movq %rdi, (%rsp)
movq %r10, 0x8(%rsp)
je 0x9c887
cmpl $0x2, %ebp
je 0x9c84f
cmpl $0x1, %ebp
jne 0x9c8ba
leal -0x1(%rsi), %edx
leal -0x1(%r10), %edi
movl %edx, %r8d
andl $0x7, %r8d
btl $0x10, %r9d
jb 0x9caaa
xorl $0x7, %r8d
movl %r10d, %eax
negl %eax
andl $0x7, %eax
xorl %r9d, %r9d
movl $0x7, %r10d
movl $0x1, %r11d
jmp 0x9cabe
leal 0x6(,%rsi,2), %eax
andl $0x6, %eax
btl $0x10, %r9d
jb 0x9c93b
xorl $0x6, %eax
leal 0x6(,%r10,2), %edx
notl %edx
andl $0x6, %edx
movl $0x2, %edi
movl $0x6, %r8d
xorl %r9d, %r9d
jmp 0x9c954
leal (,%rsi,4), %eax
andl $0x4, %eax
btl $0x10, %r9d
jb 0x9c9f2
leal (,%r10,4), %edx
andl $0x4, %edx
movl $0x4, %edi
xorl %r8d, %r8d
movl $0x4, %r9d
jmp 0x9ca0e
testl %esi, %esi
je 0x9cb56
shrl $0x3, %ebp
leal -0x1(%r10), %r12d
imulq %rbp, %r12
addq %rbx, %r12
decl %esi
imulq %rbp, %rsi
addq %rbx, %rsi
movq %rbp, %r15
negq %r15
cmpl $0x2, %ecx
movl $0x1, %eax
cmovgel %ecx, %eax
movl %eax, 0x14(%rsp)
xorl %ebx, %ebx
leaq 0x20(%rsp), %r13
movq %r13, %rdi
movq %rsi, 0x18(%rsp)
movq %rbp, %rdx
callq 0xe370
movl 0x14(%rsp), %r14d
movq %r12, %rdi
movq %r13, %rsi
movq %rbp, %rdx
callq 0xe370
addq %r15, %r12
decl %r14d
jne 0x9c90a
movq 0x18(%rsp), %rsi
addq %r15, %rsi
incl %ebx
movq (%rsp), %rax
cmpl 0x218(%rax), %ebx
jb 0x9c8f5
jmp 0x9cb46
leal 0x6(,%r10,2), %edx
andl $0x6, %edx
movl $0xfffffffe, %edi       # imm = 0xFFFFFFFE
xorl %r8d, %r8d
movl $0x6, %r9d
testl %esi, %esi
je 0x9cb46
decl %esi
movq 0x8(%rsp), %r10
decl %r10d
shrl $0x2, %esi
shrl $0x2, %r10d
addq %rbx, %rsi
addq %rbx, %r10
cmpl $0x2, %ecx
movl $0x1, %r12d
cmovgel %ecx, %r12d
xorl %r11d, %r11d
movq %rsi, %r13
movzbl (%rsi), %r15d
movl %eax, %ecx
shrl %cl, %r15d
andl $0x3, %r15d
movl %r12d, %ebx
movb $0x6, %cl
subb %dl, %cl
movl $0x3f3f, %ebp           # imm = 0x3F3F
shrl %cl, %ebp
andb (%r10), %bpl
movl %r15d, %r14d
movl %edx, %ecx
shll %cl, %r14d
orb %bpl, %r14b
movb %r14b, (%r10)
xorl %ecx, %ecx
cmpl %r8d, %edx
leal (%rdx,%rdi), %edx
sete %cl
cmovel %r9d, %edx
subq %rcx, %r10
decl %ebx
jne 0x9c996
xorl %ecx, %ecx
cmpl %r8d, %eax
leal (%rax,%rdi), %eax
sete %cl
cmovel %r9d, %eax
movq %r13, %rsi
subq %rcx, %rsi
incl %r11d
movq (%rsp), %rcx
cmpl 0x218(%rcx), %r11d
jb 0x9c983
jmp 0x9cb46
xorl $0x4, %eax
movl %r10d, %edx
notl %edx
shll $0x2, %edx
andl $0x4, %edx
movl $0xfffffffc, %r9d       # imm = 0xFFFFFFFC
xorl %edi, %edi
movl $0x4, %r8d
testl %esi, %esi
je 0x9cb46
decl %esi
movq 0x8(%rsp), %r10
decl %r10d
shrl %esi
shrl %r10d
addq %rbx, %rsi
addq %rbx, %r10
cmpl $0x2, %ecx
movl $0x1, %r12d
cmovgel %ecx, %r12d
xorl %r11d, %r11d
movq %rsi, %r13
movzbl (%rsi), %r15d
movl %eax, %ecx
shrl %cl, %r15d
andl $0xf, %r15d
movl %r12d, %ebx
movb $0x4, %cl
subb %dl, %cl
movl $0xf0f, %ebp            # imm = 0xF0F
shrl %cl, %ebp
andb (%r10), %bpl
movl %r15d, %r14d
movl %edx, %ecx
shll %cl, %r14d
orb %bpl, %r14b
movb %r14b, (%r10)
xorl %ecx, %ecx
cmpl %edi, %edx
leal (%rdx,%r9), %edx
sete %cl
cmovel %r8d, %edx
subq %rcx, %r10
decl %ebx
jne 0x9ca4e
xorl %ecx, %ecx
cmpl %edi, %eax
leal (%rax,%r9), %eax
sete %cl
cmovel %r8d, %eax
movq %r13, %rsi
subq %rcx, %rsi
incl %r11d
movq (%rsp), %rcx
cmpl 0x218(%rcx), %r11d
jb 0x9ca3b
jmp 0x9cb46
movl %edi, %eax
andl $0x7, %eax
movl $0x7, %r9d
xorl %r10d, %r10d
movl $0xffffffff, %r11d      # imm = 0xFFFFFFFF
testl %esi, %esi
je 0x9cb46
shrl $0x3, %edx
shrl $0x3, %edi
addq %rbx, %rdx
addq %rbx, %rdi
cmpl $0x2, %ecx
movl $0x1, %esi
cmovgel %ecx, %esi
xorl %r14d, %r14d
movzbl (%rdx), %ecx
xorl %r15d, %r15d
btl %r8d, %ecx
setb %r15b
movl %esi, %ebx
movb $0x7, %cl
subb %al, %cl
movl $0x7f7f, %ebp           # imm = 0x7F7F
shrl %cl, %ebp
andb (%rdi), %bpl
movl %r15d, %r12d
movl %eax, %ecx
shll %cl, %r12d
orb %bpl, %r12b
movb %r12b, (%rdi)
xorl %ecx, %ecx
cmpl %r10d, %eax
leal (%rax,%r11), %eax
sete %cl
cmovel %r9d, %eax
subq %rcx, %rdi
decl %ebx
jne 0x9caf0
xorl %ecx, %ecx
cmpl %r10d, %r8d
leal (%r8,%r11), %r8d
sete %cl
cmovel %r9d, %r8d
subq %rcx, %rdx
incl %r14d
movq (%rsp), %rcx
cmpl 0x218(%rcx), %r14d
jb 0x9cae0
movq (%rsp), %rdi
movb 0x22b(%rdi), %bpl
movq 0x8(%rsp), %r10
movl %r10d, 0x218(%rdi)
movl %r10d, %ecx
cmpb $0x8, %bpl
jb 0x9cb74
shrb $0x3, %bpl
movzbl %bpl, %eax
imulq %rcx, %rax
jmp 0x9cb84
movzbl %bpl, %eax
imulq %rcx, %rax
addq $0x7, %rax
shrq $0x3, %rax
movq %rax, 0x220(%rdi)
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq