// File: /workspace/github_cpp_makefile_star2_O2/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x268, %rsp            # imm = 0x268
movl %edx, %ebp
movq %rdi, %rbx
leaq 0x60(%rsp), %r14
pushq $0x8
popq %rdx
movq %r14, %rdi
callq 0x5510
andq $0x0, 0x10(%rbx)
xorps %xmm0, %xmm0
movups %xmm0, (%rbx)
leaq 0x38(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb $0x0, (%rax)
leaq 0x28(%rsp), %rsi
movq %r14, %rdi
callq 0x50c0
leaq 0x48(%rsp), %rdi
leaq 0x28(%rsp), %rsi
pushq $0x2c
popq %rdx
callq 0x5d12
movq 0x50(%rsp), %rax
subq 0x48(%rsp), %rax
shrq $0x5, %rax
xorl %r12d, %r12d
testl %eax, %eax
cmovgl %eax, %r12d
movq %rsp, %r14
movl %r12d, %r15d
subl $0x1, %r15d
jb 0x5bca
xorps %xmm0, %xmm0
movaps %xmm0, (%rsp)
andq $0x0, 0x10(%rsp)
movq %rbx, %rdi
movq %r14, %rsi
callq 0x5dce
movq %r14, %rdi
callq 0x6002
jmp 0x5ba2
xorl %r13d, %r13d
leaq 0x60(%rsp), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x5440
testl %ebp, %ebp
cmovgl %ebp, %r13d
leaq 0x60(%rsp), %r14
leaq 0x28(%rsp), %r15
subl $0x1, %r13d
jb 0x5bfe
movq %r14, %rdi
movq %r15, %rsi
callq 0x50c0
jmp 0x5beb
movl %r12d, %r14d
shlq $0x5, %r14
leaq 0x28(%rsp), %r15
movq %rsp, %r12
leaq 0x20(%rsp), %r13
leaq 0x60(%rsp), %rdi
movq %r15, %rsi
callq 0x50c0
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x5c87
movq %r12, %rdi
movq %r15, %rsi
pushq $0x2c
popq %rdx
callq 0x5d12
xorl %r12d, %r12d
xorl %r15d, %r15d
cmpq %r15, %r14
je 0x5c75
movq (%rbx), %rbp
movq (%rsp), %rdi
addq %r15, %rdi
xorl %esi, %esi
callq 0x5dfa
addq %r12, %rbp
movsd %xmm0, 0x20(%rsp)
movq %rbp, %rdi
movq %r13, %rsi
callq 0x62f0
addq $0x20, %r15
addq $0x18, %r12
jmp 0x5c41
movq %rsp, %r12
movq %r12, %rdi
callq 0x5e14
leaq 0x28(%rsp), %r15
jmp 0x5c12
leaq 0x48(%rsp), %rdi
callq 0x5e14
leaq 0x28(%rsp), %rdi
callq 0x5688
leaq 0x60(%rsp), %rdi
callq 0x5100
movq %rbx, %rax
addq $0x268, %rsp            # imm = 0x268
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x5cd4
jmp 0x5cbe
movq %rax, %r14
jmp 0x5cee
jmp 0x5cd4
jmp 0x5cd4
movq %rax, %r14
movq %rsp, %rdi
callq 0x6002
jmp 0x5ce4
movq %rax, %r14
jmp 0x5ce4
movq %rax, %r14
movq %rsp, %rdi
callq 0x5e14
leaq 0x48(%rsp), %rdi
callq 0x5e14
leaq 0x28(%rsp), %rdi
callq 0x5688
movq %rbx, %rdi
callq 0x5e36
leaq 0x60(%rsp), %rdi
callq 0x5100
movq %r14, %rdi
callq 0x55b0