// File: /workspace/github_c_makefile_star2_O0/kilobyte[P]colormatch/color_distance.c
// Function: deltaE2000
double deltaE2000(double *lab1, double *lab2)
{
    double Lstd = *lab1;
    double astd = *(lab1+1);
    double bstd = *(lab1+2);

    double Lsample = *lab2;
    double asample = *(lab2+1);
    double bsample = *(lab2+2);

    double Cabstd= sqrt(astd*astd+bstd*bstd);
    double Cabsample= sqrt(asample*asample+bsample*bsample);

    double Cabarithmean= (Cabstd + Cabsample)/2.0;

    double G= 0.5*( 1.0 - sqrt( pow(Cabarithmean,7.0)/(pow(Cabarithmean,7.0) + pow(25.0,7.0))));

    double apstd= (1.0+G)*astd; // aprime in paper
    double apsample= (1.0+G)*asample; // aprime in paper
    double Cpsample= sqrt(apsample*apsample+bsample*bsample);

    double Cpstd= sqrt(apstd*apstd+bstd*bstd);
    // Compute product of chromas
    double Cpprod= (Cpsample*Cpstd);


    // Ensure hue is between 0 and 2pi
    double hpstd= atan2(bstd,apstd);
    if (hpstd<0) hpstd+= 2.0*pi;  // rollover ones that come -ve

    double hpsample= atan2(bsample,apsample);
    if (hpsample<0) hpsample+= 2.0*pi;
    if ( (fabs(apsample)+fabs(bsample))==0.0)  hpsample= 0.0;

    double dL= (Lsample-Lstd);
    double dC= (Cpsample-Cpstd);

    // Computation of hue difference
    double dhp= (hpsample-hpstd);
    if (dhp>pi)  dhp-= 2.0*pi;
    if (dhp<-pi) dhp+= 2.0*pi;
    // set chroma difference to zero if the product of chromas is zero
    if (Cpprod == 0.0) dhp= 0.0;

    // Note that the defining equations actually need
    // signed Hue and chroma differences which is different
    // from prior color difference formulae

    double dH= 2.0*sqrt(Cpprod)*sin(dhp/2.0);
    //%dH2 = 4*Cpprod.*(sin(dhp/2)).^2;

    // weighting functions
    double Lp= (Lsample+Lstd)/2.0;
    double Cp= (Cpstd+Cpsample)/2.0;

    // Average Hue Computation
    // This is equivalent to that in the paper but simpler programmatically.
    // Note average hue is computed in radians and converted to degrees only
    // where needed
    double hp= (hpstd+hpsample)/2.0;
    // Identify positions for which abs hue diff exceeds 180 degrees
    if ( fabs(hpstd-hpsample)  > pi ) hp-= pi;
    // rollover ones that come -ve
    if (hp<0) hp+= 2.0*pi;

    // Check if one of the chroma values is zero, in which case set
    // mean hue to the sum which is equivalent to other value
    if (Cpprod==0.0) hp= hpsample+hpstd;

    double Lpm502= (Lp-50.0)*(Lp-50.0);;
    double Sl= 1.0+0.015*Lpm502/sqrt(20.0+Lpm502);
    double Sc= 1.0+0.045*Cp;
    double T= 1.0 - 0.17*cos(hp - pi/6.0) + 0.24*cos(2.0*hp) + 0.32*cos(3.0*hp+pi/30.0) - 0.20*cos(4.0*hp-63.0*pi/180.0);
    double Sh= 1.0 + 0.015*Cp*T;
    double delthetarad= (30.0*pi/180.0)*exp(- pow(( (180.0/pi*hp-275.0)/25.0),2.0));
    double Rc=  2.0*sqrt(pow(Cp,7.0)/(pow(Cp,7.0) + pow(25.0,7.0)));
    double RT= -sin(2.0*delthetarad)*Rc;

    // The CIE 00 color difference
    return sqrt( pow((dL/Sl),2.0) + pow((dC/Sc),2.0) + pow((dH/Sh),2.0) + RT*(dC/Sc)*(dH/Sh) );
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x170, %rsp            # imm = 0x170
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rax
movsd (%rax), %xmm0
movsd %xmm0, -0x18(%rbp)
movq -0x8(%rbp), %rax
movsd 0x8(%rax), %xmm0
movsd %xmm0, -0x20(%rbp)
movq -0x8(%rbp), %rax
movsd 0x10(%rax), %xmm0
movsd %xmm0, -0x28(%rbp)
movq -0x10(%rbp), %rax
movsd (%rax), %xmm0
movsd %xmm0, -0x30(%rbp)
movq -0x10(%rbp), %rax
movsd 0x8(%rax), %xmm0
movsd %xmm0, -0x38(%rbp)
movq -0x10(%rbp), %rax
movsd 0x10(%rax), %xmm0
movsd %xmm0, -0x40(%rbp)
movsd -0x20(%rbp), %xmm0
movsd -0x20(%rbp), %xmm2
movsd -0x28(%rbp), %xmm1
mulsd -0x28(%rbp), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
callq 0x10f0
movsd %xmm0, -0x48(%rbp)
movsd -0x38(%rbp), %xmm0
movsd -0x38(%rbp), %xmm2
movsd -0x40(%rbp), %xmm1
mulsd -0x40(%rbp), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
callq 0x10f0
movsd %xmm0, -0x50(%rbp)
movsd -0x48(%rbp), %xmm0
addsd -0x50(%rbp), %xmm0
movsd 0x1b8d(%rip), %xmm1     # 0x30d0
divsd %xmm1, %xmm0
movsd %xmm0, -0x58(%rbp)
movsd -0x58(%rbp), %xmm0
movsd 0x1b6f(%rip), %xmm1     # 0x30c8
callq 0x1040
movsd %xmm0, -0x118(%rbp)
movsd -0x58(%rbp), %xmm0
movsd 0x1b55(%rip), %xmm1     # 0x30c8
callq 0x1040
movsd %xmm0, -0x120(%rbp)
movsd 0x1b38(%rip), %xmm0     # 0x30c0
movsd 0x1b38(%rip), %xmm1     # 0x30c8
callq 0x1040
movsd -0x120(%rbp), %xmm1
movaps %xmm0, %xmm2
movsd -0x118(%rbp), %xmm0
addsd %xmm2, %xmm1
divsd %xmm1, %xmm0
callq 0x10f0
movsd 0x1af3(%rip), %xmm1     # 0x30b0
subsd %xmm0, %xmm1
movsd 0x1aef(%rip), %xmm0     # 0x30b8
mulsd %xmm1, %xmm0
movsd %xmm0, -0x60(%rbp)
movsd 0x1ad6(%rip), %xmm0     # 0x30b0
addsd -0x60(%rbp), %xmm0
mulsd -0x20(%rbp), %xmm0
movsd %xmm0, -0x68(%rbp)
movsd 0x1abf(%rip), %xmm0     # 0x30b0
addsd -0x60(%rbp), %xmm0
mulsd -0x38(%rbp), %xmm0
movsd %xmm0, -0x70(%rbp)
movsd -0x70(%rbp), %xmm0
movsd -0x70(%rbp), %xmm2
movsd -0x40(%rbp), %xmm1
mulsd -0x40(%rbp), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
callq 0x10f0
movsd %xmm0, -0x78(%rbp)
movsd -0x68(%rbp), %xmm0
movsd -0x68(%rbp), %xmm2
movsd -0x28(%rbp), %xmm1
mulsd -0x28(%rbp), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
callq 0x10f0
movsd %xmm0, -0x80(%rbp)
movsd -0x78(%rbp), %xmm0
mulsd -0x80(%rbp), %xmm0
movsd %xmm0, -0x88(%rbp)
movsd -0x28(%rbp), %xmm0
movsd -0x68(%rbp), %xmm1
callq 0x10a0
movsd %xmm0, -0x90(%rbp)
xorps %xmm0, %xmm0
ucomisd -0x90(%rbp), %xmm0
jbe 0x169a
movsd 0x1a4e(%rip), %xmm0     # 0x30d8
addsd -0x90(%rbp), %xmm0
movsd %xmm0, -0x90(%rbp)
movsd -0x40(%rbp), %xmm0
movsd -0x70(%rbp), %xmm1
callq 0x10a0
movsd %xmm0, -0x98(%rbp)
xorps %xmm0, %xmm0
ucomisd -0x98(%rbp), %xmm0
jbe 0x16d6
movsd 0x1a12(%rip), %xmm0     # 0x30d8
addsd -0x98(%rbp), %xmm0
movsd %xmm0, -0x98(%rbp)
movsd -0x70(%rbp), %xmm0
movaps 0x1b4e(%rip), %xmm1     # 0x3230
pand %xmm1, %xmm0
movsd -0x40(%rbp), %xmm1
movaps 0x1b3e(%rip), %xmm2     # 0x3230
pand %xmm2, %xmm1
addsd %xmm1, %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0x1710
jp 0x1710
xorps %xmm0, %xmm0
movsd %xmm0, -0x98(%rbp)
movsd -0x30(%rbp), %xmm0
subsd -0x18(%rbp), %xmm0
movsd %xmm0, -0xa0(%rbp)
movsd -0x78(%rbp), %xmm0
subsd -0x80(%rbp), %xmm0
movsd %xmm0, -0xa8(%rbp)
movsd -0x98(%rbp), %xmm0
subsd -0x90(%rbp), %xmm0
movsd %xmm0, -0xb0(%rbp)
movsd -0xb0(%rbp), %xmm0
movsd 0x1984(%rip), %xmm1     # 0x30e0
ucomisd %xmm1, %xmm0
jbe 0x177e
movsd -0xb0(%rbp), %xmm0
movsd 0x1966(%rip), %xmm1     # 0x30d8
subsd %xmm1, %xmm0
movsd %xmm0, -0xb0(%rbp)
movsd 0x1962(%rip), %xmm0     # 0x30e8
ucomisd -0xb0(%rbp), %xmm0
jbe 0x17a8
movsd 0x1940(%rip), %xmm0     # 0x30d8
addsd -0xb0(%rbp), %xmm0
movsd %xmm0, -0xb0(%rbp)
movsd -0x88(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0x17c6
jp 0x17c6
xorps %xmm0, %xmm0
movsd %xmm0, -0xb0(%rbp)
movsd -0x88(%rbp), %xmm0
callq 0x10f0
movaps %xmm0, %xmm1
movsd 0x18f2(%rip), %xmm0     # 0x30d0
mulsd %xmm1, %xmm0
movsd %xmm0, -0x128(%rbp)
movsd -0xb0(%rbp), %xmm0
movsd 0x18d6(%rip), %xmm1     # 0x30d0
divsd %xmm1, %xmm0
callq 0x10d0
movaps %xmm0, %xmm1
movsd -0x128(%rbp), %xmm0
mulsd %xmm1, %xmm0
movsd %xmm0, -0xb8(%rbp)
movsd -0x30(%rbp), %xmm0
addsd -0x18(%rbp), %xmm0
movsd 0x18a4(%rip), %xmm1     # 0x30d0
divsd %xmm1, %xmm0
movsd %xmm0, -0xc0(%rbp)
movsd -0x80(%rbp), %xmm0
addsd -0x78(%rbp), %xmm0
movsd 0x1886(%rip), %xmm1     # 0x30d0
divsd %xmm1, %xmm0
movsd %xmm0, -0xc8(%rbp)
movsd -0x90(%rbp), %xmm0
addsd -0x98(%rbp), %xmm0
movsd 0x1862(%rip), %xmm1     # 0x30d0
divsd %xmm1, %xmm0
movsd %xmm0, -0xd0(%rbp)
movsd -0x90(%rbp), %xmm0
subsd -0x98(%rbp), %xmm0
movaps 0x199f(%rip), %xmm1     # 0x3230
pand %xmm1, %xmm0
movsd 0x1843(%rip), %xmm1     # 0x30e0
ucomisd %xmm1, %xmm0
jbe 0x18bf
movsd -0xd0(%rbp), %xmm0
movsd 0x182d(%rip), %xmm1     # 0x30e0
subsd %xmm1, %xmm0
movsd %xmm0, -0xd0(%rbp)
xorps %xmm0, %xmm0
ucomisd -0xd0(%rbp), %xmm0
jbe 0x18e4
movsd 0x1804(%rip), %xmm0     # 0x30d8
addsd -0xd0(%rbp), %xmm0
movsd %xmm0, -0xd0(%rbp)
movsd -0x88(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0x190f
jp 0x190f
movsd -0x98(%rbp), %xmm0
addsd -0x90(%rbp), %xmm0
movsd %xmm0, -0xd0(%rbp)
movsd -0xc0(%rbp), %xmm0
movsd 0x1841(%rip), %xmm1     # 0x3160
subsd %xmm1, %xmm0
movsd -0xc0(%rbp), %xmm1
movsd 0x182d(%rip), %xmm2     # 0x3160
subsd %xmm2, %xmm1
mulsd %xmm1, %xmm0
movsd %xmm0, -0xd8(%rbp)
movsd 0x17bd(%rip), %xmm0     # 0x3108
mulsd -0xd8(%rbp), %xmm0
movsd %xmm0, -0x168(%rbp)
movsd 0x17f5(%rip), %xmm0     # 0x3158
addsd -0xd8(%rbp), %xmm0
callq 0x10f0
movsd -0x168(%rbp), %xmm1
divsd %xmm0, %xmm1
movsd 0x172c(%rip), %xmm0     # 0x30b0
addsd %xmm1, %xmm0
movsd %xmm0, -0xe0(%rbp)
movsd -0xc8(%rbp), %xmm0
movsd 0x17b0(%rip), %xmm1     # 0x3150
mulsd %xmm1, %xmm0
movsd 0x1704(%rip), %xmm1     # 0x30b0
addsd %xmm1, %xmm0
movsd %xmm0, -0xe8(%rbp)
movsd -0xd0(%rbp), %xmm0
movsd 0x1728(%rip), %xmm1     # 0x30f0
subsd %xmm1, %xmm0
callq 0x1070
movsd 0x176f(%rip), %xmm1     # 0x3148
mulsd %xmm1, %xmm0
movsd 0x16cb(%rip), %xmm1     # 0x30b0
addsd %xmm1, %xmm0
movsd %xmm0, -0x160(%rbp)
movsd 0x16d7(%rip), %xmm0     # 0x30d0
mulsd -0xd0(%rbp), %xmm0
callq 0x1070
movsd -0x160(%rbp), %xmm1
movsd 0x172a(%rip), %xmm2     # 0x3140
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x158(%rbp)
movsd -0xd0(%rbp), %xmm0
movsd 0x16fa(%rip), %xmm1     # 0x3130
mulsd %xmm1, %xmm0
movsd 0x16f6(%rip), %xmm1     # 0x3138
addsd %xmm1, %xmm0
callq 0x1070
movsd -0x158(%rbp), %xmm1
movsd 0x16cd(%rip), %xmm2     # 0x3128
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x150(%rbp)
movsd -0xd0(%rbp), %xmm0
movsd 0x169d(%rip), %xmm1     # 0x3118
mulsd %xmm1, %xmm0
movsd 0x1699(%rip), %xmm1     # 0x3120
addsd %xmm1, %xmm0
callq 0x1070
movsd -0x150(%rbp), %xmm1
movsd 0x1670(%rip), %xmm2     # 0x3110
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0xf0(%rbp)
movsd 0x1650(%rip), %xmm0     # 0x3108
mulsd -0xc8(%rbp), %xmm0
movsd -0xf0(%rbp), %xmm1
mulsd %xmm1, %xmm0
movsd 0x15dc(%rip), %xmm1     # 0x30b0
addsd %xmm1, %xmm0
movsd %xmm0, -0xf8(%rbp)
movsd -0xd0(%rbp), %xmm0
movsd 0x1608(%rip), %xmm1     # 0x30f8
mulsd %xmm1, %xmm0
movsd 0x1604(%rip), %xmm1     # 0x3100
addsd %xmm1, %xmm0
movsd 0x15b8(%rip), %xmm1     # 0x30c0
divsd %xmm1, %xmm0
movsd 0x15bc(%rip), %xmm1     # 0x30d0
callq 0x1040
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
callq 0x1100
movaps %xmm0, %xmm1
movsd 0x15b0(%rip), %xmm0     # 0x30f0
mulsd %xmm1, %xmm0
movsd %xmm0, -0x100(%rbp)
movsd -0xc8(%rbp), %xmm0
movsd 0x156c(%rip), %xmm1     # 0x30c8
callq 0x1040
movsd %xmm0, -0x140(%rbp)
movsd -0xc8(%rbp), %xmm0
movsd 0x154f(%rip), %xmm1     # 0x30c8
callq 0x1040
movsd %xmm0, -0x148(%rbp)
movsd 0x1532(%rip), %xmm0     # 0x30c0
movsd 0x1532(%rip), %xmm1     # 0x30c8
callq 0x1040
movsd -0x148(%rbp), %xmm1
movaps %xmm0, %xmm2
movsd -0x140(%rbp), %xmm0
addsd %xmm2, %xmm1
divsd %xmm1, %xmm0
callq 0x10f0
movaps %xmm0, %xmm1
movsd 0x150a(%rip), %xmm0     # 0x30d0
mulsd %xmm1, %xmm0
movsd %xmm0, -0x108(%rbp)
movsd 0x14f6(%rip), %xmm0     # 0x30d0
mulsd -0x100(%rbp), %xmm0
callq 0x10d0
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
mulsd -0x108(%rbp), %xmm0
movsd %xmm0, -0x110(%rbp)
movsd -0xa0(%rbp), %xmm0
divsd -0xe0(%rbp), %xmm0
movsd 0x14aa(%rip), %xmm1     # 0x30d0
callq 0x1040
movsd %xmm0, -0x138(%rbp)
movsd -0xa8(%rbp), %xmm0
divsd -0xe8(%rbp), %xmm0
movsd 0x1485(%rip), %xmm1     # 0x30d0
callq 0x1040
movaps %xmm0, %xmm1
movsd -0x138(%rbp), %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x130(%rbp)
movsd -0xb8(%rbp), %xmm0
divsd -0xf8(%rbp), %xmm0
movsd 0x1451(%rip), %xmm1     # 0x30d0
callq 0x1040
movsd -0x130(%rbp), %xmm1
addsd %xmm0, %xmm1
movsd -0x110(%rbp), %xmm0
movsd -0xa8(%rbp), %xmm2
divsd -0xe8(%rbp), %xmm2
mulsd %xmm2, %xmm0
movsd -0xb8(%rbp), %xmm2
divsd -0xf8(%rbp), %xmm2
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
callq 0x10f0
addq $0x170, %rsp            # imm = 0x170
popq %rbp
retq
nopw %cs:(%rax,%rax)