// File: /workspace/github_cpp_makefile_star2_O1/hanhwi[P]SimPoint/analysiscode/KMeans.cpp
// Function: KMeans::initializeFurthestFirst(int, Dataset const&, Dataset*)
void KMeans::initializeFurthestFirst(int randSeed, const Dataset &data,
        Dataset *centers) {
    if ((! centers) || (centers->numRows() <= 0)) {
        return;
    }

    Random rand(randSeed);

    int ndx = rand.randInt() % data.numRows();
    (*centers)[0] = data[ndx];

    Datapoint distances(data.numRows());

    for (unsigned int i = 1; i < centers->numRows(); i++) {
        for (unsigned int j = 0; j < data.numRows(); j++) {
            double d = data[j].distSquared((*centers)[i - 1]);
            if ((i == 1) || (d < distances[j])) {
                distances[j] = d;
            }
        }

        int next = distances.maxNdx();
        (*centers)[i] = data[next];
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x138, %rsp            # imm = 0x138
testq %rdx, %rdx
je 0x8a1a
movq %rdx, %rbx
movq 0x8(%rdx), %rax
subq (%rdx), %rax
shrq $0x3, %rax
imull $0xaaaaaaab, %eax, %eax # imm = 0xAAAAAAAB
testl %eax, %eax
je 0x8a1a
movq %rsi, %r14
movslq %edi, %rax
movq %rax, %rcx
negq %rcx
cmpl $0x2, %eax
cmovlq %rax, %rcx
leaq 0x20(%rsp), %rdi
movq %rcx, (%rdi)
movq $0x75bcd15, 0x8(%rdi)   # imm = 0x75BCD15
movq $0x0, 0x10(%rdi)
callq 0x19950
mulss 0x13a5c(%rip), %xmm0    # 0x1c330
cvttss2si %xmm0, %eax
movq (%r14), %rcx
movq 0x8(%r14), %rdx
subq %rcx, %rdx
shrq $0x3, %rdx
imull $0xaaaaaaab, %edx, %esi # imm = 0xAAAAAAAB
xorl %edx, %edx
divl %esi
movslq %edx, %rax
leaq (%rax,%rax,2), %rax
leaq (%rcx,%rax,8), %rsi
movq (%rbx), %rdi
callq 0x8260
movq 0x8(%r14), %rax
subq (%r14), %rax
shrq $0x3, %rax
imull $0xaaaaaaab, %eax, %esi # imm = 0xAAAAAAAB
leaq 0x8(%rsp), %rdi
callq 0x643c
movq 0x8(%rbx), %rax
subq (%rbx), %rax
shrq $0x3, %rax
imull $0xaaaaaaab, %eax, %eax # imm = 0xAAAAAAAB
testl $0xfffffffe, %eax       # imm = 0xFFFFFFFE
je 0x8a03
movl $0x1, %r12d
movq (%r14), %rdi
movq 0x8(%r14), %rax
subq %rdi, %rax
shrq $0x3, %rax
imull $0xaaaaaaab, %eax, %eax # imm = 0xAAAAAAAB
testl %eax, %eax
je 0x89b6
leaq (%r12,%r12,2), %r13
xorl %ebp, %ebp
xorl %r15d, %r15d
addq %rbp, %rdi
movq (%rbx), %rax
leaq (%rax,%r13,8), %rsi
addq $-0x18, %rsi
callq 0x647c
cmpq $0x1, %r12
je 0x898b
movq 0x8(%rsp), %rax
movsd (%rax,%r15,8), %xmm1
ucomisd %xmm0, %xmm1
jbe 0x8996
movq 0x8(%rsp), %rax
movsd %xmm0, (%rax,%r15,8)
incq %r15
movq (%r14), %rdi
movq 0x8(%r14), %rax
subq %rdi, %rax
shrq $0x3, %rax
imull $0xaaaaaaab, %eax, %eax # imm = 0xAAAAAAAB
addq $0x18, %rbp
cmpq %rax, %r15
jb 0x8961
leaq 0x8(%rsp), %rdi
xorl %esi, %esi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
xorl %ecx, %ecx
callq 0x64b8
cltq
leaq (%rax,%rax,2), %rsi
shlq $0x3, %rsi
addq (%r14), %rsi
leaq (%r12,%r12,2), %rdi
shlq $0x3, %rdi
addq (%rbx), %rdi
callq 0x8260
movq 0x8(%rbx), %rax
subq (%rbx), %rax
incq %r12
shrq $0x3, %rax
imull $0xaaaaaaab, %eax, %eax # imm = 0xAAAAAAAB
cmpq %rax, %r12
jb 0x8940
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0x8a1a
movq 0x18(%rsp), %rsi
subq %rdi, %rsi
callq 0x42d0
addq $0x138, %rsp            # imm = 0x138
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x8a2e
movq %rax, %rbx
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0x8a48
movq 0x18(%rsp), %rsi
subq %rdi, %rsi
callq 0x42d0
movq %rbx, %rdi
callq 0x4580