// File: jmmccracken[P]PAI/ccmsrc.cpp
// Function: Pcorr(double*, double*, int)
double Pcorr(double dX[],double dY[],int iXY_length){

    double dEX = 0,  //expectation value of X
           dEY = 0,  //expectation value of Y
           dEXdelta,  //distance from mean for point in X
           dEYdelta,  //distance from mean for point in Y
           dSX = 0,  //variance of X
           dSY = 0,  //variance of Y
           dSXY = 0,  //covariance of X and Y
           dCovNorm;  //normalization factor for the covariance

    for(int iter = 0;iter < iXY_length;iter++ ){
        dEX += dX[iter];
        dEY += dY[iter];
    }

    dEX /= iXY_length;
    dEY /= iXY_length;

    for(int iter = 0;iter < iXY_length;iter++ ){
        dEXdelta = dX[iter]-dEX;
        dEYdelta = dY[iter]-dEY;
        dSX += dEXdelta*dEXdelta;
        dSY += dEYdelta*dEYdelta;
        dSXY += dEXdelta*dEYdelta;
    }

    dCovNorm = sqrt(dSX*dSY);
    if( dCovNorm == 0 ){
        dCovNorm = nan("");
        fprintf(stderr, "Warning in Pcorr(): division by zero\n");
    }

    return(dSXY/dCovNorm);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x20(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x28(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x40(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x48(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x50(%rbp)
movl $0x0, -0x5c(%rbp)
movl -0x5c(%rbp), %eax
cmpl -0x14(%rbp), %eax
jge 0x37f3
movq -0x8(%rbp), %rax
movslq -0x5c(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
addsd -0x20(%rbp), %xmm0
movsd %xmm0, -0x20(%rbp)
movq -0x10(%rbp), %rax
movslq -0x5c(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
addsd -0x28(%rbp), %xmm0
movsd %xmm0, -0x28(%rbp)
movl -0x5c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x5c(%rbp)
jmp 0x37b2
cvtsi2sdl -0x14(%rbp), %xmm1
movsd -0x20(%rbp), %xmm0
divsd %xmm1, %xmm0
movsd %xmm0, -0x20(%rbp)
cvtsi2sdl -0x14(%rbp), %xmm1
movsd -0x28(%rbp), %xmm0
divsd %xmm1, %xmm0
movsd %xmm0, -0x28(%rbp)
movl $0x0, -0x60(%rbp)
movl -0x60(%rbp), %eax
cmpl -0x14(%rbp), %eax
jge 0x38bc
movq -0x8(%rbp), %rax
movslq -0x60(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
subsd -0x20(%rbp), %xmm0
movsd %xmm0, -0x30(%rbp)
movq -0x10(%rbp), %rax
movslq -0x60(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
subsd -0x28(%rbp), %xmm0
movsd %xmm0, -0x38(%rbp)
movsd -0x30(%rbp), %xmm0
movsd -0x30(%rbp), %xmm2
movsd -0x40(%rbp), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x40(%rbp)
movsd -0x38(%rbp), %xmm0
movsd -0x38(%rbp), %xmm2
movsd -0x48(%rbp), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x48(%rbp)
movsd -0x30(%rbp), %xmm0
movsd -0x38(%rbp), %xmm2
movsd -0x50(%rbp), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x50(%rbp)
movl -0x60(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x60(%rbp)
jmp 0x3820
movsd -0x40(%rbp), %xmm0
mulsd -0x48(%rbp), %xmm0
callq 0x3190
movsd %xmm0, -0x58(%rbp)
movsd -0x58(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0x3909
jp 0x3909
leaq 0xdcb3(%rip), %rdi      # 0x1159a
callq 0x3060
movsd %xmm0, -0x58(%rbp)
movq 0x156d0(%rip), %rax     # 0x18fc8
movq (%rax), %rdi
leaq 0xcc0a(%rip), %rsi      # 0x1050c
movb $0x0, %al
callq 0x32a0
movsd -0x50(%rbp), %xmm0
divsd -0x58(%rbp), %xmm0
addq $0x60, %rsp
popq %rbp
retq
nopl (%rax)