// File: /workspace/github_cpp_makefile_star2_O1/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), %r8d
movzbl 0x24c(%rdi), %eax
movl 0x218(%rdi), %esi
leaq 0x1561f(%rip), %rcx     # 0xb27e0
movl (%rcx,%rax,4), %ecx
movl %ecx, %r9d
imull %esi, %r9d
movq %rdi, (%rsp)
movzbl 0x22b(%rdi), %ebp
cmpl $0x4, %ebp
movq %r9, 0x8(%rsp)
je 0x9d25b
cmpl $0x2, %ebp
je 0x9d223
cmpl $0x1, %ebp
jne 0x9d28e
decl %esi
leal -0x1(%r9), %edx
movl %esi, %edi
andl $0x7, %edi
btl $0x10, %r8d
jb 0x9d4a0
xorl $0x7, %edi
movl %r9d, %eax
negl %eax
andl $0x7, %eax
xorl %r8d, %r8d
movl $0x7, %r9d
movl $0x1, %r10d
jmp 0x9d4b4
leal 0x6(,%rsi,2), %eax
andl $0x6, %eax
btl $0x10, %r8d
jb 0x9d31d
xorl $0x6, %eax
leal 0x6(,%r9,2), %edx
notl %edx
andl $0x6, %edx
movl $0x2, %edi
movl $0x6, %r8d
xorl %r9d, %r9d
jmp 0x9d336
leal (,%rsi,4), %eax
andl $0x4, %eax
btl $0x10, %r8d
jb 0x9d3de
leal (,%r9,4), %edx
andl $0x4, %edx
movl $0x4, %edi
xorl %r8d, %r8d
movl $0x4, %r9d
jmp 0x9d3fa
movq (%rsp), %rax
cmpl $0x0, 0x218(%rax)
je 0x9d54e
shrl $0x3, %ebp
movq 0x8(%rsp), %rax
leal -0x1(%rax), %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 0x9d2ec
movq 0x18(%rsp), %rsi
addq %r15, %rsi
incl %ebx
movq (%rsp), %rax
cmpl 0x218(%rax), %ebx
jb 0x9d2d7
jmp 0x9d54e
leal 0x6(,%r9,2), %edx
andl $0x6, %edx
movl $0xfffffffe, %edi       # imm = 0xFFFFFFFE
xorl %r8d, %r8d
movl $0x6, %r9d
movq (%rsp), %r10
cmpl $0x0, 0x218(%r10)
je 0x9d54e
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 0x9d382
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 0x9d36f
jmp 0x9d54e
xorl $0x4, %eax
movl %r9d, %edx
notl %edx
shll $0x2, %edx
andl $0x4, %edx
movl $0xfffffffc, %r9d       # imm = 0xFFFFFFFC
xorl %edi, %edi
movl $0x4, %r8d
movq (%rsp), %r10
cmpl $0x0, 0x218(%r10)
je 0x9d54e
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 0x9d444
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 0x9d431
jmp 0x9d54e
movl %edx, %eax
andl $0x7, %eax
movl $0x7, %r8d
xorl %r9d, %r9d
movl $0xffffffff, %r10d      # imm = 0xFFFFFFFF
movq (%rsp), %r11
cmpl $0x0, 0x218(%r11)
je 0x9d54e
shrl $0x3, %esi
shrl $0x3, %edx
addq %rbx, %rsi
addq %rbx, %rdx
cmpl $0x2, %ecx
movl $0x1, %r12d
cmovgel %ecx, %r12d
xorl %r11d, %r11d
movq %rsi, %r13
movzbl (%rsi), %ecx
xorl %r15d, %r15d
btl %edi, %ecx
setb %r15b
movl %r12d, %ebx
movb $0x7, %cl
subb %al, %cl
movl $0x7f7f, %ebp           # imm = 0x7F7F
shrl %cl, %ebp
andb (%rdx), %bpl
movl %r15d, %r14d
movl %eax, %ecx
shll %cl, %r14d
orb %bpl, %r14b
movb %r14b, (%rdx)
xorl %ecx, %ecx
cmpl %r9d, %eax
leal (%rax,%r10), %eax
sete %cl
cmovel %r8d, %eax
subq %rcx, %rdx
decl %ebx
jne 0x9d4f5
xorl %ecx, %ecx
cmpl %r9d, %edi
leal (%rdi,%r10), %edi
sete %cl
cmovel %r8d, %edi
movq %r13, %rsi
subq %rcx, %rsi
incl %r11d
movq (%rsp), %rcx
cmpl 0x218(%rcx), %r11d
jb 0x9d4e2
movq (%rsp), %rax
movq 0x8(%rsp), %rcx
movl %ecx, 0x218(%rax)
movzbl 0x22b(%rax), %eax
movl %ecx, %ecx
cmpq $0x8, %rax
jb 0x9d575
shrl $0x3, %eax
imulq %rcx, %rax
jmp 0x9d581
imulq %rcx, %rax
addq $0x7, %rax
shrq $0x3, %rax
movq (%rsp), %rcx
movq %rax, 0x220(%rcx)
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq