// File: /workspace/github_c_makefile_star2_O3/stonezwr[P]SpiKL-IP/network.C
// Function: Network::LoadSynWeightsFromFile(char const*, char*)
void Network::LoadSynWeightsFromFile(const char * syn_type, char * filename){
    ifstream f_in(filename);
    if(!f_in.is_open()){
        cout<<"In Network::LoadSynWeightsFromFile(), cannot open the file: "<<filename<<endl;
        assert(0);
    }

    synapsetype_t read_syn_type = INVALID;
    DetermineSynType(syn_type, read_syn_type, "LoadSynWeightsFromFile()");
    assert(read_syn_type != INVALID);
    vector<Synapse*> tmp;

    const vector<Synapse*> & synapses = 
        read_syn_type == RESERVOIR_SYN ? _rsynapses : 
        read_syn_type == READOUT_SYN ? _rosynapses :
        read_syn_type == INPUT_SYN ? _isynapses : tmp;

    assert(!synapses.empty());  
    // load the synaptic weights from file:
    // the synaptic weight is stored in the file in the same order as the corresponding synapses store in the vector
    int index;
    string pre;
    string post;
    
    double weight;
    while(f_in>>index>>pre>>post>>weight){//>>pre_ext>>post_ext){
        if(index < 0 || index >= synapses.size()){
            cout<<"In Network::LoadSynWeightsFromFile(), the index of the synapse you read : "<<index<<" is out of bound of the container stores the synapses!!"<<endl;
            exit(EXIT_FAILURE);
        }

        assert(strcmp(pre.c_str(), synapses[index]->PreNeuron()->Name()) == 0);
        assert(strcmp(post.c_str(), synapses[index]->PostNeuron()->Name()) == 0);
        synapses[index]->Weight(weight);
    }

}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x278, %rsp            # imm = 0x278
movq %rdx, %r14
movq %rsi, %r15
movq %rdi, %rbx
leaq 0x70(%rsp), %rdi
movq %rdx, %rsi
movl $0x8, %edx
callq 0x35d0
leaq 0xe8(%rsp), %rdi
callq 0x30b0
testb %al, %al
je 0x110f2
leaq 0x4(%rsp), %rdx
movl $0x3, (%rdx)
leaq 0x84f7(%rip), %rcx      # 0x1939c
movq %r15, %rsi
callq 0x1046e
movl 0x4(%rsp), %eax
cmpl $0x3, %eax
je 0x11140
xorps %xmm0, %xmm0
movaps %xmm0, 0x50(%rsp)
movq $0x0, 0x60(%rsp)
cmpl $0x2, %eax
je 0x10edd
testl %eax, %eax
jne 0x10ee6
addq $0x118, %rbx            # imm = 0x118
jmp 0x10ef9
addq $0x130, %rbx            # imm = 0x130
jmp 0x10ef9
addq $0x148, %rbx            # imm = 0x148
cmpl $0x1, %eax
leaq 0x50(%rsp), %rax
cmovneq %rax, %rbx
movq (%rbx), %rax
cmpq 0x8(%rbx), %rax
je 0x1115f
leaq 0x38(%rsp), %rcx
movq %rcx, -0x10(%rcx)
xorl %eax, %eax
movq %rax, -0x8(%rcx)
movb %al, (%rcx)
leaq 0x18(%rsp), %rcx
movq %rcx, -0x10(%rcx)
movq %rax, -0x8(%rcx)
movb %al, (%rcx)
movq %rsp, %r15
leaq 0x28(%rsp), %r12
leaq 0x8(%rsp), %r13
leaq 0x48(%rsp), %rbp
leaq 0x70(%rsp), %rdi
movq %r15, %rsi
callq 0x31a0
movq %rax, %rdi
movq %r12, %rsi
callq 0x33c0
movq %rax, %rdi
movq %r13, %rsi
callq 0x33c0
movq %rax, %rdi
movq %rbp, %rsi
callq 0x31c0
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x11010
movslq (%rsp), %rax
testq %rax, %rax
js 0x11064
movq (%rbx), %rcx
movq 0x8(%rbx), %rdx
subq %rcx, %rdx
sarq $0x3, %rdx
cmpq %rax, %rdx
jbe 0x11064
movq 0x28(%rsp), %r14
movq (%rcx,%rax,8), %rdi
callq 0xc17c
movq %rax, %rdi
callq 0x6ec8
movq %r14, %rdi
movq %rax, %rsi
callq 0x33f0
testl %eax, %eax
jne 0x110d3
movq 0x8(%rsp), %r14
movslq (%rsp), %rax
movq (%rbx), %rcx
movq (%rcx,%rax,8), %rdi
callq 0xc180
movq %rax, %rdi
callq 0x6ec8
movq %r14, %rdi
movq %rax, %rsi
callq 0x33f0
testl %eax, %eax
jne 0x110b4
movslq (%rsp), %rax
movq (%rbx), %rcx
movq (%rcx,%rax,8), %rax
movsd 0x48(%rsp), %xmm0
movsd %xmm0, 0x38(%rax)
jmp 0x10f38
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x1102c
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x32f0
movq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rax
cmpq %rax, %rdi
je 0x11048
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x32f0
leaq 0x70(%rsp), %rdi
callq 0x30d0
addq $0x278, %rsp            # imm = 0x278
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0xff65(%rip), %rdi      # 0x20fd0
leaq 0x835c(%rip), %rsi      # 0x193ce
movl $0x4a, %edx
callq 0x3340
movl (%rsp), %esi
movq 0xff4a(%rip), %rdi      # 0x20fd0
callq 0x3560
movq %rax, %rbx
leaq 0x8384(%rip), %rsi      # 0x19419
movl $0x37, %edx
movq %rax, %rdi
callq 0x3340
movq %rbx, %rdi
callq 0x3160
movl $0x1, %edi
callq 0x3370
leaq 0x83d5(%rip), %rdi      # 0x19490
leaq 0x7310(%rip), %rsi      # 0x183d2
leaq 0x8298(%rip), %rcx      # 0x19361
movl $0x43a, %edx            # imm = 0x43A
callq 0x31b0
leaq 0x8377(%rip), %rdi      # 0x19451
leaq 0x72f1(%rip), %rsi      # 0x183d2
leaq 0x8279(%rip), %rcx      # 0x19361
movl $0x439, %edx            # imm = 0x439
callq 0x31b0
movq 0xfed7(%rip), %rdi      # 0x20fd0
leaq 0x8186(%rip), %rsi      # 0x19286
movl $0x3c, %edx
callq 0x3340
movq 0xfebf(%rip), %rdi      # 0x20fd0
movq %r14, %rsi
callq 0x32c0
movq %rax, %rdi
callq 0x3160
leaq 0x72a8(%rip), %rdi      # 0x183d0
leaq 0x72a3(%rip), %rsi      # 0x183d2
leaq 0x822b(%rip), %rcx      # 0x19361
movl $0x41e, %edx            # imm = 0x41E
callq 0x31b0
leaq 0x826e(%rip), %rdi      # 0x193b5
leaq 0x7284(%rip), %rsi      # 0x183d2
leaq 0x820c(%rip), %rcx      # 0x19361
movl $0x423, %edx            # imm = 0x423
callq 0x31b0
leaq 0x7f58(%rip), %rdi      # 0x190be
leaq 0x7265(%rip), %rsi      # 0x183d2
leaq 0x81ed(%rip), %rcx      # 0x19361
movl $0x42b, %edx            # imm = 0x42B
callq 0x31b0
jmp 0x11180
movq %rax, %rbx
jmp 0x111c2
jmp 0x11187
movq %rax, %rbx
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x111a6
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x32f0
movq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rax
cmpq %rax, %rdi
je 0x111c2
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x32f0
leaq 0x70(%rsp), %rdi
callq 0x30d0
movq %rbx, %rdi
callq 0x3570