// File: /workspace/github_c_makefile_star2_O2/stonezwr[P]SpiKL-IP/network.C
// Function: Network::LSMSupervisedTraining(networkmode_t, int, int)
void Network::LSMSupervisedTraining(networkmode_t networkmode, int tid, int iteration){
    int info = -1;
    int count = 0;
    vector<pair<int, int> > correct, wrong, even;
    vector<pair<Speech*, bool> > predictions; // the predictions for each speech
    FILE * Foutp = NULL;
    char filename[64];
    vector<double> each_sample_errors;    

    // 1. Clear the signals
    LSMClearSignals();
   
    // 2. Load the first speech:
    info = LoadFirstSpeechTrainCV(networkmode);
    double cost = 0;
    // 3. Load the speech for training
    while(info != -1){
        count++;
        int time = 0, end_time = this->SpeechEndTime();
        Foutp = NULL;
        while(!LSMEndOfSpeech(networkmode, end_time)){
            LSMNextTimeStep(++time, true, iteration, end_time, NULL); 
        }

        LSMClearSignals();

        info = LoadNextSpeechTrainCV(networkmode);
    }
    LSMClearSignals();

    // 4. Load the speech for testing
    info = LoadFirstSpeechTestCV(networkmode);
    count = 0;
    while(info != -1){
        Foutp = NULL;
        count++;
        int time = 0, end_time = this->SpeechEndTime();
        while(!LSMEndOfSpeech(networkmode, end_time)){
            LSMNextTimeStep(++time, false, 1, end_time, Foutp);
        }

        ReadoutJudge(correct, wrong, even); // judge the readout output here

        LSMClearSignals();

        info = LoadNextSpeechTestCV(networkmode);
    }
    // 5. Push the recognition result:
    LSMPushResults(correct, wrong, even, iteration);

}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xa8, %rsp
movl %ecx, 0xc(%rsp)
movl %esi, %ebp
movq %rdi, %r14
xorps %xmm0, %xmm0
movaps %xmm0, 0x50(%rsp)
andq $0x0, 0x60(%rsp)
movaps %xmm0, 0x30(%rsp)
andq $0x0, 0x40(%rsp)
movaps %xmm0, 0x10(%rsp)
andq $0x0, 0x20(%rsp)
movaps %xmm0, 0x90(%rsp)
andq $0x0, 0xa0(%rsp)
movaps %xmm0, 0x70(%rsp)
andq $0x0, 0x80(%rsp)
callq 0xc01c
movq %r14, %rdi
movl %ebp, %esi
callq 0xc98a
pushq $0x1
popq %r15
cmpl $-0x1, %eax
je 0xc858
movq %r14, %rdi
callq 0xc116
movl %eax, %r12d
movl %r15d, %r13d
movq %r14, %rdi
movl %ebp, %esi
callq 0xc182
testb %al, %al
jne 0xc844
leal 0x1(%r13), %ebx
movq %r14, %rdi
movl %r13d, %esi
movl %r15d, %edx
movl 0xc(%rsp), %ecx
movl %r12d, %r8d
xorl %r9d, %r9d
callq 0xc1b4
movl %ebx, %r13d
jmp 0xc815
movq %r14, %rdi
callq 0xc01c
movq %r14, %rdi
movl %ebp, %esi
callq 0xcab4
jmp 0xc802
movq %r14, %rdi
callq 0xc01c
movq %r14, %rdi
movl %ebp, %esi
callq 0xcc7e
pushq $0x1
popq %r15
cmpl $-0x1, %eax
je 0xc8da
movq %r14, %rdi
callq 0xc116
movl %eax, %r13d
movl %r15d, %r12d
movq %r14, %rdi
movl %ebp, %esi
callq 0xc182
testb %al, %al
jne 0xc8af
leal 0x1(%r12), %ebx
movq %r14, %rdi
movl %r12d, %esi
xorl %edx, %edx
movl %r15d, %ecx
movl %r13d, %r8d
xorl %r9d, %r9d
callq 0xc1b4
movl %ebx, %r12d
jmp 0xc881
movq %r14, %rdi
leaq 0x50(%rsp), %rsi
leaq 0x30(%rsp), %rdx
leaq 0x10(%rsp), %rcx
callq 0xcd76
movq %r14, %rdi
callq 0xc01c
movq %r14, %rdi
movl %ebp, %esi
callq 0xce16
jmp 0xc86e
leaq 0x50(%rsp), %r15
leaq 0x30(%rsp), %r12
leaq 0x10(%rsp), %r13
movq %r14, %rdi
movq %r15, %rsi
movq %r12, %rdx
movq %r13, %rcx
movl 0xc(%rsp), %r8d
callq 0xcf5e
leaq 0x70(%rsp), %rdi
callq 0x522a
leaq 0x90(%rsp), %rdi
callq 0xf79c
movq %r13, %rdi
callq 0xa31c
movq %r12, %rdi
callq 0xa31c
movq %r15, %rdi
callq 0xa31c
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0xc94a
jmp 0xc94a
jmp 0xc94a
jmp 0xc94a
jmp 0xc94a
movq %rax, %rbx
leaq 0x70(%rsp), %rdi
callq 0x522a
leaq 0x90(%rsp), %rdi
callq 0xf79c
leaq 0x10(%rsp), %rdi
callq 0xa31c
leaq 0x30(%rsp), %rdi
callq 0xa31c
leaq 0x50(%rsp), %rdi
callq 0xa31c
movq %rbx, %rdi
callq 0x3540