// File: /workspace/github_cpp_makefile_star2_O1/tomfunkhouser[P]gaps/pkgs/png/png.c
// Function: png_check_cHRM_fixed
int /* PRIVATE */
png_check_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)
{
   int ret = 1;
   unsigned long xy_hi,xy_lo,yx_hi,yx_lo;

   png_debug(1, "in function png_check_cHRM_fixed");

   if (png_ptr == NULL)
      return 0;

   if (white_x < 0 || white_y <= 0 ||
         red_x < 0 ||   red_y <  0 ||
       green_x < 0 || green_y <  0 ||
        blue_x < 0 ||  blue_y <  0)
   {
      png_warning(png_ptr,
        "Ignoring attempt to set negative chromaticity value");
      ret = 0;
   }
   if (white_x > (png_fixed_point) PNG_UINT_31_MAX ||
       white_y > (png_fixed_point) PNG_UINT_31_MAX ||
         red_x > (png_fixed_point) PNG_UINT_31_MAX ||
         red_y > (png_fixed_point) PNG_UINT_31_MAX ||
       green_x > (png_fixed_point) PNG_UINT_31_MAX ||
       green_y > (png_fixed_point) PNG_UINT_31_MAX ||
        blue_x > (png_fixed_point) PNG_UINT_31_MAX ||
        blue_y > (png_fixed_point) PNG_UINT_31_MAX )
   {
      png_warning(png_ptr,
        "Ignoring attempt to set chromaticity value exceeding 21474.83");
      ret = 0;
   }
   if (white_x > 100000L - white_y)
   {
      png_warning(png_ptr, "Invalid cHRM white point");
      ret = 0;
   }
   if (red_x > 100000L - red_y)
   {
      png_warning(png_ptr, "Invalid cHRM red point");
      ret = 0;
   }
   if (green_x > 100000L - green_y)
   {
      png_warning(png_ptr, "Invalid cHRM green point");
      ret = 0;
   }
   if (blue_x > 100000L - blue_y)
   {
      png_warning(png_ptr, "Invalid cHRM blue point");
      ret = 0;
   }

   png_64bit_product(green_x - red_x, blue_y - red_y, &xy_hi, &xy_lo);
   png_64bit_product(green_y - red_y, blue_x - red_x, &yx_hi, &yx_lo);

   if (xy_hi == yx_hi && xy_lo == yx_lo)
   {
      png_warning(png_ptr,
         "Ignoring attempt to set cHRM RGB triangle with zero area");
      ret = 0;
   }

   return ret;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl %ecx, 0xc(%rsp)
xorl %eax, %eax
movq %rdi, 0x10(%rsp)
testq %rdi, %rdi
je 0x88517
movl %r9d, %r15d
movl %edx, %r12d
movl %esi, %r13d
movl 0x60(%rsp), %r14d
movl 0x58(%rsp), %ebp
movl 0x50(%rsp), %ebx
testl %edx, %edx
movl %r8d, 0x8(%rsp)
jle 0x883a4
movl 0xc(%rsp), %eax
orl %r13d, %eax
movl %r8d, %ecx
orl %r15d, %ecx
orl %eax, %ecx
orl %ebx, %ecx
movl %ebp, %eax
orl %r14d, %eax
orl %ecx, %eax
movl $0x1, %eax
jns 0x883bc
leaq 0x23d89(%rip), %rsi     # 0xac134
movq 0x10(%rsp), %rdi
callq 0x92e6e
movl 0x8(%rsp), %r8d
xorl %eax, %eax
movslq %r13d, %rcx
movslq %r12d, %rdx
movl $0x186a0, %r12d         # imm = 0x186A0
movl $0x186a0, %esi          # imm = 0x186A0
subq %rdx, %rsi
cmpq %rcx, %rsi
movq 0x10(%rsp), %r13
jge 0x883f0
leaq 0x23d87(%rip), %rsi     # 0xac168
movq %r13, %rdi
callq 0x92e6e
movl 0x8(%rsp), %r8d
xorl %eax, %eax
movslq 0xc(%rsp), %rcx
movslq %r8d, %rdx
subq %rdx, %r12
cmpq %rcx, %r12
jge 0x88411
leaq 0x23d7a(%rip), %rsi     # 0xac181
movq %r13, %rdi
callq 0x92e6e
xorl %eax, %eax
movslq %r15d, %rcx
movslq %ebx, %rdx
movl $0x186a0, %r12d         # imm = 0x186A0
movl $0x186a0, %esi          # imm = 0x186A0
subq %rdx, %rsi
cmpq %rcx, %rsi
jge 0x8843b
leaq 0x23d67(%rip), %rsi     # 0xac198
movq %r13, %rdi
callq 0x92e6e
xorl %eax, %eax
movslq %ebp, %rcx
movslq %r14d, %rdx
subq %rdx, %r12
cmpq %rcx, %r12
jge 0x8845a
leaq 0x23d61(%rip), %rsi     # 0xac1b1
movq %r13, %rdi
callq 0x92e6e
xorl %eax, %eax
movl 0xc(%rsp), %r10d
subl %r10d, %r15d
movl 0x8(%rsp), %r11d
subl %r11d, %r14d
movl %r15d, %r8d
shrl $0x10, %r8d
movl $0xffff, %ecx           # imm = 0xFFFF
andl %ecx, %r15d
movl %r14d, %edi
shrl $0x10, %edi
andl %ecx, %r14d
movl %r14d, %esi
imull %r15d, %esi
imull %r8d, %r14d
imull %edi, %r15d
addl %r14d, %r15d
movl %esi, %edx
shrl $0x10, %edx
addq %r15, %rdx
movq %rdx, %r9
shrq $0x10, %r9
imull %r8d, %edi
addq %r9, %rdi
subl %r11d, %ebx
subl %r10d, %ebp
movl %ebx, %r10d
shrl $0x10, %r10d
andl %ecx, %ebx
movl %ebp, %r11d
shrl $0x10, %r11d
andl %ecx, %ebp
movl %ebp, %r8d
imull %ebx, %r8d
imull %r10d, %ebp
imull %r11d, %ebx
addl %ebp, %ebx
movl %r8d, %r9d
shrl $0x10, %r9d
addq %rbx, %r9
movq %r9, %rbx
shrq $0x10, %rbx
imull %r10d, %r11d
addq %rbx, %r11
cmpq %r11, %rdi
jne 0x88517
andl %ecx, %esi
shll $0x10, %edx
orl %esi, %edx
andl %ecx, %r8d
shll $0x10, %r9d
orl %r8d, %r9d
cmpl %r9d, %edx
jne 0x88517
leaq 0x23cbc(%rip), %rsi     # 0xac1c9
movq %r13, %rdi
callq 0x92e6e
xorl %eax, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq