// File: 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:
subq $0x318, %rsp            # imm = 0x318
movq %rdi, 0x310(%rsp)
movq 0x310(%rsp), %rdi
movq %rdi, 0x70(%rsp)
addq $0x58, %rdi
addq $0xa8, %rdi
leaq 0x1df5b(%rip), %rsi     # 0x337f9
callq 0x7b40
testb $0x1, %al
jne 0x158ac
jmp 0x1594d
xorl %edi, %edi
callq 0x7ba0
movq %rax, %rdi
leaq 0x1e08d(%rip), %rsi     # 0x3394a
callq 0x5360
movq 0x70(%rsp), %rax
movq (%rax), %rdi
callq 0xc0c0
movl %eax, %eax
cvtsi2sd %rax, %xmm1
movsd 0x1d972(%rip), %xmm0    # 0x33250
divsd %xmm1, %xmm0
movsd %xmm0, 0x308(%rsp)
movl $0x0, 0x304(%rsp)
movq 0x70(%rsp), %rax
movl 0x304(%rsp), %ecx
movl %ecx, 0x6c(%rsp)
movq (%rax), %rdi
callq 0xc0c0
movl %eax, %ecx
movl 0x6c(%rsp), %eax
cmpl %ecx, %eax
jae 0x15948
movq 0x70(%rsp), %rax
movq (%rax), %rdi
movl 0x304(%rsp), %esi
movsd 0x308(%rsp), %xmm0
callq 0xc150
movl 0x304(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x304(%rsp)
jmp 0x158f6
jmp 0x15ce2
movq 0x70(%rsp), %rdi
addq $0x58, %rdi
addq $0x2c8, %rdi            # imm = 0x2C8
leaq 0x1d89b(%rip), %rsi     # 0x331ff
callq 0x7b70
testb $0x1, %al
jne 0x15972
jmp 0x15ce0
xorl %edi, %edi
callq 0x7ba0
movq %rax, %rdi
leaq 0x1e001(%rip), %rsi     # 0x33984
callq 0x5360
movq 0x70(%rsp), %rsi
movq %rax, %rdi
addq $0x320, %rsi            # imm = 0x320
movq %rsi, 0x50(%rsp)
callq 0x5320
movq %rax, %rdi
movq 0x2e615(%rip), %rsi     # 0x43fc0
callq 0x53c0
movq 0x50(%rsp), %rdi
callq 0x12540
movq 0x50(%rsp), %rdx
movb %al, 0x5f(%rsp)
leaq 0x1dfdf(%rip), %rsi     # 0x339a9
leaq 0x2e0(%rsp), %rdi
movq %rdi, 0x60(%rsp)
callq 0x7880
movb 0x5f(%rsp), %al
movq 0x60(%rsp), %rsi
movzbl %al, %edi
callq 0x7480
jmp 0x159ef
leaq 0x2e0(%rsp), %rdi
callq 0x5788
movq 0x70(%rsp), %rdi
addq $0x320, %rdi            # imm = 0x320
callq 0x5190
movq %rax, %rsi
leaq 0xc8(%rsp), %rdi
movq %rdi, 0x40(%rsp)
movl $0x8, %edx
callq 0x56d0
movq 0x40(%rsp), %rdi
callq 0x5630
movb %al, 0x4f(%rsp)
jmp 0x15a37
movq 0x70(%rsp), %rdx
addq $0x320, %rdx            # imm = 0x320
leaq 0x1df80(%rip), %rsi     # 0x339ca
leaq 0xa8(%rsp), %rdi
callq 0x7880
jmp 0x15a59
movb 0x4f(%rsp), %al
movzbl %al, %edi
andl $0x1, %edi
leaq 0xa8(%rsp), %rsi
callq 0x7480
jmp 0x15a72
leaq 0xa8(%rsp), %rdi
callq 0x5788
movq 0x70(%rsp), %rax
movq (%rax), %rdi
callq 0xc0c0
movl %eax, 0x3c(%rsp)
jmp 0x15a92
movl 0x3c(%rsp), %eax
movl %eax, %eax
movq %rax, 0x28(%rsp)
leaq 0x8f(%rsp), %rdi
movq %rdi, 0x30(%rsp)
callq 0x99c0
movq 0x28(%rsp), %rsi
movq 0x30(%rsp), %rdx
leaq 0x90(%rsp), %rdi
callq 0x99d0
jmp 0x15ac8
leaq 0x8f(%rsp), %rdi
callq 0x9a50
xorps %xmm0, %xmm0
movsd %xmm0, 0x80(%rsp)
movl $0x0, 0x7c(%rsp)
movq 0x70(%rsp), %rax
movl 0x7c(%rsp), %ecx
movl %ecx, 0x20(%rsp)
movq (%rax), %rdi
callq 0xc0c0
movl %eax, 0x24(%rsp)
jmp 0x15b04
movl 0x20(%rsp), %eax
movl 0x24(%rsp), %ecx
cmpl %ecx, %eax
jae 0x15c23
movl 0x7c(%rsp), %eax
movl %eax, %esi
leaq 0x90(%rsp), %rdi
callq 0x9ba0
movq %rax, %rsi
leaq 0xc8(%rsp), %rdi
callq 0x52e0
jmp 0x15b39
movl 0x7c(%rsp), %eax
movl %eax, %esi
leaq 0x90(%rsp), %rdi
callq 0x9ba0
movsd (%rax), %xmm0
addsd 0x80(%rsp), %xmm0
movsd %xmm0, 0x80(%rsp)
movl 0x7c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x7c(%rsp)
jmp 0x15ae9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x2d8(%rsp)
movl %eax, 0x2d4(%rsp)
leaq 0x2e0(%rsp), %rdi
callq 0x5788
jmp 0x15cea
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x2d8(%rsp)
movl %eax, 0x2d4(%rsp)
jmp 0x15cd1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x2d8(%rsp)
movl %eax, 0x2d4(%rsp)
leaq 0xa8(%rsp), %rdi
callq 0x5788
jmp 0x15cd1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x2d8(%rsp)
movl %eax, 0x2d4(%rsp)
leaq 0x8f(%rsp), %rdi
callq 0x9a50
jmp 0x15cd1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x2d8(%rsp)
movl %eax, 0x2d4(%rsp)
leaq 0x90(%rsp), %rdi
callq 0x9960
jmp 0x15cd1
movl $0x0, 0x78(%rsp)
movq 0x70(%rsp), %rax
movl 0x78(%rsp), %ecx
movl %ecx, 0x18(%rsp)
movq (%rax), %rdi
callq 0xc0c0
movl %eax, 0x1c(%rsp)
jmp 0x15c46
movl 0x18(%rsp), %eax
movl 0x1c(%rsp), %ecx
cmpl %ecx, %eax
jae 0x15ca6
movq 0x70(%rsp), %rax
movq (%rax), %rax
movq %rax, 0x8(%rsp)
movl 0x78(%rsp), %eax
movl %eax, 0x14(%rsp)
movl %eax, %esi
leaq 0x90(%rsp), %rdi
callq 0x9ba0
movq 0x8(%rsp), %rdi
movl 0x14(%rsp), %esi
movsd (%rax), %xmm0
movsd 0x80(%rsp), %xmm1
divsd %xmm1, %xmm0
callq 0xc150
jmp 0x15c97
jmp 0x15c99
movl 0x78(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x78(%rsp)
jmp 0x15c2b
leaq 0xc8(%rsp), %rdi
callq 0x50d0
jmp 0x15cb5
leaq 0x90(%rsp), %rdi
callq 0x9960
leaq 0xc8(%rsp), %rdi
callq 0x5100
jmp 0x15ce0
leaq 0xc8(%rsp), %rdi
callq 0x5100
jmp 0x15cea
jmp 0x15ce2
addq $0x318, %rsp            # imm = 0x318
retq
movq 0x2d8(%rsp), %rdi
callq 0x5690
nopw (%rax,%rax)