// File: /workspace/github_c_makefile_star2_O1/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 $0x58, %rsp
movl %ecx, %ebx
movl %esi, %ebp
movq %rdi, %r14
xorps %xmm0, %xmm0
movaps %xmm0, 0x20(%rsp)
xorl %eax, %eax
movq %rax, 0x30(%rsp)
movq %rax, 0x10(%rsp)
movaps %xmm0, (%rsp)
movq %rax, 0x50(%rsp)
movaps %xmm0, 0x40(%rsp)
callq 0xe448
movq %r14, %rdi
movl %ebp, %esi
callq 0xf0e0
cmpl $-0x1, %eax
je 0xef75
movq %r14, %rdi
callq 0xe554
movl %eax, %r15d
movl $0x1, %esi
testl %ebp, %ebp
sete %cl
movl 0x2b0(%r14), %eax
testl %eax, %eax
setg %dl
testb %dl, %cl
jne 0xef43
cmpl $0x2, %ebp
je 0xef61
testl %eax, %eax
setg %al
cmpl $0x0, 0x2b4(%r14)
setg %cl
orb %al, %cl
je 0xef61
leal 0x1(%rsi), %r12d
movq %r14, %rdi
movl $0x1, %edx
movl %ebx, %ecx
movl %r15d, %r8d
xorl %r9d, %r9d
callq 0xe62a
movl %r12d, %esi
jmp 0xef15
movq %r14, %rdi
callq 0xe448
movq %r14, %rdi
movl %ebp, %esi
callq 0xf240
jmp 0xef00
movq %r14, %rdi
callq 0xe448
movq %r14, %rdi
movl %ebp, %esi
callq 0xf412
leaq 0x40(%rsp), %r13
cmpl $-0x1, %eax
je 0xf01b
movq %r14, %rdi
callq 0xe554
movl %eax, %r15d
movl $0x1, %esi
testl %ebp, %ebp
sete %cl
movl 0x2b0(%r14), %eax
testl %eax, %eax
setg %dl
testb %dl, %cl
jne 0xefd3
cmpl $0x2, %ebp
je 0xeff1
testl %eax, %eax
setg %al
cmpl $0x0, 0x2b4(%r14)
setg %cl
orb %al, %cl
je 0xeff1
leal 0x1(%rsi), %r12d
movq %r14, %rdi
xorl %edx, %edx
movl $0x1, %ecx
movl %r15d, %r8d
xorl %r9d, %r9d
callq 0xe62a
movl %r12d, %esi
jmp 0xefa5
movq %r14, %rdi
leaq 0x20(%rsp), %rsi
movq %rsp, %rdx
movq %r13, %rcx
callq 0xf510
movq %r14, %rdi
callq 0xe448
movq %r14, %rdi
movl %ebp, %esi
callq 0xf648
jmp 0xef8c
leaq 0x20(%rsp), %rsi
movq %rsp, %rdx
leaq 0x40(%rsp), %r15
movq %r14, %rdi
movq %r15, %rcx
movl %ebx, %r8d
callq 0xf794
movq (%r15), %rdi
testq %rdi, %rdi
je 0xf04b
movq 0x50(%rsp), %rsi
subq %rdi, %rsi
callq 0x32f0
movq (%rsp), %rdi
testq %rdi, %rdi
je 0xf061
movq 0x10(%rsp), %rsi
subq %rdi, %rsi
callq 0x32f0
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0xf078
movq 0x30(%rsp), %rsi
subq %rdi, %rsi
callq 0x32f0
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0xf091
jmp 0xf091
jmp 0xf091
jmp 0xf091
jmp 0xf091
movq %rax, %rbx
movq 0x40(%rsp), %rdi
testq %rdi, %rdi
je 0xf0ab
movq 0x50(%rsp), %rsi
subq %rdi, %rsi
callq 0x32f0
movq (%rsp), %rdi
testq %rdi, %rdi
je 0xf0c1
movq 0x10(%rsp), %rsi
subq %rdi, %rsi
callq 0x32f0
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0xf0d8
movq 0x30(%rsp), %rsi
subq %rdi, %rsi
callq 0x32f0
movq %rbx, %rdi
callq 0x3570