// File: /workspace/github_cpp_makefile_star2_O2/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), %ecx
leaq 0x15292(%rip), %rdx     # 0xa34e0
movl (%rdx,%rax,4), %eax
movl %eax, %r15d
movl %eax, %r10d
imull %ecx, %r10d
movq %rdi, 0x8(%rsp)
movzbl 0x22b(%rdi), %ebp
cmpl $0x4, %ebp
movq %r10, 0x18(%rsp)
je 0x8e302
cmpl $0x2, %ebp
je 0x8e2bf
cmpl $0x1, %ebp
jne 0x8e33d
leal -0x1(%rcx), %r8d
movl %r8d, %edx
shrl $0x3, %edx
leal -0x1(%r10), %eax
movl %eax, %edi
shrl $0x3, %edi
andl $0x7, %r8d
btl $0x10, %r9d
jb 0x8e4f0
xorl $0x7, %r8d
movl %r10d, %eax
negl %eax
andl $0x7, %eax
xorl %r9d, %r9d
pushq $0x7
popq %r10
pushq $0x1
jmp 0x8e4fc
leal -0x1(%rcx), %edi
shrl $0x2, %edi
leal -0x1(%r10), %r8d
shrl $0x2, %r8d
leal 0x6(,%rcx,2), %eax
andl $0x6, %eax
btl $0x10, %r9d
jb 0x8e3bf
xorl $0x6, %eax
leal 0x6(,%r10,2), %edx
notl %edx
andl $0x6, %edx
pushq $0x2
popq %r9
pushq $0x6
popq %r10
xorl %r11d, %r11d
jmp 0x8e3d5
leal -0x1(%rcx), %edi
shrl %edi
leal -0x1(%r10), %r8d
shrl %r8d
leal (,%rcx,4), %eax
andl $0x4, %eax
btl $0x10, %r9d
jb 0x8e456
leal (,%r10,4), %edx
andl $0x4, %edx
pushq $0x4
popq %r9
xorl %r10d, %r10d
movl %r9d, %r11d
jmp 0x8e46f
shrl $0x3, %ebp
leal -0x1(%rcx), %esi
imulq %rbp, %rsi
addq %rbx, %rsi
leal -0x1(%r10), %r12d
imulq %rbp, %r12
addq %rbx, %r12
movq %rbp, %r14
negq %r14
xorl %edx, %edx
testl %r15d, %r15d
cmovlel %edx, %r15d
movl %r15d, 0x10(%rsp)
leaq 0x20(%rsp), %r13
cmpl %ecx, %edx
jae 0x8e57d
movl %edx, 0x14(%rsp)
movq %r13, %rdi
movq %rsi, %rbx
movq %rbp, %rdx
callq 0xe380
movl 0x10(%rsp), %r15d
subl $0x1, %r15d
jb 0x8e3a6
movq %r12, %rdi
movq %r13, %rsi
movq %rbp, %rdx
callq 0xe380
addq %r14, %r12
jmp 0x8e38d
movq %rbx, %rsi
addq %r14, %rsi
movl 0x14(%rsp), %edx
incl %edx
movq 0x8(%rsp), %rax
movl 0x218(%rax), %ecx
jmp 0x8e36e
leal 0x6(,%r10,2), %edx
andl $0x6, %edx
pushq $-0x2
popq %r9
xorl %r10d, %r10d
pushq $0x6
popq %r11
addq %rbx, %rdi
addq %rbx, %r8
xorl %esi, %esi
testl %r15d, %r15d
cmovlel %esi, %r15d
movl %r15d, %r12d
cmpl %ecx, %esi
jae 0x8e57d
movzbl (%rdi), %ebp
movl %eax, %ecx
shrl %cl, %ebp
andl $0x3, %ebp
movl %r12d, %ebx
subl $0x1, %ebx
jb 0x8e434
movb $0x6, %cl
subb %dl, %cl
movl $0x3f3f, %r14d          # imm = 0x3F3F
shrl %cl, %r14d
movl %ebp, %r15d
movl %edx, %ecx
shll %cl, %r15d
andb (%r8), %r14b
orb %r14b, %r15b
movb %r15b, (%r8)
xorl %ecx, %ecx
cmpl %r10d, %edx
leal (%rdx,%r9), %edx
sete %cl
cmovel %r11d, %edx
subq %rcx, %r8
jmp 0x8e3fc
xorl %ecx, %ecx
cmpl %r10d, %eax
leal (%rax,%r9), %eax
sete %cl
cmovel %r11d, %eax
subq %rcx, %rdi
incl %esi
movq 0x8(%rsp), %rcx
movl 0x218(%rcx), %ecx
jmp 0x8e3e7
xorl $0x4, %eax
movl %r10d, %edx
notl %edx
shll $0x2, %edx
andl $0x4, %edx
pushq $-0x4
popq %r11
xorl %r9d, %r9d
pushq $0x4
popq %r10
addq %rbx, %rdi
addq %rbx, %r8
xorl %esi, %esi
testl %r15d, %r15d
cmovlel %esi, %r15d
movl %r15d, %r12d
cmpl %ecx, %esi
jae 0x8e57d
movzbl (%rdi), %ebp
movl %eax, %ecx
shrl %cl, %ebp
andl $0xf, %ebp
movl %r12d, %ebx
subl $0x1, %ebx
jb 0x8e4ce
movb $0x4, %cl
subb %dl, %cl
movl $0xf0f, %r14d           # imm = 0xF0F
shrl %cl, %r14d
movl %ebp, %r15d
movl %edx, %ecx
shll %cl, %r15d
andb (%r8), %r14b
orb %r14b, %r15b
movb %r15b, (%r8)
xorl %ecx, %ecx
cmpl %r9d, %edx
leal (%rdx,%r11), %edx
sete %cl
cmovel %r10d, %edx
subq %rcx, %r8
jmp 0x8e496
xorl %ecx, %ecx
cmpl %r9d, %eax
leal (%rax,%r11), %eax
sete %cl
cmovel %r10d, %eax
subq %rcx, %rdi
incl %esi
movq 0x8(%rsp), %rcx
movl 0x218(%rcx), %ecx
jmp 0x8e481
andl $0x7, %eax
pushq $0x7
popq %r9
xorl %r10d, %r10d
pushq $-0x1
popq %r11
addq %rbx, %rdx
addq %rbx, %rdi
xorl %esi, %esi
testl %r15d, %r15d
cmovlel %esi, %r15d
movl %r15d, %r12d
cmpl %ecx, %esi
jae 0x8e57d
movzbl (%rdx), %ecx
xorl %ebx, %ebx
btl %r8d, %ecx
setb %bl
movl %r12d, %ebp
subl $0x1, %ebp
jb 0x8e55b
movb $0x7, %cl
subb %al, %cl
movl $0x7f7f, %r14d          # imm = 0x7F7F
shrl %cl, %r14d
movl %ebx, %r15d
movl %eax, %ecx
shll %cl, %r15d
andb (%rdi), %r14b
orb %r14b, %r15b
movb %r15b, (%rdi)
xorl %ecx, %ecx
cmpl %r10d, %eax
leal (%rax,%r11), %eax
sete %cl
cmovel %r9d, %eax
subq %rcx, %rdi
jmp 0x8e523
xorl %ecx, %ecx
cmpl %r10d, %r8d
leal (%r8,%r11), %r8d
sete %cl
cmovel %r9d, %r8d
subq %rcx, %rdx
incl %esi
movq 0x8(%rsp), %rcx
movl 0x218(%rcx), %ecx
jmp 0x8e510
movq 0x8(%rsp), %rax
movq 0x18(%rsp), %rcx
movl %ecx, 0x218(%rax)
movzbl 0x22b(%rax), %eax
movl %ecx, %ecx
cmpq $0x8, %rax
jb 0x8e5a5
shrl $0x3, %eax
imulq %rcx, %rax
jmp 0x8e5b1
imulq %rcx, %rax
addq $0x7, %rax
shrq $0x3, %rax
movq 0x8(%rsp), %rcx
movq %rax, 0x220(%rcx)
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq