// File: /workspace/github_cpp_makefile_star2_O1/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 %r12
pushq %rbx
movl 0x1e4(%rdi), %eax
incl %eax
movl %eax, 0x1e4(%rdi)
cmpl 0x1c4(%rdi), %eax
jb 0xa04c4
movq %rdi, %rbx
cmpb $0x0, 0x24b(%rdi)
je 0xa0414
movl $0x0, 0x1e4(%rbx)
movl 0x124(%rbx), %r8d
movb 0x24c(%rbx), %al
incb %al
testb $0x2, %r8b
jne 0xa03c8
leaq 0x137b4(%rip), %r10     # 0xb3b00
leaq 0x1378d(%rip), %r11     # 0xb3ae0
leaq 0x13766(%rip), %r14     # 0xb3ac0
leaq 0x1373f(%rip), %r15     # 0xb3aa0
movl %eax, %r9d
cmpb $0x6, %al
ja 0xa03cb
movzbl %r9b, %esi
shll $0x2, %esi
movl (%rsi,%r10), %ebp
movl 0x1bc(%rbx), %eax
addl %ebp, %eax
movl (%rsi,%r11), %ecx
notl %ecx
addl %eax, %ecx
movl %ecx, %eax
xorl %edx, %edx
divl %ebp
movl %eax, %edi
movl (%rsi,%r14), %r12d
movl 0x1c0(%rbx), %eax
addl %r12d, %eax
movl (%rsi,%r15), %esi
notl %esi
addl %eax, %esi
movl %esi, %eax
xorl %edx, %edx
divl %r12d
movl %edi, 0x1c8(%rbx)
movl %eax, 0x1c4(%rbx)
testb $0x2, %r8b
jne 0xa03cb
leal 0x1(%r9), %eax
cmpl %ecx, %ebp
ja 0xa0361
cmpl %esi, %r12d
ja 0xa0361
jmp 0xa03cb
movl %eax, %r9d
movb %r9b, 0x24c(%rbx)
cmpb $0x6, %r9b
ja 0xa0414
movq 0x1e8(%rbx), %rdi
testq %rdi, %rdi
je 0xa04c4
movzbl 0x253(%rbx), %ecx
movzbl 0x250(%rbx), %eax
imull %ecx, %eax
movl 0x1bc(%rbx), %edx
cmpl $0x8, %eax
jb 0xa04cd
shrl $0x3, %eax
imulq %rax, %rdx
jmp 0xa04db
leaq 0x128(%rbx), %r14
leaq 0xc4a0(%rip), %r15      # 0xac8c2
movq %r14, %rdi
movl $0x4, %esi
callq 0x93c32
movl %eax, %ebp
testl %eax, %eax
je 0xa0453
cmpl $0x1, %ebp
je 0xa0491
movq 0x158(%rbx), %rsi
movq %rbx, %rdi
testq %rsi, %rsi
jne 0xa044c
movq %r15, %rsi
callq 0x92dd0
jmp 0xa048c
cmpl $0x0, 0x148(%rbx)
jne 0xa048c
movq 0x198(%rbx), %rsi
movq 0x1a0(%rbx), %rdx
movq %rbx, %rdi
callq 0x9e8aa
movq 0x198(%rbx), %rax
movq %rax, 0x140(%rbx)
movl 0x1a0(%rbx), %eax
movl %eax, 0x148(%rbx)
cmpl $0x1, %ebp
jne 0xa0422
movl 0x148(%rbx), %eax
movq 0x1a0(%rbx), %rdx
subq %rax, %rdx
jbe 0xa04b2
movq 0x198(%rbx), %rsi
movq %rbx, %rdi
callq 0x9e8aa
movq %r14, %rdi
callq 0x9388a
movl $0x0, 0x180(%rbx)
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movl %eax, %eax
imulq %rax, %rdx
addq $0x7, %rdx
shrq $0x3, %rdx
incq %rdx
xorl %esi, %esi
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0xe260