// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/png/pngwutil.c
// Function: png_do_write_interlace
void /* PRIVATE */
png_do_write_interlace(png_row_infop row_info, png_bytep row, int pass)
{
   /* Arrays to facilitate easy interlacing - use pass (0 - 6) as index */

   /* Start of interlace block */
   int png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0};

   /* Offset to next interlace block */
   int png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1};

   png_debug(1, "in png_do_write_interlace");

   /* We don't have to do anything on the last pass (6) */
   if (pass < 6)
   {
      /* Each pixel depth is handled separately */
      switch (row_info->pixel_depth)
      {
         case 1:
         {
            png_bytep sp;
            png_bytep dp;
            int shift;
            int d;
            int value;
            png_uint_32 i;
            png_uint_32 row_width = row_info->width;

            dp = row;
            d = 0;
            shift = 7;
            for (i = png_pass_start[pass]; i < row_width;
               i += png_pass_inc[pass])
            {
               sp = row + (png_size_t)(i >> 3);
               value = (int)(*sp >> (7 - (int)(i & 0x07))) & 0x01;
               d |= (value << shift);

               if (shift == 0)
               {
                  shift = 7;
                  *dp++ = (png_byte)d;
                  d = 0;
               }
               else
                  shift--;

            }
            if (shift != 7)
               *dp = (png_byte)d;
            break;
         }
         case 2:
         {
            png_bytep sp;
            png_bytep dp;
            int shift;
            int d;
            int value;
            png_uint_32 i;
            png_uint_32 row_width = row_info->width;

            dp = row;
            shift = 6;
            d = 0;
            for (i = png_pass_start[pass]; i < row_width;
               i += png_pass_inc[pass])
            {
               sp = row + (png_size_t)(i >> 2);
               value = (*sp >> ((3 - (int)(i & 0x03)) << 1)) & 0x03;
               d |= (value << shift);

               if (shift == 0)
               {
                  shift = 6;
                  *dp++ = (png_byte)d;
                  d = 0;
               }
               else
                  shift -= 2;
            }
            if (shift != 6)
                   *dp = (png_byte)d;
            break;
         }
         case 4:
         {
            png_bytep sp;
            png_bytep dp;
            int shift;
            int d;
            int value;
            png_uint_32 i;
            png_uint_32 row_width = row_info->width;

            dp = row;
            shift = 4;
            d = 0;
            for (i = png_pass_start[pass]; i < row_width;
               i += png_pass_inc[pass])
            {
               sp = row + (png_size_t)(i >> 1);
               value = (*sp >> ((1 - (int)(i & 0x01)) << 2)) & 0x0f;
               d |= (value << shift);

               if (shift == 0)
               {
                  shift = 4;
                  *dp++ = (png_byte)d;
                  d = 0;
               }
               else
                  shift -= 4;
            }
            if (shift != 4)
               *dp = (png_byte)d;
            break;
         }
         default:
         {
            png_bytep sp;
            png_bytep dp;
            png_uint_32 i;
            png_uint_32 row_width = row_info->width;
            png_size_t pixel_bytes;

            /* Start at the beginning */
            dp = row;
            /* Find out how many bytes each pixel takes up */
            pixel_bytes = (row_info->pixel_depth >> 3);
            /* Loop through the row, only looking at the pixels that
               matter */
            for (i = png_pass_start[pass]; i < row_width;
               i += png_pass_inc[pass])
            {
               /* Find out where the original pixel is */
               sp = row + (png_size_t)i * pixel_bytes;
               /* Move the pixel */
               if (dp != sp)
                  png_memcpy(dp, sp, pixel_bytes);
               /* Next pixel */
               dp += pixel_bytes;
            }
            break;
         }
      }
      /* Set new row width */
      row_info->width = (row_info->width +
         png_pass_inc[pass] - 1 -
         png_pass_start[pass]) /
         png_pass_inc[pass];
         row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth,
            row_info->width);
   }
}

// Assembly:
cmpl $0x5, %edx
jg 0x915b8
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rsi, %r14
movzbl 0x13(%rdi), %r15d
movl (%rdi), %ebx
cmpl $0x4, %r15d
je 0x9149b
cmpl $0x2, %r15d
je 0x91427
cmpl $0x1, %r15d
jne 0x91519
movslq %edx, %r13
leaq 0x13421(%rip), %rax     # 0xa47e0
movl (%rax,%r13,4), %eax
pushq $0x7
popq %rbp
xorl %esi, %esi
leaq 0x13431(%rip), %r15     # 0xa4800
movl %eax, %r8d
movl %ebp, %ecx
movq %r14, %rdx
cmpl %ebx, %r8d
jae 0x9150f
movl %r8d, %r9d
shrl $0x3, %r9d
movzbl (%r14,%r9), %r10d
movl %r8d, %r9d
notb %r9b
movzbl %r9b, %r11d
andl $0x7, %r11d
xorl %r9d, %r9d
btl %r11d, %r10d
setb %r9b
shll %cl, %r9d
orl %esi, %r9d
testl %ecx, %ecx
je 0x91413
decl %ecx
jmp 0x9141e
movb %r9b, (%rdx)
incq %rdx
xorl %r9d, %r9d
movl %ebp, %ecx
addl (%r15,%r13,4), %r8d
movl %r9d, %esi
jmp 0x913d7
movslq %edx, %r13
leaq 0x133af(%rip), %rax     # 0xa47e0
movl (%rax,%r13,4), %eax
pushq $0x6
popq %r11
xorl %esi, %esi
leaq 0x133be(%rip), %r8      # 0xa4800
movl %eax, %r9d
movl %r11d, %ebp
movq %r14, %rdx
cmpl %ebx, %r9d
jae 0x91491
movl %r9d, %ecx
shrl $0x2, %ecx
movzbl (%r14,%rcx), %r10d
leal (%r9,%r9), %ecx
notb %cl
andb $0x6, %cl
shrl %cl, %r10d
andl $0x3, %r10d
movl %ebp, %ecx
shll %cl, %r10d
orl %esi, %r10d
testl %ebp, %ebp
je 0x9147c
addl $-0x2, %ebp
jmp 0x91488
movb %r10b, (%rdx)
incq %rdx
xorl %r10d, %r10d
movl %r11d, %ebp
addl (%r8,%r13,4), %r9d
movl %r10d, %esi
jmp 0x9144b
cmpl $0x6, %ebp
jne 0x91514
jmp 0x9156d
movslq %edx, %r13
leaq 0x1333b(%rip), %rax     # 0xa47e0
movl (%rax,%r13,4), %eax
xorl %esi, %esi
pushq $0x4
popq %r11
leaq 0x1334a(%rip), %r8      # 0xa4800
movq %r14, %rdx
movl %r11d, %ebp
movl %eax, %r9d
cmpl %ebx, %r9d
jae 0x91508
movl %r9d, %ecx
shrl %ecx
movzbl (%r14,%rcx), %r10d
leal (,%r9,4), %ecx
notb %cl
andb $0x4, %cl
shrl %cl, %r10d
andl $0xf, %r10d
movl %ebp, %ecx
shll %cl, %r10d
orl %esi, %r10d
testl %ebp, %ebp
je 0x914f3
addl $-0x4, %ebp
jmp 0x914ff
movb %r10b, (%rdx)
incq %rdx
xorl %r10d, %r10d
movl %r11d, %ebp
addl (%r8,%r13,4), %r9d
movl %r10d, %esi
jmp 0x914bf
cmpl $0x4, %ebp
jne 0x91514
jmp 0x9156d
cmpl $0x7, %ecx
je 0x9156d
movb %sil, (%rdx)
jmp 0x9156d
movq %rdi, 0x10(%rsp)
shrl $0x3, %r15d
movslq %edx, %r13
leaq 0x132b4(%rip), %rax     # 0xa47e0
movl (%rax,%r13,4), %ebp
movq %r14, %r12
movl %ebp, 0xc(%rsp)
cmpl %ebx, %ebp
jae 0x91564
movl %ebp, %esi
imulq %r15, %rsi
addq %r14, %rsi
cmpq %rsi, %r12
je 0x91554
movq %r12, %rdi
movq %r15, %rdx
callq 0xe380
addq %r15, %r12
leaq 0x132a2(%rip), %rax     # 0xa4800
addl (%rax,%r13,4), %ebp
jmp 0x91537
movq 0x10(%rsp), %rdi
movl 0xc(%rsp), %eax
leaq 0x1328c(%rip), %rcx     # 0xa4800
movl (%rcx,%r13,4), %ecx
movl (%rdi), %edx
addl %ecx, %edx
notl %eax
addl %edx, %eax
xorl %edx, %edx
divl %ecx
movl %eax, (%rdi)
movzbl 0x13(%rdi), %ecx
cmpq $0x8, %rcx
leaq 0x18(%rsp), %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jb 0x915a8
shrl $0x3, %ecx
imulq %rax, %rcx
jmp 0x915b4
imulq %rax, %rcx
addq $0x7, %rcx
shrq $0x3, %rcx
movq %rcx, 0x8(%rdi)
retq