// File: /workspace/github_cpp_makefile_star2_O3/j-faria[P]cpp-loadtxt/./src/loadtxt.hpp
// Function: loadtxt<double>::operator()()
vector<vector<T>> operator()()
    {
        if (_fname.empty()) {
            string msg = "loadtxt: filename is empty";
            throw invalid_argument(msg);
        }

        ifstream infile( _fname );

        if (infile.fail()) {
            string msg = "loadtxt: could not read file (" + _fname + ")!";
            throw runtime_error(msg);
        }
        
        // ignore first `skiprows` lines
        static const int max_line = 65536;
        for (size_t i = 0; i < _skiprows; i++)
            infile.ignore(max_line, '\n');

        vector<T> record;
        size_t rows_read = 0;

        // read each line
        while (rows_read < _max_rows || _max_rows == 0)
        {
            // clear the record before reading
            record.clear();

            // read the entire line into a string (a record is terminated by a newline)
            string line;
            getline(infile, line);

            if (infile.eof() && line.empty())
                break;
            
            if (line.find(_comments, 0) == 0)
                continue;

            // // use a stringstream to separate the fields out of the line
            // stringstream ss(line);

            size_t found = line.find_first_of(_delimiters);

            while (found != string::npos) {
                string cell = line.substr(0, found);

                if (!cell.empty()) {
                    // convert the field to a double
                    try
                    {
                        T val = convert(cell);
                        record.push_back(val);
                    }
                    catch(const std::invalid_argument& e)
                    {
                        std::cerr << "loadtxt: while reading file \"" << _fname << "\", ";
                        std::cerr << "could not convert field '" << cell << "' to double ";
                        std::cerr << "at row " << rows_read << " column " << record.size() + 1 << "\n";
                        throw;
                    }
                    
                }
                line.erase(0, found + 1);
                found = line.find_first_of(_delimiters);

                if (found == string::npos) {
                    if (line.empty())
                        continue;

                    try
                    {
                        T val = convert(line);
                        record.push_back(val);
                    }
                    catch(const std::invalid_argument& e)
                    {
                        std::cerr << "loadtxt: while reading file \"" << _fname << "\", ";
                        std::cerr << "could not convert field '" << line << "' to double ";
                        std::cerr << "at row " << rows_read << " column " << record.size() + 1 << "\n";
                        // throw;
                    }
                }
            }
            // // convert each field to a double
            // // and add the newly-converted field to the end of the record
            // string cell;
            // double f;

            // while (getline(ss, cell, _delimiters[0])) {
            //     if (cell.empty()) continue;
            //     f = stod(cell);   
            //     record.push_back(f);
            // }

            // while (ss >> f) {
            //         record.push_back(f);
            // }

            _filedata.push_back(record);

            rows_read++;
        }
        
        // complain if something went wrong
        if (rows_read != _max_rows && !infile.eof())
        {
            cout << "loadtxt: could not read file (" << _fname << ")!\n";
            exit(1);
        }

        infile.close();

        size_t nlines = _filedata.size();

        // only read _max_rows of content
        if (_max_rows != 0)
            nlines = min(nlines, _max_rows);

        size_t ncols = _filedata[0].size();

        vector<int> cols;
        if (_usecols.size() == 0)
        {
            data.resize(ncols);
            cols.resize(ncols);
            std::iota(cols.begin(), cols.end(), 0);
        }
        else
        {
            data.resize(_usecols.size());
            cols = _usecols;
            //! usecols starts from 1!
            for (auto& j : cols)
                j--;
        }

        for (size_t i = 0; i < data.size(); i++)
            data[i].reserve(nlines);
        
        for (size_t i = 0; i < nlines; i++)
        {
            int k = 0;
            for (auto j : cols)
            {
                data[k].push_back(_filedata[i][j]);
                k++;
            }
        }
        
        return data;
    }

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x298, %rsp            # imm = 0x298
movq %rdi, -0xa8(%rbp)
cmpq $0x0, 0x20(%rsi)
je 0x3bba
movq %rsi, %rbx
leaq 0x18(%rsi), %r14
leaq -0x2c0(%rbp), %r13
movq %r13, %rdi
movq %r14, %rsi
movl $0x8, %edx
callq 0x2270
movq (%r13), %rax
movq -0x18(%rax), %rax
testb $0x5, -0x2a0(%rbp,%rax)
jne 0x3c16
movq %rbx, -0x78(%rbp)
cmpq $0x0, 0x78(%rbx)
je 0x3687
xorl %ebx, %ebx
leaq -0x2c0(%rbp), %r14
movl $0x10000, %esi          # imm = 0x10000
movq %r14, %rdi
movl $0xa, %edx
callq 0x2120
incq %rbx
movq -0x78(%rbp), %rax
cmpq 0x78(%rax), %rbx
jb 0x3668
xorps %xmm0, %xmm0
leaq -0x70(%rbp), %rax
movaps %xmm0, (%rax)
movq $0x0, 0x10(%rax)
leaq -0x40(%rbp), %r15
movq -0x78(%rbp), %rbx
leaq 0xa0(%rbx), %rax
movq %rax, -0xb8(%rbp)
movq $0x0, -0x58(%rbp)
leaq -0x50(%rbp), %r14
leaq -0xa0(%rbp), %r12
movq 0x98(%rbx), %rax
leaq -0x1(%rax), %rcx
cmpq -0x58(%rbp), %rcx
jb 0x39b3
movq -0x70(%rbp), %rax
cmpq %rax, -0x68(%rbp)
je 0x36e5
movq %rax, -0x68(%rbp)
movq %r15, -0x50(%rbp)
movq $0x0, -0x48(%rbp)
movb $0x0, -0x40(%rbp)
movq -0x2c0(%rbp), %rax
movq -0x18(%rax), %rdi
addq %r13, %rdi
movl $0xa, %esi
callq 0x21b0
movsbl %al, %edx
movq %r13, %rdi
movq %r14, %rsi
callq 0x2300
movq -0x2c0(%rbp), %rax
movq -0x18(%rax), %rax
movb -0x2a0(%rbp,%rax), %al
shrb %al
cmpq $0x0, -0x48(%rbp)
sete %r13b
andb %al, %r13b
jne 0x3987
movq 0x38(%rbx), %rsi
movq 0x40(%rbx), %rcx
movq %r14, %rdi
xorl %edx, %edx
callq 0x22d0
testq %rax, %rax
je 0x3987
movq 0x58(%rbx), %rsi
movq 0x60(%rbx), %rcx
movq %r14, %rdi
xorl %edx, %edx
callq 0x2240
cmpq $-0x1, %rax
je 0x396f
movq %rax, %r15
movq %r12, %rdi
movq %r14, %rsi
xorl %edx, %edx
movq %r15, %rcx
callq 0x21f0
cmpq $0x0, -0x98(%rbp)
je 0x37ca
movq %rbx, %rdi
movq %r12, %rsi
callq 0x424a
movsd %xmm0, -0x80(%rbp)
movq -0x68(%rbp), %rsi
cmpq -0x60(%rbp), %rsi
je 0x37bd
movsd %xmm0, (%rsi)
addq $0x8, %rsi
movq %rsi, -0x68(%rbp)
jmp 0x37ca
leaq -0x70(%rbp), %rdi
leaq -0x80(%rbp), %rdx
callq 0x45b8
incq %r15
movq %r14, %rdi
xorl %esi, %esi
movq %r15, %rdx
callq 0x2060
movq 0x58(%rbx), %rsi
movq 0x60(%rbx), %rcx
movq %r14, %rdi
xorl %edx, %edx
callq 0x2240
movq %rax, %r15
cmpq $-0x1, %rax
jne 0x3831
cmpq $0x0, -0x48(%rbp)
je 0x3831
movq %rbx, %rdi
movq %r14, %rsi
callq 0x424a
movsd %xmm0, -0x80(%rbp)
movq -0x68(%rbp), %rsi
cmpq -0x60(%rbp), %rsi
je 0x3824
movsd %xmm0, (%rsi)
addq $0x8, %rsi
movq %rsi, -0x68(%rbp)
jmp 0x3831
leaq -0x70(%rbp), %rdi
leaq -0x80(%rbp), %rdx
callq 0x45b8
movq -0xa0(%rbp), %rdi
leaq -0x90(%rbp), %rax
cmpq %rax, %rdi
je 0x3853
movq -0x90(%rbp), %rsi
incq %rsi
callq 0x21e0
cmpq $-0x1, %r15
jne 0x377b
jmp 0x396f
cmpl $0x1, %edx
jne 0x3d19
movq %rax, %rdi
callq 0x20b0
movl $0x1d, %edx
movq 0x4769(%rip), %rdi      # 0x7fe8
leaq 0x1c5d(%rip), %rsi      # 0x54e3
callq 0x2200
movq 0x18(%rbx), %rsi
movq 0x20(%rbx), %rdx
movq 0x474e(%rip), %rdi      # 0x7fe8
callq 0x2200
movl $0x3, %edx
movq %rax, %rdi
leaq 0x1c53(%rip), %rsi      # 0x5501
callq 0x2200
movl $0x19, %edx
movq 0x4729(%rip), %rdi      # 0x7fe8
leaq 0x1c3f(%rip), %rsi      # 0x5505
callq 0x2200
movq -0x50(%rbp), %rsi
movq -0x48(%rbp), %rdx
movq 0x470e(%rip), %rdi      # 0x7fe8
callq 0x2200
movl $0xc, %edx
movq %rax, %rdi
leaq 0x1c31(%rip), %rsi      # 0x551f
callq 0x2200
movl $0x7, %edx
movq 0x46e9(%rip), %rdi      # 0x7fe8
leaq 0x1c26(%rip), %rsi      # 0x552c
callq 0x2200
movq 0x46d6(%rip), %rdi      # 0x7fe8
movq -0x58(%rbp), %rsi
callq 0x2140
movl $0x8, %edx
movq %rax, %rdi
leaq 0x1c0a(%rip), %rsi      # 0x5534
movq %rax, -0xb0(%rbp)
callq 0x2200
movq -0xb0(%rbp), %rdi
movq -0x68(%rbp), %rsi
subq -0x70(%rbp), %rsi
sarq $0x3, %rsi
incq %rsi
callq 0x2140
movl $0x1, %edx
movq %rax, %rdi
leaq 0x1bdf(%rip), %rsi      # 0x553f
callq 0x2200
callq 0x22a0
jmp 0x3831
movq -0xb8(%rbp), %rdi
leaq -0x70(%rbp), %rsi
leaq -0x40(%rbp), %r15
callq 0x42c4
incq -0x58(%rbp)
movq -0x50(%rbp), %rdi
cmpq %r15, %rdi
je 0x399c
movq -0x40(%rbp), %rsi
incq %rsi
callq 0x21e0
testb %r13b, %r13b
leaq -0x2c0(%rbp), %r13
je 0x36c2
movq 0x98(%rbx), %rax
cmpq %rax, -0x58(%rbp)
je 0x39d2
movq -0x2c0(%rbp), %rax
movq -0x18(%rax), %rax
testb $0x2, -0x2a0(%rbp,%rax)
je 0x3c5f
leaq -0x2c0(%rbp), %rdi
callq 0x2050
movq 0xa8(%rbx), %rax
movq 0x98(%rbx), %rcx
movq 0xa0(%rbx), %rdx
subq %rdx, %rax
sarq $0x3, %rax
movabsq $-0x5555555555555555, %r12 # imm = 0xAAAAAAAAAAAAAAAB
imulq %r12, %rax
cmpq %rax, %rcx
movq %rax, %r13
cmovbq %rcx, %r13
testq %rcx, %rcx
cmoveq %rax, %r13
movq 0x8(%rdx), %r15
subq (%rdx), %r15
xorps %xmm0, %xmm0
movaps %xmm0, -0x50(%rbp)
movq $0x0, -0x40(%rbp)
movq 0x88(%rbx), %rsi
subq 0x80(%rbx), %rsi
je 0x3a70
sarq $0x2, %rsi
movq %rbx, %rdi
callq 0x4300
leaq 0x80(%rbx), %rsi
leaq -0x50(%rbp), %rdi
callq 0x437c
movq -0x50(%rbp), %rax
movq -0x48(%rbp), %rcx
cmpq %rcx, %rax
je 0x3aa7
decl (%rax)
addq $0x4, %rax
jmp 0x3a63
sarq $0x3, %r15
movq %rbx, %rdi
movq %r15, %rsi
callq 0x4300
leaq -0x50(%rbp), %rdi
movq %r15, %rsi
callq 0x4344
movq -0x50(%rbp), %rax
movq -0x48(%rbp), %rcx
cmpq %rcx, %rax
je 0x3aa7
xorl %edx, %edx
movl %edx, (%rax)
incl %edx
addq $0x4, %rax
cmpq %rcx, %rax
jne 0x3a9a
movq (%rbx), %rdi
cmpq %rdi, 0x8(%rbx)
je 0x3ae2
xorl %ebx, %ebx
xorl %r14d, %r14d
addq %rbx, %rdi
movq %r13, %rsi
callq 0x446a
incq %r14
movq -0x78(%rbp), %rax
movq (%rax), %rdi
movq 0x8(%rax), %rax
subq %rdi, %rax
sarq $0x3, %rax
imulq %r12, %rax
addq $0x18, %rbx
cmpq %rax, %r14
jb 0x3ab5
testq %r13, %r13
je 0x3b5b
xorl %r15d, %r15d
movq %r13, -0x58(%rbp)
movq -0x50(%rbp), %r12
movq -0x48(%rbp), %r13
cmpq %r13, %r12
je 0x3b4f
leaq (%r15,%r15,2), %r14
xorl %ebx, %ebx
movslq (%r12), %rdx
movq -0x78(%rbp), %rcx
movq 0xa0(%rcx), %rax
shlq $0x3, %rdx
addq (%rax,%r14,8), %rdx
movq (%rcx), %rdi
movq 0x8(%rdi,%rbx), %rsi
cmpq 0x10(%rdi,%rbx), %rsi
je 0x3b3a
movsd (%rdx), %xmm0
movsd %xmm0, (%rsi)
addq $0x8, %rsi
movq %rsi, 0x8(%rdi,%rbx)
jmp 0x3b42
addq %rbx, %rdi
callq 0x45b8
addq $0x4, %r12
addq $0x18, %rbx
cmpq %r13, %r12
jne 0x3b01
incq %r15
movq -0x58(%rbp), %r13
cmpq %r13, %r15
jne 0x3aee
movq -0xa8(%rbp), %rdi
movq -0x78(%rbp), %rsi
callq 0x4514
movq -0x50(%rbp), %rdi
testq %rdi, %rdi
je 0x3b80
movq -0x40(%rbp), %rsi
subq %rdi, %rsi
callq 0x21e0
movq -0x70(%rbp), %rdi
testq %rdi, %rdi
je 0x3b95
movq -0x60(%rbp), %rsi
subq %rdi, %rsi
callq 0x21e0
leaq -0x2c0(%rbp), %rdi
callq 0x2070
movq -0xa8(%rbp), %rax
addq $0x298, %rsp            # imm = 0x298
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq -0x2b0(%rbp), %r14
movq %r14, -0x10(%r14)
leaq 0x18da(%rip), %rsi      # 0x54a6
leaq 0x18ed(%rip), %rdx      # 0x54c0
leaq -0x2c0(%rbp), %rdi
callq 0x411a
movl $0x10, %edi
callq 0x20d0
movq %rax, %rbx
leaq -0x2c0(%rbp), %rsi
movq %rax, %rdi
callq 0x22c0
movq 0x43ce(%rip), %rsi      # 0x7fd0
movq 0x43b7(%rip), %rdx      # 0x7fc0
movq %rbx, %rdi
callq 0x22b0
jmp 0x3eee
leaq 0x18a4(%rip), %rsi      # 0x54c1
leaq -0xa0(%rbp), %rdi
movq %r14, %rdx
callq 0x41b8
leaq 0x18ad(%rip), %rsi      # 0x54e0
leaq -0xa0(%rbp), %rdi
callq 0x2310
leaq -0x40(%rbp), %r14
movq %r14, -0x10(%r14)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
jne 0x3ca4
movups (%rcx), %xmm0
movups %xmm0, (%r14)
jmp 0x3caf
movq 0x4352(%rip), %rdi      # 0x7fb8
leaq 0x1854(%rip), %rsi      # 0x54c1
movl $0x1e, %edx
callq 0x2200
movq 0x18(%rbx), %rsi
movq 0x20(%rbx), %rdx
movq 0x4332(%rip), %rdi      # 0x7fb8
callq 0x2200
leaq 0x18ab(%rip), %rsi      # 0x553d
movq %rax, %rdi
callq 0x21c0
movl $0x1, %edi
callq 0x2210
movq %rdx, -0x50(%rbp)
movq (%rcx), %rdx
movq %rdx, -0x40(%rbp)
movq 0x8(%rax), %rdx
movq %rdx, -0x48(%rbp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
leaq -0x90(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x3ce5
movq -0x90(%rbp), %rsi
incq %rsi
callq 0x21e0
movl $0x10, %edi
callq 0x20d0
movq %rax, %rbx
leaq -0x50(%rbp), %rsi
movq %rax, %rdi
callq 0x2280
movq 0x42eb(%rip), %rsi      # 0x7ff0
movq 0x42a4(%rip), %rdx      # 0x7fb0
movq %rbx, %rdi
callq 0x22b0
jmp 0x3eee
leaq -0x40(%rbp), %r15
movq %rax, %rbx
jmp 0x3f10
jmp 0x3f09
movq %rax, %rbx
callq 0x22a0
jmp 0x3f0c
movq %rax, %r15
jmp 0x3d47
movq %rax, %r15
movq %rbx, %rdi
callq 0x2160
movq -0x50(%rbp), %rdi
cmpq %r14, %rdi
je 0x3daa
movq -0x40(%rbp), %rsi
jmp 0x3d70
movq %rax, %r15
leaq -0x90(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x3daa
movq -0x90(%rbp), %rsi
incq %rsi
callq 0x21e0
jmp 0x3daa
movq %rax, %r15
jmp 0x3d8a
movq %rax, %r15
movq %rbx, %rdi
callq 0x2160
movq -0x2c0(%rbp), %rdi
cmpq %r14, %rdi
je 0x3db5
movq -0x2b0(%rbp), %rsi
incq %rsi
callq 0x21e0
jmp 0x3db5
movq %rax, %r15
movq %r15, %rbx
jmp 0x3f71
movq %rax, %r15
movq %r15, %rbx
jmp 0x3f7d
movq %rax, %rbx
jmp 0x3f5c
jmp 0x3f44
jmp 0x3dd9
jmp 0x3f44
movq %rax, %rbx
jmp 0x3f71
movq %rax, %rbx
jmp 0x3f32
movq %rax, %rbx
cmpl $0x1, %edx
jne 0x3f0c
movq %rbx, %rdi
callq 0x20b0
movq 0x41ec(%rip), %rdi      # 0x7fe8
leaq 0x16e0(%rip), %rsi      # 0x54e3
movl $0x1d, %edx
callq 0x2200
movq -0x78(%rbp), %rax
movq 0x18(%rax), %rsi
movq 0x20(%rax), %rdx
movq 0x41c8(%rip), %rdi      # 0x7fe8
callq 0x2200
leaq 0x16d5(%rip), %rsi      # 0x5501
movl $0x3, %edx
movq %rax, %rdi
callq 0x2200
movq 0x41a8(%rip), %rdi      # 0x7fe8
leaq 0x16be(%rip), %rsi      # 0x5505
movl $0x19, %edx
callq 0x2200
movq -0xa0(%rbp), %rsi
movq -0x98(%rbp), %rdx
movq 0x4182(%rip), %rdi      # 0x7fe8
callq 0x2200
leaq 0x16ad(%rip), %rsi      # 0x551f
movl $0xc, %edx
movq %rax, %rdi
callq 0x2200
movq 0x4162(%rip), %rdi      # 0x7fe8
leaq 0x169f(%rip), %rsi      # 0x552c
movl $0x7, %edx
callq 0x2200
movq 0x414a(%rip), %rdi      # 0x7fe8
movq -0x58(%rbp), %rsi
callq 0x2140
movq %rax, %rbx
leaq 0x1683(%rip), %rsi      # 0x5534
movl $0x8, %edx
movq %rax, %rdi
callq 0x2200
movq -0x68(%rbp), %rsi
subq -0x70(%rbp), %rsi
sarq $0x3, %rsi
incq %rsi
movq %rbx, %rdi
callq 0x2140
leaq 0x1663(%rip), %rsi      # 0x553f
movl $0x1, %edx
movq %rax, %rdi
callq 0x2200
callq 0x2230
movq %rax, %rbx
callq 0x22a0
jmp 0x3f0c
movq %rax, %rdi
callq 0x406e
movq %rax, %rbx
leaq -0x40(%rbp), %r15
jmp 0x3f32
movq %rax, %rbx
leaq -0x40(%rbp), %r15
movq -0xa0(%rbp), %rdi
leaq -0x90(%rbp), %rax
cmpq %rax, %rdi
je 0x3f32
movq -0x90(%rbp), %rsi
incq %rsi
callq 0x21e0
movq -0x50(%rbp), %rdi
cmpq %r15, %rdi
je 0x3f5c
movq -0x40(%rbp), %rsi
incq %rsi
jmp 0x3f57
movq %rax, %rbx
movq -0x50(%rbp), %rdi
testq %rdi, %rdi
je 0x3f5c
movq -0x40(%rbp), %rsi
subq %rdi, %rsi
callq 0x21e0
movq -0x70(%rbp), %rdi
testq %rdi, %rdi
je 0x3f71
movq -0x60(%rbp), %rsi
subq %rdi, %rsi
callq 0x21e0
leaq -0x2c0(%rbp), %rdi
callq 0x2070
movq %rbx, %rdi
callq 0x22e0
nop