// File: /workspace/github_cpp_makefile_star2_O2/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 %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movl %edx, %ebp
movq %rsi, %r14
movq %rdi, %rbx
movl 0x11c(%rdi), %eax
testb $0x1, %al
jne 0x8c260
leaq 0x17739(%rip), %rsi     # 0xa3846
movq %rbx, %rdi
callq 0x849c0
testq %r14, %r14
je 0x8c134
movl $0x804, %eax            # imm = 0x804
andl 0x8(%r14), %eax
cmpl $0x4, %eax
jne 0x8c134
leaq 0x17761(%rip), %rsi     # 0xa3890
jmp 0x8c290
cmpl $0x20, %ebp
jne 0x8c280
leaq 0x30(%rsp), %rsi
pushq $0x20
popq %rdx
movq %rbx, %rdi
callq 0x8b6d7
movq %rbx, %rdi
xorl %esi, %esi
callq 0x8b703
testl %eax, %eax
jne 0x8c324
movl 0x30(%rsp), %r13d
movl 0x34(%rsp), %r12d
bswapl %r13d
bswapl %r12d
movl 0x38(%rsp), %r15d
bswapl %r15d
movl 0x3c(%rsp), %ebp
bswapl %ebp
movl 0x40(%rsp), %esi
bswapl %esi
movl 0x44(%rsp), %edx
bswapl %edx
movl 0x48(%rsp), %ecx
bswapl %ecx
movl 0x4c(%rsp), %eax
cvtsi2ss %r13d, %xmm1
bswapl %eax
cvtsi2ss %r12d, %xmm2
movss 0x17355(%rip), %xmm0    # 0xa34fc
cvtsi2ss %r15d, %xmm3
divss %xmm0, %xmm1
cvtsi2ss %ebp, %xmm8
divss %xmm0, %xmm2
cvtsi2ss %esi, %xmm4
divss %xmm0, %xmm3
cvtsi2ss %edx, %xmm5
divss %xmm0, %xmm8
cvtsi2ss %ecx, %xmm6
divss %xmm0, %xmm4
cvtsi2ss %eax, %xmm7
divss %xmm0, %xmm5
divss %xmm0, %xmm6
divss %xmm0, %xmm7
testq %r14, %r14
je 0x8c1f2
testb $0x8, 0x9(%r14)
jne 0x8c2b0
cvtss2sd %xmm1, %xmm0
cvtss2sd %xmm2, %xmm1
cvtss2sd %xmm3, %xmm2
cvtss2sd %xmm8, %xmm3
cvtss2sd %xmm4, %xmm4
cvtss2sd %xmm5, %xmm5
cvtss2sd %xmm6, %xmm6
cvtss2sd %xmm7, %xmm7
movq %rbx, %rdi
movq %rsi, 0x18(%rsp)
movq %r14, %rsi
movq %rax, (%rsp)
movq %rcx, 0x8(%rsp)
movq %rdx, 0x10(%rsp)
callq 0x7ad3c
movq %rbx, %rdi
movq %r14, %rsi
movl %r13d, %edx
movl %r12d, %ecx
movl %r15d, %r8d
movl %ebp, %r9d
pushq (%rsp)
pushq 0x10(%rsp)
pushq 0x20(%rsp)
pushq 0x30(%rsp)
callq 0x7ade5
addq $0x20, %rsp
jmp 0x8c324
testb $0x4, %al
jne 0x8c289
testb $0x2, %al
je 0x8c115
leaq 0x17604(%rip), %rsi     # 0xa3877
movq %rbx, %rdi
callq 0x84a53
jmp 0x8c115
leaq 0x1761e(%rip), %rsi     # 0xa38a5
jmp 0x8c290
leaq 0x175cf(%rip), %rsi     # 0xa385f
movq %rbx, %rdi
callq 0x84a53
movq %rbx, %rdi
movl %ebp, %esi
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x8b703
addl $0xffff81f1, %r13d      # imm = 0xFFFF81F1
cmpl $0xfffff82f, %r13d      # imm = 0xFFFFF82F
jb 0x8c333
addl $0xffff7b93, %r12d      # imm = 0xFFFF7B93
cmpl $0xfffff82f, %r12d      # imm = 0xFFFFF82F
jb 0x8c333
addl $0xffff0217, %r15d      # imm = 0xFFFF0217
cmpl $0xfffff82f, %r15d      # imm = 0xFFFFF82F
jb 0x8c333
addl $0xffff7b2f, %ebp       # imm = 0xFFFF7B2F
cmpl $0xfffff82f, %ebp       # imm = 0xFFFFF82F
jb 0x8c333
addl $0xffff86e7, %esi       # imm = 0xFFFF86E7
cmpl $0xfffff82f, %esi       # imm = 0xFFFFF82F
jb 0x8c333
addl $0xffff11b7, %edx       # imm = 0xFFFF11B7
cmpl $0xfffff82f, %edx       # imm = 0xFFFFF82F
jb 0x8c333
addl $0xffffc17f, %ecx       # imm = 0xFFFFC17F
cmpl $0xfffff82f, %ecx       # imm = 0xFFFFF82F
jb 0x8c333
addl $0xffffe4a7, %eax       # imm = 0xFFFFE4A7
cmpl $0xfffff82e, %eax       # imm = 0xFFFFF82E
jbe 0x8c333
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x17587(%rip), %rsi     # 0xa38c1
movq %rbx, %rdi
movss %xmm4, (%rsp)
movss %xmm5, 0x8(%rsp)
movss %xmm1, 0x24(%rsp)
movss %xmm6, 0x10(%rsp)
movss %xmm7, 0x18(%rsp)
movss %xmm2, 0x20(%rsp)
movss %xmm3, 0x28(%rsp)
movss %xmm8, 0x2c(%rsp)
callq 0x84a53
movq 0x4dc47(%rip), %rbx     # 0xd9fc0
movq (%rbx), %rdi
cvtss2sd 0x24(%rsp), %xmm0
cvtss2sd 0x20(%rsp), %xmm1
cvtss2sd 0x28(%rsp), %xmm2
cvtss2sd 0x2c(%rsp), %xmm3
leaq 0x1755e(%rip), %rsi     # 0xa38f9
movb $0x4, %al
callq 0xe6a0
movq (%rbx), %rdi
cvtss2sd (%rsp), %xmm0
cvtss2sd 0x8(%rsp), %xmm1
cvtss2sd 0x10(%rsp), %xmm2
cvtss2sd 0x18(%rsp), %xmm3
leaq 0x17552(%rip), %rsi     # 0xa3915
movb $0x4, %al
callq 0xe6a0
jmp 0x8c324