LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: tomfunkhouser[P]gaps/pkgs/png/pngtrans.c
// Function: png_do_invert
void /* PRIVATE */
png_do_invert(png_row_infop row_info, png_bytep row)
{
   png_debug(1, "in png_do_invert");

  /* This test removed from libpng version 1.0.13 and 1.2.0:
   *   if (row_info->bit_depth == 1 &&
   */
   if (row_info->color_type == PNG_COLOR_TYPE_GRAY)
   {
      png_bytep rp = row;
      png_uint_32 i;
      png_uint_32 istop = row_info->rowbytes;

      for (i = 0; i < istop; i++)
      {
         *rp = (png_byte)(~(*rp));
         rp++;
      }
   }
   else if (row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA &&
      row_info->bit_depth == 8)
   {
      png_bytep rp = row;
      png_uint_32 i;
      png_uint_32 istop = row_info->rowbytes;

      for (i = 0; i < istop; i+=2)
      {
         *rp = (png_byte)(~(*rp));
         rp+=2;
      }
   }
   else if (row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA &&
      row_info->bit_depth == 16)
   {
      png_bytep rp = row;
      png_uint_32 i;
      png_uint_32 istop = row_info->rowbytes;

      for (i = 0; i < istop; i+=4)
      {
         *rp = (png_byte)(~(*rp));
         *(rp+1) = (png_byte)(~(*(rp+1)));
         rp+=4;
      }
   }
}

// Assembly:
movq %rdi, -0x8(%rsp)
movq %rsi, -0x10(%rsp)
movq -0x8(%rsp), %rax
movzbl 0x10(%rax), %eax
cmpl $0x0, %eax
jne 0x12a205
movq -0x10(%rsp), %rax
movq %rax, -0x18(%rsp)
movq -0x8(%rsp), %rax
movq 0x8(%rax), %rax
movl %eax, -0x20(%rsp)
movl $0x0, -0x1c(%rsp)
movl -0x1c(%rsp), %eax
cmpl -0x20(%rsp), %eax
jae 0x12a200
movq -0x18(%rsp), %rax
movzbl (%rax), %eax
xorl $-0x1, %eax
movb %al, %cl
movq -0x18(%rsp), %rax
movb %cl, (%rax)
movq -0x18(%rsp), %rax
addq $0x1, %rax
movq %rax, -0x18(%rsp)
movl -0x1c(%rsp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rsp)
jmp 0x12a1c7
jmp 0x12a30e
movq -0x8(%rsp), %rax
movzbl 0x10(%rax), %eax
cmpl $0x4, %eax
jne 0x12a27e
movq -0x8(%rsp), %rax
movzbl 0x11(%rax), %eax
cmpl $0x8, %eax
jne 0x12a27e
movq -0x10(%rsp), %rax
movq %rax, -0x28(%rsp)
movq -0x8(%rsp), %rax
movq 0x8(%rax), %rax
movl %eax, -0x30(%rsp)
movl $0x0, -0x2c(%rsp)
movl -0x2c(%rsp), %eax
cmpl -0x30(%rsp), %eax
jae 0x12a279
movq -0x28(%rsp), %rax
movzbl (%rax), %eax
xorl $-0x1, %eax
movb %al, %cl
movq -0x28(%rsp), %rax
movb %cl, (%rax)
movq -0x28(%rsp), %rax
addq $0x2, %rax
movq %rax, -0x28(%rsp)
movl -0x2c(%rsp), %eax
addl $0x2, %eax
movl %eax, -0x2c(%rsp)
jmp 0x12a240
jmp 0x12a30c
movq -0x8(%rsp), %rax
movzbl 0x10(%rax), %eax
cmpl $0x4, %eax
jne 0x12a30a
movq -0x8(%rsp), %rax
movzbl 0x11(%rax), %eax
cmpl $0x10, %eax
jne 0x12a30a
movq -0x10(%rsp), %rax
movq %rax, -0x38(%rsp)
movq -0x8(%rsp), %rax
movq 0x8(%rax), %rax
movl %eax, -0x40(%rsp)
movl $0x0, -0x3c(%rsp)
movl -0x3c(%rsp), %eax
cmpl -0x40(%rsp), %eax
jae 0x12a308
movq -0x38(%rsp), %rax
movzbl (%rax), %eax
xorl $-0x1, %eax
movb %al, %cl
movq -0x38(%rsp), %rax
movb %cl, (%rax)
movq -0x38(%rsp), %rax
movzbl 0x1(%rax), %eax
xorl $-0x1, %eax
movb %al, %cl
movq -0x38(%rsp), %rax
movb %cl, 0x1(%rax)
movq -0x38(%rsp), %rax
addq $0x4, %rax
movq %rax, -0x38(%rsp)
movl -0x3c(%rsp), %eax
addl $0x4, %eax
movl %eax, -0x3c(%rsp)
jmp 0x12a2b9
jmp 0x12a30a
jmp 0x12a30c
jmp 0x12a30e
retq
nop
// File: tomfunkhouser[P]gaps/pkgs/png/pngtrans.c
// Function: png_do_swap
void /* PRIVATE */
png_do_swap(png_row_infop row_info, png_bytep row)
{
   png_debug(1, "in png_do_swap");

   if (
       row_info->bit_depth == 16)
   {
      png_bytep rp = row;
      png_uint_32 i;
      png_uint_32 istop= row_info->width * row_info->channels;

      for (i = 0; i < istop; i++, rp += 2)
      {
         png_byte t = *rp;
         *rp = *(rp + 1);
         *(rp + 1) = t;
      }
   }
}

// Assembly:
movq %rdi, -0x8(%rsp)
movq %rsi, -0x10(%rsp)
movq -0x8(%rsp), %rax
movzbl 0x11(%rax), %eax
cmpl $0x10, %eax
jne 0x12a39e
movq -0x10(%rsp), %rax
movq %rax, -0x18(%rsp)
movq -0x8(%rsp), %rax
movl (%rax), %eax
movq -0x8(%rsp), %rcx
movzbl 0x12(%rcx), %ecx
imull %ecx, %eax
movl %eax, -0x20(%rsp)
movl $0x0, -0x1c(%rsp)
movl -0x1c(%rsp), %eax
cmpl -0x20(%rsp), %eax
jae 0x12a39c
movq -0x18(%rsp), %rax
movb (%rax), %al
movb %al, -0x21(%rsp)
movq -0x18(%rsp), %rax
movb 0x1(%rax), %cl
movq -0x18(%rsp), %rax
movb %cl, (%rax)
movb -0x21(%rsp), %cl
movq -0x18(%rsp), %rax
movb %cl, 0x1(%rax)
movl -0x1c(%rsp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rsp)
movq -0x18(%rsp), %rax
addq $0x2, %rax
movq %rax, -0x18(%rsp)
jmp 0x12a351
jmp 0x12a39e
retq
nop
// File: tomfunkhouser[P]gaps/pkgs/png/pngtrans.c
// Function: png_do_packswap
void /* PRIVATE */
png_do_packswap(png_row_infop row_info, png_bytep row)
{
   png_debug(1, "in png_do_packswap");

   if (
       row_info->bit_depth < 8)
   {
      png_bytep rp, end, table;

      end = row + row_info->rowbytes;

      if (row_info->bit_depth == 1)
         table = (png_bytep)onebppswaptable;
      else if (row_info->bit_depth == 2)
         table = (png_bytep)twobppswaptable;
      else if (row_info->bit_depth == 4)
         table = (png_bytep)fourbppswaptable;
      else
         return;

      for (rp = row; rp < end; rp++)
         *rp = table[*rp];
   }
}

// Assembly:
movq %rdi, -0x8(%rsp)
movq %rsi, -0x10(%rsp)
movq -0x8(%rsp), %rax
movzbl 0x11(%rax), %eax
cmpl $0x8, %eax
jge 0x12a468
movq -0x10(%rsp), %rax
movq -0x8(%rsp), %rcx
addq 0x8(%rcx), %rax
movq %rax, -0x20(%rsp)
movq -0x8(%rsp), %rax
movzbl 0x11(%rax), %eax
cmpl $0x1, %eax
jne 0x12a3eb
leaq 0x15cbc(%rip), %rax     # 0x1400a0
movq %rax, -0x28(%rsp)
jmp 0x12a429
movq -0x8(%rsp), %rax
movzbl 0x11(%rax), %eax
cmpl $0x2, %eax
jne 0x12a407
leaq 0x15da0(%rip), %rax     # 0x1401a0
movq %rax, -0x28(%rsp)
jmp 0x12a427
movq -0x8(%rsp), %rax
movzbl 0x11(%rax), %eax
cmpl $0x4, %eax
jne 0x12a423
leaq 0x15e84(%rip), %rax     # 0x1402a0
movq %rax, -0x28(%rsp)
jmp 0x12a425
jmp 0x12a468
jmp 0x12a427
jmp 0x12a429
movq -0x10(%rsp), %rax
movq %rax, -0x18(%rsp)
movq -0x18(%rsp), %rax
cmpq -0x20(%rsp), %rax
jae 0x12a466
movq -0x28(%rsp), %rax
movq -0x18(%rsp), %rcx
movzbl (%rcx), %ecx
movb (%rax,%rcx), %cl
movq -0x18(%rsp), %rax
movb %cl, (%rax)
movq -0x18(%rsp), %rax
addq $0x1, %rax
movq %rax, -0x18(%rsp)
jmp 0x12a433
jmp 0x12a468
retq
nopl (%rax)
// File: tomfunkhouser[P]gaps/pkgs/png/pngtrans.c
// Function: png_set_user_transform_info
void PNGAPI
png_set_user_transform_info(png_structp png_ptr, png_voidp
   user_transform_ptr, int user_transform_depth, int user_transform_channels)
{
   png_debug(1, "in png_set_user_transform_info");

   if (png_ptr == NULL)
      return;
#ifdef PNG_USER_TRANSFORM_PTR_SUPPORTED
   png_ptr->user_transform_ptr = user_transform_ptr;
   png_ptr->user_transform_depth = (png_byte)user_transform_depth;
   png_ptr->user_transform_channels = (png_byte)user_transform_channels;
#else
   if (user_transform_ptr || user_transform_depth || user_transform_channels)
      png_warning(png_ptr,
        "This version of libpng does not support user transform info");
#endif
}

// Assembly:
movq %rdi, -0x8(%rsp)
movq %rsi, -0x10(%rsp)
movl %edx, -0x14(%rsp)
movl %ecx, -0x18(%rsp)
cmpq $0x0, -0x8(%rsp)
jne 0x12ae4c
jmp 0x12ae7f
movq -0x10(%rsp), %rcx
movq -0x8(%rsp), %rax
movq %rcx, 0x110(%rax)
movl -0x14(%rsp), %eax
movb %al, %cl
movq -0x8(%rsp), %rax
movb %cl, 0x118(%rax)
movl -0x18(%rsp), %eax
movb %al, %cl
movq -0x8(%rsp), %rax
movb %cl, 0x119(%rax)
retq
// File: tomfunkhouser[P]gaps/pkgs/png/pngwutil.c
// Function: png_save_uint_32
void PNGAPI
png_save_uint_32(png_bytep buf, png_uint_32 i)
{
   buf[0] = (png_byte)((i >> 24) & 0xff);
   buf[1] = (png_byte)((i >> 16) & 0xff);
   buf[2] = (png_byte)((i >> 8) & 0xff);
   buf[3] = (png_byte)(i & 0xff);
}

// Assembly:
movq %rdi, -0x8(%rsp)
movl %esi, -0xc(%rsp)
movl -0xc(%rsp), %eax
shrl $0x18, %eax
andl $0xff, %eax
movb %al, %cl
movq -0x8(%rsp), %rax
movb %cl, (%rax)
movl -0xc(%rsp), %eax
shrl $0x10, %eax
andl $0xff, %eax
movb %al, %cl
movq -0x8(%rsp), %rax
movb %cl, 0x1(%rax)
movl -0xc(%rsp), %eax
shrl $0x8, %eax
andl $0xff, %eax
movb %al, %cl
movq -0x8(%rsp), %rax
movb %cl, 0x2(%rax)
movl -0xc(%rsp), %eax
andl $0xff, %eax
movb %al, %cl
movq -0x8(%rsp), %rax
movb %cl, 0x3(%rax)
retq
nop
// File: tomfunkhouser[P]gaps/pkgs/png/pngwutil.c
// Function: png_save_int_32
void PNGAPI
png_save_int_32(png_bytep buf, png_int_32 i)
{
   buf[0] = (png_byte)((i >> 24) & 0xff);
   buf[1] = (png_byte)((i >> 16) & 0xff);
   buf[2] = (png_byte)((i >> 8) & 0xff);
   buf[3] = (png_byte)(i & 0xff);
}

// Assembly:
movq %rdi, -0x8(%rsp)
movl %esi, -0xc(%rsp)
movl -0xc(%rsp), %eax
sarl $0x18, %eax
andl $0xff, %eax
movb %al, %cl
movq -0x8(%rsp), %rax
movb %cl, (%rax)
movl -0xc(%rsp), %eax
sarl $0x10, %eax
andl $0xff, %eax
movb %al, %cl
movq -0x8(%rsp), %rax
movb %cl, 0x1(%rax)
movl -0xc(%rsp), %eax
sarl $0x8, %eax
andl $0xff, %eax
movb %al, %cl
movq -0x8(%rsp), %rax
movb %cl, 0x2(%rax)
movl -0xc(%rsp), %eax
andl $0xff, %eax
movb %al, %cl
movq -0x8(%rsp), %rax
movb %cl, 0x3(%rax)
retq
nop
// File: tomfunkhouser[P]gaps/pkgs/png/pngwutil.c
// Function: png_write_sig
void PNGAPI
png_write_sig(png_structp png_ptr)
{
   png_byte png_signature[8] = {137, 80, 78, 71, 13, 10, 26, 10};

#ifdef PNG_IO_STATE_SUPPORTED
   /* Inform the I/O callback that the signature is being written */
   png_ptr->io_state = PNG_IO_WRITING | PNG_IO_SIGNATURE;
#endif

   /* Write the rest of the 8 byte signature */
   png_write_data(png_ptr, &png_signature[png_ptr->sig_bytes],
      (png_size_t)(8 - png_ptr->sig_bytes));
   if (png_ptr->sig_bytes < 3)
      png_ptr->mode |= PNG_HAVE_PNG_SIGNATURE;
}

// Assembly:
subq $0x18, %rsp
movq %rdi, 0x10(%rsp)
movq 0x15540(%rip), %rax     # 0x140500
movq %rax, 0x8(%rsp)
movq 0x10(%rsp), %rax
movl $0x12, 0x490(%rax)
movq 0x10(%rsp), %rdi
movq 0x10(%rsp), %rax
movzbl 0x254(%rax), %eax
leaq 0x8(%rsp), %rsi
addq %rax, %rsi
movq 0x10(%rsp), %rax
movzbl 0x254(%rax), %ecx
movl $0x8, %eax
subl %ecx, %eax
movslq %eax, %rdx
callq 0x1311e0
movq 0x10(%rsp), %rax
movzbl 0x254(%rax), %eax
cmpl $0x3, %eax
jge 0x12b030
movq 0x10(%rsp), %rax
movl 0x11c(%rax), %ecx
orl $0x1000, %ecx           # imm = 0x1000
movl %ecx, 0x11c(%rax)
addq $0x18, %rsp
retq
nopw %cs:(%rax,%rax)
// File: tomfunkhouser[P]gaps/pkgs/png/pngwutil.c
// Function: png_write_chunk
void PNGAPI
png_write_chunk(png_structp png_ptr, png_bytep chunk_name,
   png_bytep data, png_size_t length)
{
   if (png_ptr == NULL)
      return;
   png_write_chunk_start(png_ptr, chunk_name, (png_uint_32)length);
   png_write_chunk_data(png_ptr, data, (png_size_t)length);
   png_write_chunk_end(png_ptr);
}

// Assembly:
subq $0x28, %rsp
movq %rdi, 0x20(%rsp)
movq %rsi, 0x18(%rsp)
movq %rdx, 0x10(%rsp)
movq %rcx, 0x8(%rsp)
cmpq $0x0, 0x20(%rsp)
jne 0x12b062
jmp 0x12b096
movq 0x20(%rsp), %rdi
movq 0x18(%rsp), %rsi
movq 0x8(%rsp), %rax
movl %eax, %edx
callq 0x12b0a0
movq 0x20(%rsp), %rdi
movq 0x10(%rsp), %rsi
movq 0x8(%rsp), %rdx
callq 0x12b140
movq 0x20(%rsp), %rdi
callq 0x12b1a0
addq $0x28, %rsp
retq
nopl (%rax,%rax)
// File: tomfunkhouser[P]gaps/pkgs/png/pngwutil.c
// Function: png_write_chunk_data
void PNGAPI
png_write_chunk_data(png_structp png_ptr, png_bytep data, png_size_t length)
{
   /* Write the data, and run the CRC over it */
   if (png_ptr == NULL)
      return;
   if (data != NULL && length > 0)
   {
      png_write_data(png_ptr, data, length);
      /* Update the CRC after writing the data,
       * in case that the user I/O routine alters it.
       */
      png_calculate_crc(png_ptr, data, length);
   }
}

// Assembly:
subq $0x18, %rsp
movq %rdi, 0x10(%rsp)
movq %rsi, 0x8(%rsp)
movq %rdx, (%rsp)
cmpq $0x0, 0x10(%rsp)
jne 0x12b15c
jmp 0x12b191
cmpq $0x0, 0x8(%rsp)
je 0x12b191
cmpq $0x0, (%rsp)
jbe 0x12b191
movq 0x10(%rsp), %rdi
movq 0x8(%rsp), %rsi
movq (%rsp), %rdx
callq 0x1311e0
movq 0x10(%rsp), %rdi
movq 0x8(%rsp), %rsi
movq (%rsp), %rdx
callq 0xfb770
addq $0x18, %rsp
retq
nopw %cs:(%rax,%rax)
// File: tomfunkhouser[P]gaps/pkgs/png/pngwutil.c
// Function: png_write_gAMA
void /* PRIVATE */
png_write_gAMA(png_structp png_ptr, double file_gamma)
{
   PNG_gAMA;
   png_uint_32 igamma;
   png_byte buf[4];

   png_debug(1, "in png_write_gAMA");

   /* file_gamma is saved in 1/100,000ths */
   igamma = (png_uint_32)(file_gamma * 100000.0 + 0.5);
   png_save_uint_32(buf, igamma);
   png_write_chunk(png_ptr, (png_bytep)png_gAMA, buf, (png_size_t)4);
}

// Assembly:
subq $0x28, %rsp
movq %rdi, 0x20(%rsp)
movsd %xmm0, 0x18(%rsp)
movb $0x0, 0x14(%rsp)
movl $0x414d4167, 0x10(%rsp) # imm = 0x414D4167
movsd 0x18(%rsp), %xmm0
movsd 0xd146(%rip), %xmm1     # 0x138d80
mulsd %xmm1, %xmm0
movsd 0x73ca(%rip), %xmm1     # 0x133010
addsd %xmm1, %xmm0
cvttsd2si %xmm0, %rax
movl %eax, 0xc(%rsp)
leaq 0x8(%rsp), %rdi
movl 0xc(%rsp), %esi
callq 0x12aeb0
movq 0x20(%rsp), %rdi
leaq 0x10(%rsp), %rsi
leaq 0x8(%rsp), %rdx
movl $0x4, %ecx
callq 0x12b040
addq $0x28, %rsp
retq
nop
// File: tomfunkhouser[P]gaps/pkgs/png/pngwutil.c
// Function: png_write_sRGB
void /* PRIVATE */
png_write_sRGB(png_structp png_ptr, int srgb_intent)
{
   PNG_sRGB;
   png_byte buf[1];

   png_debug(1, "in png_write_sRGB");

   if (srgb_intent >= PNG_sRGB_INTENT_LAST)
         png_warning(png_ptr,
            "Invalid sRGB rendering intent specified");
   buf[0]=(png_byte)srgb_intent;
   png_write_chunk(png_ptr, (png_bytep)png_sRGB, buf, (png_size_t)1);
}

// Assembly:
subq $0x18, %rsp
movq %rdi, 0x10(%rsp)
movl %esi, 0xc(%rsp)
movl 0x138c2(%rip), %eax     # 0x13f5a5
movl %eax, 0x7(%rsp)
movb 0x138bc(%rip), %al      # 0x13f5a9
movb %al, 0xb(%rsp)
cmpl $0x4, 0xc(%rsp)
jl 0x12bd09
movq 0x10(%rsp), %rdi
leaq 0x14a90(%rip), %rsi     # 0x140794
callq 0x113940
movl 0xc(%rsp), %eax
movb %al, 0x6(%rsp)
movq 0x10(%rsp), %rdi
leaq 0x7(%rsp), %rsi
leaq 0x6(%rsp), %rdx
movl $0x1, %ecx
callq 0x12b040
addq $0x18, %rsp
retq
nop
// File: tomfunkhouser[P]gaps/pkgs/png/pngwutil.c
// Function: png_write_compressed_data_out
static void /* PRIVATE */
png_write_compressed_data_out(png_structp png_ptr, compression_state *comp)
{
   int i;

   /* Handle the no-compression case */
   if (comp->input)
   {
      png_write_chunk_data(png_ptr, (png_bytep)comp->input,
                            (png_size_t)comp->input_len);
      return;
   }

   /* Write saved output buffers, if any */
   for (i = 0; i < comp->num_output_ptr; i++)
   {
      png_write_chunk_data(png_ptr, (png_bytep)comp->output_ptr[i],
         (png_size_t)png_ptr->zbuf_size);
      png_free(png_ptr, comp->output_ptr[i]);
   }
   if (comp->max_output_ptr != 0)
      png_free(png_ptr, comp->output_ptr);
   /* Write anything left in zbuf */
   if (png_ptr->zstream.avail_out < (png_uint_32)png_ptr->zbuf_size)
      png_write_chunk_data(png_ptr, png_ptr->zbuf,
         (png_size_t)(png_ptr->zbuf_size - png_ptr->zstream.avail_out));

   /* Reset zlib for another zTXt/iTXt or image data */
   deflateReset(&png_ptr->zstream);
   png_ptr->zstream.data_type = Z_BINARY;
}

// Assembly:
subq $0x18, %rsp
movq %rdi, 0x10(%rsp)
movq %rsi, 0x8(%rsp)
movq 0x8(%rsp), %rax
cmpq $0x0, (%rax)
je 0x12c859
movq 0x10(%rsp), %rdi
movq 0x8(%rsp), %rax
movq (%rax), %rsi
movq 0x8(%rsp), %rax
movslq 0x8(%rax), %rdx
callq 0x12b140
jmp 0x12c949
movl $0x0, 0x4(%rsp)
movl 0x4(%rsp), %eax
movq 0x8(%rsp), %rcx
cmpl 0xc(%rcx), %eax
jge 0x12c8c0
movq 0x10(%rsp), %rdi
movq 0x8(%rsp), %rax
movq 0x18(%rax), %rax
movslq 0x4(%rsp), %rcx
movq (%rax,%rcx,8), %rsi
movq 0x10(%rsp), %rax
movq 0x1a0(%rax), %rdx
callq 0x12b140
movq 0x10(%rsp), %rdi
movq 0x8(%rsp), %rax
movq 0x18(%rax), %rax
movslq 0x4(%rsp), %rcx
movq (%rax,%rcx,8), %rsi
callq 0x1136d0
movl 0x4(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x4(%rsp)
jmp 0x12c861
movq 0x8(%rsp), %rax
cmpl $0x0, 0x10(%rax)
je 0x12c8de
movq 0x10(%rsp), %rdi
movq 0x8(%rsp), %rax
movq 0x18(%rax), %rsi
callq 0x1136d0
movq 0x10(%rsp), %rax
movl 0x148(%rax), %eax
movq 0x10(%rsp), %rcx
movq 0x1a0(%rcx), %rcx
cmpl %ecx, %eax
jae 0x12c929
movq 0x10(%rsp), %rdi
movq 0x10(%rsp), %rax
movq 0x198(%rax), %rsi
movq 0x10(%rsp), %rax
movq 0x1a0(%rax), %rdx
movq 0x10(%rsp), %rax
movl 0x148(%rax), %eax
subq %rax, %rdx
callq 0x12b140
movq 0x10(%rsp), %rdi
addq $0x128, %rdi            # imm = 0x128
callq 0x1154e0
movq 0x10(%rsp), %rax
movl $0x0, 0x180(%rax)
addq $0x18, %rsp
retq
nop
// File: tomfunkhouser[P]gaps/pkgs/png/pngwutil.c
// Function: png_write_cHRM_fixed
void /* PRIVATE */
png_write_cHRM_fixed(png_structp png_ptr, png_fixed_point white_x,
   png_fixed_point white_y, png_fixed_point red_x, png_fixed_point red_y,
   png_fixed_point green_x, png_fixed_point green_y, png_fixed_point blue_x,
   png_fixed_point blue_y)
{
   PNG_cHRM;
   png_byte buf[32];

   png_debug(1, "in png_write_cHRM");

   /* Each value is saved in 1/100,000ths */
#ifdef PNG_CHECK_cHRM_SUPPORTED
   if (png_check_cHRM_fixed(png_ptr, white_x, white_y, red_x, red_y,
      green_x, green_y, blue_x, blue_y))
#endif
   {
      png_save_uint_32(buf, (png_uint_32)white_x);
      png_save_uint_32(buf + 4, (png_uint_32)white_y);

      png_save_uint_32(buf + 8, (png_uint_32)red_x);
      png_save_uint_32(buf + 12, (png_uint_32)red_y);

      png_save_uint_32(buf + 16, (png_uint_32)green_x);
      png_save_uint_32(buf + 20, (png_uint_32)green_y);

      png_save_uint_32(buf + 24, (png_uint_32)blue_x);
      png_save_uint_32(buf + 28, (png_uint_32)blue_y);

      png_write_chunk(png_ptr, (png_bytep)png_cHRM, buf, (png_size_t)32);
   }
}

// Assembly:
subq $0x68, %rsp
movl 0x80(%rsp), %eax
movl 0x78(%rsp), %eax
movl 0x70(%rsp), %eax
movq %rdi, 0x60(%rsp)
movl %esi, 0x5c(%rsp)
movl %edx, 0x58(%rsp)
movl %ecx, 0x54(%rsp)
movl %r8d, 0x50(%rsp)
movl %r9d, 0x4c(%rsp)
movl 0x12517(%rip), %eax     # 0x13f4eb
movl %eax, 0x47(%rsp)
movb 0x12511(%rip), %al      # 0x13f4ef
movb %al, 0x4b(%rsp)
movq 0x60(%rsp), %rdi
movl 0x5c(%rsp), %esi
movl 0x58(%rsp), %edx
movl 0x54(%rsp), %ecx
movl 0x50(%rsp), %r8d
movl 0x4c(%rsp), %r9d
movl 0x70(%rsp), %r11d
movl 0x78(%rsp), %r10d
movl 0x80(%rsp), %eax
movl %r11d, (%rsp)
movl %r10d, 0x8(%rsp)
movl %eax, 0x10(%rsp)
callq 0xfc610
cmpl $0x0, %eax
je 0x12d0d1
leaq 0x20(%rsp), %rdi
movl 0x5c(%rsp), %esi
callq 0x12aeb0
leaq 0x20(%rsp), %rdi
addq $0x4, %rdi
movl 0x58(%rsp), %esi
callq 0x12aeb0
leaq 0x20(%rsp), %rdi
addq $0x8, %rdi
movl 0x54(%rsp), %esi
callq 0x12aeb0
leaq 0x20(%rsp), %rdi
addq $0xc, %rdi
movl 0x50(%rsp), %esi
callq 0x12aeb0
leaq 0x20(%rsp), %rdi
addq $0x10, %rdi
movl 0x4c(%rsp), %esi
callq 0x12aeb0
leaq 0x20(%rsp), %rdi
addq $0x14, %rdi
movl 0x70(%rsp), %esi
callq 0x12aeb0
leaq 0x20(%rsp), %rdi
addq $0x18, %rdi
movl 0x78(%rsp), %esi
callq 0x12aeb0
leaq 0x20(%rsp), %rdi
addq $0x1c, %rdi
movl 0x80(%rsp), %esi
callq 0x12aeb0
movq 0x60(%rsp), %rdi
leaq 0x47(%rsp), %rsi
leaq 0x20(%rsp), %rdx
movl $0x20, %ecx
callq 0x12b040
addq $0x68, %rsp
retq
nopw %cs:(%rax,%rax)
// File: tomfunkhouser[P]gaps/pkgs/png/pngwutil.c
// Function: png_write_hIST
void /* PRIVATE */
png_write_hIST(png_structp png_ptr, png_uint_16p hist, int num_hist)
{
   PNG_hIST;
   int i;
   png_byte buf[3];

   png_debug(1, "in png_write_hIST");

   if (num_hist > (int)png_ptr->num_palette)
   {
      png_debug2(3, "num_hist = %d, num_palette = %d", num_hist,
         png_ptr->num_palette);
      png_warning(png_ptr, "Invalid number of histogram entries specified");
      return;
   }

   png_write_chunk_start(png_ptr, (png_bytep)png_hIST,
     (png_uint_32)(num_hist * 2));
   for (i = 0; i < num_hist; i++)
   {
      png_save_uint_16(buf, hist[i]);
      png_write_chunk_data(png_ptr, buf, (png_size_t)2);
   }
   png_write_chunk_end(png_ptr);
}

// Assembly:
subq $0x28, %rsp
movq %rdi, 0x20(%rsp)
movq %rsi, 0x18(%rsp)
movl %edx, 0x14(%rsp)
movl 0x12540(%rip), %eax     # 0x13f9b8
movl %eax, 0xf(%rsp)
movb 0x1253a(%rip), %al      # 0x13f9bc
movb %al, 0x13(%rsp)
movl 0x14(%rsp), %eax
movq 0x20(%rsp), %rcx
movzwl 0x240(%rcx), %ecx
cmpl %ecx, %eax
jle 0x12d4ad
movq 0x20(%rsp), %rdi
leaq 0x13565(%rip), %rsi     # 0x140a0b
callq 0x113940
jmp 0x12d517
movq 0x20(%rsp), %rdi
leaq 0xf(%rsp), %rsi
movl 0x14(%rsp), %edx
shll %edx
callq 0x12b0a0
movl $0x0, 0x8(%rsp)
movl 0x8(%rsp), %eax
cmpl 0x14(%rsp), %eax
jge 0x12d50d
leaq 0x5(%rsp), %rdi
movq 0x18(%rsp), %rax
movslq 0x8(%rsp), %rcx
movzwl (%rax,%rcx,2), %esi
callq 0x12af70
movq 0x20(%rsp), %rdi
leaq 0x5(%rsp), %rsi
movl $0x2, %edx
callq 0x12b140
movl 0x8(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x8(%rsp)
jmp 0x12d4ca
movq 0x20(%rsp), %rdi
callq 0x12b1a0
addq $0x28, %rsp
retq
nopl (%rax)
// File: tomfunkhouser[P]gaps/pkgs/png/pngwutil.c
// Function: png_write_tEXt
void /* PRIVATE */
png_write_tEXt(png_structp png_ptr, png_charp key, png_charp text,
   png_size_t text_len)
{
   PNG_tEXt;
   png_size_t key_len;
   png_charp new_key;

   png_debug(1, "in png_write_tEXt");

   if ((key_len = png_check_keyword(png_ptr, key, &new_key))==0)
      return;

   if (text == NULL || *text == '\0')
      text_len = 0;
   else
      text_len = png_strlen(text);

   /* Make sure we include the 0 after the key */
   png_write_chunk_start(png_ptr, (png_bytep)png_tEXt,
      (png_uint_32)(key_len + text_len + 1));
   /*
    * We leave it to the application to meet PNG-1.0 requirements on the
    * contents of the text.  PNG-1.0 through PNG-1.2 discourage the use of
    * any non-Latin-1 characters except for NEWLINE.  ISO PNG will forbid them.
    * The NUL character is forbidden by PNG-1.0 through PNG-1.2 and ISO PNG.
    */
   png_write_chunk_data(png_ptr, (png_bytep)new_key,
     (png_size_t)(key_len + 1));
   if (text_len)
      png_write_chunk_data(png_ptr, (png_bytep)text, (png_size_t)text_len);

   png_write_chunk_end(png_ptr);
   png_free(png_ptr, new_key);
}

// Assembly:
subq $0x38, %rsp
movq %rdi, 0x30(%rsp)
movq %rsi, 0x28(%rsp)
movq %rdx, 0x20(%rsp)
movq %rcx, 0x18(%rsp)
movl 0x127b5(%rip), %eax     # 0x13fcf3
movl %eax, 0x13(%rsp)
movb 0x127af(%rip), %al      # 0x13fcf7
movb %al, 0x17(%rsp)
movq 0x30(%rsp), %rdi
movq 0x28(%rsp), %rsi
movq %rsp, %rdx
callq 0x12bf40
movq %rax, 0x8(%rsp)
cmpq $0x0, %rax
jne 0x12d56e
jmp 0x12d607
cmpq $0x0, 0x20(%rsp)
je 0x12d583
movq 0x20(%rsp), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
jne 0x12d58e
movq $0x0, 0x18(%rsp)
jmp 0x12d59d
movq 0x20(%rsp), %rdi
callq 0xf200
movq %rax, 0x18(%rsp)
movq 0x30(%rsp), %rdi
leaq 0x13(%rsp), %rsi
movq 0x8(%rsp), %rax
addq 0x18(%rsp), %rax
addq $0x1, %rax
movl %eax, %edx
callq 0x12b0a0
movq 0x30(%rsp), %rdi
movq (%rsp), %rsi
movq 0x8(%rsp), %rdx
addq $0x1, %rdx
callq 0x12b140
cmpq $0x0, 0x18(%rsp)
je 0x12d5ef
movq 0x30(%rsp), %rdi
movq 0x20(%rsp), %rsi
movq 0x18(%rsp), %rdx
callq 0x12b140
movq 0x30(%rsp), %rdi
callq 0x12b1a0
movq 0x30(%rsp), %rdi
movq (%rsp), %rsi
callq 0x1136d0
addq $0x38, %rsp
retq
nopl (%rax)
// File: tomfunkhouser[P]gaps/pkgs/png/pngwutil.c
// Function: png_write_zTXt
void /* PRIVATE */
png_write_zTXt(png_structp png_ptr, png_charp key, png_charp text,
   png_size_t text_len, int compression)
{
   PNG_zTXt;
   png_size_t key_len;
   char buf[1];
   png_charp new_key;
   compression_state comp;

   png_debug(1, "in png_write_zTXt");

   comp.num_output_ptr = 0;
   comp.max_output_ptr = 0;
   comp.output_ptr = NULL;
   comp.input = NULL;
   comp.input_len = 0;

   if ((key_len = png_check_keyword(png_ptr, key, &new_key))==0)
   {
      png_free(png_ptr, new_key);
      return;
   }

   if (text == NULL || *text == '\0' || compression==PNG_TEXT_COMPRESSION_NONE)
   {
      png_write_tEXt(png_ptr, new_key, text, (png_size_t)0);
      png_free(png_ptr, new_key);
      return;
   }

   text_len = png_strlen(text);

   /* Compute the compressed data; do it now for the length */
   text_len = png_text_compress(png_ptr, text, text_len, compression,
       &comp);

   /* Write start of chunk */
   png_write_chunk_start(png_ptr, (png_bytep)png_zTXt,
     (png_uint_32)(key_len+text_len + 2));
   /* Write key */
   png_write_chunk_data(png_ptr, (png_bytep)new_key,
     (png_size_t)(key_len + 1));
   png_free(png_ptr, new_key);

   buf[0] = (png_byte)compression;
   /* Write compression */
   png_write_chunk_data(png_ptr, (png_bytep)buf, (png_size_t)1);
   /* Write the compressed data */
   png_write_compressed_data_out(png_ptr, &comp);

   /* Close the chunk */
   png_write_chunk_end(png_ptr);
}

// Assembly:
subq $0x68, %rsp
movq %rdi, 0x60(%rsp)
movq %rsi, 0x58(%rsp)
movq %rdx, 0x50(%rsp)
movq %rcx, 0x48(%rsp)
movl %r8d, 0x44(%rsp)
movl 0x1276c(%rip), %eax     # 0x13fd9f
movl %eax, 0x3f(%rsp)
movb 0x12766(%rip), %al      # 0x13fda3
movb %al, 0x43(%rsp)
movl $0x0, 0xc(%rsp)
movl $0x0, 0x10(%rsp)
movq $0x0, 0x18(%rsp)
movq $0x0, (%rsp)
movl $0x0, 0x8(%rsp)
movq 0x60(%rsp), %rdi
movq 0x58(%rsp), %rsi
leaq 0x20(%rsp), %rdx
callq 0x12bf40
movq %rax, 0x30(%rsp)
cmpq $0x0, %rax
jne 0x12d69d
movq 0x60(%rsp), %rdi
movq 0x20(%rsp), %rsi
callq 0x1136d0
jmp 0x12d78f
cmpq $0x0, 0x50(%rsp)
je 0x12d6b9
movq 0x50(%rsp), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
je 0x12d6b9
cmpl $-0x1, 0x44(%rsp)
jne 0x12d6e5
movq 0x60(%rsp), %rdi
movq 0x20(%rsp), %rsi
movq 0x50(%rsp), %rdx
xorl %eax, %eax
movl %eax, %ecx
callq 0x12d520
movq 0x60(%rsp), %rdi
movq 0x20(%rsp), %rsi
callq 0x1136d0
jmp 0x12d78f
movq 0x50(%rsp), %rdi
callq 0xf200
movq %rax, 0x48(%rsp)
movq 0x60(%rsp), %rdi
movq 0x50(%rsp), %rsi
movq 0x48(%rsp), %rdx
movl 0x44(%rsp), %ecx
movq %rsp, %r8
callq 0x12c2c0
cltq
movq %rax, 0x48(%rsp)
movq 0x60(%rsp), %rdi
leaq 0x3f(%rsp), %rsi
movq 0x30(%rsp), %rax
addq 0x48(%rsp), %rax
addq $0x2, %rax
movl %eax, %edx
callq 0x12b0a0
movq 0x60(%rsp), %rdi
movq 0x20(%rsp), %rsi
movq 0x30(%rsp), %rdx
addq $0x1, %rdx
callq 0x12b140
movq 0x60(%rsp), %rdi
movq 0x20(%rsp), %rsi
callq 0x1136d0
movl 0x44(%rsp), %eax
movb %al, 0x2f(%rsp)
movq 0x60(%rsp), %rdi
leaq 0x2f(%rsp), %rsi
movl $0x1, %edx
callq 0x12b140
movq 0x60(%rsp), %rdi
movq %rsp, %rsi
callq 0x12c820
movq 0x60(%rsp), %rdi
callq 0x12b1a0
addq $0x68, %rsp
retq
nopw %cs:(%rax,%rax)
// File: tomfunkhouser[P]gaps/pkgs/png/pngwutil.c
// Function: png_write_oFFs
void /* PRIVATE */
png_write_oFFs(png_structp png_ptr, png_int_32 x_offset, png_int_32 y_offset,
   int unit_type)
{
   PNG_oFFs;
   png_byte buf[9];

   png_debug(1, "in png_write_oFFs");

   if (unit_type >= PNG_OFFSET_LAST)
      png_warning(png_ptr, "Unrecognized unit type for oFFs chunk");

   png_save_int_32(buf, x_offset);
   png_save_int_32(buf + 4, y_offset);
   buf[8] = (png_byte)unit_type;

   png_write_chunk(png_ptr, (png_bytep)png_oFFs, buf, (png_size_t)9);
}

// Assembly:
subq $0x28, %rsp
movq %rdi, 0x20(%rsp)
movl %esi, 0x1c(%rsp)
movl %edx, 0x18(%rsp)
movl %ecx, 0x14(%rsp)
movl 0x11fc9(%rip), %eax     # 0x13fa64
movl %eax, 0xf(%rsp)
movb 0x11fc3(%rip), %al      # 0x13fa68
movb %al, 0x13(%rsp)
cmpl $0x2, 0x14(%rsp)
jl 0x12dac1
movq 0x20(%rsp), %rdi
leaq 0x130ac(%rip), %rsi     # 0x140b68
callq 0x113940
leaq 0x6(%rsp), %rdi
movl 0x1c(%rsp), %esi
callq 0x12af10
leaq 0x6(%rsp), %rdi
addq $0x4, %rdi
movl 0x18(%rsp), %esi
callq 0x12af10
movl 0x14(%rsp), %eax
movb %al, 0xe(%rsp)
movq 0x20(%rsp), %rdi
leaq 0xf(%rsp), %rsi
leaq 0x6(%rsp), %rdx
movl $0x9, %ecx
callq 0x12b040
addq $0x28, %rsp
retq
nopw (%rax,%rax)
// File: tomfunkhouser[P]gaps/pkgs/png/pngwutil.c
// Function: png_write_sCAL
void /* PRIVATE */
png_write_sCAL(png_structp png_ptr, int unit, double width, double height)
{
   PNG_sCAL;
   char buf[64];
   png_size_t total_len;

   png_debug(1, "in png_write_sCAL");

   buf[0] = (char)unit;
   png_snprintf(buf + 1, 63, "%12.12e", width);
   total_len = 1 + png_strlen(buf + 1) + 1;
   png_snprintf(buf + total_len, 64-total_len, "%12.12e", height);
   total_len += png_strlen(buf + total_len);

   png_debug1(3, "sCAL total length = %u", (unsigned int)total_len);
   png_write_chunk(png_ptr, (png_bytep)png_sCAL, (png_bytep)buf, total_len);
}

// Assembly:
subq $0x78, %rsp
movq %rdi, 0x70(%rsp)
movl %esi, 0x6c(%rsp)
movsd %xmm0, 0x60(%rsp)
movsd %xmm1, 0x58(%rsp)
movl 0x11e48(%rip), %eax     # 0x13fba7
movl %eax, 0x53(%rsp)
movb 0x11e42(%rip), %al      # 0x13fbab
movb %al, 0x57(%rsp)
movl 0x6c(%rsp), %eax
movb %al, 0x10(%rsp)
leaq 0x10(%rsp), %rdi
addq $0x1, %rdi
movsd 0x60(%rsp), %xmm0
movl $0x3f, %esi
leaq 0x12dfe(%rip), %rdx     # 0x140b8e
movb $0x1, %al
callq 0xf800
leaq 0x10(%rsp), %rdi
addq $0x1, %rdi
callq 0xf200
addq $0x1, %rax
addq $0x1, %rax
movq %rax, 0x8(%rsp)
leaq 0x10(%rsp), %rdi
addq 0x8(%rsp), %rdi
movl $0x40, %esi
subq 0x8(%rsp), %rsi
movsd 0x58(%rsp), %xmm0
leaq 0x12dbb(%rip), %rdx     # 0x140b8e
movb $0x1, %al
callq 0xf800
leaq 0x10(%rsp), %rdi
addq 0x8(%rsp), %rdi
callq 0xf200
addq 0x8(%rsp), %rax
movq %rax, 0x8(%rsp)
movq 0x70(%rsp), %rdi
leaq 0x53(%rsp), %rsi
leaq 0x10(%rsp), %rdx
movq 0x8(%rsp), %rcx
callq 0x12b040
addq $0x78, %rsp
retq
nopw %cs:(%rax,%rax)
// File: tomfunkhouser[P]gaps/pkgs/png/pngwutil.c
// Function: png_write_pHYs
void /* PRIVATE */
png_write_pHYs(png_structp png_ptr, png_uint_32 x_pixels_per_unit,
   png_uint_32 y_pixels_per_unit,
   int unit_type)
{
   PNG_pHYs;
   png_byte buf[9];

   png_debug(1, "in png_write_pHYs");

   if (unit_type >= PNG_RESOLUTION_LAST)
      png_warning(png_ptr, "Unrecognized unit type for pHYs chunk");

   png_save_uint_32(buf, x_pixels_per_unit);
   png_save_uint_32(buf + 4, y_pixels_per_unit);
   buf[8] = (png_byte)unit_type;

   png_write_chunk(png_ptr, (png_bytep)png_pHYs, buf, (png_size_t)9);
}

// Assembly:
subq $0x28, %rsp
movq %rdi, 0x20(%rsp)
movl %esi, 0x1c(%rsp)
movl %edx, 0x18(%rsp)
movl %ecx, 0x14(%rsp)
movl 0x11bc7(%rip), %eax     # 0x13fa02
movl %eax, 0xf(%rsp)
movb 0x11bc1(%rip), %al      # 0x13fa06
movb %al, 0x13(%rsp)
cmpl $0x2, 0x14(%rsp)
jl 0x12de61
movq 0x20(%rsp), %rdi
leaq 0x12d3a(%rip), %rsi     # 0x140b96
callq 0x113940
leaq 0x6(%rsp), %rdi
movl 0x1c(%rsp), %esi
callq 0x12aeb0
leaq 0x6(%rsp), %rdi
addq $0x4, %rdi
movl 0x18(%rsp), %esi
callq 0x12aeb0
movl 0x14(%rsp), %eax
movb %al, 0xe(%rsp)
movq 0x20(%rsp), %rdi
leaq 0xf(%rsp), %rsi
leaq 0x6(%rsp), %rdx
movl $0x9, %ecx
callq 0x12b040
addq $0x28, %rsp
retq
nopw (%rax,%rax)
// File: tomfunkhouser[P]gaps/pkgs/png/pngwutil.c
// Function: png_write_tIME
void /* PRIVATE */
png_write_tIME(png_structp png_ptr, png_timep mod_time)
{
   PNG_tIME;
   png_byte buf[7];

   png_debug(1, "in png_write_tIME");

   if (mod_time->month  > 12 || mod_time->month  < 1 ||
       mod_time->day    > 31 || mod_time->day    < 1 ||
       mod_time->hour   > 23 || mod_time->second > 60)
   {
      png_warning(png_ptr, "Invalid time specified for tIME chunk");
      return;
   }

   png_save_uint_16(buf, mod_time->year);
   buf[2] = mod_time->month;
   buf[3] = mod_time->day;
   buf[4] = mod_time->hour;
   buf[5] = mod_time->minute;
   buf[6] = mod_time->second;

   png_write_chunk(png_ptr, (png_bytep)png_tIME, buf, (png_size_t)7);
}

// Assembly:
subq $0x28, %rsp
movq %rdi, 0x20(%rsp)
movq %rsi, 0x18(%rsp)
movl 0xb2f4(%rip), %eax      # 0x1391b8
movl %eax, 0x13(%rsp)
movb 0xb2ee(%rip), %al       # 0x1391bc
movb %al, 0x17(%rsp)
movq 0x18(%rsp), %rax
movzbl 0x2(%rax), %eax
cmpl $0xc, %eax
jg 0x12df26
movq 0x18(%rsp), %rax
movzbl 0x2(%rax), %eax
cmpl $0x1, %eax
jl 0x12df26
movq 0x18(%rsp), %rax
movzbl 0x3(%rax), %eax
cmpl $0x1f, %eax
jg 0x12df26
movq 0x18(%rsp), %rax
movzbl 0x3(%rax), %eax
cmpl $0x1, %eax
jl 0x12df26
movq 0x18(%rsp), %rax
movzbl 0x4(%rax), %eax
cmpl $0x17, %eax
jg 0x12df26
movq 0x18(%rsp), %rax
movzbl 0x6(%rax), %eax
cmpl $0x3c, %eax
jle 0x12df39
movq 0x20(%rsp), %rdi
leaq 0x12c8a(%rip), %rsi     # 0x140bbc
callq 0x113940
jmp 0x12dfa0
leaq 0xc(%rsp), %rdi
movq 0x18(%rsp), %rax
movzwl (%rax), %esi
callq 0x12af70
movq 0x18(%rsp), %rax
movb 0x2(%rax), %al
movb %al, 0xe(%rsp)
movq 0x18(%rsp), %rax
movb 0x3(%rax), %al
movb %al, 0xf(%rsp)
movq 0x18(%rsp), %rax
movb 0x4(%rax), %al
movb %al, 0x10(%rsp)
movq 0x18(%rsp), %rax
movb 0x5(%rax), %al
movb %al, 0x11(%rsp)
movq 0x18(%rsp), %rax
movb 0x6(%rax), %al
movb %al, 0x12(%rsp)
movq 0x20(%rsp), %rdi
leaq 0x13(%rsp), %rsi
leaq 0xc(%rsp), %rdx
movl $0x7, %ecx
callq 0x12b040
addq $0x28, %rsp
retq
nopw %cs:(%rax,%rax)
// File: tomfunkhouser[P]gaps/pkgs/png/pngwio.c
// Function: png_default_write_data
void PNGAPI
png_default_write_data(png_structp png_ptr, png_bytep data, png_size_t length)
{
   png_uint_32 check;

   if (png_ptr == NULL)
      return;
   check = fwrite(data, 1, length, (png_FILE_p)(png_ptr->io_ptr));
   if (check != length)
      png_error(png_ptr, "Write Error");
}

// Assembly:
subq $0x28, %rsp
movq %rdi, 0x20(%rsp)
movq %rsi, 0x18(%rsp)
movq %rdx, 0x10(%rsp)
cmpq $0x0, 0x20(%rsp)
jne 0x13125d
jmp 0x13129d
movq 0x18(%rsp), %rdi
movq 0x10(%rsp), %rdx
movq 0x20(%rsp), %rax
movq 0xf8(%rax), %rcx
movl $0x1, %esi
callq 0xf980
movl %eax, 0xc(%rsp)
movl 0xc(%rsp), %eax
cmpq 0x10(%rsp), %rax
je 0x13129d
movq 0x20(%rsp), %rdi
leaq 0xf982(%rip), %rsi      # 0x140c1a
callq 0x113860
addq $0x28, %rsp
retq
nopw %cs:(%rax,%rax)
// File: tomfunkhouser[P]gaps/pkgs/png/pngwio.c
// Function: png_default_flush
void PNGAPI
png_default_flush(png_structp png_ptr)
{
   png_FILE_p io_ptr;
   if (png_ptr == NULL)
      return;
   io_ptr = (png_FILE_p)CVT_PTR((png_ptr->io_ptr));
   fflush(io_ptr);
}

// Assembly:
subq $0x18, %rsp
movq %rdi, 0x10(%rsp)
cmpq $0x0, 0x10(%rsp)
jne 0x1312f3
jmp 0x13130e
movq 0x10(%rsp), %rax
movq 0xf8(%rax), %rax
movq %rax, 0x8(%rsp)
movq 0x8(%rsp), %rdi
callq 0xf5d0
addq $0x18, %rsp
retq
nopw %cs:(%rax,%rax)
// File: tomfunkhouser[P]gaps/pkgs/png/pngwio.c
// Function: png_set_write_fn
void PNGAPI
png_set_write_fn(png_structp png_ptr, png_voidp io_ptr,
   png_rw_ptr write_data_fn, png_flush_ptr output_flush_fn)
{
   if (png_ptr == NULL)
      return;

   png_ptr->io_ptr = io_ptr;

#ifdef PNG_STDIO_SUPPORTED
   if (write_data_fn != NULL)
      png_ptr->write_data_fn = write_data_fn;

   else
      png_ptr->write_data_fn = png_default_write_data;
#else
   png_ptr->write_data_fn = write_data_fn;
#endif

#ifdef PNG_WRITE_FLUSH_SUPPORTED
#ifdef PNG_STDIO_SUPPORTED
   if (output_flush_fn != NULL)
      png_ptr->output_flush_fn = output_flush_fn;

   else
      png_ptr->output_flush_fn = png_default_flush;
#else
   png_ptr->output_flush_fn = output_flush_fn;
#endif
#endif /* PNG_WRITE_FLUSH_SUPPORTED */

   /* It is an error to read while writing a png file */
   if (png_ptr->read_data_fn != NULL)
   {
      png_ptr->read_data_fn = NULL;
      png_warning(png_ptr,
         "Attempted to set both read_data_fn and write_data_fn in");
      png_warning(png_ptr,
         "the same structure.  Resetting read_data_fn to NULL");
   }
}

// Assembly:
subq $0x28, %rsp
movq %rdi, 0x20(%rsp)
movq %rsi, 0x18(%rsp)
movq %rdx, 0x10(%rsp)
movq %rcx, 0x8(%rsp)
cmpq $0x0, 0x20(%rsp)
jne 0x131345
jmp 0x1313f3
movq 0x18(%rsp), %rcx
movq 0x20(%rsp), %rax
movq %rcx, 0xf8(%rax)
cmpq $0x0, 0x10(%rsp)
je 0x131371
movq 0x10(%rsp), %rcx
movq 0x20(%rsp), %rax
movq %rcx, 0xe8(%rax)
jmp 0x131384
movq 0x20(%rsp), %rax
leaq -0x13d(%rip), %rcx      # 0x131240
movq %rcx, 0xe8(%rax)
cmpq $0x0, 0x8(%rsp)
je 0x13139f
movq 0x8(%rsp), %rcx
movq 0x20(%rsp), %rax
movq %rcx, 0x278(%rax)
jmp 0x1313b2
movq 0x20(%rsp), %rax
leaq -0xcb(%rip), %rcx       # 0x1312e0
movq %rcx, 0x278(%rax)
movq 0x20(%rsp), %rax
cmpq $0x0, 0xf0(%rax)
je 0x1313f3
movq 0x20(%rsp), %rax
movq $0x0, 0xf0(%rax)
movq 0x20(%rsp), %rdi
leaq 0xf849(%rip), %rsi      # 0x140c26
callq 0x113940
movq 0x20(%rsp), %rdi
leaq 0xf870(%rip), %rsi      # 0x140c5e
callq 0x113940
addq $0x28, %rsp
retq
nopl (%rax,%rax)
// File: tomfunkhouser[P]gaps/pkgs/png/adler32.c
// Function: adler32_combine_
local uLong adler32_combine_(adler1, adler2, len2)
    uLong adler1;
    uLong adler2;
    z_off64_t len2;
{
    unsigned long sum1;
    unsigned long sum2;
    unsigned rem;

    /* the derivation of this formula is left as an exercise for the reader */
    rem = (unsigned)(len2 % BASE);
    sum1 = adler1 & 0xffff;
    sum2 = rem * sum1;
    MOD(sum2);
    sum1 += (adler2 & 0xffff) + BASE - 1;
    sum2 += ((adler1 >> 16) & 0xffff) + ((adler2 >> 16) & 0xffff) + BASE - rem;
    if (sum1 >= BASE) sum1 -= BASE;
    if (sum1 >= BASE) sum1 -= BASE;
    if (sum2 >= (BASE << 1)) sum2 -= (BASE << 1);
    if (sum2 >= BASE) sum2 -= BASE;
    return sum1 | (sum2 << 16);
}

// Assembly:
movq %rdi, -0x8(%rsp)
movq %rsi, -0x10(%rsp)
movq %rdx, -0x18(%rsp)
movq -0x18(%rsp), %rax
movl $0xfff1, %ecx           # imm = 0xFFF1
xorl %edx, %edx
divq %rcx
movl %edx, %eax
movl %eax, -0x2c(%rsp)
movq -0x8(%rsp), %rax
andq $0xffff, %rax           # imm = 0xFFFF
movq %rax, -0x20(%rsp)
movl -0x2c(%rsp), %eax
imulq -0x20(%rsp), %rax
movq %rax, -0x28(%rsp)
movq -0x28(%rsp), %rax
movl $0xfff1, %ecx           # imm = 0xFFF1
xorl %edx, %edx
divq %rcx
movq %rdx, -0x28(%rsp)
movq -0x10(%rsp), %rax
andq $0xffff, %rax           # imm = 0xFFFF
addq $0xfff1, %rax           # imm = 0xFFF1
subq $0x1, %rax
addq -0x20(%rsp), %rax
movq %rax, -0x20(%rsp)
movq -0x8(%rsp), %rax
shrq $0x10, %rax
andq $0xffff, %rax           # imm = 0xFFFF
movq -0x10(%rsp), %rcx
shrq $0x10, %rcx
andq $0xffff, %rcx           # imm = 0xFFFF
addq %rcx, %rax
addq $0xfff1, %rax           # imm = 0xFFF1
movl -0x2c(%rsp), %ecx
subq %rcx, %rax
addq -0x28(%rsp), %rax
movq %rax, -0x28(%rsp)
cmpq $0xfff1, -0x20(%rsp)    # imm = 0xFFF1
jb 0x131bca
movq -0x20(%rsp), %rax
subq $0xfff1, %rax           # imm = 0xFFF1
movq %rax, -0x20(%rsp)
cmpq $0xfff1, -0x20(%rsp)    # imm = 0xFFF1
jb 0x131be5
movq -0x20(%rsp), %rax
subq $0xfff1, %rax           # imm = 0xFFF1
movq %rax, -0x20(%rsp)
cmpq $0x1ffe2, -0x28(%rsp)   # imm = 0x1FFE2
jb 0x131c00
movq -0x28(%rsp), %rax
subq $0x1ffe2, %rax          # imm = 0x1FFE2
movq %rax, -0x28(%rsp)
cmpq $0xfff1, -0x28(%rsp)    # imm = 0xFFF1
jb 0x131c1b
movq -0x28(%rsp), %rax
subq $0xfff1, %rax           # imm = 0xFFF1
movq %rax, -0x28(%rsp)
movq -0x20(%rsp), %rax
movq -0x28(%rsp), %rcx
shlq $0x10, %rcx
orq %rcx, %rax
retq
nopl (%rax)
// File: EverybodyHops[P]Permutations/media_number.cpp
// Function: media_number::print_num()
void media_number::print_num(){
    cout << "now num: ";
    for(int i = num.size() - 1; i >= 0; i--){
        cout << num[i] << " ";
    }
    cout << endl;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x18(%rbp)
movq 0x10bcd(%rip), %rdi     # 0x12fd8
leaq 0xabf2(%rip), %rsi      # 0xd004
callq 0x20e0
movq -0x18(%rbp), %rdi
callq 0x30f0
subq $0x1, %rax
movl %eax, -0xc(%rbp)
cmpl $0x0, -0xc(%rbp)
jl 0x2462
movq -0x18(%rbp), %rdi
movslq -0xc(%rbp), %rsi
callq 0x3110
movl (%rax), %esi
movq 0x10b95(%rip), %rdi     # 0x12fd8
callq 0x21a0
movq %rax, %rdi
leaq 0xabba(%rip), %rsi      # 0xd00c
callq 0x20e0
movl -0xc(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0xc(%rbp)
jmp 0x2427
movq 0x10b6f(%rip), %rdi     # 0x12fd8
movq 0x10b58(%rip), %rsi     # 0x12fc8
callq 0x2100
addq $0x20, %rsp
popq %rbp
retq
nopl (%rax,%rax)
// File: EverybodyHops[P]Permutations/media_number.cpp
// Function: media_number::print_carry()
void media_number::print_carry(){
    cout << "now carry: ";
    for(int i = carry.size() - 1; i >= 0; i--){
        cout << carry[i] << " ";
    }
    cout << endl;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x18(%rbp)
movq 0x10b3d(%rip), %rdi     # 0x12fd8
leaq 0xab6c(%rip), %rsi      # 0xd00e
callq 0x20e0
movq -0x18(%rbp), %rdi
addq $0x18, %rdi
callq 0x30f0
subq $0x1, %rax
movl %eax, -0xc(%rbp)
cmpl $0x0, -0xc(%rbp)
jl 0x24fa
movq -0x18(%rbp), %rdi
addq $0x18, %rdi
movslq -0xc(%rbp), %rsi
callq 0x3110
movl (%rax), %esi
movq 0x10afd(%rip), %rdi     # 0x12fd8
callq 0x21a0
movq %rax, %rdi
leaq 0xab22(%rip), %rsi      # 0xd00c
callq 0x20e0
movl -0xc(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0xc(%rbp)
jmp 0x24bb
movq 0x10ad7(%rip), %rdi     # 0x12fd8
movq 0x10ac0(%rip), %rsi     # 0x12fc8
callq 0x2100
addq $0x20, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: EverybodyHops[P]Permutations/media_number.cpp
// Function: media_number::dec2media(int)
vector<int> media_number::dec2media(int dec){
    vector<int> res;
    int t = 0;
    while(dec > 0){
        if(t == carry.size()){
            res.push_back(dec);
            break;
        }
        res.push_back(dec % carry[t]);
        dec /= carry[t++];
    }
    return res;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x48(%rbp)
movq %rdi, %rax
movq %rax, -0x40(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x38(%rbp)
movb $0x0, -0x15(%rbp)
callq 0x3130
movl $0x0, -0x1c(%rbp)
cmpl $0x0, -0x14(%rbp)
jle 0x2668
movq -0x38(%rbp), %rdi
movslq -0x1c(%rbp), %rax
movq %rax, -0x50(%rbp)
addq $0x18, %rdi
callq 0x30f0
movq %rax, %rcx
movq -0x50(%rbp), %rax
cmpq %rcx, %rax
jne 0x2609
movq -0x48(%rbp), %rdi
leaq -0x14(%rbp), %rsi
callq 0x3150
jmp 0x25f0
jmp 0x2668
movq -0x48(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
callq 0x3090
jmp 0x2685
movq -0x38(%rbp), %rdi
movl -0x14(%rbp), %eax
movl %eax, -0x54(%rbp)
addq $0x18, %rdi
movslq -0x1c(%rbp), %rsi
callq 0x3110
movq -0x48(%rbp), %rdi
movq %rax, %rcx
movl -0x54(%rbp), %eax
movl (%rcx), %ecx
cltd
idivl %ecx
movl %edx, -0x30(%rbp)
leaq -0x30(%rbp), %rsi
callq 0x31c0
jmp 0x263d
movq -0x38(%rbp), %rdi
addq $0x18, %rdi
movl -0x1c(%rbp), %eax
movl %eax, %ecx
addl $0x1, %ecx
movl %ecx, -0x1c(%rbp)
movslq %eax, %rsi
callq 0x3110
movl (%rax), %ecx
movl -0x14(%rbp), %eax
cltd
idivl %ecx
movl %eax, -0x14(%rbp)
jmp 0x25b6
movb $0x1, -0x15(%rbp)
testb $0x1, -0x15(%rbp)
jne 0x267b
movq -0x48(%rbp), %rdi
callq 0x3090
movq -0x40(%rbp), %rax
addq $0x60, %rsp
popq %rbp
retq
movq -0x28(%rbp), %rdi
callq 0x21b0
nop
// File: EverybodyHops[P]Permutations/media_number.cpp
// Function: media_number::if_vector_legal(std::vector<int, std::allocator<int>>)
bool media_number::if_vector_legal(vector<int> v){
    if(v.size() > carry.size()){
        #ifdef DEBUG
            cout << "Vector illegal (too long)!" << endl;
            print_vector<int>(v);
        #endif
        return false;
    }
    for(int i = 0; i < v.size(); i++){
        if(v[i] >= carry[i]){
            #ifdef DEBUG
                cout << "Vector illegal (bigger than carry)!" << endl;
                print_vector<int>(v);
            #endif
            return false;
        }
    }
    return true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rsi, -0x40(%rbp)
movq %rdi, %rax
movq -0x40(%rbp), %rdi
movq %rdi, -0x38(%rbp)
movq %rax, -0x10(%rbp)
movq %rdi, -0x18(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x30(%rbp)
callq 0x30f0
movq -0x30(%rbp), %rdi
movq %rax, -0x28(%rbp)
addq $0x18, %rdi
callq 0x30f0
movq %rax, %rcx
movq -0x28(%rbp), %rax
cmpq %rcx, %rax
jbe 0x26df
movb $0x0, -0x1(%rbp)
jmp 0x2747
movl $0x0, -0x1c(%rbp)
movq -0x38(%rbp), %rdi
movslq -0x1c(%rbp), %rax
movq %rax, -0x48(%rbp)
callq 0x30f0
movq %rax, %rcx
movq -0x48(%rbp), %rax
cmpq %rcx, %rax
jae 0x2743
movq -0x38(%rbp), %rdi
movslq -0x1c(%rbp), %rsi
callq 0x3110
movq -0x30(%rbp), %rdi
movl (%rax), %eax
movl %eax, -0x4c(%rbp)
addq $0x18, %rdi
movslq -0x1c(%rbp), %rsi
callq 0x3110
movq %rax, %rcx
movl -0x4c(%rbp), %eax
cmpl (%rcx), %eax
jl 0x2736
movb $0x0, -0x1(%rbp)
jmp 0x2747
jmp 0x2738
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x26e6
movb $0x1, -0x1(%rbp)
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x50, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: EverybodyHops[P]Permutations/media_number.cpp
// Function: media_number::add_vector(std::vector<int, std::allocator<int>>)
bool media_number::add_vector(vector<int> v){
    if(!if_vector_legal(v)){
        return false;
    }

    for(int i = 0; i < num.size() - 1; i++){
        if(i < v.size()){  
            num[i] += v[i];
        }
        if(num[i] >= carry[i]){
            num[i] -= carry[i];
            num[i + 1] += 1;
        }
    }

    if(num[num.size() - 1] > 0){
        #ifdef DEBUG
            cout << "Overflow!" << endl;
            print_num();
        #endif
        sub_vector(v);
        #ifdef DEBUG
            cout << "After handle overflow." << endl;
            print_num();
        #endif
        return false;
    }
    return true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xa0, %rsp
movq %rsi, -0x70(%rbp)
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x68(%rbp)
leaq -0x30(%rbp), %rdi
callq 0x2f70
movq -0x68(%rbp), %rdi
leaq -0x30(%rbp), %rsi
callq 0x2690
xorb $-0x1, %al
movb %al, -0x5d(%rbp)
leaq -0x30(%rbp), %rdi
callq 0x3090
movb -0x5d(%rbp), %al
testb $0x1, %al
jne 0x27ac
jmp 0x27b5
movb $0x0, -0x1(%rbp)
jmp 0x2926
movl $0x0, -0x34(%rbp)
movq -0x68(%rbp), %rdi
movslq -0x34(%rbp), %rax
movq %rax, -0x78(%rbp)
callq 0x30f0
movq %rax, %rcx
movq -0x78(%rbp), %rax
subq $0x1, %rcx
cmpq %rcx, %rax
jae 0x28b8
movq -0x70(%rbp), %rdi
movslq -0x34(%rbp), %rax
movq %rax, -0x80(%rbp)
callq 0x30f0
movq %rax, %rcx
movq -0x80(%rbp), %rax
cmpq %rcx, %rax
jae 0x282a
movq -0x70(%rbp), %rdi
movslq -0x34(%rbp), %rsi
callq 0x3110
movq -0x68(%rbp), %rdi
movl (%rax), %eax
movl %eax, -0x84(%rbp)
movslq -0x34(%rbp), %rsi
callq 0x3110
movl -0x84(%rbp), %ecx
addl (%rax), %ecx
movl %ecx, (%rax)
movq -0x68(%rbp), %rdi
movslq -0x34(%rbp), %rsi
callq 0x3110
movq -0x68(%rbp), %rdi
movl (%rax), %eax
movl %eax, -0x88(%rbp)
addq $0x18, %rdi
movslq -0x34(%rbp), %rsi
callq 0x3110
movq %rax, %rcx
movl -0x88(%rbp), %eax
cmpl (%rcx), %eax
jl 0x28a8
movq -0x68(%rbp), %rdi
addq $0x18, %rdi
movslq -0x34(%rbp), %rsi
callq 0x3110
movq -0x68(%rbp), %rdi
movl (%rax), %eax
movl %eax, -0x8c(%rbp)
movslq -0x34(%rbp), %rsi
callq 0x3110
movl -0x8c(%rbp), %edx
movq -0x68(%rbp), %rdi
movl (%rax), %ecx
subl %edx, %ecx
movl %ecx, (%rax)
movl -0x34(%rbp), %eax
addl $0x1, %eax
movslq %eax, %rsi
callq 0x3110
movl (%rax), %ecx
addl $0x1, %ecx
movl %ecx, (%rax)
jmp 0x28aa
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x27bc
movq -0x68(%rbp), %rdi
callq 0x30f0
movq -0x68(%rbp), %rdi
movq %rax, %rsi
subq $0x1, %rsi
callq 0x3110
cmpl $0x0, (%rax)
jle 0x2922
movq -0x70(%rbp), %rsi
leaq -0x50(%rbp), %rdi
movq %rdi, -0x98(%rbp)
callq 0x2f70
movq -0x68(%rbp), %rdi
movq -0x98(%rbp), %rsi
callq 0x2940
jmp 0x28fc
leaq -0x50(%rbp), %rdi
callq 0x3090
movb $0x0, -0x1(%rbp)
jmp 0x2926
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x50(%rbp), %rdi
callq 0x3090
jmp 0x2934
movb $0x1, -0x1(%rbp)
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0xa0, %rsp
popq %rbp
retq
movq -0x58(%rbp), %rdi
callq 0x21b0
nopl (%rax)