// File: tomfunkhouser[P]gaps/pkgs/png/pngwutil.c
// Function: png_write_start_row
void /* PRIVATE */
png_write_start_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

   png_size_t buf_size;

   png_debug(1, "in png_write_start_row");

   buf_size = (png_size_t)(PNG_ROWBYTES(
      png_ptr->usr_channels*png_ptr->usr_bit_depth, png_ptr->width) + 1);

   /* Set up row buffer */
   png_ptr->row_buf = (png_bytep)png_malloc(png_ptr,
     (png_alloc_size_t)buf_size);
   png_ptr->row_buf[0] = PNG_FILTER_VALUE_NONE;

#ifdef PNG_WRITE_FILTER_SUPPORTED
   /* Set up filtering buffer, if using this filter */
   if (png_ptr->do_filter & PNG_FILTER_SUB)
   {
      png_ptr->sub_row = (png_bytep)png_malloc(png_ptr,
         (png_alloc_size_t)(png_ptr->rowbytes + 1));
      png_ptr->sub_row[0] = PNG_FILTER_VALUE_SUB;
   }

   /* We only need to keep the previous row if we are using one of these. */
   if (png_ptr->do_filter & (PNG_FILTER_AVG | PNG_FILTER_UP | PNG_FILTER_PAETH))
   {
      /* Set up previous row buffer */
      png_ptr->prev_row = (png_bytep)png_calloc(png_ptr,
         (png_alloc_size_t)buf_size);

      if (png_ptr->do_filter & PNG_FILTER_UP)
      {
         png_ptr->up_row = (png_bytep)png_malloc(png_ptr,
            (png_size_t)(png_ptr->rowbytes + 1));
         png_ptr->up_row[0] = PNG_FILTER_VALUE_UP;
      }

      if (png_ptr->do_filter & PNG_FILTER_AVG)
      {
         png_ptr->avg_row = (png_bytep)png_malloc(png_ptr,
            (png_alloc_size_t)(png_ptr->rowbytes + 1));
         png_ptr->avg_row[0] = PNG_FILTER_VALUE_AVG;
      }

      if (png_ptr->do_filter & PNG_FILTER_PAETH)
      {
         png_ptr->paeth_row = (png_bytep)png_malloc(png_ptr,
            (png_size_t)(png_ptr->rowbytes + 1));
         png_ptr->paeth_row[0] = PNG_FILTER_VALUE_PAETH;
      }
   }
#endif /* PNG_WRITE_FILTER_SUPPORTED */

#ifdef PNG_WRITE_INTERLACING_SUPPORTED
   /* If interlaced, we need to set up width and height of pass */
   if (png_ptr->interlaced)
   {
      if (!(png_ptr->transformations & PNG_INTERLACE))
      {
         png_ptr->num_rows = (png_ptr->height + png_pass_yinc[0] - 1 -
            png_pass_ystart[0]) / png_pass_yinc[0];
         png_ptr->usr_width = (png_ptr->width + png_pass_inc[0] - 1 -
            png_pass_start[0]) / png_pass_inc[0];
      }
      else
      {
         png_ptr->num_rows = png_ptr->height;
         png_ptr->usr_width = png_ptr->width;
      }
   }
   else
#endif
   {
      png_ptr->num_rows = png_ptr->height;
      png_ptr->usr_width = png_ptr->width;
   }
   png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size;
   png_ptr->zstream.next_out = png_ptr->zbuf;
}

// Assembly:
subq $0x98, %rsp
movq %rdi, 0x90(%rsp)
movq 0x123fa(%rip), %rax     # 0x1403c0
movq %rax, 0x70(%rsp)
movq 0x123f6(%rip), %rax     # 0x1403c8
movq %rax, 0x78(%rsp)
movq 0x123f2(%rip), %rax     # 0x1403d0
movq %rax, 0x80(%rsp)
movl 0x123ec(%rip), %eax     # 0x1403d8
movl %eax, 0x88(%rsp)
movq 0x123e6(%rip), %rax     # 0x1403e0
movq %rax, 0x50(%rsp)
movq 0x123e2(%rip), %rax     # 0x1403e8
movq %rax, 0x58(%rsp)
movq 0x123de(%rip), %rax     # 0x1403f0
movq %rax, 0x60(%rsp)
movl 0x123db(%rip), %eax     # 0x1403f8
movl %eax, 0x68(%rsp)
movq 0x123d8(%rip), %rax     # 0x140400
movq %rax, 0x30(%rsp)
movq 0x123d4(%rip), %rax     # 0x140408
movq %rax, 0x38(%rsp)
movq 0x123d0(%rip), %rax     # 0x140410
movq %rax, 0x40(%rsp)
movl 0x123cd(%rip), %eax     # 0x140418
movl %eax, 0x48(%rsp)
movq 0x123ca(%rip), %rax     # 0x140420
movq %rax, 0x10(%rsp)
movq 0x123c6(%rip), %rax     # 0x140428
movq %rax, 0x18(%rsp)
movq 0x123c2(%rip), %rax     # 0x140430
movq %rax, 0x20(%rsp)
movl 0x123bf(%rip), %eax     # 0x140438
movl %eax, 0x28(%rsp)
movq 0x90(%rsp), %rax
movzbl 0x253(%rax), %eax
movq 0x90(%rsp), %rcx
movzbl 0x250(%rcx), %ecx
imull %ecx, %eax
cmpl $0x8, %eax
jl 0x12e0e3
movq 0x90(%rsp), %rax
movl 0x1bc(%rax), %eax
movq 0x90(%rsp), %rcx
movzbl 0x253(%rcx), %ecx
movq 0x90(%rsp), %rdx
movzbl 0x250(%rdx), %edx
imull %edx, %ecx
movslq %ecx, %rcx
shrq $0x3, %rcx
imulq %rcx, %rax
movq %rax, (%rsp)
jmp 0x12e125
movq 0x90(%rsp), %rax
movl 0x1bc(%rax), %eax
movq 0x90(%rsp), %rcx
movzbl 0x253(%rcx), %ecx
movq 0x90(%rsp), %rdx
movzbl 0x250(%rdx), %edx
imull %edx, %ecx
movslq %ecx, %rcx
imulq %rcx, %rax
addq $0x7, %rax
shrq $0x3, %rax
movq %rax, (%rsp)
movq (%rsp), %rax
addq $0x1, %rax
movq %rax, 0x8(%rsp)
movq 0x90(%rsp), %rdi
movq 0x8(%rsp), %rsi
callq 0x1135b0
movq %rax, %rcx
movq 0x90(%rsp), %rax
movq %rcx, 0x1f0(%rax)
movq 0x90(%rsp), %rax
movq 0x1f0(%rax), %rax
movb $0x0, (%rax)
movq 0x90(%rsp), %rax
movzbl 0x24d(%rax), %eax
andl $0x10, %eax
cmpl $0x0, %eax
je 0x12e1c3
movq 0x90(%rsp), %rdi
movq 0x90(%rsp), %rax
movq 0x1d0(%rax), %rsi
addq $0x1, %rsi
callq 0x1135b0
movq %rax, %rcx
movq 0x90(%rsp), %rax
movq %rcx, 0x1f8(%rax)
movq 0x90(%rsp), %rax
movq 0x1f8(%rax), %rax
movb $0x1, (%rax)
movq 0x90(%rsp), %rax
movzbl 0x24d(%rax), %eax
andl $0xe0, %eax
cmpl $0x0, %eax
je 0x12e319
movq 0x90(%rsp), %rdi
movq 0x8(%rsp), %rsi
callq 0x113560
movq %rax, %rcx
movq 0x90(%rsp), %rax
movq %rcx, 0x1e8(%rax)
movq 0x90(%rsp), %rax
movzbl 0x24d(%rax), %eax
andl $0x20, %eax
cmpl $0x0, %eax
je 0x12e25f
movq 0x90(%rsp), %rdi
movq 0x90(%rsp), %rax
movq 0x1d0(%rax), %rsi
addq $0x1, %rsi
callq 0x1135b0
movq %rax, %rcx
movq 0x90(%rsp), %rax
movq %rcx, 0x200(%rax)
movq 0x90(%rsp), %rax
movq 0x200(%rax), %rax
movb $0x2, (%rax)
movq 0x90(%rsp), %rax
movzbl 0x24d(%rax), %eax
andl $0x40, %eax
cmpl $0x0, %eax
je 0x12e2ba
movq 0x90(%rsp), %rdi
movq 0x90(%rsp), %rax
movq 0x1d0(%rax), %rsi
addq $0x1, %rsi
callq 0x1135b0
movq %rax, %rcx
movq 0x90(%rsp), %rax
movq %rcx, 0x208(%rax)
movq 0x90(%rsp), %rax
movq 0x208(%rax), %rax
movb $0x3, (%rax)
movq 0x90(%rsp), %rax
movzbl 0x24d(%rax), %eax
andl $0x80, %eax
cmpl $0x0, %eax
je 0x12e317
movq 0x90(%rsp), %rdi
movq 0x90(%rsp), %rax
movq 0x1d0(%rax), %rsi
addq $0x1, %rsi
callq 0x1135b0
movq %rax, %rcx
movq 0x90(%rsp), %rax
movq %rcx, 0x210(%rax)
movq 0x90(%rsp), %rax
movq 0x210(%rax), %rax
movb $0x4, (%rax)
jmp 0x12e319
movq 0x90(%rsp), %rax
cmpb $0x0, 0x24b(%rax)
je 0x12e3de
movq 0x90(%rsp), %rax
movl 0x124(%rax), %eax
andl $0x2, %eax
cmpl $0x0, %eax
jne 0x12e3a4
movq 0x90(%rsp), %rax
movl 0x1c0(%rax), %eax
addl 0x10(%rsp), %eax
subl $0x1, %eax
subl 0x30(%rsp), %eax
xorl %edx, %edx
divl 0x10(%rsp)
movl %eax, %ecx
movq 0x90(%rsp), %rax
movl %ecx, 0x1c4(%rax)
movq 0x90(%rsp), %rax
movl 0x1bc(%rax), %eax
addl 0x50(%rsp), %eax
subl $0x1, %eax
subl 0x70(%rsp), %eax
xorl %edx, %edx
divl 0x50(%rsp)
movl %eax, %ecx
movq 0x90(%rsp), %rax
movl %ecx, 0x1c8(%rax)
jmp 0x12e3dc
movq 0x90(%rsp), %rax
movl 0x1c0(%rax), %ecx
movq 0x90(%rsp), %rax
movl %ecx, 0x1c4(%rax)
movq 0x90(%rsp), %rax
movl 0x1bc(%rax), %ecx
movq 0x90(%rsp), %rax
movl %ecx, 0x1c8(%rax)
jmp 0x12e416
movq 0x90(%rsp), %rax
movl 0x1c0(%rax), %ecx
movq 0x90(%rsp), %rax
movl %ecx, 0x1c4(%rax)
movq 0x90(%rsp), %rax
movl 0x1bc(%rax), %ecx
movq 0x90(%rsp), %rax
movl %ecx, 0x1c8(%rax)
movq 0x90(%rsp), %rax
movq 0x1a0(%rax), %rax
movl %eax, %ecx
movq 0x90(%rsp), %rax
movl %ecx, 0x148(%rax)
movq 0x90(%rsp), %rax
movq 0x198(%rax), %rcx
movq 0x90(%rsp), %rax
movq %rcx, 0x140(%rax)
addq $0x98, %rsp
retq
nopl (%rax,%rax)