// File: /workspace/github_cpp_makefile_star2_O2/hanhwi[P]SimPoint/analysiscode/Simpoint.cpp
// Function: Simpoint::applyWeights()
void Simpoint::applyWeights() {
    if (options.fixedLength == "on") {
        Logger::log() << "  Applying fixed-length vector weights (uniform weights)\n";
        double weight = 1.0 / (double)wholeDataset->numRows();
        for (unsigned int i = 0; i < wholeDataset->numRows(); i++) {
            wholeDataset->setWeight(i, weight);
        }
    } else if (options.loadVectorWeightsName != "") {
        Logger::log() << "  Applying vector weights from file " << options.loadVectorWeightsName << endl;
        Utilities::check(isRegularFile(options.loadVectorWeightsName),
                "applyWeights() not regular file " + options.loadVectorWeightsName);
        ifstream input(options.loadVectorWeightsName.c_str());
        Utilities::check(input.is_open(), "Simpoint::applyWeights(): could not open file " +
                                options.loadVectorWeightsName);
        vector<double> weights(wholeDataset->numRows());
        double totalWeight = 0.0;
        for (unsigned int i = 0; i < wholeDataset->numRows(); i++) {
            input >> weights[i];
            totalWeight += weights[i];
        }

        for (unsigned int i = 0; i < wholeDataset->numRows(); i++) {
            wholeDataset->setWeight(i, weights[i] / totalWeight);
        }

        input.close();
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x238, %rsp            # imm = 0x238
movq %rdi, %rbx
addq $0x100, %rdi            # imm = 0x100
leaq 0xba0d(%rip), %rsi      # 0x15809
callq 0x5549
testb %al, %al
je 0x9e60
leaq 0x1750c(%rip), %rax     # 0x21318
movl (%rax), %ecx
shrl $0x1f, %ecx
movq 0x8(%rax,%rcx,8), %rdi
leaq 0xbb3d(%rip), %rsi      # 0x1595a
callq 0x4290
movq (%rbx), %rcx
movq 0x8(%rcx), %rax
subq (%rcx), %rax
pushq $0x18
popq %rsi
cqto
idivq %rsi
movl %eax, %eax
cvtsi2sd %rax, %xmm1
movsd 0xb40d(%rip), %xmm0     # 0x15250
divsd %xmm1, %xmm0
xorl %edx, %edx
cmpq %rdx, %rax
je 0x9fe7
movq 0x18(%rcx), %rsi
movsd %xmm0, (%rsi,%rdx,8)
incq %rdx
jmp 0x9e49
leaq 0x320(%rbx), %r14
leaq 0xb391(%rip), %rsi      # 0x151ff
movq %r14, %rdi
callq 0x5556
testb %al, %al
je 0x9fe7
leaq 0x17493(%rip), %rax     # 0x21318
movl (%rax), %ecx
shrl $0x1f, %ecx
movq 0x8(%rax,%rcx,8), %rdi
leaq 0xbafe(%rip), %rsi      # 0x15994
callq 0x4290
movq %rax, %rdi
movq %r14, %rsi
callq 0x4270
movq %rax, %rdi
callq 0x4180
movq %r14, %rdi
callq 0x8734
movl %eax, %ebp
leaq 0xbafa(%rip), %rsi      # 0x159b9
leaq 0x30(%rsp), %r15
movq %r15, %rdi
movq %r14, %rdx
callq 0x54af
movzbl %bpl, %edi
movq %r15, %rsi
callq 0x5364
leaq 0x30(%rsp), %rdi
callq 0x45e8
movq (%r14), %rsi
leaq 0x30(%rsp), %rdi
pushq $0x8
popq %rdx
callq 0x4550
leaq 0xa8(%rsp), %rdi
callq 0x40a0
movl %eax, %ebp
leaq 0xbacf(%rip), %rsi      # 0x159da
leaq 0x8(%rsp), %rdi
movq %r14, %rdx
callq 0x54af
movzbl %bpl, %edi
leaq 0x8(%rsp), %rsi
callq 0x5364
leaq 0x8(%rsp), %rdi
callq 0x45e8
movq (%rbx), %rcx
movq 0x8(%rcx), %rax
subq (%rcx), %rax
pushq $0x18
popq %r15
cqto
idivq %r15
movl %eax, %esi
leaq 0x8(%rsp), %rdi
leaq 0x7(%rsp), %rdx
callq 0x5e38
xorpd %xmm1, %xmm1
xorl %r12d, %r12d
leaq 0x30(%rsp), %r14
xorl %r13d, %r13d
movq (%rbx), %rcx
movq 0x8(%rcx), %rax
subq (%rcx), %rax
cqto
idivq %r15
movl %eax, %edx
movq 0x8(%rsp), %rsi
cmpq %rdx, %r13
jae 0x9fa9
movsd %xmm1, 0x28(%rsp)
addq %r12, %rsi
movq %r14, %rdi
callq 0x41d0
movq 0x8(%rsp), %rax
movsd 0x28(%rsp), %xmm1
addsd (%rax,%r12), %xmm1
incq %r13
addq $0x8, %r12
jmp 0x9f63
movl %eax, %eax
xorl %edx, %edx
cmpq %rdx, %rax
je 0x9fc9
movsd (%rsi,%rdx,8), %xmm0
divsd %xmm1, %xmm0
movq 0x18(%rcx), %rdi
movsd %xmm0, (%rdi,%rdx,8)
incq %rdx
jmp 0x9fad
leaq 0x30(%rsp), %rdi
callq 0x4090
leaq 0x8(%rsp), %rdi
callq 0x5f0a
leaq 0x30(%rsp), %rdi
callq 0x40c0
addq $0x238, %rsp            # imm = 0x238
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0xa020
jmp 0xa00c
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x45e8
jmp 0xa02d
movq %rax, %rbx
jmp 0xa02d
movq %rax, %rbx
leaq 0x30(%rsp), %rdi
callq 0x45e8
jmp 0xa037
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x5f0a
leaq 0x30(%rsp), %rdi
callq 0x40c0
movq %rbx, %rdi
callq 0x4530
nop