// File: godofecht[P]Slow-Feature-Analysis/./sfa.h
// Function: SFA::write_csv(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::vector<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::vector<double, std::allocator<double>>>, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::vector<double, std::allocator<double>>>>>)
void write_csv(std::string filename, std::vector<std::pair<std::string, std::vector<double>>> dataset)
    {
    // Make a CSV file with one or more columns of integer values
    // Each column of data is represented by the pair <column name, column data>
    //   as std::pair<std::string, std::vector<int>>
    // The dataset is represented as a vector of these columns
    // Note that all columns should be the same size
    
    // Create an output filestream object
    std::ofstream myFile(filename);
    
    // Send column names to the stream
    for(int j = 0; j < dataset.size(); ++j)
    {
        myFile << dataset.at(j).first;
        if(j != dataset.size() - 1) myFile << ","; // No comma at end of line
    }
    myFile << "\n";
    
    // Send data to the stream
    for(int i = 0; i < dataset.at(0).second.size(); ++i)
    {
        for(int j = 0; j < dataset.size(); ++j)
        {
            myFile << dataset.at(j).second.at(i);
            if(j != dataset.size() - 1) myFile << ","; // No comma at end of line
        }
        myFile << "\n";
    }
    
    // Close the file
    myFile.close();
    }

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x290, %rsp            # imm = 0x290
movq %rdx, -0x240(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
leaq -0x218(%rbp), %rdi
movl $0x10, %edx
callq 0x2340
movl $0x0, -0x21c(%rbp)
movq -0x240(%rbp), %rdi
movslq -0x21c(%rbp), %rax
movq %rax, -0x248(%rbp)
callq 0x9d80
movq %rax, %rcx
movq -0x248(%rbp), %rax
cmpq %rcx, %rax
jae 0x8494
movq -0x240(%rbp), %rdi
movslq -0x21c(%rbp), %rsi
callq 0x9db0
movq %rax, -0x250(%rbp)
jmp 0x8402
movq -0x250(%rbp), %rsi
leaq -0x218(%rbp), %rdi
callq 0x21a0
jmp 0x8417
movq -0x240(%rbp), %rdi
movslq -0x21c(%rbp), %rax
movq %rax, -0x258(%rbp)
callq 0x9d80
movq %rax, %rcx
movq -0x258(%rbp), %rax
subq $0x1, %rcx
cmpq %rcx, %rax
je 0x847e
leaq 0x5d8d(%rip), %rsi      # 0xe1d8
leaq -0x218(%rbp), %rdi
callq 0x21e0
jmp 0x8459
jmp 0x847e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x228(%rbp)
movl %eax, -0x22c(%rbp)
leaq -0x218(%rbp), %rdi
callq 0x2280
jmp 0x8631
jmp 0x8480
movl -0x21c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x21c(%rbp)
jmp 0x83b9
leaq 0x5d3f(%rip), %rsi      # 0xe1da
leaq -0x218(%rbp), %rdi
callq 0x21e0
jmp 0x84a9
movl $0x0, -0x230(%rbp)
movq -0x240(%rbp), %rdi
movslq -0x230(%rbp), %rax
movq %rax, -0x268(%rbp)
xorl %eax, %eax
movl %eax, %esi
callq 0x9db0
movq %rax, -0x260(%rbp)
jmp 0x84da
movq -0x260(%rbp), %rdi
addq $0x20, %rdi
callq 0x42b0
movq %rax, %rcx
movq -0x268(%rbp), %rax
cmpq %rcx, %rax
jae 0x860e
movl $0x0, -0x234(%rbp)
movq -0x240(%rbp), %rdi
movslq -0x234(%rbp), %rax
movq %rax, -0x270(%rbp)
callq 0x9d80
movq %rax, %rcx
movq -0x270(%rbp), %rax
cmpq %rcx, %rax
jae 0x85e3
movq -0x240(%rbp), %rdi
movslq -0x234(%rbp), %rsi
callq 0x9db0
movq %rax, -0x278(%rbp)
jmp 0x8550
movq -0x278(%rbp), %rdi
addq $0x20, %rdi
movslq -0x230(%rbp), %rsi
callq 0x9df0
movq %rax, -0x280(%rbp)
jmp 0x8570
movq -0x280(%rbp), %rax
movsd (%rax), %xmm0
leaq -0x218(%rbp), %rdi
callq 0x2320
jmp 0x8589
movq -0x240(%rbp), %rdi
movslq -0x234(%rbp), %rax
movq %rax, -0x288(%rbp)
callq 0x9d80
movq %rax, %rcx
movq -0x288(%rbp), %rax
subq $0x1, %rcx
cmpq %rcx, %rax
je 0x85cd
leaq 0x5c1b(%rip), %rsi      # 0xe1d8
leaq -0x218(%rbp), %rdi
callq 0x21e0
jmp 0x85cb
jmp 0x85cd
jmp 0x85cf
movl -0x234(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x234(%rbp)
jmp 0x8507
leaq 0x5bf0(%rip), %rsi      # 0xe1da
leaq -0x218(%rbp), %rdi
callq 0x21e0
jmp 0x85f8
jmp 0x85fa
movl -0x230(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x230(%rbp)
jmp 0x84b3
leaq -0x218(%rbp), %rdi
callq 0x2260
jmp 0x861c
leaq -0x218(%rbp), %rdi
callq 0x2280
addq $0x290, %rsp            # imm = 0x290
popq %rbp
retq
movq -0x228(%rbp), %rdi
callq 0x22f0
nopl (%rax)