// File: /workspace/github_c_makefile_star2_O0/stonezwr[P]SpiKL-IP/simulator.C
// Function: Simulator::LSMRun(long)
void Simulator::LSMRun(long tid){
    //_network->PrintAllNeuronName();

    char filename[64];
    int info, count;
    int x,y,loss_neuron;
    int Tid;
    double temp;
    FILE * Fp = NULL;
    FILE * Foutp = NULL;
    networkmode_t networkmode;

    Timer myTimer;

    srand(0);
    _network->IndexSpeech();
    cout<<"Number of speeches: "<<_network->NumSpeech()<<endl;

    //for(int count = 0; count < _network->NumSpeech(); count++){
    //    // empty files
    //    sprintf(filename,"outputs/spikepattern%d.dat",count);
    //    InitializeFile(filename);
    //}

    if(tid == 0){
        sprintf(filename, "i_weights_info.txt");
        _network->WriteSynWeightsToFile("input", "reservoir", filename);
        sprintf(filename, "r_weights_recurrent_info.txt");
        _network->WriteSynWeightsToFile("reservoir", "reservoir", filename);
        sprintf(filename, "o_weights_info.txt");
        _network->WriteSynWeightsToFile("reservoir", "output", filename);
    }

#ifdef _RM_ZERO_RES_WEIGHT
    _network->RemoveZeroWeights("reservoir");
#endif  


    // produce transient state
    networkmode = TRANSIENTSTATE;
    _network->LSMSetNetworkMode(networkmode);
    myTimer.Start();
    _network->LSMTransientSim(networkmode, tid, "train_sample");
    myTimer.End("running transient");

    // train the readout layer
    myTimer.Start();
    networkmode = READOUT; // choose the readout supervised algorithm here!
    _network->LSMSetNetworkMode(networkmode);
    Tid = (int)tid;
    cout<<"Tid:"<<Tid<<endl;
    _network->Fold(Tid);

    for(int iii = 0; iii < NUM_ITERS; iii++){
        if(tid == 0)    cout<<"Run the iteration: "<<iii<<endl;
            // random shuffle the training samples for better generalization
        _network->ShuffleTrainingSamples();
        _network->LSMSupervisedTraining(networkmode, tid, iii);
            _network->CurrentPerformance(iii);
        }
    myTimer.End("supervised training the readout"); 
    if(tid == 0){
        sprintf(filename, "o_weights_info_trained_all.txt");
        _network->WriteSelectedSynToFile("readout", filename);
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x300, %rsp            # imm = 0x300
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x278(%rbp)
movq $0x0, -0x78(%rbp)
movq $0x0, -0x80(%rbp)
leaq -0xc8(%rbp), %rdi
callq 0x2d110
xorl %edi, %edi
callq 0x4350
movq -0x278(%rbp), %rax
movq 0x18(%rax), %rdi
callq 0x21b50
movq 0x20f90(%rip), %rdi     # 0x4cfc8
leaq 0xa7d5(%rip), %rsi      # 0x36814
callq 0x4360
movq %rax, %rcx
movq -0x278(%rbp), %rax
movq %rcx, -0x270(%rbp)
movq 0x18(%rax), %rdi
callq 0x2c930
movq -0x270(%rbp), %rdi
movl %eax, %esi
callq 0x46c0
movq %rax, %rdi
movq 0x20f42(%rip), %rsi     # 0x4cfb8
callq 0x43b0
cmpq $0x0, -0x10(%rbp)
jne 0x2c44e
leaq 0xa79c(%rip), %rsi      # 0x36829
xorl %eax, %eax
leaq -0x50(%rbp), %rdi
callq 0x40a0
movq -0x278(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x288(%rbp)
leaq -0xe9(%rbp), %rdi
movq %rdi, -0x280(%rbp)
callq 0x46f0
movq -0x280(%rbp), %rdx
leaq 0x81f7(%rip), %rsi      # 0x342c2
leaq -0xe8(%rbp), %rdi
callq 0x12880
jmp 0x2c0d9
leaq -0x121(%rbp), %rdi
movq %rdi, -0x290(%rbp)
callq 0x46f0
movq -0x290(%rbp), %rdx
leaq 0x81fd(%rip), %rsi      # 0x342f7
leaq -0x120(%rbp), %rdi
callq 0x12880
jmp 0x2c108
movq -0x288(%rbp), %rdi
leaq -0xe8(%rbp), %rsi
leaq -0x120(%rbp), %rdx
leaq -0x50(%rbp), %rcx
callq 0x22ad0
jmp 0x2c128
leaq -0x120(%rbp), %rdi
callq 0x4200
leaq -0x121(%rbp), %rdi
callq 0x43d0
leaq -0xe8(%rbp), %rdi
callq 0x4200
leaq -0xe9(%rbp), %rdi
callq 0x43d0
leaq 0xa6dd(%rip), %rsi      # 0x3683c
xorl %eax, %eax
leaq -0x50(%rbp), %rdi
callq 0x40a0
movq -0x278(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x2a0(%rbp)
leaq -0x149(%rbp), %rdi
movq %rdi, -0x298(%rbp)
callq 0x46f0
movq -0x298(%rbp), %rdx
leaq 0x815a(%rip), %rsi      # 0x342f7
leaq -0x148(%rbp), %rdi
callq 0x12880
jmp 0x2c1ab
leaq -0x171(%rbp), %rdi
movq %rdi, -0x2a8(%rbp)
callq 0x46f0
movq -0x2a8(%rbp), %rdx
leaq 0x812b(%rip), %rsi      # 0x342f7
leaq -0x170(%rbp), %rdi
callq 0x12880
jmp 0x2c1da
movq -0x2a0(%rbp), %rdi
leaq -0x148(%rbp), %rsi
leaq -0x170(%rbp), %rdx
leaq -0x50(%rbp), %rcx
callq 0x22ad0
jmp 0x2c1fa
leaq -0x170(%rbp), %rdi
callq 0x4200
leaq -0x171(%rbp), %rdi
callq 0x43d0
leaq -0x148(%rbp), %rdi
callq 0x4200
leaq -0x149(%rbp), %rdi
callq 0x43d0
leaq 0xa628(%rip), %rsi      # 0x36859
xorl %eax, %eax
leaq -0x50(%rbp), %rdi
callq 0x40a0
movq -0x278(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x2b8(%rbp)
leaq -0x199(%rbp), %rdi
movq %rdi, -0x2b0(%rbp)
callq 0x46f0
movq -0x2b0(%rbp), %rdx
leaq 0x8088(%rip), %rsi      # 0x342f7
leaq -0x198(%rbp), %rdi
callq 0x12880
jmp 0x2c27d
leaq -0x1c1(%rbp), %rdi
movq %rdi, -0x2c0(%rbp)
callq 0x46f0
movq -0x2c0(%rbp), %rdx
leaq 0x9134(%rip), %rsi      # 0x353d2
leaq -0x1c0(%rbp), %rdi
callq 0x12880
jmp 0x2c2ac
movq -0x2b8(%rbp), %rdi
leaq -0x198(%rbp), %rsi
leaq -0x1c0(%rbp), %rdx
leaq -0x50(%rbp), %rcx
callq 0x22ad0
jmp 0x2c2cc
leaq -0x1c0(%rbp), %rdi
callq 0x4200
leaq -0x1c1(%rbp), %rdi
callq 0x43d0
leaq -0x198(%rbp), %rdi
callq 0x4200
leaq -0x199(%rbp), %rdi
callq 0x43d0
jmp 0x2c44e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xf8(%rbp)
movl %eax, -0xfc(%rbp)
jmp 0x2c35f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xf8(%rbp)
movl %eax, -0xfc(%rbp)
jmp 0x2c347
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xf8(%rbp)
movl %eax, -0xfc(%rbp)
leaq -0x120(%rbp), %rdi
callq 0x4200
leaq -0x121(%rbp), %rdi
callq 0x43d0
leaq -0xe8(%rbp), %rdi
callq 0x4200
leaq -0xe9(%rbp), %rdi
callq 0x43d0
jmp 0x2c8a4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xf8(%rbp)
movl %eax, -0xfc(%rbp)
jmp 0x2c3ce
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xf8(%rbp)
movl %eax, -0xfc(%rbp)
jmp 0x2c3b6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xf8(%rbp)
movl %eax, -0xfc(%rbp)
leaq -0x170(%rbp), %rdi
callq 0x4200
leaq -0x171(%rbp), %rdi
callq 0x43d0
leaq -0x148(%rbp), %rdi
callq 0x4200
leaq -0x149(%rbp), %rdi
callq 0x43d0
jmp 0x2c8a4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xf8(%rbp)
movl %eax, -0xfc(%rbp)
jmp 0x2c43d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xf8(%rbp)
movl %eax, -0xfc(%rbp)
jmp 0x2c425
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xf8(%rbp)
movl %eax, -0xfc(%rbp)
leaq -0x1c0(%rbp), %rdi
callq 0x4200
leaq -0x1c1(%rbp), %rdi
callq 0x43d0
leaq -0x198(%rbp), %rdi
callq 0x4200
leaq -0x199(%rbp), %rdi
callq 0x43d0
jmp 0x2c8a4
movq -0x278(%rbp), %rax
movq 0x18(%rax), %rdi
leaq 0x7e97(%rip), %rsi      # 0x342f7
callq 0x225a0
movq -0x278(%rbp), %rax
movl $0x0, -0x84(%rbp)
movq 0x18(%rax), %rdi
movl -0x84(%rbp), %esi
callq 0x2c960
leaq -0xc8(%rbp), %rdi
callq 0x2d140
movq -0x278(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x2d8(%rbp)
movl -0x84(%rbp), %eax
movl %eax, -0x2d0(%rbp)
movl -0x10(%rbp), %eax
movl %eax, -0x2cc(%rbp)
leaq -0x1e9(%rbp), %rdi
movq %rdi, -0x2c8(%rbp)
callq 0x46f0
movq -0x2c8(%rbp), %rdx
leaq 0xa393(%rip), %rsi      # 0x3686c
leaq -0x1e8(%rbp), %rdi
callq 0x12880
jmp 0x2c4e7
movl -0x2cc(%rbp), %edx
movl -0x2d0(%rbp), %esi
movq -0x2d8(%rbp), %rdi
leaq -0x1e8(%rbp), %rcx
callq 0x1ed20
jmp 0x2c508
leaq -0x1e8(%rbp), %rdi
callq 0x4200
leaq -0x1e9(%rbp), %rdi
callq 0x43d0
leaq -0x211(%rbp), %rdi
movq %rdi, -0x2e0(%rbp)
callq 0x46f0
movq -0x2e0(%rbp), %rdx
leaq 0xa338(%rip), %rsi      # 0x36879
leaq -0x210(%rbp), %rdi
callq 0x12880
jmp 0x2c54f
leaq -0xc8(%rbp), %rdi
leaq -0x210(%rbp), %rsi
callq 0x2d290
jmp 0x2c564
leaq -0x210(%rbp), %rdi
callq 0x4200
leaq -0x211(%rbp), %rdi
callq 0x43d0
leaq -0xc8(%rbp), %rdi
callq 0x2d140
movq -0x278(%rbp), %rax
movl $0x1, -0x84(%rbp)
movq 0x18(%rax), %rdi
movl -0x84(%rbp), %esi
callq 0x2c960
movq -0x10(%rbp), %rax
movl %eax, -0x68(%rbp)
movq 0x20a12(%rip), %rdi     # 0x4cfc8
leaq 0xa2ce(%rip), %rsi      # 0x3688b
callq 0x4360
movq %rax, %rdi
movl -0x68(%rbp), %esi
callq 0x46c0
movq %rax, %rdi
movq 0x209e1(%rip), %rsi     # 0x4cfb8
callq 0x43b0
movq -0x278(%rbp), %rax
movq 0x18(%rax), %rdi
movl -0x68(%rbp), %esi
callq 0x2c980
movl $0x0, -0x218(%rbp)
cmpl $0x1f4, -0x218(%rbp)    # imm = 0x1F4
jge 0x2c72b
cmpq $0x0, -0x10(%rbp)
jne 0x2c6cf
movq 0x209ad(%rip), %rdi     # 0x4cfc8
leaq 0xa26e(%rip), %rsi      # 0x36890
callq 0x4360
movq %rax, %rdi
movl -0x218(%rbp), %esi
callq 0x46c0
movq %rax, %rdi
movq 0x20979(%rip), %rsi     # 0x4cfb8
callq 0x43b0
jmp 0x2c6cf
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xf8(%rbp)
movl %eax, -0xfc(%rbp)
jmp 0x2c67b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xf8(%rbp)
movl %eax, -0xfc(%rbp)
leaq -0x1e8(%rbp), %rdi
callq 0x4200
leaq -0x1e9(%rbp), %rdi
callq 0x43d0
jmp 0x2c8a4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xf8(%rbp)
movl %eax, -0xfc(%rbp)
jmp 0x2c6be
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xf8(%rbp)
movl %eax, -0xfc(%rbp)
leaq -0x210(%rbp), %rdi
callq 0x4200
leaq -0x211(%rbp), %rdi
callq 0x43d0
jmp 0x2c8a4
movq -0x278(%rbp), %rax
movq 0x18(%rax), %rdi
callq 0x221c0
movq -0x278(%rbp), %rax
movq 0x18(%rax), %rdi
movl -0x84(%rbp), %esi
movq -0x10(%rbp), %rax
movl %eax, %edx
movl -0x218(%rbp), %ecx
callq 0x1fd90
movq -0x278(%rbp), %rax
movq 0x18(%rax), %rdi
movl -0x218(%rbp), %esi
callq 0x21bc0
movl -0x218(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x218(%rbp)
jmp 0x2c5f9
leaq -0x239(%rbp), %rdi
movq %rdi, -0x2e8(%rbp)
callq 0x46f0
movq -0x2e8(%rbp), %rdx
leaq 0xa158(%rip), %rsi      # 0x368a4
leaq -0x238(%rbp), %rdi
callq 0x12880
jmp 0x2c75a
leaq -0xc8(%rbp), %rdi
leaq -0x238(%rbp), %rsi
callq 0x2d290
jmp 0x2c76f
leaq -0x238(%rbp), %rdi
callq 0x4200
leaq -0x239(%rbp), %rdi
callq 0x43d0
cmpq $0x0, -0x10(%rbp)
jne 0x2c89b
leaq 0xa12b(%rip), %rsi      # 0x368c4
xorl %eax, %eax
leaq -0x50(%rbp), %rdi
callq 0x40a0
movq -0x278(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x2f8(%rbp)
leaq -0x261(%rbp), %rdi
movq %rdi, -0x2f0(%rbp)
callq 0x46f0
movq -0x2f0(%rbp), %rdx
leaq 0xa0e5(%rip), %rsi      # 0x368bc
leaq -0x260(%rbp), %rdi
callq 0x12880
jmp 0x2c7e5
movq -0x2f8(%rbp), %rdi
leaq -0x260(%rbp), %rsi
leaq -0x50(%rbp), %rdx
callq 0x226d0
jmp 0x2c7fe
leaq -0x260(%rbp), %rdi
callq 0x4200
leaq -0x261(%rbp), %rdi
callq 0x43d0
jmp 0x2c89b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xf8(%rbp)
movl %eax, -0xfc(%rbp)
jmp 0x2c84d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xf8(%rbp)
movl %eax, -0xfc(%rbp)
leaq -0x238(%rbp), %rdi
callq 0x4200
leaq -0x239(%rbp), %rdi
callq 0x43d0
jmp 0x2c8a4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xf8(%rbp)
movl %eax, -0xfc(%rbp)
jmp 0x2c88d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xf8(%rbp)
movl %eax, -0xfc(%rbp)
leaq -0x260(%rbp), %rdi
callq 0x4200
leaq -0x261(%rbp), %rdi
callq 0x43d0
jmp 0x2c8a4
addq $0x300, %rsp            # imm = 0x300
popq %rbp
retq
movq -0xf8(%rbp), %rdi
callq 0x46d0