// File: /workspace/github_cpp_makefile_star2_O2/godofecht[P]Slow-Feature-Analysis/./sfa.h
// Function: SFA::Train()
void Train()
    {

        //Pre-processing
        alpha = 0.0f;
        for(int t=0;t<4.0f * ro;t++)
        {
            int v = GetSignalValue(t);
            signalVector.push_back(v);
            OscillateFeedForward(v,t);

            f_vector1.push_back(log(V/U));
        }

        signalVector.clear();
        resultVector.clear();

        //Training
        alpha = 0.001f;
        for(int t = 4.0f * ro;t<(4.0f*ro+TOTAL_TIME);t++)
        {
            int v = GetSignalValue(t);
            signalVector.push_back(v);
            OscillateFeedForward(v,t);
            getNetwork()->UpdateWeights();

            f_vector1.push_back(log(V/U));


            double correlation = GetCorrelationTrace(signalVector,resultVector,t);
       //     cout<<correlation<<endl;
         //   cout<<resultVector.size()<<endl;
            corVector1.push_back(correlation);
        }  

        string ro_string = to_string(ro);
        string prefix_o = "Output: ro= ";
        
        std::vector<std::pair<std::string,
        std::vector<double>>> vals = {{"Values", resultVector}};
        string stt = prefix_o+ro_string+" .csv";
        write_csv(ro_string + " values.csv", vals);

        std::vector<std::pair<std::string,
        std::vector<double>>> f_vals = {{"Values", f_vector1}};
        string spp = (string)"F values: ro= "+ro_string+(string)" .csv";
        write_csv(ro_string + " F.csv", f_vals);

        std::vector<std::pair<std::string,
        std::vector<double>>> c_vals = {{"Values", corVector1}};
        write_csv(ro_string + " Cor.csv", c_vals);

/*
        std::vector<std::pair<std::string,
        std::vector<double>>> vals2 = {{"j", getNetwork()->GetWeights()}};
        write_csv("weight_vector.csv", vals2);
*/


    }

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x238, %rsp            # imm = 0x238
movq %rdi, %rbx
andq $0x0, 0x68(%rdi)
leaq 0x2a0(%rdi), %rax
movq %rax, -0x78(%rbp)
leaq 0x2e8(%rdi), %rax
movq %rax, -0x70(%rbp)
xorl %r14d, %r14d
leaq -0x68(%rbp), %r15
cvtsi2sd %r14d, %xmm2
movsd 0x1d0(%rbx), %xmm0
movapd %xmm0, %xmm1
mulsd 0x2574(%rip), %xmm1     # 0x6038
ucomisd %xmm2, %xmm1
jbe 0x3b26
movq %rbx, %rdi
movl %r14d, %esi
callq 0x4658
movl %eax, %r13d
cvtsi2sd %eax, %xmm0
movsd %xmm0, -0x68(%rbp)
movq -0x78(%rbp), %rdi
movq %r15, %rsi
callq 0x5a92
movq %rbx, %rdi
movl %r13d, %esi
movl %r14d, %edx
callq 0x4710
movsd 0x168(%rbx), %xmm0
divsd 0x160(%rbx), %xmm0
callq 0x2120
movsd %xmm0, -0x68(%rbp)
movq -0x70(%rbp), %rdi
movq %r15, %rsi
callq 0x5a92
incl %r14d
jmp 0x3aab
movq 0x2a0(%rbx), %rax
cmpq %rax, 0x2a8(%rbx)
je 0x3b3d
movq %rax, 0x2a8(%rbx)
movq 0x1f8(%rbx), %rax
cmpq %rax, 0x200(%rbx)
je 0x3b54
movq %rax, 0x200(%rbx)
leaq 0x1f8(%rbx), %rax
movq %rax, -0x88(%rbp)
movabsq $0x3f50624de0000000, %rax # imm = 0x3F50624DE0000000
movq %rax, 0x68(%rbx)
cvttsd2si %xmm1, %r14d
leaq 0x38(%rbx), %rax
movq %rax, -0x80(%rbp)
leaq -0x240(%rbp), %r12
cvtsi2sd %r14d, %xmm1
cvtsi2sdl 0x1d8(%rbx), %xmm2
movapd %xmm0, %xmm3
mulsd 0x249b(%rip), %xmm3     # 0x6038
addsd %xmm2, %xmm3
ucomisd %xmm1, %xmm3
jbe 0x3c83
movq %rbx, %rdi
movl %r14d, %esi
callq 0x4658
movl %eax, %r13d
cvtsi2sd %eax, %xmm0
movsd %xmm0, -0x68(%rbp)
movq -0x78(%rbp), %rdi
leaq -0x68(%rbp), %r15
movq %r15, %rsi
callq 0x5a92
movq %rbx, %rdi
movl %r13d, %esi
movl %r14d, %edx
callq 0x4710
movq (%rbx), %rdi
callq 0x28e4
movsd 0x168(%rbx), %xmm0
divsd 0x160(%rbx), %xmm0
callq 0x2120
movsd %xmm0, -0x68(%rbp)
movq -0x70(%rbp), %rdi
movq %r15, %rsi
leaq -0x258(%rbp), %r15
callq 0x5a92
movq %r15, %rdi
movq -0x78(%rbp), %rsi
callq 0x33cc
movq %r12, %rdi
movq -0x88(%rbp), %rsi
callq 0x33cc
movq %rbx, %rdi
movq %r15, %rsi
movq %r12, %rdx
movl %r14d, %ecx
callq 0x4860
movsd %xmm0, -0x90(%rbp)
movq %r12, %rdi
callq 0x5c12
movq %r15, %rdi
callq 0x5c12
movsd -0x90(%rbp), %xmm0
movsd %xmm0, -0x68(%rbp)
movq -0x80(%rbp), %rdi
leaq -0x68(%rbp), %rsi
callq 0x3398
incl %r14d
movsd 0x1d0(%rbx), %xmm0
jmp 0x3b84
leaq -0xd0(%rbp), %rdi
callq 0x49e1
leaq 0x249b(%rip), %rsi      # 0x6131
leaq -0x228(%rbp), %rdi
leaq -0x68(%rbp), %rdx
callq 0x2070
leaq 0x2491(%rip), %rsi      # 0x613e
leaq -0x68(%rbp), %rdi
movq -0x88(%rbp), %rdx
callq 0x4a0e
leaq -0x148(%rbp), %rdi
leaq -0x68(%rbp), %rsi
pushq $0x1
popq %rdx
leaq -0x208(%rbp), %rcx
callq 0x4a70
leaq -0x68(%rbp), %rdi
callq 0x4a50
leaq -0x68(%rbp), %rdi
leaq -0x228(%rbp), %rsi
leaq -0xd0(%rbp), %rdx
callq 0x4ad2
leaq 0x2447(%rip), %rdx      # 0x6145
leaq -0x208(%rbp), %rdi
leaq -0x68(%rbp), %rsi
callq 0x4aa9
leaq -0x68(%rbp), %rdi
callq 0x20a0
leaq 0x242d(%rip), %rdx      # 0x614b
leaq -0x1e8(%rbp), %rdi
leaq -0xd0(%rbp), %rsi
callq 0x4c84
leaq -0x130(%rbp), %rdi
leaq -0x148(%rbp), %rsi
callq 0x4cbc
leaq -0x1e8(%rbp), %rsi
leaq -0x130(%rbp), %rdx
movq %rbx, %rdi
callq 0x4b0a
leaq -0x130(%rbp), %rdi
callq 0x4d16
leaq -0x1e8(%rbp), %rdi
callq 0x20a0
leaq 0x23c5(%rip), %rsi      # 0x613e
leaq -0x68(%rbp), %rdi
movq -0x70(%rbp), %rdx
callq 0x4a0e
leaq -0x118(%rbp), %rdi
leaq -0x68(%rbp), %rsi
pushq $0x1
popq %rdx
leaq -0x1c8(%rbp), %rcx
callq 0x4a70
leaq -0x68(%rbp), %rdi
callq 0x4a50
leaq 0x23a7(%rip), %rsi      # 0x6157
leaq -0xb0(%rbp), %rdi
leaq -0x2a(%rbp), %rdx
callq 0x2070
leaq -0x68(%rbp), %rdi
leaq -0xb0(%rbp), %rsi
leaq -0xd0(%rbp), %rdx
callq 0x4db2
leaq 0x2367(%rip), %rsi      # 0x6145
leaq -0x168(%rbp), %rdi
leaq -0x29(%rbp), %rdx
callq 0x2070
leaq -0x1c8(%rbp), %rdi
leaq -0x68(%rbp), %rsi
leaq -0x168(%rbp), %rdx
callq 0x4d41
leaq -0x168(%rbp), %rdi
callq 0x20a0
leaq -0x68(%rbp), %rdi
callq 0x20a0
leaq -0xb0(%rbp), %rdi
callq 0x20a0
leaq 0x2339(%rip), %rdx      # 0x6166
leaq -0x1a8(%rbp), %rdi
leaq -0xd0(%rbp), %rsi
callq 0x4c84
leaq -0x100(%rbp), %rdi
leaq -0x118(%rbp), %rsi
callq 0x4cbc
leaq -0x1a8(%rbp), %rsi
leaq -0x100(%rbp), %rdx
movq %rbx, %rdi
callq 0x4b0a
leaq -0x100(%rbp), %rdi
callq 0x4d16
leaq -0x1a8(%rbp), %rdi
callq 0x20a0
leaq 0x22b6(%rip), %rsi      # 0x613e
leaq -0x68(%rbp), %rdi
movq -0x80(%rbp), %rdx
callq 0x4a0e
leaq -0xb0(%rbp), %rdi
leaq -0x68(%rbp), %rsi
pushq $0x1
popq %rdx
leaq -0x168(%rbp), %rcx
callq 0x4a70
leaq -0x68(%rbp), %rdi
callq 0x4a50
leaq 0x22ae(%rip), %rdx      # 0x616d
leaq -0x188(%rbp), %rdi
leaq -0xd0(%rbp), %rsi
callq 0x4c84
leaq -0xe8(%rbp), %rdi
leaq -0xb0(%rbp), %rsi
callq 0x4cbc
leaq -0x188(%rbp), %rsi
leaq -0xe8(%rbp), %rdx
movq %rbx, %rdi
callq 0x4b0a
leaq -0xe8(%rbp), %rdi
callq 0x4d16
leaq -0x188(%rbp), %rdi
callq 0x20a0
leaq -0xb0(%rbp), %rdi
callq 0x4d16
leaq -0x1c8(%rbp), %rdi
callq 0x20a0
leaq -0x118(%rbp), %rdi
callq 0x4d16
leaq -0x208(%rbp), %rdi
callq 0x20a0
leaq -0x148(%rbp), %rdi
callq 0x4d16
leaq -0x228(%rbp), %rdi
callq 0x20a0
leaq -0xd0(%rbp), %rdi
callq 0x20a0
addq $0x238, %rsp            # imm = 0x238
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq -0xe8(%rbp), %rdi
callq 0x4d16
jmp 0x3f8d
movq %rax, %rbx
leaq -0x188(%rbp), %rdi
callq 0x20a0
jmp 0x3f9e
movq %rax, %rbx
leaq -0xb0(%rbp), %rdi
callq 0x4d16
jmp 0x3fe1
movq %rax, %rbx
leaq -0x68(%rbp), %rdi
callq 0x4a50
jmp 0x3fe1
jmp 0x3fde
movq %rax, %rbx
leaq -0x100(%rbp), %rdi
callq 0x4d16
jmp 0x3fd0
movq %rax, %rbx
leaq -0x1a8(%rbp), %rdi
callq 0x20a0
jmp 0x3fe1
movq %rax, %rbx
leaq -0x1c8(%rbp), %rdi
jmp 0x4013
movq %rax, %rbx
leaq -0x168(%rbp), %rdi
callq 0x20a0
jmp 0x3ffe
movq %rax, %rbx
leaq -0x68(%rbp), %rdi
callq 0x20a0
jmp 0x400c
movq %rax, %rbx
leaq -0xb0(%rbp), %rdi
callq 0x20a0
leaq -0x118(%rbp), %rdi
callq 0x4d16
leaq -0x208(%rbp), %rdi
callq 0x20a0
leaq -0x148(%rbp), %rdi
callq 0x4d16
leaq -0x228(%rbp), %rdi
callq 0x20a0
leaq -0xd0(%rbp), %rdi
callq 0x20a0
jmp 0x40db
movq %rax, %rbx
jmp 0x4018
movq %rax, %rbx
leaq -0x68(%rbp), %rdi
callq 0x4a50
jmp 0x4024
jmp 0x4090
movq %rax, %rbx
leaq -0x130(%rbp), %rdi
callq 0x4d16
jmp 0x4082
movq %rax, %rbx
leaq -0x1e8(%rbp), %rdi
callq 0x20a0
jmp 0x4024
movq %rax, %rbx
jmp 0x4024
movq %rax, %rbx
leaq -0x68(%rbp), %rdi
jmp 0x402b
movq %rax, %rbx
jmp 0x4030
movq %rax, %rbx
leaq -0x68(%rbp), %rdi
callq 0x4a50
jmp 0x403c
movq %rax, %rbx
jmp 0x403c
movq %rax, %rbx
jmp 0x4048
movq %rax, %rbx
leaq -0x240(%rbp), %rdi
callq 0x5c12
jmp 0x40cf
movq %rax, %rbx
leaq -0x258(%rbp), %rdi
callq 0x5c12
movq %rbx, %rdi
callq 0x2280
nop