// File: /workspace/github_cpp_makefile_star2_O3/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 0x10d1d(%rip), %rsi     # 0x1c859
callq 0x40e0
testl %eax, %eax
je 0xbd81
leaq 0x320(%rbx), %r14
leaq 0x106e3(%rip), %rsi     # 0x1c23a
movq %r14, %rdi
callq 0x40e0
testl %eax, %eax
je 0xbe73
leaq 0x1b7c2(%rip), %r12     # 0x27330
movl (%r12), %eax
shrl $0x1f, %eax
movq 0x8(%r12,%rax,8), %r15
leaq 0x10e63(%rip), %rsi     # 0x1c9e4
movl $0x24, %edx
movq %r15, %rdi
callq 0x4330
movq 0x320(%rbx), %rsi
movq 0x328(%rbx), %rdx
movq %r15, %rdi
callq 0x4330
movq %rax, %r15
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x4290
movsbl %al, %esi
movq %r15, %rdi
callq 0x4030
movq %rax, %rdi
callq 0x41d0
movq 0x320(%rbx), %rdi
leaq 0x30(%rsp), %r15
movq %r15, %rsi
callq 0x4280
movl %eax, %ebp
movl $0xf000, %r13d          # imm = 0xF000
andl 0x18(%r15), %r13d
leaq 0x10e14(%rip), %rsi     # 0x1ca09
leaq 0x30(%rsp), %rdi
movq %r14, %rdx
callq 0x5ea5
testl %ebp, %ebp
jne 0xbe85
cmpl $0x8000, %r13d          # imm = 0x8000
jne 0xbe85
leaq 0x40(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xbc32
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x42d0
movq (%r14), %rsi
leaq 0x30(%rsp), %rdi
movl $0x8, %edx
callq 0x45a0
leaq 0xa8(%rsp), %rdi
callq 0x40b0
movl %eax, %ebp
leaq 0x10dd0(%rip), %rsi     # 0x1ca2a
leaq 0x8(%rsp), %rdi
movq %r14, %rdx
callq 0x5ea5
testb %bpl, %bpl
je 0xbec1
leaq 0x18(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xbc8b
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x42d0
movq (%rbx), %rax
movq 0x8(%rax), %rcx
subq (%rax), %rcx
shrq $0x3, %rcx
imull $0xaaaaaaab, %ecx, %esi # imm = 0xAAAAAAAB
leaq 0x8(%rsp), %rdi
leaq 0x7(%rsp), %rdx
callq 0x6ad6
movq (%rbx), %rax
movq 0x8(%rax), %rcx
subq (%rax), %rcx
shrq $0x3, %rcx
imull $0xaaaaaaab, %ecx, %eax # imm = 0xAAAAAAAB
testl %eax, %eax
je 0xbd51
xorpd %xmm1, %xmm1
movq 0x8(%rsp), %rsi
xorl %r15d, %r15d
leaq 0x30(%rsp), %r14
movabsq $-0x5555555555555555, %r12 # imm = 0xAAAAAAAAAAAAAAAB
xorl %r13d, %r13d
movsd %xmm1, 0x28(%rsp)
addq %r15, %rsi
movq %r14, %rdi
callq 0x41b0
movq 0x8(%rsp), %rsi
movsd 0x28(%rsp), %xmm1
addsd (%rsi,%r15), %xmm1
incq %r13
movq (%rbx), %rcx
movq 0x8(%rcx), %rax
subq (%rcx), %rax
sarq $0x3, %rax
imulq %r12, %rax
movl %eax, %edx
addq $0x8, %r15
cmpq %rdx, %r13
jb 0xbce8
testl %eax, %eax
je 0xbd51
movq 0x8(%rsp), %rdx
movq 0x18(%rcx), %rcx
movl %eax, %eax
xorl %esi, %esi
movsd (%rdx,%rsi,8), %xmm0
divsd %xmm1, %xmm0
movsd %xmm0, (%rcx,%rsi,8)
incq %rsi
cmpq %rsi, %rax
jne 0xbd3b
leaq 0x30(%rsp), %rdi
callq 0x40a0
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0xbd72
movq 0x18(%rsp), %rsi
subq %rdi, %rsi
callq 0x42d0
leaq 0x30(%rsp), %rdi
callq 0x40c0
jmp 0xbe73
leaq 0x1b5a8(%rip), %rax     # 0x27330
movl (%rax), %ecx
shrl $0x1f, %ecx
movq 0x8(%rax,%rcx,8), %rdi
leaq 0x10c11(%rip), %rsi     # 0x1c9aa
movl $0x39, %edx
callq 0x4330
movq (%rbx), %rax
movq 0x8(%rax), %rdx
subq (%rax), %rdx
sarq $0x3, %rdx
movabsq $-0x5555555555555555, %rcx # imm = 0xAAAAAAAAAAAAAAAB
imulq %rdx, %rcx
testl %ecx, %ecx
je 0xbe73
movl %ecx, %edx
cvtsi2sd %rdx, %xmm1
movsd 0x104b2(%rip), %xmm0    # 0x1c288
divsd %xmm1, %xmm0
movq 0x18(%rax), %rax
movl %ecx, %edx
leaq 0x1(%rdx), %rcx
andq $-0x2, %rcx
decq %rdx
movq %rdx, %xmm1
pshufd $0x44, %xmm1, %xmm1     # xmm1 = xmm1[0,1,0,1]
movdqa 0x103d3(%rip), %xmm2    # 0x1c1d0
xorl %edx, %edx
movdqa 0x103d9(%rip), %xmm3    # 0x1c1e0
pxor %xmm3, %xmm1
pcmpeqd %xmm4, %xmm4
movdqa 0x103d9(%rip), %xmm5    # 0x1c1f0
movdqa %xmm2, %xmm6
pxor %xmm3, %xmm6
movdqa %xmm6, %xmm7
pcmpgtd %xmm1, %xmm7
pcmpeqd %xmm1, %xmm6
pshufd $0xf5, %xmm6, %xmm8     # xmm8 = xmm6[1,1,3,3]
pand %xmm7, %xmm8
pshufd $0xf5, %xmm7, %xmm6     # xmm6 = xmm7[1,1,3,3]
por %xmm8, %xmm6
movd %xmm6, %esi
notl %esi
testb $0x1, %sil
je 0xbe51
movsd %xmm0, (%rax,%rdx,8)
pxor %xmm4, %xmm6
pextrw $0x4, %xmm6, %esi
testb $0x1, %sil
je 0xbe66
movsd %xmm0, 0x8(%rax,%rdx,8)
addq $0x2, %rdx
paddq %xmm5, %xmm2
cmpq %rdx, %rcx
jne 0xbe17
addq $0x238, %rsp            # imm = 0x238
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl (%r12), %eax
shrl $0x1f, %eax
movq 0x8(%r12,%rax,8), %rbx
leaq 0x102e0(%rip), %rsi     # 0x1c178
movl $0x8, %edx
movq %rbx, %rdi
callq 0x4330
movq 0x30(%rsp), %rsi
movq 0x38(%rsp), %rdx
movq %rbx, %rdi
callq 0x4330
movq %rax, %rdi
callq 0x4160
jmp 0xbefb
movl (%r12), %eax
shrl $0x1f, %eax
movq 0x8(%r12,%rax,8), %rbx
leaq 0x102a4(%rip), %rsi     # 0x1c178
movl $0x8, %edx
movq %rbx, %rdi
callq 0x4330
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
movq %rbx, %rdi
callq 0x4330
movq %rax, %rdi
callq 0x4160
movl $0x1, %edi
callq 0x4370
movq %rax, %rbx
leaq 0x18(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xbf63
movq 0x18(%rsp), %rsi
incq %rsi
jmp 0xbf5e
movq %rax, %rbx
leaq 0x40(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xbf6d
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x42d0
jmp 0xbf6d
jmp 0xbf49
jmp 0xbf44
movq %rax, %rbx
jmp 0xbf63
movq %rax, %rbx
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0xbf63
movq 0x18(%rsp), %rsi
subq %rdi, %rsi
callq 0x42d0
leaq 0x30(%rsp), %rdi
callq 0x40c0
movq %rbx, %rdi
callq 0x4580
nop