// File: tomfunkhouser[P]gaps/pkgs/png/pngwutil.c
// Function: png_write_cHRM
void /* PRIVATE */
png_write_cHRM(png_structp png_ptr, double white_x, double white_y,
   double red_x, double red_y, double green_x, double green_y,
   double blue_x, double blue_y)
{
   PNG_cHRM;
   png_byte buf[32];

   png_fixed_point int_white_x, int_white_y, int_red_x, int_red_y,
      int_green_x, int_green_y, int_blue_x, int_blue_y;

   png_debug(1, "in png_write_cHRM");

   int_white_x = (png_uint_32)(white_x * 100000.0 + 0.5);
   int_white_y = (png_uint_32)(white_y * 100000.0 + 0.5);
   int_red_x   = (png_uint_32)(red_x   * 100000.0 + 0.5);
   int_red_y   = (png_uint_32)(red_y   * 100000.0 + 0.5);
   int_green_x = (png_uint_32)(green_x * 100000.0 + 0.5);
   int_green_y = (png_uint_32)(green_y * 100000.0 + 0.5);
   int_blue_x  = (png_uint_32)(blue_x  * 100000.0 + 0.5);
   int_blue_y  = (png_uint_32)(blue_y  * 100000.0 + 0.5);

#ifdef PNG_CHECK_cHRM_SUPPORTED
   if (png_check_cHRM_fixed(png_ptr, int_white_x, int_white_y,
      int_red_x, int_red_y, int_green_x, int_green_y, int_blue_x, int_blue_y))
#endif
   {
      /* Each value is saved in 1/100,000ths */

      png_save_uint_32(buf, int_white_x);
      png_save_uint_32(buf + 4, int_white_y);

      png_save_uint_32(buf + 8, int_red_x);
      png_save_uint_32(buf + 12, int_red_y);

      png_save_uint_32(buf + 16, int_green_x);
      png_save_uint_32(buf + 20, int_green_y);

      png_save_uint_32(buf + 24, int_blue_x);
      png_save_uint_32(buf + 28, int_blue_y);

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

// Assembly:
subq $0xc8, %rsp
movq %rdi, 0xc0(%rsp)
movsd %xmm0, 0xb8(%rsp)
movsd %xmm1, 0xb0(%rsp)
movsd %xmm2, 0xa8(%rsp)
movsd %xmm3, 0xa0(%rsp)
movsd %xmm4, 0x98(%rsp)
movsd %xmm5, 0x90(%rsp)
movsd %xmm6, 0x88(%rsp)
movsd %xmm7, 0x80(%rsp)
movb $0x0, 0x7c(%rsp)
movl $0x4d524863, 0x78(%rsp) # imm = 0x4D524863
movsd 0xb8(%rsp), %xmm0
movsd 0xbfbb(%rip), %xmm2     # 0x138d80
movsd %xmm2, 0x20(%rsp)
mulsd %xmm2, %xmm0
movsd 0x6239(%rip), %xmm1     # 0x133010
movsd %xmm1, 0x28(%rsp)
addsd %xmm1, %xmm0
cvttsd2si %xmm0, %rax
movl %eax, 0x4c(%rsp)
movsd 0xb0(%rsp), %xmm0
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
cvttsd2si %xmm0, %rax
movl %eax, 0x48(%rsp)
movsd 0xa8(%rsp), %xmm0
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
cvttsd2si %xmm0, %rax
movl %eax, 0x44(%rsp)
movsd 0xa0(%rsp), %xmm0
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
cvttsd2si %xmm0, %rax
movl %eax, 0x40(%rsp)
movsd 0x98(%rsp), %xmm0
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
cvttsd2si %xmm0, %rax
movl %eax, 0x3c(%rsp)
movsd 0x90(%rsp), %xmm0
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
cvttsd2si %xmm0, %rax
movl %eax, 0x38(%rsp)
movsd 0x88(%rsp), %xmm0
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
cvttsd2si %xmm0, %rax
movl %eax, 0x34(%rsp)
movsd 0x80(%rsp), %xmm0
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
cvttsd2si %xmm0, %rax
movl %eax, 0x30(%rsp)
movq 0xc0(%rsp), %rdi
movl 0x4c(%rsp), %esi
movl 0x48(%rsp), %edx
movl 0x44(%rsp), %ecx
movl 0x40(%rsp), %r8d
movl 0x3c(%rsp), %r9d
movl 0x38(%rsp), %r11d
movl 0x34(%rsp), %r10d
movl 0x30(%rsp), %eax
movl %r11d, (%rsp)
movl %r10d, 0x8(%rsp)
movl %eax, 0x10(%rsp)
callq 0xfc610
cmpl $0x0, %eax
je 0x12cf8f
leaq 0x50(%rsp), %rdi
movl 0x4c(%rsp), %esi
callq 0x12aeb0
leaq 0x50(%rsp), %rdi
addq $0x4, %rdi
movl 0x48(%rsp), %esi
callq 0x12aeb0
leaq 0x50(%rsp), %rdi
addq $0x8, %rdi
movl 0x44(%rsp), %esi
callq 0x12aeb0
leaq 0x50(%rsp), %rdi
addq $0xc, %rdi
movl 0x40(%rsp), %esi
callq 0x12aeb0
leaq 0x50(%rsp), %rdi
addq $0x10, %rdi
movl 0x3c(%rsp), %esi
callq 0x12aeb0
leaq 0x50(%rsp), %rdi
addq $0x14, %rdi
movl 0x38(%rsp), %esi
callq 0x12aeb0
leaq 0x50(%rsp), %rdi
addq $0x18, %rdi
movl 0x34(%rsp), %esi
callq 0x12aeb0
leaq 0x50(%rsp), %rdi
addq $0x1c, %rdi
movl 0x30(%rsp), %esi
callq 0x12aeb0
movq 0xc0(%rsp), %rdi
leaq 0x78(%rsp), %rsi
leaq 0x50(%rsp), %rdx
movl $0x20, %ecx
callq 0x12b040
addq $0xc8, %rsp
retq
nopw (%rax,%rax)