// File: /workspace/github_cpp_makefile_star2_O3/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 $0x298, %rsp            # imm = 0x298
movl %edx, %ebp
movq %rdi, %rbx
leaq 0x90(%rsp), %r14
movq %r14, %rdi
movl $0x8, %edx
callq 0x5540
xorl %eax, %eax
movq %rax, 0x10(%rbx)
xorps %xmm0, %xmm0
movq %rbx, 0x10(%rsp)
movups %xmm0, (%rbx)
leaq 0x50(%rsp), %rcx
movq %rcx, -0x10(%rcx)
movq %rax, -0x8(%rcx)
movb $0x0, (%rcx)
movq (%r14), %rax
addq -0x18(%rax), %r14
movq %r14, %rdi
movl $0xa, %esi
callq 0x5330
movsbl %al, %edx
leaq 0x90(%rsp), %rdi
leaq 0x40(%rsp), %rsi
callq 0x5630
leaq 0x78(%rsp), %rdi
leaq 0x40(%rsp), %rsi
movl $0x2c, %edx
callq 0x7833
movq 0x80(%rsp), %rax
subq 0x78(%rsp), %rax
shrq $0x5, %rax
movq %rax, 0x18(%rsp)
testl %eax, %eax
jle 0x75c4
leaq 0x20(%rsp), %r14
movq 0x18(%rsp), %rax
movl %eax, %ebx
xorps %xmm0, %xmm0
movaps %xmm0, 0x20(%rsp)
movq $0x0, 0x30(%rsp)
movq 0x10(%rsp), %rdi
movq %r14, %rsi
callq 0x7936
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x75c0
movq 0x30(%rsp), %rsi
subq %rdi, %rsi
callq 0x5350
decl %ebx
jne 0x758b
leaq 0x90(%rsp), %rbx
movq %rbx, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x5460
testl %ebp, %ebp
jle 0x760c
leaq 0x40(%rsp), %r15
movq 0x90(%rsp), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x5330
movsbl %al, %edx
movq %rbx, %rdi
movq %r15, %rsi
callq 0x5630
decl %ebp
jne 0x75e1
movq 0x18(%rsp), %rax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movq %rax, 0x60(%rsp)
leaq 0x40(%rsp), %r14
leaq 0x20(%rsp), %r15
movq 0x90(%rsp), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x5330
movsbl %al, %edx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x5630
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x773b
movq %r15, %rdi
movq %r14, %rsi
movl $0x2c, %edx
callq 0x7833
cmpl $0x0, 0x18(%rsp)
jle 0x771c
callq 0x5060
movq %rax, %r14
movq 0x60(%rsp), %rbp
xorl %ebx, %ebx
xorl %r13d, %r13d
movq 0x10(%rsp), %rax
movq (%rax), %r15
movq 0x20(%rsp), %rax
movq (%rax,%rbx), %r12
movl (%r14), %eax
movl %eax, 0xc(%rsp)
movl $0x0, (%r14)
movq %r12, %rdi
leaq 0x70(%rsp), %rsi
callq 0x5290
cmpq %r12, 0x70(%rsp)
je 0x7785
movl (%r14), %eax
testl %eax, %eax
je 0x76d3
cmpl $0x22, %eax
jne 0x76da
jmp 0x7794
movl 0xc(%rsp), %eax
movl %eax, (%r14)
movsd %xmm0, 0x68(%rsp)
movq 0x8(%r15,%r13), %rsi
cmpq 0x10(%r15,%r13), %rsi
je 0x76fb
movsd %xmm0, (%rsi)
addq $0x8, %rsi
movq %rsi, 0x8(%r15,%r13)
jmp 0x770b
addq %r13, %r15
movq %r15, %rdi
leaq 0x68(%rsp), %rdx
callq 0x7cde
addq $0x18, %r13
addq $0x20, %rbx
decq %rbp
jne 0x768b
leaq 0x20(%rsp), %r15
movq %r15, %rdi
callq 0x7962
leaq 0x90(%rsp), %rbx
leaq 0x40(%rsp), %r14
jmp 0x7625
leaq 0x78(%rsp), %rdi
callq 0x7962
movq 0x40(%rsp), %rdi
leaq 0x50(%rsp), %rax
cmpq %rax, %rdi
je 0x7761
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x5350
leaq 0x90(%rsp), %rdi
callq 0x50f0
movq 0x10(%rsp), %rax
addq $0x298, %rsp            # imm = 0x298
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r14, %rbx
leaq 0x2f9a1(%rip), %rdi     # 0x37130
callq 0x5210
movq %r14, %rbx
leaq 0x2f992(%rip), %rdi     # 0x37130
callq 0x54d0
jmp 0x77cc
jmp 0x77a7
movq %rax, %r14
jmp 0x77f8
movq %rax, %r14
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x77ee
movq 0x30(%rsp), %rsi
subq %rdi, %rsi
callq 0x5350
jmp 0x77ee
jmp 0x77cc
jmp 0x77cc
movq %rax, %r14
jmp 0x77ee
movq %rax, %r14
jmp 0x77e4
movq %rax, %r14
cmpl $0x0, (%rbx)
jne 0x77e4
movl 0xc(%rsp), %eax
movl %eax, (%rbx)
leaq 0x20(%rsp), %rdi
callq 0x7962
leaq 0x78(%rsp), %rdi
callq 0x7962
movq 0x40(%rsp), %rdi
leaq 0x50(%rsp), %rax
cmpq %rax, %rdi
je 0x7814
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x5350
movq 0x10(%rsp), %rdi
callq 0x79c0
leaq 0x90(%rsp), %rdi
callq 0x50f0
movq %r14, %rdi
callq 0x55e0