// File: /workspace/github_c_makefile_star2_O0/jonof[P]jftekwar/jfbuild/libsquish/clusterfit.cpp
// Function: squish::ClusterFit::ClusterFit(squish::ColourSet const*, int, float*)
ClusterFit::ClusterFit( ColourSet const* colours, int flags, float* metric )
  : ColourFit( colours, flags )
{
    // set the iteration count
    m_iterationCount = ( m_flags & kColourIterativeClusterFit ) ? kMaxIterations : 1;

    // initialise the metric (old perceptual = 0.2126f, 0.7152f, 0.0722f)
    if( metric )
        m_metric = Vec4( metric[0], metric[1], metric[2], 1.0f );
    else
        m_metric = VEC4_CONST( 1.0f );

    // initialise the best error
    m_besterror = VEC4_CONST( FLT_MAX );

    // cache some values
    int const count = m_colours->GetCount();
    Vec3 const* values = m_colours->GetPoints();

    // get the covariance matrix
    Sym3x3 covariance = ComputeWeightedCovariance( count, values, m_colours->GetWeights() );

    // compute the principle component
    m_principle = ComputePrincipleComponent( covariance );
}

// Assembly:
subq $0xd8, %rsp
movq %rdi, 0xd0(%rsp)
movq %rsi, 0xc8(%rsp)
movl %edx, 0xc4(%rsp)
movq %rcx, 0xb8(%rsp)
movq 0xd0(%rsp), %rdi
movq %rdi, 0x28(%rsp)
movq 0xc8(%rsp), %rsi
movl 0xc4(%rsp), %edx
callq 0xac5b0
movq 0x28(%rsp), %rdi
leaq 0x25abd(%rip), %rax     # 0xcebd0
addq $0x10, %rax
movq %rax, (%rdi)
addq $0x18, %rdi
callq 0xab3a0
movq 0x28(%rsp), %rax
addq $0xa4, %rax
movq %rax, %rcx
addq $0x100, %rcx            # imm = 0x100
movq %rcx, 0x30(%rsp)
movq %rax, 0x38(%rsp)
movq 0x38(%rsp), %rdi
movq %rdi, 0x20(%rsp)
callq 0xab3b0
movq 0x20(%rsp), %rax
movq 0x30(%rsp), %rcx
addq $0x10, %rax
cmpq %rcx, %rax
movq %rax, 0x38(%rsp)
jne 0xa9142
movq 0x28(%rsp), %rdi
addq $0x1a4, %rdi            # imm = 0x1A4
callq 0xab3b0
movq 0x28(%rsp), %rdi
addq $0x1b4, %rdi            # imm = 0x1B4
callq 0xab3b0
movq 0x28(%rsp), %rdi
addq $0x1c4, %rdi            # imm = 0x1C4
callq 0xab3b0
movq 0x28(%rsp), %rax
movl 0x10(%rax), %esi
andl $0x100, %esi            # imm = 0x100
movl $0x1, %ecx
movl $0x8, %edx
cmpl $0x0, %esi
cmovnel %edx, %ecx
movl %ecx, 0x14(%rax)
cmpq $0x0, 0xb8(%rsp)
je 0xa9228
movq 0xb8(%rsp), %rax
movss (%rax), %xmm0
movq 0xb8(%rsp), %rax
movss 0x4(%rax), %xmm1
movq 0xb8(%rsp), %rax
movss 0x8(%rax), %xmm2
leaq 0xa8(%rsp), %rdi
movss 0x9c02(%rip), %xmm3     # 0xb2e00
callq 0xab3c0
movq 0x28(%rsp), %rax
movq 0xa8(%rsp), %rcx
movq %rcx, 0x1b4(%rax)
movq 0xb0(%rsp), %rcx
movq %rcx, 0x1bc(%rax)
jmp 0xa9260
leaq 0x98(%rsp), %rdi
movss 0x9bc8(%rip), %xmm0     # 0xb2e00
callq 0xab410
movq 0x28(%rsp), %rax
movq 0x98(%rsp), %rcx
movq %rcx, 0x1b4(%rax)
movq 0xa0(%rsp), %rcx
movq %rcx, 0x1bc(%rax)
leaq 0x88(%rsp), %rdi
movss 0x11804(%rip), %xmm0    # 0xbaa74
callq 0xab410
movq 0x28(%rsp), %rax
movups 0x88(%rsp), %xmm0
movups %xmm0, 0x1c4(%rax)
movq 0x8(%rax), %rdi
callq 0xa43d0
movl %eax, %ecx
movq 0x28(%rsp), %rax
movl %ecx, 0x84(%rsp)
movq 0x8(%rax), %rdi
callq 0xab450
movq %rax, %rcx
movq 0x28(%rsp), %rax
movq %rcx, 0x78(%rsp)
movl 0x84(%rsp), %ecx
movl %ecx, 0xc(%rsp)
movq 0x78(%rsp), %rcx
movq %rcx, 0x10(%rsp)
movq 0x8(%rax), %rdi
callq 0xab460
movl 0xc(%rsp), %esi
movq 0x10(%rsp), %rdx
movq %rax, %rcx
leaq 0x60(%rsp), %rdi
movq %rdi, 0x18(%rsp)
callq 0xacc00
movq 0x18(%rsp), %rdi
callq 0xacfc0
movq 0x28(%rsp), %rax
movss %xmm1, 0x48(%rsp)
movlpd %xmm0, 0x40(%rsp)
movq 0x40(%rsp), %rcx
movq %rcx, 0x54(%rsp)
movl 0x48(%rsp), %ecx
movl %ecx, 0x5c(%rsp)
movq 0x54(%rsp), %rcx
movq %rcx, 0x18(%rax)
movl 0x5c(%rsp), %ecx
movl %ecx, 0x20(%rax)
addq $0xd8, %rsp
retq
nopw %cs:(%rax,%rax)