// File: /workspace/github_c_makefile_star2_O0/jonof[P]jftekwar/jfbuild/libsquish/maths.cpp
// Function: squish::ComputeWeightedCovariance(int, squish::Vec3 const*, float const*)
Sym3x3 ComputeWeightedCovariance( int n, Vec3 const* points, float const* weights )
{
    // compute the centroid
    float total = 0.0f;
    Vec3 centroid( 0.0f );
    for( int i = 0; i < n; ++i )
    {
        total += weights[i];
        centroid += weights[i]*points[i];
    }
    if( total > FLT_EPSILON )
        centroid /= total;

    // accumulate the covariance matrix
    Sym3x3 covariance( 0.0f );
    for( int i = 0; i < n; ++i )
    {
        Vec3 a = points[i] - centroid;
        Vec3 b = weights[i]*a;

        covariance[0] += a.X()*b.X();
        covariance[1] += a.X()*b.Y();
        covariance[2] += a.X()*b.Z();
        covariance[3] += a.Y()*b.Y();
        covariance[4] += a.Y()*b.Z();
        covariance[5] += a.Z()*b.Z();
    }

    // return it
    return covariance;
}

// Assembly:
subq $0xc8, %rsp
movq %rdi, 0x30(%rsp)
movq %rdi, 0x38(%rsp)
movl %esi, 0xc4(%rsp)
movq %rdx, 0xb8(%rsp)
movq %rcx, 0xb0(%rsp)
xorps %xmm0, %xmm0
movss %xmm0, 0xac(%rsp)
leaq 0xa0(%rsp), %rdi
xorps %xmm0, %xmm0
callq 0xad380
movl $0x0, 0x9c(%rsp)
movl 0x9c(%rsp), %eax
cmpl 0xc4(%rsp), %eax
jge 0xacd13
movq 0xb0(%rsp), %rax
movslq 0x9c(%rsp), %rcx
movss (%rax,%rcx,4), %xmm1
movss 0xac(%rsp), %xmm0
addss %xmm1, %xmm0
movss %xmm0, 0xac(%rsp)
movq 0xb0(%rsp), %rax
movslq 0x9c(%rsp), %rcx
movss (%rax,%rcx,4), %xmm0
movq 0xb8(%rsp), %rax
leaq (%rcx,%rcx,2), %rcx
leaq (%rax,%rcx,4), %rdi
callq 0xad3c0
movss %xmm1, 0x88(%rsp)
movlpd %xmm0, 0x80(%rsp)
movq 0x80(%rsp), %rax
movq %rax, 0x90(%rsp)
movl 0x88(%rsp), %eax
movl %eax, 0x98(%rsp)
leaq 0xa0(%rsp), %rdi
leaq 0x90(%rsp), %rsi
callq 0xad430
movl 0x9c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x9c(%rsp)
jmp 0xacc4f
movss 0xac(%rsp), %xmm0
movss 0xdd78(%rip), %xmm1     # 0xbaa9c
ucomiss %xmm1, %xmm0
jbe 0xacd3f
movss 0xac(%rsp), %xmm0
leaq 0xa0(%rsp), %rdi
callq 0xad480
movq 0x30(%rsp), %rdi
xorps %xmm0, %xmm0
callq 0xad4e0
movl $0x0, 0x7c(%rsp)
movl 0x7c(%rsp), %eax
cmpl 0xc4(%rsp), %eax
jge 0xacfac
movq 0xb8(%rsp), %rax
movslq 0x7c(%rsp), %rcx
leaq (%rcx,%rcx,2), %rcx
leaq (%rax,%rcx,4), %rdi
leaq 0xa0(%rsp), %rsi
callq 0xad530
movss %xmm1, 0x68(%rsp)
movlpd %xmm0, 0x60(%rsp)
movl 0x68(%rsp), %eax
movl %eax, 0x78(%rsp)
movq 0x60(%rsp), %rax
movq %rax, 0x70(%rsp)
movq 0xb0(%rsp), %rax
movslq 0x7c(%rsp), %rcx
movss (%rax,%rcx,4), %xmm0
leaq 0x70(%rsp), %rdi
callq 0xad3c0
movss %xmm1, 0x48(%rsp)
movlpd %xmm0, 0x40(%rsp)
movq 0x40(%rsp), %rax
movq %rax, 0x54(%rsp)
movl 0x48(%rsp), %eax
movl %eax, 0x5c(%rsp)
leaq 0x70(%rsp), %rdi
callq 0xab550
movss %xmm0, (%rsp)
leaq 0x54(%rsp), %rdi
callq 0xab550
movq 0x30(%rsp), %rdi
movss %xmm0, 0x4(%rsp)
xorl %esi, %esi
callq 0xad5a0
movss (%rsp), %xmm0
movss 0x4(%rsp), %xmm2
movss (%rax), %xmm1
mulss %xmm2, %xmm0
addss %xmm1, %xmm0
movss %xmm0, (%rax)
leaq 0x70(%rsp), %rdi
callq 0xab550
movss %xmm0, 0x8(%rsp)
leaq 0x54(%rsp), %rdi
callq 0xab560
movq 0x30(%rsp), %rdi
movss %xmm0, 0xc(%rsp)
movl $0x1, %esi
callq 0xad5a0
movss 0x8(%rsp), %xmm0
movss 0xc(%rsp), %xmm2
movss (%rax), %xmm1
mulss %xmm2, %xmm0
addss %xmm1, %xmm0
movss %xmm0, (%rax)
leaq 0x70(%rsp), %rdi
callq 0xab550
movss %xmm0, 0x10(%rsp)
leaq 0x54(%rsp), %rdi
callq 0xab570
movq 0x30(%rsp), %rdi
movss %xmm0, 0x14(%rsp)
movl $0x2, %esi
callq 0xad5a0
movss 0x10(%rsp), %xmm0
movss 0x14(%rsp), %xmm2
movss (%rax), %xmm1
mulss %xmm2, %xmm0
addss %xmm1, %xmm0
movss %xmm0, (%rax)
leaq 0x70(%rsp), %rdi
callq 0xab560
movss %xmm0, 0x18(%rsp)
leaq 0x54(%rsp), %rdi
callq 0xab560
movq 0x30(%rsp), %rdi
movss %xmm0, 0x1c(%rsp)
movl $0x3, %esi
callq 0xad5a0
movss 0x18(%rsp), %xmm0
movss 0x1c(%rsp), %xmm2
movss (%rax), %xmm1
mulss %xmm2, %xmm0
addss %xmm1, %xmm0
movss %xmm0, (%rax)
leaq 0x70(%rsp), %rdi
callq 0xab560
movss %xmm0, 0x20(%rsp)
leaq 0x54(%rsp), %rdi
callq 0xab570
movq 0x30(%rsp), %rdi
movss %xmm0, 0x24(%rsp)
movl $0x4, %esi
callq 0xad5a0
movss 0x20(%rsp), %xmm0
movss 0x24(%rsp), %xmm2
movss (%rax), %xmm1
mulss %xmm2, %xmm0
addss %xmm1, %xmm0
movss %xmm0, (%rax)
leaq 0x70(%rsp), %rdi
callq 0xab570
movss %xmm0, 0x28(%rsp)
leaq 0x54(%rsp), %rdi
callq 0xab570
movq 0x30(%rsp), %rdi
movss %xmm0, 0x2c(%rsp)
movl $0x5, %esi
callq 0xad5a0
movss 0x28(%rsp), %xmm0
movss 0x2c(%rsp), %xmm2
movss (%rax), %xmm1
mulss %xmm2, %xmm0
addss %xmm1, %xmm0
movss %xmm0, (%rax)
movl 0x7c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x7c(%rsp)
jmp 0xacd54
movq 0x38(%rsp), %rax
addq $0xc8, %rsp
retq
nopl (%rax)