// File: /workspace/github_cpp_makefile_star2_O2/hanhwi[P]SimPoint/analysiscode/Utilities.cpp
// Function: Utilities::loadFVFile(FVParser&, Dataset*)
void Utilities::loadFVFile(FVParser &parser,
        Dataset *result) {
    check(NULL != result, "Utilities::loadFVFile() result is null");

    list<FVParserToken> current_vector;
    double totalWeight = 0.0;
    vector<double> rowWeights(result->numRows());

    int largestDimensionSeen = 0;

    while (parser.nextLine(&current_vector)) {
        unsigned int point = parser.currentLineNumber() - 1;
        if (point >= result->numRows()) {
            check(false, "Utilities::loadFVFile() more vectors than expected "
                    "(loading vector " + toString((int)(point + 1)) + " when expecting " 
                    + toString((int)(result->numRows())) + ")");
        }

        // normalize the vector
        double sumVector = 0.0;
        list<FVParserToken>::iterator i;
        for (i = current_vector.begin(); i != current_vector.end(); i++) {
            sumVector += i->value;
            if (i->dimension > largestDimensionSeen) { largestDimensionSeen = i->dimension; }
        }

        rowWeights[point] = sumVector;
        totalWeight += sumVector;

        for (i = current_vector.begin(); i != current_vector.end(); i++) {
            if (i->dimension > (int)result->numCols() || i->dimension < 1) {
                check(i->dimension <= (int)result->numCols(),
                    "Utilities::loadFVFile() expecting only " +
                    toString((int)result->numCols()) +
                    " dimensions, but found dimension " +
                    toString((int)i->dimension));
                check(i->dimension >= 1,
                    "Utilities::loadFVFile() dimension < 1");
            }
            // put the value in the destination dataset (switching to 0-offset
            // and normalizing by the total vector sum)
            (*result)[point][i->dimension - 1] = i->value / sumVector;
        }
    }
    check(parser.currentLineNumber() == (int)result->numRows(),
            "Utilities::loadFVFile() the number of vectors loaded "
            "disagrees with the number specified (expected " +
            toString((int)result->numRows()) + " but loaded " +
            toString(parser.currentLineNumber()) + ")");

    check(largestDimensionSeen == (int)result->numCols(),
            "Utilities::loadFVFile() the number of dimensions loaded "
            "disagrees with the number specified (expected " +
            toString((int)result->numCols()) + " but loaded " +
            toString((int)largestDimensionSeen) + ")");

    // normalize the weights and put them in the dataset
    for (unsigned int row = 0; row < result->numRows(); row++) {
        result->setWeight(row, rowWeights[row] / totalWeight);
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x128, %rsp            # imm = 0x128
movq %rsi, %r12
movq %rdi, %rbx
leaq 0x4849(%rip), %rsi      # 0x186fb
leaq 0x8(%rsp), %rdi
leaq 0x58(%rsp), %rdx
callq 0x53a6
xorl %edi, %edi
testq %r12, %r12
setne %dil
leaq 0x8(%rsp), %rsi
callq 0x5364
leaq 0x8(%rsp), %rdi
callq 0x45e8
leaq 0x110(%rsp), %r14
movq %r14, 0x8(%r14)
movq %r14, (%r14)
andq $0x0, 0x10(%r14)
movq 0x8(%r12), %rax
subq (%r12), %rax
pushq $0x18
popq %rcx
cqto
idivq %rcx
movl %eax, %esi
leaq 0xf8(%rsp), %rdi
leaq 0x8(%rsp), %rdx
callq 0x5e38
xorpd %xmm0, %xmm0
movsd %xmm0, 0x28(%rsp)
xorl %ebp, %ebp
movq %rbx, 0xe0(%rsp)
movq %r12, 0xb8(%rsp)
movq %rbx, %rdi
movq %r14, %rsi
callq 0x73fe
movl 0x8(%rbx), %r13d
testb %al, %al
je 0x14200
leal -0x1(%r13), %r15d
movq 0x8(%r12), %rax
subq (%r12), %rax
cqto
pushq $0x18
popq %rcx
idivq %rcx
cmpl %eax, %r15d
jb 0x1403f
leaq 0x78(%rsp), %rbx
movq %rbx, %rdi
movl %r13d, %esi
callq 0x13a78
leaq 0x98(%rsp), %r13
movq %r13, %rdi
leaq 0x4798(%rip), %rsi      # 0x18722
movq %rbx, %rdx
callq 0x11fc4
leaq 0x38(%rsp), %rdi
movq %r13, %rsi
leaq 0x47c5(%rip), %rdx      # 0x18766
callq 0x5490
movq 0x8(%r12), %rax
subq (%r12), %rax
cqto
pushq $0x18
popq %rcx
idivq %rcx
leaq 0xc0(%rsp), %rbx
movq %rbx, %rdi
movl %eax, %esi
callq 0x13a78
leaq 0x58(%rsp), %r13
movq %r13, %rdi
leaq 0x38(%rsp), %rsi
movq %rbx, %rdx
callq 0x5429
leaq 0x8(%rsp), %rbx
movq %rbx, %rdi
movq %r13, %rsi
leaq 0x123f(%rip), %rdx      # 0x1522f
callq 0x5490
xorl %edi, %edi
movq %rbx, %rsi
callq 0x5364
movq %rbx, %rdi
callq 0x45e8
leaq 0x58(%rsp), %rdi
callq 0x45e8
leaq 0xc0(%rsp), %rdi
callq 0x45e8
leaq 0x38(%rsp), %rdi
callq 0x45e8
leaq 0x98(%rsp), %rdi
callq 0x45e8
leaq 0x78(%rsp), %rdi
callq 0x45e8
xorpd %xmm0, %xmm0
movq 0x110(%rsp), %rbx
movq %rbx, %rax
cmpq %r14, %rax
je 0x14065
addsd 0x18(%rax), %xmm0
movl 0x10(%rax), %ecx
cmpl %ebp, %ecx
cmovgl %ecx, %ebp
movq (%rax), %rax
jmp 0x1404e
movl %r15d, %eax
movq 0xf8(%rsp), %rcx
movsd %xmm0, (%rcx,%rax,8)
movapd %xmm0, %xmm1
movsd 0x28(%rsp), %xmm0
movsd %xmm1, 0xf0(%rsp)
addsd %xmm1, %xmm0
movsd %xmm0, 0x28(%rsp)
imulq $0x18, %rax, %rax
movq %rax, 0xe8(%rsp)
movl %ebp, 0x34(%rsp)
cmpq %r14, %rbx
je 0x141f3
movl 0x10(%rbx), %r13d
movq (%r12), %rax
movq 0x8(%rax), %r12
subq (%rax), %r12
shrq $0x3, %r12
testl %r13d, %r13d
jle 0x140d5
cmpl %r12d, %r13d
jg 0x140d5
movq 0xb8(%rsp), %r12
jmp 0x141bc
leaq 0x98(%rsp), %r15
movq %r15, %rdi
movl %r12d, %esi
callq 0x13a78
leaq 0x38(%rsp), %rbp
movq %rbp, %rdi
leaq 0x4680(%rip), %rsi      # 0x18777
movq %r15, %rdx
callq 0x11fc4
leaq 0x58(%rsp), %rdi
movq %rbp, %rsi
leaq 0x4691(%rip), %rdx      # 0x1879f
callq 0x5490
movl 0x10(%rbx), %esi
leaq 0x78(%rsp), %rbp
movq %rbp, %rdi
callq 0x13a78
leaq 0x8(%rsp), %r14
movq %r14, %rdi
leaq 0x58(%rsp), %r15
movq %r15, %rsi
movq %rbp, %rdx
callq 0x5429
xorl %edi, %edi
cmpl %r12d, %r13d
setle %dil
movq %r14, %rsi
callq 0x5364
movq %r14, %rdi
callq 0x45e8
leaq 0x78(%rsp), %rdi
callq 0x45e8
movq %r15, %rdi
callq 0x45e8
leaq 0x38(%rsp), %rdi
callq 0x45e8
leaq 0x98(%rsp), %rdi
callq 0x45e8
movl 0x10(%rbx), %r12d
movq %r14, %rdi
leaq 0x4636(%rip), %rsi      # 0x187c1
movq %r15, %rdx
callq 0x53a6
xorl %edi, %edi
testl %r12d, %r12d
setg %dil
movq %r14, %rsi
callq 0x5364
movq %r14, %rdi
callq 0x45e8
movq 0xb8(%rsp), %r12
movq (%r12), %rax
movl 0x10(%rbx), %r13d
movsd 0x18(%rbx), %xmm0
divsd 0xf0(%rsp), %xmm0
movq 0xe8(%rsp), %rcx
movq (%rax,%rcx), %rax
movslq %r13d, %rcx
movsd %xmm0, -0x8(%rax,%rcx,8)
movq (%rbx), %rbx
leaq 0x110(%rsp), %r14
movl 0x34(%rsp), %ebp
jmp 0x140a2
movq 0xe0(%rsp), %rbx
jmp 0x13f33
movq 0x8(%r12), %rax
subq (%r12), %rax
cqto
pushq $0x18
popq %rcx
idivq %rcx
movq %rax, %r14
leaq 0x78(%rsp), %rdi
movl %r14d, %esi
callq 0x13a78
leaq 0x45bf(%rip), %rsi      # 0x187e7
leaq 0x98(%rsp), %rdi
leaq 0x78(%rsp), %rdx
callq 0x11fc4
leaq 0x460a(%rip), %rdx      # 0x1884b
leaq 0x38(%rsp), %rdi
leaq 0x98(%rsp), %rsi
callq 0x5490
movl 0x8(%rbx), %esi
leaq 0xc0(%rsp), %rdi
callq 0x13a78
leaq 0x58(%rsp), %rdi
leaq 0x38(%rsp), %rsi
leaq 0xc0(%rsp), %rdx
callq 0x5429
leaq 0xfae(%rip), %rdx       # 0x1522f
leaq 0x8(%rsp), %rdi
leaq 0x58(%rsp), %rsi
callq 0x5490
xorl %edi, %edi
cmpl %r14d, %r13d
sete %dil
leaq 0x8(%rsp), %rsi
callq 0x5364
leaq 0x8(%rsp), %rdi
callq 0x45e8
leaq 0x58(%rsp), %rdi
callq 0x45e8
leaq 0xc0(%rsp), %rdi
callq 0x45e8
leaq 0x38(%rsp), %rdi
callq 0x45e8
leaq 0x98(%rsp), %rdi
callq 0x45e8
leaq 0x78(%rsp), %rdi
callq 0x45e8
movq (%r12), %rax
movq 0x8(%rax), %r14
subq (%rax), %r14
shrq $0x3, %r14
leaq 0x78(%rsp), %rdi
movl %r14d, %esi
callq 0x13a78
leaq 0x4550(%rip), %rsi      # 0x18858
leaq 0x98(%rsp), %rdi
leaq 0x78(%rsp), %rdx
callq 0x11fc4
leaq 0x452a(%rip), %rdx      # 0x1884b
leaq 0x38(%rsp), %rdi
leaq 0x98(%rsp), %rsi
callq 0x5490
leaq 0xc0(%rsp), %rdi
movl %ebp, %esi
callq 0x13a78
leaq 0x58(%rsp), %rdi
leaq 0x38(%rsp), %rsi
leaq 0xc0(%rsp), %rdx
callq 0x5429
leaq 0xecf(%rip), %rdx       # 0x1522f
leaq 0x8(%rsp), %rdi
leaq 0x58(%rsp), %rsi
callq 0x5490
xorl %edi, %edi
cmpl %r14d, %ebp
sete %dil
leaq 0x8(%rsp), %rsi
callq 0x5364
leaq 0x8(%rsp), %rdi
callq 0x45e8
leaq 0x58(%rsp), %rdi
callq 0x45e8
leaq 0xc0(%rsp), %rdi
callq 0x45e8
leaq 0x38(%rsp), %rdi
callq 0x45e8
leaq 0x98(%rsp), %rdi
callq 0x45e8
leaq 0x78(%rsp), %rdi
callq 0x45e8
movq 0x8(%r12), %rax
subq (%r12), %rax
cqto
pushq $0x18
popq %rcx
idivq %rcx
movq 0xf8(%rsp), %rcx
movl %eax, %eax
xorl %edx, %edx
cmpq %rdx, %rax
je 0x14400
movsd (%rcx,%rdx,8), %xmm0
divsd 0x28(%rsp), %xmm0
movq 0x18(%r12), %rsi
movsd %xmm0, (%rsi,%rdx,8)
incq %rdx
jmp 0x143e1
leaq 0xf8(%rsp), %rdi
callq 0x5f0a
leaq 0x110(%rsp), %rdi
callq 0x7628
addq $0x128, %rsp            # imm = 0x128
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x14489
jmp 0x1447f
jmp 0x1447a
jmp 0x14484
jmp 0x14475
jmp 0x144cb
jmp 0x144de
jmp 0x14489
jmp 0x1447f
jmp 0x1447a
jmp 0x14484
jmp 0x14475
jmp 0x144cb
jmp 0x144de
movq %rax, %rbx
jmp 0x14532
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x45e8
jmp 0x1453f
movq %rax, %rbx
jmp 0x1453f
jmp 0x144de
movq %rax, %rbx
jmp 0x144b7
movq %rax, %rbx
jmp 0x144a0
movq %rax, %rbx
jmp 0x14496
movq %rax, %rbx
jmp 0x144ad
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x45e8
leaq 0x58(%rsp), %rdi
callq 0x45e8
leaq 0xc0(%rsp), %rdi
callq 0x45e8
leaq 0x38(%rsp), %rdi
callq 0x45e8
leaq 0x98(%rsp), %rdi
callq 0x45e8
leaq 0x78(%rsp), %rdi
jmp 0x14520
movq %rax, %rbx
jmp 0x144c4
jmp 0x144de
jmp 0x144de
movq %rax, %rbx
jmp 0x1450e
movq %rax, %rbx
jmp 0x144fa
movq %rax, %rbx
jmp 0x14525
movq %rax, %rbx
jmp 0x14518
movq %rax, %rbx
jmp 0x14504
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x45e8
leaq 0x78(%rsp), %rdi
callq 0x45e8
leaq 0x58(%rsp), %rdi
callq 0x45e8
leaq 0x38(%rsp), %rdi
callq 0x45e8
leaq 0x98(%rsp), %rdi
callq 0x45e8
leaq 0xf8(%rsp), %rdi
callq 0x5f0a
leaq 0x110(%rsp), %rdi
callq 0x7628
movq %rbx, %rdi
callq 0x4530
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
jmp 0x14520
nop