// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/png/pngwutil.c
// Function: png_write_finish_row
void /* PRIVATE */
png_write_finish_row(png_structp png_ptr)
{
#ifdef PNG_WRITE_INTERLACING_SUPPORTED
   /* 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};

   /* Start of interlace block in the y direction */
   int png_pass_ystart[7] = {0, 0, 4, 0, 2, 0, 1};

   /* Offset to next interlace block in the y direction */
   int png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2};
#endif

   int ret;

   png_debug(1, "in png_write_finish_row");

   /* Next row */
   png_ptr->row_number++;

   /* See if we are done */
   if (png_ptr->row_number < png_ptr->num_rows)
      return;

#ifdef PNG_WRITE_INTERLACING_SUPPORTED
   /* If interlaced, go to next pass */
   if (png_ptr->interlaced)
   {
      png_ptr->row_number = 0;
      if (png_ptr->transformations & PNG_INTERLACE)
      {
         png_ptr->pass++;
      }
      else
      {
         /* Loop until we find a non-zero width or height pass */
         do
         {
            png_ptr->pass++;
            if (png_ptr->pass >= 7)
               break;
            png_ptr->usr_width = (png_ptr->width +
               png_pass_inc[png_ptr->pass] - 1 -
               png_pass_start[png_ptr->pass]) /
               png_pass_inc[png_ptr->pass];
            png_ptr->num_rows = (png_ptr->height +
               png_pass_yinc[png_ptr->pass] - 1 -
               png_pass_ystart[png_ptr->pass]) /
               png_pass_yinc[png_ptr->pass];
            if (png_ptr->transformations & PNG_INTERLACE)
               break;
         } while (png_ptr->usr_width == 0 || png_ptr->num_rows == 0);

      }

      /* Reset the row above the image for the next pass */
      if (png_ptr->pass < 7)
      {
         if (png_ptr->prev_row != NULL)
            png_memset(png_ptr->prev_row, 0,
               (png_size_t)(PNG_ROWBYTES(png_ptr->usr_channels*
               png_ptr->usr_bit_depth, png_ptr->width)) + 1);
         return;
      }
   }
#endif

   /* If we get here, we've just written the last row, so we need
      to flush the compressor */
   do
   {
      /* Tell the compressor we are done */
      ret = deflate(&png_ptr->zstream, Z_FINISH);
      /* Check for an error */
      if (ret == Z_OK)
      {
         /* Check to see if we need more room */
         if (!(png_ptr->zstream.avail_out))
         {
            png_write_IDAT(png_ptr, png_ptr->zbuf, png_ptr->zbuf_size);
            png_ptr->zstream.next_out = png_ptr->zbuf;
            png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size;
         }
      }
      else if (ret != Z_STREAM_END)
      {
         if (png_ptr->zstream.msg != NULL)
            png_error(png_ptr, png_ptr->zstream.msg);
         else
            png_error(png_ptr, "zlib error");
      }
   } while (ret != Z_STREAM_END);

   /* Write any extra space */
   if (png_ptr->zstream.avail_out < png_ptr->zbuf_size)
   {
      png_write_IDAT(png_ptr, png_ptr->zbuf, png_ptr->zbuf_size -
         png_ptr->zstream.avail_out);
   }

   deflateReset(&png_ptr->zstream);
   png_ptr->zstream.data_type = Z_BINARY;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movl 0x1e4(%rdi), %eax
incl %eax
movl %eax, 0x1e4(%rdi)
cmpl 0x1c4(%rdi), %eax
jb 0x9134d
movq %rdi, %rbx
cmpb $0x0, 0x24b(%rdi)
je 0x912a5
andl $0x0, 0x1e4(%rbx)
testb $0x2, 0x124(%rbx)
movb 0x24c(%rbx), %al
jne 0x91257
incb %al
leaq 0x1361c(%rip), %rdi     # 0xa4800
leaq 0x135f5(%rip), %r9      # 0xa47e0
leaq 0x135ce(%rip), %r10     # 0xa47c0
leaq 0x135a7(%rip), %r11     # 0xa47a0
movl %eax, %r8d
cmpb $0x6, %al
ja 0x9125c
movzbl %r8b, %ecx
shll $0x2, %ecx
movl (%rcx,%rdi), %ebp
movl 0x1bc(%rbx), %eax
addl %ebp, %eax
movl (%rcx,%r9), %esi
notl %esi
addl %eax, %esi
movl %esi, %eax
xorl %edx, %edx
divl %ebp
movl %eax, 0x1c8(%rbx)
movl (%rcx,%r10), %r14d
movl 0x1c0(%rbx), %eax
addl %r14d, %eax
movl (%rcx,%r11), %ecx
notl %ecx
addl %eax, %ecx
movl %ecx, %eax
xorl %edx, %edx
divl %r14d
movl %eax, 0x1c4(%rbx)
leal 0x1(%r8), %eax
cmpl %esi, %ebp
ja 0x911f9
cmpl %ecx, %r14d
ja 0x911f9
jmp 0x9125c
incb %al
movl %eax, %r8d
movb %r8b, 0x24c(%rbx)
cmpb $0x6, %r8b
ja 0x912a5
movq 0x1e8(%rbx), %rdi
testq %rdi, %rdi
je 0x9134d
movzbl 0x253(%rbx), %ecx
movzbl 0x250(%rbx), %eax
imull %ecx, %eax
movl 0x1bc(%rbx), %edx
cmpl $0x8, %eax
jb 0x91358
shrl $0x3, %eax
imulq %rax, %rdx
jmp 0x91366
leaq 0x128(%rbx), %r14
pushq $0x4
popq %rbp
leaq 0xc32c(%rip), %r15      # 0x9d5e2
movq %r14, %rdi
movl %ebp, %esi
callq 0x856ed
testl %eax, %eax
je 0x912e2
cmpl $0x1, %eax
je 0x9131d
movq 0x158(%rbx), %rsi
movq %rbx, %rdi
testq %rsi, %rsi
jne 0x912db
movq %r15, %rsi
callq 0x849c0
jmp 0x912b6
cmpl $0x0, 0x148(%rbx)
jne 0x912b6
movq 0x198(%rbx), %rsi
movq 0x1a0(%rbx), %rdx
movq %rbx, %rdi
callq 0x8f7c6
movq 0x198(%rbx), %rax
movq %rax, 0x140(%rbx)
movl 0x1a0(%rbx), %eax
movl %eax, 0x148(%rbx)
jmp 0x912b6
movl 0x148(%rbx), %eax
movq 0x1a0(%rbx), %rdx
subq %rax, %rdx
jbe 0x9133e
movq 0x198(%rbx), %rsi
movq %rbx, %rdi
callq 0x8f7c6
movq %r14, %rdi
callq 0x85384
andl $0x0, 0x180(%rbx)
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
movl %eax, %eax
imulq %rax, %rdx
addq $0x7, %rdx
shrq $0x3, %rdx
incq %rdx
xorl %esi, %esi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0xe270