// File: sus304[P]ForRocket/src/fileio.cpp
// Function: forrocket::LoadCsvLog(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, int)
std::vector<std::vector<double>> forrocket::LoadCsvLog(std::string file_path, int skip_rows) {
    std::ifstream ifs(file_path);
    std::vector<std::vector<double>> res_vectors;
    std::string line;
    
    std::getline(ifs, line);
    auto str = split(line, ',');
    int n_cols = str.size();
    for (int i=0; i < n_cols; ++i) {
        std::vector<double> temp1;
        res_vectors.push_back(temp1);
    }
    ifs.seekg(0, std::ios_base::beg);

    // skip rows
    for (int i=0; i < skip_rows; ++i) std::getline(ifs, line);

    while (std::getline(ifs, line)) {
        auto str = split(line, ',');
        for (int i=0; i < n_cols; ++i) {
            res_vectors[i].push_back(std::stod(str[i]));
        }
    }

    // if (n_cols == 2) {
    //     std::vector<double> temp1;
    //     std::vector<double> temp2;
    //     while (std::getline(ifs, line)) {
    //         auto str = split(line, ',');
    //         temp1.push_back(std::stod(str[0]));
    //         temp1.push_back(std::stod(str[1]));
    //     }
    //     res_vectors.push_back(temp1);
    //     res_vectors.push_back(temp2);
    // } else if (n_cols == 3) {
    //     std::vector<double> temp1;
    //     std::vector<double> temp2;
    //     std::vector<double> temp3;
    //     while (std::getline(ifs, line)) {
    //         auto str = split(line, ',');
    //         temp1.push_back(std::stod(str[0]));
    //         temp1.push_back(std::stod(str[1]));
    //         temp1.push_back(std::stod(str[2]));
    //     }
    //     res_vectors.push_back(temp1);
    //     res_vectors.push_back(temp2);
    //     res_vectors.push_back(temp3);
    // } else if (n_cols == 4) {
    //     std::vector<double> temp1;
    //     std::vector<double> temp2;
    //     std::vector<double> temp3;
    //     std::vector<double> temp4;
    //     while (std::getline(ifs, line)) {
    //         auto str = split(line, ',');
    //         temp1.push_back(std::stod(str[0]));
    //         temp1.push_back(std::stod(str[1]));
    //         temp1.push_back(std::stod(str[2]));
    //         temp1.push_back(std::stod(str[3]));
    //     }
    //     res_vectors.push_back(temp1);
    //     res_vectors.push_back(temp2);
    //     res_vectors.push_back(temp3);
    //     res_vectors.push_back(temp4);
    // }
    return res_vectors;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x310, %rsp            # imm = 0x310
movq %rdi, -0x2d8(%rbp)
movq %rdi, %rax
movq %rax, -0x2e0(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
leaq -0x220(%rbp), %rdi
movq %rdi, -0x2d0(%rbp)
movl $0x8, %edx
callq 0x66a0
movq -0x2d8(%rbp), %rdi
movb $0x0, -0x221(%rbp)
callq 0x7690
leaq -0x248(%rbp), %rdi
movq %rdi, -0x2c8(%rbp)
callq 0x65f0
movq -0x2d0(%rbp), %rdi
movq -0x2c8(%rbp), %rsi
callq 0x6100
jmp 0x724a
leaq -0x270(%rbp), %rdi
leaq -0x248(%rbp), %rsi
movl $0x2c, %edx
callq 0x7540
jmp 0x7264
leaq -0x270(%rbp), %rdi
callq 0x76b0
movl %eax, -0x274(%rbp)
movl $0x0, -0x278(%rbp)
movl -0x278(%rbp), %eax
cmpl -0x274(%rbp), %eax
jge 0x730d
leaq -0x290(%rbp), %rdi
movq %rdi, -0x2e8(%rbp)
callq 0x76d0
movq -0x2d8(%rbp), %rdi
movq -0x2e8(%rbp), %rsi
callq 0x76f0
jmp 0x72b6
leaq -0x290(%rbp), %rdi
callq 0x7760
movl -0x278(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x278(%rbp)
jmp 0x7280
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x250(%rbp)
movl %eax, -0x254(%rbp)
jmp 0x74d9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x250(%rbp)
movl %eax, -0x254(%rbp)
leaq -0x290(%rbp), %rdi
callq 0x7760
jmp 0x74cd
xorl %edx, %edx
movl %edx, %esi
leaq -0x220(%rbp), %rdi
callq 0x65d0
jmp 0x731f
movl $0x0, -0x294(%rbp)
movl -0x294(%rbp), %eax
cmpl -0x14(%rbp), %eax
jge 0x7373
leaq -0x220(%rbp), %rdi
leaq -0x248(%rbp), %rsi
callq 0x6100
jmp 0x7349
jmp 0x734b
movl -0x294(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x294(%rbp)
jmp 0x7329
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x250(%rbp)
movl %eax, -0x254(%rbp)
jmp 0x74cd
jmp 0x7375
leaq -0x220(%rbp), %rdi
leaq -0x248(%rbp), %rsi
callq 0x6100
movq %rax, -0x2f0(%rbp)
jmp 0x7391
movq -0x2f0(%rbp), %rdi
movq (%rdi), %rax
movq -0x18(%rax), %rax
addq %rax, %rdi
callq 0x6540
movb %al, -0x2f1(%rbp)
jmp 0x73af
movb -0x2f1(%rbp), %al
testb $0x1, %al
jne 0x73be
jmp 0x74a3
leaq -0x2b0(%rbp), %rdi
leaq -0x248(%rbp), %rsi
movl $0x2c, %edx
callq 0x7540
jmp 0x73d8
movl $0x0, -0x2b4(%rbp)
movl -0x2b4(%rbp), %eax
cmpl -0x274(%rbp), %eax
jge 0x7492
movq -0x2d8(%rbp), %rdi
movslq -0x2b4(%rbp), %rsi
callq 0x77c0
movq %rax, -0x308(%rbp)
movslq -0x2b4(%rbp), %rsi
leaq -0x2b0(%rbp), %rdi
callq 0x7850
movq %rax, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x7810
movsd %xmm0, -0x300(%rbp)
jmp 0x7437
movq -0x308(%rbp), %rdi
movsd -0x300(%rbp), %xmm0
movsd %xmm0, -0x2c0(%rbp)
leaq -0x2c0(%rbp), %rsi
callq 0x77e0
jmp 0x745c
jmp 0x745e
movl -0x2b4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2b4(%rbp)
jmp 0x73e2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x250(%rbp)
movl %eax, -0x254(%rbp)
leaq -0x2b0(%rbp), %rdi
callq 0x7870
jmp 0x74cd
leaq -0x2b0(%rbp), %rdi
callq 0x7870
jmp 0x7375
movb $0x1, -0x221(%rbp)
leaq -0x270(%rbp), %rdi
callq 0x7870
leaq -0x248(%rbp), %rdi
callq 0x6898
testb $0x1, -0x221(%rbp)
jne 0x750b
jmp 0x74ff
leaq -0x270(%rbp), %rdi
callq 0x7870
leaq -0x248(%rbp), %rdi
callq 0x6898
movq -0x2d8(%rbp), %rdi
callq 0x78d0
leaq -0x220(%rbp), %rdi
callq 0x6150
jmp 0x7527
movq -0x2d8(%rbp), %rdi
callq 0x78d0
leaq -0x220(%rbp), %rdi
callq 0x6150
movq -0x2e0(%rbp), %rax
addq $0x310, %rsp            # imm = 0x310
popq %rbp
retq
movq -0x250(%rbp), %rdi
callq 0x6760
nopw %cs:(%rax,%rax)