// File: /workspace/github_c_makefile_star2_O3/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 0xe1b8
movq %r14, %rdi
movl %ebp, %esi
callq 0xee58
cmpl $-0x1, %eax
je 0xecea
movq %r14, %rdi
callq 0xe2c4
movl %eax, %r15d
movl $0x1, %esi
testl %ebp, %ebp
sete %cl
movl 0x2b0(%r14), %eax
testl %eax, %eax
setg %dl
testb %dl, %cl
jne 0xecb8
cmpl $0x2, %ebp
je 0xecd6
testl %eax, %eax
setg %al
cmpl $0x0, 0x2b4(%r14)
setg %cl
orb %al, %cl
cmpb $0x1, %cl
jne 0xecd6
leal 0x1(%rsi), %r12d
movq %r14, %rdi
movl $0x1, %edx
movl %ebx, %ecx
movl %r15d, %r8d
xorl %r9d, %r9d
callq 0xe396
movl %r12d, %esi
jmp 0xec87
movq %r14, %rdi
callq 0xe1b8
movq %r14, %rdi
movl %ebp, %esi
callq 0xefba
jmp 0xec72
movq %r14, %rdi
callq 0xe1b8
movq %r14, %rdi
movl %ebp, %esi
callq 0xf18a
leaq 0x40(%rsp), %r13
cmpl $-0x1, %eax
je 0xed93
movq %r14, %rdi
callq 0xe2c4
movl %eax, %r15d
movl $0x1, %esi
testl %ebp, %ebp
sete %cl
movl 0x2b0(%r14), %eax
testl %eax, %eax
setg %dl
testb %dl, %cl
jne 0xed4b
cmpl $0x2, %ebp
je 0xed69
testl %eax, %eax
setg %al
cmpl $0x0, 0x2b4(%r14)
setg %cl
orb %al, %cl
cmpb $0x1, %cl
jne 0xed69
leal 0x1(%rsi), %r12d
movq %r14, %rdi
xorl %edx, %edx
movl $0x1, %ecx
movl %r15d, %r8d
xorl %r9d, %r9d
callq 0xe396
movl %r12d, %esi
jmp 0xed1a
movq %r14, %rdi
leaq 0x20(%rsp), %rsi
movq %rsp, %rdx
movq %r13, %rcx
callq 0xf288
movq %r14, %rdi
callq 0xe1b8
movq %r14, %rdi
movl %ebp, %esi
callq 0xf3b0
jmp 0xed01
leaq 0x20(%rsp), %rsi
movq %rsp, %rdx
leaq 0x40(%rsp), %r15
movq %r14, %rdi
movq %r15, %rcx
movl %ebx, %r8d
callq 0xf4fc
movq (%r15), %rdi
testq %rdi, %rdi
je 0xedc3
movq 0x50(%rsp), %rsi
subq %rdi, %rsi
callq 0x32f0
movq (%rsp), %rdi
testq %rdi, %rdi
je 0xedd9
movq 0x10(%rsp), %rsi
subq %rdi, %rsi
callq 0x32f0
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0xedf0
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 0xee09
jmp 0xee09
jmp 0xee09
jmp 0xee09
jmp 0xee09
movq %rax, %rbx
movq 0x40(%rsp), %rdi
testq %rdi, %rdi
je 0xee23
movq 0x50(%rsp), %rsi
subq %rdi, %rsi
callq 0x32f0
movq (%rsp), %rdi
testq %rdi, %rdi
je 0xee39
movq 0x10(%rsp), %rsi
subq %rdi, %rsi
callq 0x32f0
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0xee50
movq 0x30(%rsp), %rsi
subq %rdi, %rsi
callq 0x32f0
movq %rbx, %rdi
callq 0x3570