// File: tomfunkhouser[P]gaps/pkgs/png/pngrutil.c
// Function: png_read_finish_row
void /* PRIVATE */
png_read_finish_row(png_structp png_ptr)
{
#ifdef PNG_READ_INTERLACING_SUPPORTED
   /* Arrays to facilitate easy interlacing - use pass (0 - 6) as index */

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

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

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

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

   png_debug(1, "in png_read_finish_row");
   png_ptr->row_number++;
   if (png_ptr->row_number < png_ptr->num_rows)
      return;

#ifdef PNG_READ_INTERLACING_SUPPORTED
   if (png_ptr->interlaced)
   {
      png_ptr->row_number = 0;
      png_memset(png_ptr->prev_row, 0,
         png_ptr->rowbytes + 1);
      do
      {
         png_ptr->pass++;
         if (png_ptr->pass >= 7)
            break;
         png_ptr->iwidth = (png_ptr->width +
            png_pass_inc[png_ptr->pass] - 1 -
            png_pass_start[png_ptr->pass]) /
            png_pass_inc[png_ptr->pass];

         if (!(png_ptr->transformations & PNG_INTERLACE))
         {
            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->num_rows))
               continue;
         }
         else  /* if (png_ptr->transformations & PNG_INTERLACE) */
            break;
      } while (png_ptr->iwidth == 0);

      if (png_ptr->pass < 7)
         return;
   }
#endif /* PNG_READ_INTERLACING_SUPPORTED */

   if (!(png_ptr->flags & PNG_FLAG_ZLIB_FINISHED))
   {
      PNG_IDAT;
      char extra;
      int ret;

      png_ptr->zstream.next_out = (Byte *)&extra;
      png_ptr->zstream.avail_out = (uInt)1;
      for (;;)
      {
         if (!(png_ptr->zstream.avail_in))
         {
            while (!png_ptr->idat_size)
            {
               png_byte chunk_length[4];

               png_crc_finish(png_ptr, 0);

               png_read_data(png_ptr, chunk_length, 4);
               png_ptr->idat_size = png_get_uint_31(png_ptr, chunk_length);
               png_reset_crc(png_ptr);
               png_crc_read(png_ptr, png_ptr->chunk_name, 4);
               if (png_memcmp(png_ptr->chunk_name, png_IDAT, 4))
                  png_error(png_ptr, "Not enough image data");

            }
            png_ptr->zstream.avail_in = (uInt)png_ptr->zbuf_size;
            png_ptr->zstream.next_in = png_ptr->zbuf;
            if (png_ptr->zbuf_size > png_ptr->idat_size)
               png_ptr->zstream.avail_in = (uInt)png_ptr->idat_size;
            png_crc_read(png_ptr, png_ptr->zbuf, png_ptr->zstream.avail_in);
            png_ptr->idat_size -= png_ptr->zstream.avail_in;
         }
         ret = inflate(&png_ptr->zstream, Z_PARTIAL_FLUSH);
         if (ret == Z_STREAM_END)
         {
            if (!(png_ptr->zstream.avail_out) || png_ptr->zstream.avail_in ||
               png_ptr->idat_size)
               png_warning(png_ptr, "Extra compressed data");
            png_ptr->mode |= PNG_AFTER_IDAT;
            png_ptr->flags |= PNG_FLAG_ZLIB_FINISHED;
            break;
         }
         if (ret != Z_OK)
            png_error(png_ptr, png_ptr->zstream.msg ? png_ptr->zstream.msg :
                      "Decompression Error");

         if (!(png_ptr->zstream.avail_out))
         {
            png_warning(png_ptr, "Extra compressed data");
            png_ptr->mode |= PNG_AFTER_IDAT;
            png_ptr->flags |= PNG_FLAG_ZLIB_FINISHED;
            break;
         }

      }
      png_ptr->zstream.avail_out = 0;
   }

   if (png_ptr->idat_size || png_ptr->zstream.avail_in)
      png_warning(png_ptr, "Extra compression data");

   inflateReset(&png_ptr->zstream);

   png_ptr->mode |= PNG_AFTER_IDAT;
}

// Assembly:
subq $0xa8, %rsp
movq %rdi, 0xa0(%rsp)
movq 0x1604a(%rip), %rax     # 0x13f060
movq %rax, 0x80(%rsp)
movq 0x16043(%rip), %rax     # 0x13f068
movq %rax, 0x88(%rsp)
movq 0x1603c(%rip), %rax     # 0x13f070
movq %rax, 0x90(%rsp)
movl 0x16036(%rip), %eax     # 0x13f078
movl %eax, 0x98(%rsp)
movq 0x16030(%rip), %rax     # 0x13f080
movq %rax, 0x60(%rsp)
movq 0x1602c(%rip), %rax     # 0x13f088
movq %rax, 0x68(%rsp)
movq 0x16028(%rip), %rax     # 0x13f090
movq %rax, 0x70(%rsp)
movl 0x16025(%rip), %eax     # 0x13f098
movl %eax, 0x78(%rsp)
movq 0x16022(%rip), %rax     # 0x13f0a0
movq %rax, 0x40(%rsp)
movq 0x1601e(%rip), %rax     # 0x13f0a8
movq %rax, 0x48(%rsp)
movq 0x1601a(%rip), %rax     # 0x13f0b0
movq %rax, 0x50(%rsp)
movl 0x16017(%rip), %eax     # 0x13f0b8
movl %eax, 0x58(%rsp)
movq 0x16014(%rip), %rax     # 0x13f0c0
movq %rax, 0x20(%rsp)
movq 0x16010(%rip), %rax     # 0x13f0c8
movq %rax, 0x28(%rsp)
movq 0x1600c(%rip), %rax     # 0x13f0d0
movq %rax, 0x30(%rsp)
movl 0x16009(%rip), %eax     # 0x13f0d8
movl %eax, 0x38(%rsp)
movq 0xa0(%rsp), %rax
movl 0x1e4(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x1e4(%rax)
movq 0xa0(%rsp), %rax
movl 0x1e4(%rax), %eax
movq 0xa0(%rsp), %rcx
cmpl 0x1c4(%rcx), %eax
jae 0x12910d
jmp 0x12966e
movq 0xa0(%rsp), %rax
cmpb $0x0, 0x24b(%rax)
je 0x1292a7
movq 0xa0(%rsp), %rax
movl $0x0, 0x1e4(%rax)
movq 0xa0(%rsp), %rax
movq 0x1e8(%rax), %rdi
movq 0xa0(%rsp), %rax
movq 0x1d0(%rax), %rdx
addq $0x1, %rdx
xorl %esi, %esi
callq 0xf280
movq 0xa0(%rsp), %rax
movb 0x24c(%rax), %cl
addb $0x1, %cl
movb %cl, 0x24c(%rax)
movq 0xa0(%rsp), %rax
movzbl 0x24c(%rax), %eax
cmpl $0x7, %eax
jl 0x12918d
jmp 0x12928c
movq 0xa0(%rsp), %rax
movl 0x1bc(%rax), %eax
movq 0xa0(%rsp), %rcx
movzbl 0x24c(%rcx), %ecx
addl 0x60(%rsp,%rcx,4), %eax
subl $0x1, %eax
movq 0xa0(%rsp), %rcx
movzbl 0x24c(%rcx), %ecx
subl 0x80(%rsp,%rcx,4), %eax
movq 0xa0(%rsp), %rcx
movzbl 0x24c(%rcx), %ecx
xorl %edx, %edx
divl 0x60(%rsp,%rcx,4)
movl %eax, %ecx
movq 0xa0(%rsp), %rax
movl %ecx, 0x1e0(%rax)
movq 0xa0(%rsp), %rax
movl 0x124(%rax), %eax
andl $0x2, %eax
cmpl $0x0, %eax
jne 0x129273
movq 0xa0(%rsp), %rax
movl 0x1c0(%rax), %eax
movq 0xa0(%rsp), %rcx
movzbl 0x24c(%rcx), %ecx
addl 0x20(%rsp,%rcx,4), %eax
subl $0x1, %eax
movq 0xa0(%rsp), %rcx
movzbl 0x24c(%rcx), %ecx
subl 0x40(%rsp,%rcx,4), %eax
movq 0xa0(%rsp), %rcx
movzbl 0x24c(%rcx), %ecx
xorl %edx, %edx
divl 0x20(%rsp,%rcx,4)
movl %eax, %ecx
movq 0xa0(%rsp), %rax
movl %ecx, 0x1c4(%rax)
movq 0xa0(%rsp), %rax
cmpl $0x0, 0x1c4(%rax)
jne 0x129271
jmp 0x129277
jmp 0x129275
jmp 0x12928c
jmp 0x129277
movq 0xa0(%rsp), %rax
cmpl $0x0, 0x1e0(%rax)
je 0x12915d
movq 0xa0(%rsp), %rax
movzbl 0x24c(%rax), %eax
cmpl $0x7, %eax
jge 0x1292a5
jmp 0x12966e
jmp 0x1292a7
movq 0xa0(%rsp), %rax
movl 0x120(%rax), %eax
andl $0x20, %eax
cmpl $0x0, %eax
jne 0x12960d
movl 0xff23(%rip), %eax      # 0x1391ea
movl %eax, 0x1b(%rsp)
movb 0xff1d(%rip), %al       # 0x1391ee
movb %al, 0x1f(%rsp)
movq 0xa0(%rsp), %rax
leaq 0x1a(%rsp), %rcx
movq %rcx, 0x140(%rax)
movq 0xa0(%rsp), %rax
movl $0x1, 0x148(%rax)
movq 0xa0(%rsp), %rax
cmpl $0x0, 0x130(%rax)
jne 0x1294ad
jmp 0x129312
movq 0xa0(%rsp), %rax
cmpl $0x0, 0x230(%rax)
setne %al
xorb $-0x1, %al
testb $0x1, %al
jne 0x12932f
jmp 0x1293e2
movq 0xa0(%rsp), %rdi
xorl %esi, %esi
callq 0x122b90
movq 0xa0(%rsp), %rdi
leaq 0x10(%rsp), %rsi
movl $0x4, %edx
callq 0x103570
movq 0xa0(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0x122900
movl %eax, %ecx
movq 0xa0(%rsp), %rax
movl %ecx, 0x230(%rax)
movq 0xa0(%rsp), %rdi
callq 0xfb740
movq 0xa0(%rsp), %rdi
movq 0xa0(%rsp), %rsi
addq $0x244, %rsi            # imm = 0x244
movl $0x4, %edx
callq 0x122b40
movq 0xa0(%rsp), %rax
addq $0x244, %rax            # imm = 0x244
leaq 0x1b(%rsp), %rcx
movl (%rcx), %ecx
movl (%rax), %eax
subl %ecx, %eax
setne %al
movzbl %al, %eax
cmpl $0x0, %eax
je 0x1293dd
movq 0xa0(%rsp), %rdi
leaq 0xfe7f(%rip), %rsi      # 0x139257
callq 0x113860
jmp 0x129312
movq 0xa0(%rsp), %rax
movq 0x1a0(%rax), %rax
movl %eax, %ecx
movq 0xa0(%rsp), %rax
movl %ecx, 0x130(%rax)
movq 0xa0(%rsp), %rax
movq 0x198(%rax), %rcx
movq 0xa0(%rsp), %rax
movq %rcx, 0x128(%rax)
movq 0xa0(%rsp), %rax
movq 0x1a0(%rax), %rax
movq 0xa0(%rsp), %rcx
movl 0x230(%rcx), %ecx
cmpq %rcx, %rax
jbe 0x12945d
movq 0xa0(%rsp), %rax
movl 0x230(%rax), %ecx
movq 0xa0(%rsp), %rax
movl %ecx, 0x130(%rax)
movq 0xa0(%rsp), %rdi
movq 0xa0(%rsp), %rax
movq 0x198(%rax), %rsi
movq 0xa0(%rsp), %rax
movl 0x130(%rax), %eax
movl %eax, %edx
callq 0x122b40
movq 0xa0(%rsp), %rax
movl 0x130(%rax), %edx
movq 0xa0(%rsp), %rax
movl 0x230(%rax), %ecx
subl %edx, %ecx
movl %ecx, 0x230(%rax)
movq 0xa0(%rsp), %rdi
addq $0x128, %rdi            # imm = 0x128
movl $0x1, %esi
callq 0x11a290
movl %eax, 0x14(%rsp)
cmpl $0x1, 0x14(%rsp)
jne 0x12954b
movq 0xa0(%rsp), %rax
cmpl $0x0, 0x148(%rax)
je 0x129504
movq 0xa0(%rsp), %rax
cmpl $0x0, 0x130(%rax)
jne 0x129504
movq 0xa0(%rsp), %rax
cmpl $0x0, 0x230(%rax)
je 0x129518
movq 0xa0(%rsp), %rdi
leaq 0xfd5a(%rip), %rsi      # 0x13926d
callq 0x113940
movq 0xa0(%rsp), %rax
movl 0x11c(%rax), %ecx
orl $0x8, %ecx
movl %ecx, 0x11c(%rax)
movq 0xa0(%rsp), %rax
movl 0x120(%rax), %ecx
orl $0x20, %ecx
movl %ecx, 0x120(%rax)
jmp 0x1295fb
cmpl $0x0, 0x14(%rsp)
je 0x1295a1
movq 0xa0(%rsp), %rax
movq %rax, 0x8(%rsp)
movq 0xa0(%rsp), %rax
cmpq $0x0, 0x158(%rax)
je 0x129586
movq 0xa0(%rsp), %rax
movq 0x158(%rax), %rax
movq %rax, (%rsp)
jmp 0x129593
leaq 0x16a25(%rip), %rax     # 0x13ffb2
movq %rax, (%rsp)
jmp 0x129593
movq 0x8(%rsp), %rdi
movq (%rsp), %rsi
callq 0x113860
movq 0xa0(%rsp), %rax
cmpl $0x0, 0x148(%rax)
jne 0x1295f6
movq 0xa0(%rsp), %rdi
leaq 0xfcac(%rip), %rsi      # 0x13926d
callq 0x113940
movq 0xa0(%rsp), %rax
movl 0x11c(%rax), %ecx
orl $0x8, %ecx
movl %ecx, 0x11c(%rax)
movq 0xa0(%rsp), %rax
movl 0x120(%rax), %ecx
orl $0x20, %ecx
movl %ecx, 0x120(%rax)
jmp 0x1295fb
jmp 0x1292fb
movq 0xa0(%rsp), %rax
movl $0x0, 0x148(%rax)
movq 0xa0(%rsp), %rax
cmpl $0x0, 0x230(%rax)
jne 0x12962f
movq 0xa0(%rsp), %rax
cmpl $0x0, 0x130(%rax)
je 0x129643
movq 0xa0(%rsp), %rdi
leaq 0x16988(%rip), %rsi     # 0x13ffc6
callq 0x113940
movq 0xa0(%rsp), %rdi
addq $0x128, %rdi            # imm = 0x128
callq 0x119dc0
movq 0xa0(%rsp), %rax
movl 0x11c(%rax), %ecx
orl $0x8, %ecx
movl %ecx, 0x11c(%rax)
addq $0xa8, %rsp
retq
nopw %cs:(%rax,%rax)