// File: /workspace/github_cpp_makefile_star2_O1/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 0x7753
movq 0x80(%rsp), %rax
subq 0x78(%rsp), %rax
shrq $0x5, %rax
movq %rax, 0x18(%rsp)
testl %eax, %eax
jle 0x74e4
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 0x7856
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x74e0
movq 0x30(%rsp), %rsi
subq %rdi, %rsi
callq 0x5350
decl %ebx
jne 0x74ab
leaq 0x90(%rsp), %rbx
movq %rbx, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x5460
testl %ebp, %ebp
jle 0x752c
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 0x7501
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 0x765b
movq %r15, %rdi
movq %r14, %rsi
movl $0x2c, %edx
callq 0x7753
cmpl $0x0, 0x18(%rsp)
jle 0x763c
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 0x76a5
movl (%r14), %eax
testl %eax, %eax
je 0x75f3
cmpl $0x22, %eax
jne 0x75fa
jmp 0x76b4
movl 0xc(%rsp), %eax
movl %eax, (%r14)
movsd %xmm0, 0x68(%rsp)
movq 0x8(%r15,%r13), %rsi
cmpq 0x10(%r15,%r13), %rsi
je 0x761b
movsd %xmm0, (%rsi)
addq $0x8, %rsi
movq %rsi, 0x8(%r15,%r13)
jmp 0x762b
addq %r13, %r15
movq %r15, %rdi
leaq 0x68(%rsp), %rdx
callq 0x7c14
addq $0x18, %r13
addq $0x20, %rbx
decq %rbp
jne 0x75ab
leaq 0x20(%rsp), %r15
movq %r15, %rdi
callq 0x7882
leaq 0x90(%rsp), %rbx
leaq 0x40(%rsp), %r14
jmp 0x7545
leaq 0x78(%rsp), %rdi
callq 0x7882
movq 0x40(%rsp), %rdi
leaq 0x50(%rsp), %rax
cmpq %rax, %rdi
je 0x7681
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 0x2fa81(%rip), %rdi     # 0x37130
callq 0x5210
movq %r14, %rbx
leaq 0x2fa72(%rip), %rdi     # 0x37130
callq 0x54d0
jmp 0x76ec
jmp 0x76c7
movq %rax, %r14
jmp 0x7718
movq %rax, %r14
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x770e
movq 0x30(%rsp), %rsi
subq %rdi, %rsi
callq 0x5350
jmp 0x770e
jmp 0x76ec
jmp 0x76ec
movq %rax, %r14
jmp 0x770e
movq %rax, %r14
jmp 0x7704
movq %rax, %r14
cmpl $0x0, (%rbx)
jne 0x7704
movl 0xc(%rsp), %eax
movl %eax, (%rbx)
leaq 0x20(%rsp), %rdi
callq 0x7882
leaq 0x78(%rsp), %rdi
callq 0x7882
movq 0x40(%rsp), %rdi
leaq 0x50(%rsp), %rax
cmpq %rax, %rdi
je 0x7734
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x5350
movq 0x10(%rsp), %rdi
callq 0x78de
leaq 0x90(%rsp), %rdi
callq 0x50f0
movq %r14, %rdi
callq 0x55e0