// File: tomfunkhouser[P]gaps/pkgs/png/pngrutil.c
// Function: png_handle_cHRM
void /* PRIVATE */
png_handle_cHRM(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
{
   png_byte buf[32];
#ifdef PNG_FLOATING_POINT_SUPPORTED
   float white_x, white_y, red_x, red_y, green_x, green_y, blue_x, blue_y;
#endif
   png_fixed_point int_x_white, int_y_white, int_x_red, int_y_red, int_x_green,
      int_y_green, int_x_blue, int_y_blue;

   png_uint_32 uint_x, uint_y;

   png_debug(1, "in png_handle_cHRM");

   if (!(png_ptr->mode & PNG_HAVE_IHDR))
      png_error(png_ptr, "Missing IHDR before cHRM");
   else if (png_ptr->mode & PNG_HAVE_IDAT)
   {
      png_warning(png_ptr, "Invalid cHRM after IDAT");
      png_crc_finish(png_ptr, length);
      return;
   }
   else if (png_ptr->mode & PNG_HAVE_PLTE)
      /* Should be an error, but we can cope with it */
      png_warning(png_ptr, "Missing PLTE before cHRM");

   if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_cHRM)
#ifdef PNG_READ_sRGB_SUPPORTED
      && !(info_ptr->valid & PNG_INFO_sRGB)
#endif
      )
   {
      png_warning(png_ptr, "Duplicate cHRM chunk");
      png_crc_finish(png_ptr, length);
      return;
   }

   if (length != 32)
   {
      png_warning(png_ptr, "Incorrect cHRM chunk length");
      png_crc_finish(png_ptr, length);
      return;
   }

   png_crc_read(png_ptr, buf, 32);
   if (png_crc_finish(png_ptr, 0))
      return;

   uint_x = png_get_uint_32(buf);
   uint_y = png_get_uint_32(buf + 4);
   int_x_white = (png_fixed_point)uint_x;
   int_y_white = (png_fixed_point)uint_y;

   uint_x = png_get_uint_32(buf + 8);
   uint_y = png_get_uint_32(buf + 12);
   int_x_red = (png_fixed_point)uint_x;
   int_y_red = (png_fixed_point)uint_y;

   uint_x = png_get_uint_32(buf + 16);
   uint_y = png_get_uint_32(buf + 20);
   int_x_green = (png_fixed_point)uint_x;
   int_y_green = (png_fixed_point)uint_y;

   uint_x = png_get_uint_32(buf + 24);
   uint_y = png_get_uint_32(buf + 28);
   int_x_blue = (png_fixed_point)uint_x;
   int_y_blue = (png_fixed_point)uint_y;

#ifdef PNG_FLOATING_POINT_SUPPORTED
   white_x = (float)int_x_white / (float)100000.0;
   white_y = (float)int_y_white / (float)100000.0;
   red_x   = (float)int_x_red   / (float)100000.0;
   red_y   = (float)int_y_red   / (float)100000.0;
   green_x = (float)int_x_green / (float)100000.0;
   green_y = (float)int_y_green / (float)100000.0;
   blue_x  = (float)int_x_blue  / (float)100000.0;
   blue_y  = (float)int_y_blue  / (float)100000.0;
#endif

#ifdef PNG_READ_sRGB_SUPPORTED
   if ((info_ptr != NULL) && (info_ptr->valid & PNG_INFO_sRGB))
      {
      if (PNG_OUT_OF_RANGE(int_x_white, 31270,  1000) ||
          PNG_OUT_OF_RANGE(int_y_white, 32900,  1000) ||
          PNG_OUT_OF_RANGE(int_x_red,   64000L, 1000) ||
          PNG_OUT_OF_RANGE(int_y_red,   33000,  1000) ||
          PNG_OUT_OF_RANGE(int_x_green, 30000,  1000) ||
          PNG_OUT_OF_RANGE(int_y_green, 60000L, 1000) ||
          PNG_OUT_OF_RANGE(int_x_blue,  15000,  1000) ||
          PNG_OUT_OF_RANGE(int_y_blue,   6000,  1000))
         {
            png_warning(png_ptr,
              "Ignoring incorrect cHRM value when sRGB is also present");
#ifdef PNG_CONSOLE_IO_SUPPORTED
#ifdef PNG_FLOATING_POINT_SUPPORTED
            fprintf(stderr, "wx=%f, wy=%f, rx=%f, ry=%f\n",
               white_x, white_y, red_x, red_y);
            fprintf(stderr, "gx=%f, gy=%f, bx=%f, by=%f\n",
               green_x, green_y, blue_x, blue_y);
#else
            fprintf(stderr, "wx=%ld, wy=%ld, rx=%ld, ry=%ld\n",
               (long)int_x_white, (long)int_y_white,
               (long)int_x_red, (long)int_y_red);
            fprintf(stderr, "gx=%ld, gy=%ld, bx=%ld, by=%ld\n",
               (long)int_x_green, (long)int_y_green,
               (long)int_x_blue, (long)int_y_blue);
#endif
#endif /* PNG_CONSOLE_IO_SUPPORTED */
         }
         return;
      }
#endif /* PNG_READ_sRGB_SUPPORTED */

#ifdef PNG_FLOATING_POINT_SUPPORTED
   png_set_cHRM(png_ptr, info_ptr,
      white_x, white_y, red_x, red_y, green_x, green_y, blue_x, blue_y);
#endif
#ifdef PNG_FIXED_POINT_SUPPORTED
   png_set_cHRM_fixed(png_ptr, info_ptr,
      int_x_white, int_y_white, int_x_red, int_y_red, int_x_green,
      int_y_green, int_x_blue, int_y_blue);
#endif
}

// Assembly:
pushq %rbx
subq $0xb0, %rsp
movq %rdi, 0xa8(%rsp)
movq %rsi, 0xa0(%rsp)
movl %edx, 0x9c(%rsp)
movq 0xa8(%rsp), %rax
movl 0x11c(%rax), %eax
andl $0x1, %eax
cmpl $0x0, %eax
jne 0x123ddb
movq 0xa8(%rsp), %rdi
leaq 0x1b6d2(%rip), %rsi     # 0x13f4a6
callq 0x113860
jmp 0x123e4c
movq 0xa8(%rsp), %rax
movl 0x11c(%rax), %eax
andl $0x4, %eax
cmpl $0x0, %eax
je 0x123e1e
movq 0xa8(%rsp), %rdi
leaq 0x1b6bf(%rip), %rsi     # 0x13f4bf
callq 0x113940
movq 0xa8(%rsp), %rdi
movl 0x9c(%rsp), %esi
callq 0x122b90
jmp 0x1243ab
movq 0xa8(%rsp), %rax
movl 0x11c(%rax), %eax
andl $0x2, %eax
cmpl $0x0, %eax
je 0x123e48
movq 0xa8(%rsp), %rdi
leaq 0x1b694(%rip), %rsi     # 0x13f4d7
callq 0x113940
jmp 0x123e4a
jmp 0x123e4c
cmpq $0x0, 0xa0(%rsp)
je 0x123eac
movq 0xa0(%rsp), %rax
movl 0x8(%rax), %eax
andl $0x4, %eax
cmpl $0x0, %eax
je 0x123eac
movq 0xa0(%rsp), %rax
movl 0x8(%rax), %eax
andl $0x800, %eax            # imm = 0x800
cmpl $0x0, %eax
jne 0x123eac
movq 0xa8(%rsp), %rdi
leaq 0x1b662(%rip), %rsi     # 0x13f4f0
callq 0x113940
movq 0xa8(%rsp), %rdi
movl 0x9c(%rsp), %esi
callq 0x122b90
jmp 0x1243ab
cmpl $0x20, 0x9c(%rsp)
je 0x123ee3
movq 0xa8(%rsp), %rdi
leaq 0x1b640(%rip), %rsi     # 0x13f505
callq 0x113940
movq 0xa8(%rsp), %rdi
movl 0x9c(%rsp), %esi
callq 0x122b90
jmp 0x1243ab
movq 0xa8(%rsp), %rdi
leaq 0x70(%rsp), %rsi
movl $0x20, %edx
callq 0x122b40
movq 0xa8(%rsp), %rdi
xorl %esi, %esi
callq 0x122b90
cmpl $0x0, %eax
je 0x123f13
jmp 0x1243ab
movzbl 0x70(%rsp), %eax
shll $0x18, %eax
movzbl 0x71(%rsp), %ecx
shll $0x10, %ecx
addl %ecx, %eax
movzbl 0x72(%rsp), %ecx
shll $0x8, %ecx
addl %ecx, %eax
movzbl 0x73(%rsp), %ecx
addl %ecx, %eax
movl %eax, 0x2c(%rsp)
movzbl 0x74(%rsp), %eax
shll $0x18, %eax
movzbl 0x75(%rsp), %ecx
shll $0x10, %ecx
addl %ecx, %eax
movzbl 0x76(%rsp), %ecx
shll $0x8, %ecx
addl %ecx, %eax
movzbl 0x77(%rsp), %ecx
addl %ecx, %eax
movl %eax, 0x28(%rsp)
movl 0x2c(%rsp), %eax
movl %eax, 0x4c(%rsp)
movl 0x28(%rsp), %eax
movl %eax, 0x48(%rsp)
movzbl 0x78(%rsp), %eax
shll $0x18, %eax
movzbl 0x79(%rsp), %ecx
shll $0x10, %ecx
addl %ecx, %eax
movzbl 0x7a(%rsp), %ecx
shll $0x8, %ecx
addl %ecx, %eax
movzbl 0x7b(%rsp), %ecx
addl %ecx, %eax
movl %eax, 0x2c(%rsp)
movzbl 0x7c(%rsp), %eax
shll $0x18, %eax
movzbl 0x7d(%rsp), %ecx
shll $0x10, %ecx
addl %ecx, %eax
movzbl 0x7e(%rsp), %ecx
shll $0x8, %ecx
addl %ecx, %eax
movzbl 0x7f(%rsp), %ecx
addl %ecx, %eax
movl %eax, 0x28(%rsp)
movl 0x2c(%rsp), %eax
movl %eax, 0x44(%rsp)
movl 0x28(%rsp), %eax
movl %eax, 0x40(%rsp)
movzbl 0x80(%rsp), %eax
shll $0x18, %eax
movzbl 0x81(%rsp), %ecx
shll $0x10, %ecx
addl %ecx, %eax
movzbl 0x82(%rsp), %ecx
shll $0x8, %ecx
addl %ecx, %eax
movzbl 0x83(%rsp), %ecx
addl %ecx, %eax
movl %eax, 0x2c(%rsp)
movzbl 0x84(%rsp), %eax
shll $0x18, %eax
movzbl 0x85(%rsp), %ecx
shll $0x10, %ecx
addl %ecx, %eax
movzbl 0x86(%rsp), %ecx
shll $0x8, %ecx
addl %ecx, %eax
movzbl 0x87(%rsp), %ecx
addl %ecx, %eax
movl %eax, 0x28(%rsp)
movl 0x2c(%rsp), %eax
movl %eax, 0x3c(%rsp)
movl 0x28(%rsp), %eax
movl %eax, 0x38(%rsp)
movzbl 0x88(%rsp), %eax
shll $0x18, %eax
movzbl 0x89(%rsp), %ecx
shll $0x10, %ecx
addl %ecx, %eax
movzbl 0x8a(%rsp), %ecx
shll $0x8, %ecx
addl %ecx, %eax
movzbl 0x8b(%rsp), %ecx
addl %ecx, %eax
movl %eax, 0x2c(%rsp)
movzbl 0x8c(%rsp), %eax
shll $0x18, %eax
movzbl 0x8d(%rsp), %ecx
shll $0x10, %ecx
addl %ecx, %eax
movzbl 0x8e(%rsp), %ecx
shll $0x8, %ecx
addl %ecx, %eax
movzbl 0x8f(%rsp), %ecx
addl %ecx, %eax
movl %eax, 0x28(%rsp)
movl 0x2c(%rsp), %eax
movl %eax, 0x34(%rsp)
movl 0x28(%rsp), %eax
movl %eax, 0x30(%rsp)
cvtsi2ssl 0x4c(%rsp), %xmm0
movss 0x1b093(%rip), %xmm1    # 0x13f15c
divss %xmm1, %xmm0
movss %xmm0, 0x6c(%rsp)
cvtsi2ssl 0x48(%rsp), %xmm0
movss 0x1b07b(%rip), %xmm1    # 0x13f15c
divss %xmm1, %xmm0
movss %xmm0, 0x68(%rsp)
cvtsi2ssl 0x44(%rsp), %xmm0
movss 0x1b063(%rip), %xmm1    # 0x13f15c
divss %xmm1, %xmm0
movss %xmm0, 0x64(%rsp)
cvtsi2ssl 0x40(%rsp), %xmm0
movss 0x1b04b(%rip), %xmm1    # 0x13f15c
divss %xmm1, %xmm0
movss %xmm0, 0x60(%rsp)
cvtsi2ssl 0x3c(%rsp), %xmm0
movss 0x1b033(%rip), %xmm1    # 0x13f15c
divss %xmm1, %xmm0
movss %xmm0, 0x5c(%rsp)
cvtsi2ssl 0x38(%rsp), %xmm0
movss 0x1b01b(%rip), %xmm1    # 0x13f15c
divss %xmm1, %xmm0
movss %xmm0, 0x58(%rsp)
cvtsi2ssl 0x34(%rsp), %xmm0
movss 0x1b003(%rip), %xmm1    # 0x13f15c
divss %xmm1, %xmm0
movss %xmm0, 0x54(%rsp)
cvtsi2ssl 0x30(%rsp), %xmm0
movss 0x1afeb(%rip), %xmm1    # 0x13f15c
divss %xmm1, %xmm0
movss %xmm0, 0x50(%rsp)
cmpq $0x0, 0xa0(%rsp)
je 0x1242fc
movq 0xa0(%rsp), %rax
movl 0x8(%rax), %eax
andl $0x800, %eax            # imm = 0x800
cmpl $0x0, %eax
je 0x1242fc
cmpl $0x763e, 0x4c(%rsp)     # imm = 0x763E
jl 0x124263
cmpl $0x7e0e, 0x4c(%rsp)     # imm = 0x7E0E
jg 0x124263
cmpl $0x7c9c, 0x48(%rsp)     # imm = 0x7C9C
jl 0x124263
cmpl $0x846c, 0x48(%rsp)     # imm = 0x846C
jg 0x124263
movslq 0x44(%rsp), %rax
cmpq $0xf618, %rax           # imm = 0xF618
jl 0x124263
movslq 0x44(%rsp), %rax
cmpq $0xfde8, %rax           # imm = 0xFDE8
jg 0x124263
cmpl $0x7d00, 0x40(%rsp)     # imm = 0x7D00
jl 0x124263
cmpl $0x84d0, 0x40(%rsp)     # imm = 0x84D0
jg 0x124263
cmpl $0x7148, 0x3c(%rsp)     # imm = 0x7148
jl 0x124263
cmpl $0x7918, 0x3c(%rsp)     # imm = 0x7918
jg 0x124263
movslq 0x38(%rsp), %rax
cmpq $0xe678, %rax           # imm = 0xE678
jl 0x124263
movslq 0x38(%rsp), %rax
cmpq $0xee48, %rax           # imm = 0xEE48
jg 0x124263
cmpl $0x36b0, 0x34(%rsp)     # imm = 0x36B0
jl 0x124263
cmpl $0x3e80, 0x34(%rsp)     # imm = 0x3E80
jg 0x124263
cmpl $0x1388, 0x30(%rsp)     # imm = 0x1388
jl 0x124263
cmpl $0x1b58, 0x30(%rsp)     # imm = 0x1B58
jle 0x1242f7
movq 0xa8(%rsp), %rdi
leaq 0x1b2af(%rip), %rsi     # 0x13f521
callq 0x113940
movq 0x4ad4a(%rip), %rax     # 0x16efc8
movq (%rax), %rdi
movss 0x6c(%rsp), %xmm0
cvtss2sd %xmm0, %xmm0
movss 0x68(%rsp), %xmm1
cvtss2sd %xmm1, %xmm1
movss 0x64(%rsp), %xmm2
cvtss2sd %xmm2, %xmm2
movss 0x60(%rsp), %xmm3
cvtss2sd %xmm3, %xmm3
leaq 0x1b2a9(%rip), %rsi     # 0x13f559
movb $0x4, %al
callq 0xf730
movq 0x4ad0a(%rip), %rax     # 0x16efc8
movq (%rax), %rdi
movss 0x5c(%rsp), %xmm0
cvtss2sd %xmm0, %xmm0
movss 0x58(%rsp), %xmm1
cvtss2sd %xmm1, %xmm1
movss 0x54(%rsp), %xmm2
cvtss2sd %xmm2, %xmm2
movss 0x50(%rsp), %xmm3
cvtss2sd %xmm3, %xmm3
leaq 0x1b285(%rip), %rsi     # 0x13f575
movb $0x4, %al
callq 0xf730
jmp 0x1243ab
movq 0xa8(%rsp), %rdi
movq 0xa0(%rsp), %rsi
movss 0x6c(%rsp), %xmm0
cvtss2sd %xmm0, %xmm0
movss 0x68(%rsp), %xmm1
cvtss2sd %xmm1, %xmm1
movss 0x64(%rsp), %xmm2
cvtss2sd %xmm2, %xmm2
movss 0x60(%rsp), %xmm3
cvtss2sd %xmm3, %xmm3
movss 0x5c(%rsp), %xmm4
cvtss2sd %xmm4, %xmm4
movss 0x58(%rsp), %xmm5
cvtss2sd %xmm5, %xmm5
movss 0x54(%rsp), %xmm6
cvtss2sd %xmm6, %xmm6
movss 0x50(%rsp), %xmm7
cvtss2sd %xmm7, %xmm7
callq 0xfcbd0
movq 0xa8(%rsp), %rdi
movq 0xa0(%rsp), %rsi
movl 0x4c(%rsp), %edx
movl 0x48(%rsp), %ecx
movl 0x44(%rsp), %r8d
movl 0x40(%rsp), %r9d
movl 0x3c(%rsp), %ebx
movl 0x38(%rsp), %r11d
movl 0x34(%rsp), %r10d
movl 0x30(%rsp), %eax
movl %ebx, (%rsp)
movl %r11d, 0x8(%rsp)
movl %r10d, 0x10(%rsp)
movl %eax, 0x18(%rsp)
callq 0xfce50
addq $0xb0, %rsp
popq %rbx
retq
nopw %cs:(%rax,%rax)