// File: canzarlab[P]Trajan/src/read_csv.cpp
// Function: CSVReader::getDoubleData(int, int)
std::vector<std::vector<double> > CSVReader::getDoubleData(int from_row, int to_row)
{
    vector<vector<double> > data;
    ifstream inputFile(fileName);
    int l = 0; // 0
    int count =0;
 
    while (inputFile) {
        if (count >= to_row) break;
        l++;
        string s;
        if (!getline(inputFile, s)) break;
        if (s[0] != '#') {
            istringstream ss(s);
            vector<double> record;
            int removefist = 0;
            
            while (ss) {
                string line;
                if (!getline(ss, line, ','))
                {
                    break;
                }
                try {
                    if (removefist >= 0){ // matrix
                        record.push_back(stod(line));
                    }    
                    
                    else
                        removefist++;
                }
                catch (const std::invalid_argument e) {
                    cout << "NaN found in file " << fileName << " line " << l
                         << endl;
                    e.what();
                }
            }
            if (count >= from_row)
                data.push_back(record);
            count ++;
        }
    }
 
    if (!inputFile.eof()) {
        cerr << "Could not read file " << fileName << "\n";
        __throw_invalid_argument("File not found.");
    }
 
    return data;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x4f0, %rsp            # imm = 0x4F0
movq %rdi, -0x458(%rbp)
movq %rdi, %rax
movq %rax, -0x450(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movl %ecx, -0x18(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x448(%rbp)
movb $0x0, -0x19(%rbp)
callq 0x15d30
movq -0x448(%rbp), %rsi
leaq -0x228(%rbp), %rdi
movl $0x8, %edx
callq 0x4460
jmp 0x15548
movl $0x0, -0x238(%rbp)
movl $0x0, -0x23c(%rbp)
movq -0x228(%rbp), %rax
movq -0x18(%rax), %rax
leaq -0x228(%rbp,%rax), %rdi
callq 0x43a0
movb %al, -0x459(%rbp)
jmp 0x1557c
movb -0x459(%rbp), %al
testb $0x1, %al
jne 0x1558b
jmp 0x159da
movl -0x23c(%rbp), %eax
cmpl -0x18(%rbp), %eax
jl 0x155c9
jmp 0x159da
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x230(%rbp)
movl %eax, -0x234(%rbp)
jmp 0x15aad
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x230(%rbp)
movl %eax, -0x234(%rbp)
jmp 0x15a83
movl -0x238(%rbp), %eax
incl %eax
movl %eax, -0x238(%rbp)
leaq -0x260(%rbp), %rdi
movq %rdi, -0x470(%rbp)
callq 0x43f0
movq -0x470(%rbp), %rsi
leaq -0x228(%rbp), %rdi
callq 0x4090
movq %rax, -0x468(%rbp)
jmp 0x15606
movq -0x468(%rbp), %rdi
movq (%rdi), %rax
movq -0x18(%rax), %rax
addq %rax, %rdi
callq 0x4150
movb %al, -0x471(%rbp)
jmp 0x15624
movb -0x471(%rbp), %al
testb $0x1, %al
jne 0x15630
jmp 0x15656
movl $0x3, -0x264(%rbp)
jmp 0x159aa
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x230(%rbp)
movl %eax, -0x234(%rbp)
jmp 0x159c9
xorl %eax, %eax
movl %eax, %esi
leaq -0x260(%rbp), %rdi
callq 0x4580
movq %rax, -0x480(%rbp)
jmp 0x1566f
movq -0x480(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x23, %eax
je 0x159a0
leaq -0x3e8(%rbp), %rdi
leaq -0x260(%rbp), %rsi
movl $0x8, %edx
callq 0x44b0
jmp 0x1569c
leaq -0x400(%rbp), %rdi
callq 0x15dc0
movl $0x0, -0x404(%rbp)
movq -0x3e8(%rbp), %rax
movq -0x18(%rax), %rax
leaq -0x3e8(%rbp,%rax), %rdi
callq 0x43a0
movb %al, -0x481(%rbp)
jmp 0x156d2
movb -0x481(%rbp), %al
testb $0x1, %al
jne 0x156e1
jmp 0x1593b
leaq -0x428(%rbp), %rdi
movq %rdi, -0x498(%rbp)
callq 0x43f0
movq -0x498(%rbp), %rsi
leaq -0x3e8(%rbp), %rdi
movl $0x2c, %edx
callq 0x4530
movq %rax, -0x490(%rbp)
jmp 0x15715
movq -0x490(%rbp), %rdi
movq (%rdi), %rax
movq -0x18(%rax), %rax
addq %rax, %rdi
callq 0x4150
movb %al, -0x499(%rbp)
jmp 0x15733
movb -0x499(%rbp), %al
testb $0x1, %al
jne 0x1573f
jmp 0x1577c
movl $0x5, -0x264(%rbp)
jmp 0x158d6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x230(%rbp)
movl %eax, -0x234(%rbp)
jmp 0x15986
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x230(%rbp)
movl %eax, -0x234(%rbp)
jmp 0x1592d
cmpl $0x0, -0x404(%rbp)
jl 0x158f5
xorl %eax, %eax
movl %eax, %esi
leaq -0x428(%rbp), %rdi
callq 0x15f10
movsd %xmm0, -0x4a8(%rbp)
jmp 0x157a3
movsd -0x4a8(%rbp), %xmm0
movsd %xmm0, -0x430(%rbp)
leaq -0x400(%rbp), %rdi
leaq -0x430(%rbp), %rsi
callq 0x15ee0
jmp 0x157c8
jmp 0x15904
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x230(%rbp)
movl %eax, -0x234(%rbp)
movl -0x234(%rbp), %eax
movl $0x1, %ecx
cmpl %ecx, %eax
jne 0x1592d
movq -0x230(%rbp), %rdi
movq %rdi, -0x4b8(%rbp)
callq 0x4390
movq %rax, %rsi
leaq -0x440(%rbp), %rdi
callq 0x15fe0
movq -0x4b8(%rbp), %rdi
callq 0x4100
movq 0x187a9(%rip), %rdi     # 0x2dfd0
leaq 0x8a06(%rip), %rsi      # 0x1e234
callq 0x42c0
movq %rax, -0x4b0(%rbp)
jmp 0x1583c
movq -0x448(%rbp), %rsi
movq -0x4b0(%rbp), %rdi
callq 0x42a0
movq %rax, -0x4c0(%rbp)
jmp 0x15858
movq -0x4c0(%rbp), %rdi
leaq 0x89e1(%rip), %rsi      # 0x1e247
callq 0x42c0
movq %rax, -0x4c8(%rbp)
jmp 0x15874
movq -0x4c8(%rbp), %rdi
movl -0x238(%rbp), %esi
callq 0x44d0
movq %rax, -0x4d0(%rbp)
jmp 0x1588f
movq -0x4d0(%rbp), %rdi
movq 0x18713(%rip), %rsi     # 0x2dfb0
callq 0x4310
jmp 0x158a4
leaq -0x440(%rbp), %rdi
movq %rdi, -0x4d8(%rbp)
callq 0x4430
movq -0x4d8(%rbp), %rdi
callq 0x4490
callq 0x4480
jmp 0x158ca
jmp 0x158cc
movl $0x0, -0x264(%rbp)
leaq -0x428(%rbp), %rdi
callq 0x41e0
movl -0x264(%rbp), %eax
testl %eax, %eax
je 0x158f0
jmp 0x158ee
jmp 0x1593b
jmp 0x156b2
movl -0x404(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x404(%rbp)
jmp 0x158cc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x230(%rbp)
movl %eax, -0x234(%rbp)
leaq -0x440(%rbp), %rdi
callq 0x4490
callq 0x4480
jmp 0x1592b
jmp 0x1592d
leaq -0x428(%rbp), %rdi
callq 0x41e0
jmp 0x15986
movl -0x23c(%rbp), %eax
cmpl -0x14(%rbp), %eax
jl 0x1595d
movq -0x458(%rbp), %rdi
leaq -0x400(%rbp), %rsi
callq 0x15f70
jmp 0x1595b
jmp 0x1595d
movl -0x23c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x23c(%rbp)
leaq -0x400(%rbp), %rdi
callq 0x14cc0
leaq -0x3e8(%rbp), %rdi
callq 0x4160
jmp 0x159a0
leaq -0x400(%rbp), %rdi
callq 0x14cc0
leaq -0x3e8(%rbp), %rdi
callq 0x4160
jmp 0x159c9
movl $0x0, -0x264(%rbp)
leaq -0x260(%rbp), %rdi
callq 0x41e0
movl -0x264(%rbp), %eax
testl %eax, %eax
je 0x159c4
jmp 0x159c2
jmp 0x159da
jmp 0x1555c
leaq -0x260(%rbp), %rdi
callq 0x41e0
jmp 0x15a83
movq -0x228(%rbp), %rax
movq -0x18(%rax), %rax
leaq -0x228(%rbp,%rax), %rdi
callq 0x4520
movb %al, -0x4d9(%rbp)
jmp 0x159fa
movb -0x4d9(%rbp), %al
testb $0x1, %al
jne 0x15a61
jmp 0x15a06
movq 0x185e3(%rip), %rdi     # 0x2dff0
leaq 0x883a(%rip), %rsi      # 0x1e24e
callq 0x42c0
movq %rax, -0x4e8(%rbp)
jmp 0x15a22
movq -0x448(%rbp), %rsi
movq -0x4e8(%rbp), %rdi
callq 0x42a0
movq %rax, -0x4f0(%rbp)
jmp 0x15a3e
movq -0x4f0(%rbp), %rdi
leaq 0x864f(%rip), %rsi      # 0x1e09b
callq 0x42c0
jmp 0x15a53
leaq 0x8809(%rip), %rdi      # 0x1e263
callq 0x41c0
jmp 0x15a61
movb $0x1, -0x19(%rbp)
movl $0x1, -0x264(%rbp)
leaq -0x228(%rbp), %rdi
callq 0x40b0
testb $0x1, -0x19(%rbp)
jne 0x15a9d
jmp 0x15a91
leaq -0x228(%rbp), %rdi
callq 0x40b0
jmp 0x15aad
movq -0x458(%rbp), %rdi
callq 0x94e0
movq -0x450(%rbp), %rax
addq $0x4f0, %rsp            # imm = 0x4F0
popq %rbp
retq
movq -0x458(%rbp), %rdi
callq 0x94e0
movq -0x230(%rbp), %rdi
callq 0x44e0
movq %rax, %rdi
callq 0x9830
nopl (%rax)