// File: /workspace/github_c_makefile_star2_O2/stonezwr[P]SpiKL-IP/./network.h
// Function: void Network::LSMAddSynapse<double>(Neuron*, Neuron*, double, bool, double, bool, NeuronGroup*)
void LSMAddSynapse(Neuron * pre, Neuron * post, T weight, bool fixed, T weight_limit,bool liquid, NeuronGroup * group = NULL){
        Synapse * synapse = new Synapse(pre, post, weight, fixed, weight_limit, pre->IsExcitatory(),liquid);
        _synapses.push_back(synapse);
        std::string pre_name = std::string(pre->Name());
        std::string post_name = std::string(post->Name());
        if(_synapses_map.find(pre_name) == _synapses_map.end()){
            _synapses_map[pre_name] = std::unordered_map<std::string, Synapse*>();
        }
        if(_synapses_map[pre_name].find(post_name) != _synapses_map[pre_name].end()){
            std::cout<<"Warning:: duplicate synapse "<<pre_name<<" to "<<post_name<<" detected"<<std::endl;
        }
        _synapses_map[pre_name][post_name] = synapse; 
    
        // push back the reservoir, readout and input synapses into the vector:
        if(!synapse->IsReadoutSyn() && !synapse->IsInputSyn())
            _rsynapses.push_back(synapse);
        else if(synapse->IsReadoutSyn())
            _rosynapses.push_back(synapse);
        else
            _isynapses.push_back(synapse);

        if(group)  group->AddSynapse(synapse);
        pre->AddPostSyn(synapse);
        post->AddPreSyn(synapse);	
    }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xa8, %rsp
movq %r9, 0x38(%rsp)
movl %r8d, %ebp
movsd %xmm1, 0x48(%rsp)
movl %ecx, %r15d
movsd %xmm0, 0x40(%rsp)
movq %rdx, %rbx
movq %rsi, %r14
movq %rdi, %r12
movl $0xc0, %edi
callq 0x32c0
movq %rax, %r13
movzbl 0x110(%r14), %r8d
movq %rax, %rdi
movq %r14, %rsi
movq %rbx, 0x10(%rsp)
movq %rbx, %rdx
movsd 0x40(%rsp), %xmm0
movl %r15d, %ecx
movsd 0x48(%rsp), %xmm1
movl %ebp, %r9d
callq 0xa604
leaq 0x8(%rsp), %rsi
movq %r13, (%rsi)
leaq 0x100(%r12), %rdi
callq 0x97ec
movq 0x10(%r14), %rsi
leaq 0x18(%rsp), %rdi
leaq 0x70(%rsp), %rdx
callq 0x8d8c
movq 0x10(%rsp), %rax
movq 0x10(%rax), %rsi
leaq 0x50(%rsp), %rdi
leaq 0x70(%rsp), %rdx
callq 0x8d8c
leaq 0x50(%r12), %r13
leaq 0x18(%rsp), %rsi
movq %r13, %rdi
callq 0x98b4
testq %rax, %rax
jne 0x8f6e
leaq 0xa0(%rsp), %rax
andq $0x0, -0x10(%rax)
movq %rax, -0x30(%rax)
movq $0x1, -0x28(%rax)
xorps %xmm0, %xmm0
movups %xmm0, -0x20(%rax)
movl $0x3f800000, -0x10(%rax) # imm = 0x3F800000
movups %xmm0, -0x8(%rax)
leaq 0x18(%rsp), %rsi
movq %r13, %rdi
callq 0x99a0
leaq 0x70(%rsp), %r15
movq %rax, %rdi
movq %r15, %rsi
callq 0x9d78
movq %r15, %rdi
callq 0x9e92
leaq 0x18(%rsp), %rsi
movq %r13, %rdi
callq 0x99a0
leaq 0x50(%rsp), %rsi
movq %rax, %rdi
callq 0x9eec
movq %rax, %rbp
leaq 0x18(%rsp), %rsi
movq %r13, %rdi
callq 0x99a0
testq %rbp, %rbp
movq 0x38(%rsp), %rbp
je 0x8ff5
movq 0x1701f(%rip), %rdi     # 0x1ffc8
leaq 0xc200(%rip), %rsi      # 0x151b0
callq 0x32a0
leaq 0x18(%rsp), %rsi
movq %rax, %rdi
callq 0x3250
leaq 0xc204(%rip), %rsi      # 0x151cd
movq %rax, %rdi
callq 0x32a0
leaq 0x50(%rsp), %rsi
movq %rax, %rdi
callq 0x3250
leaq 0xc1ed(%rip), %rsi      # 0x151d2
movq %rax, %rdi
callq 0x32a0
movq %rax, %rdi
callq 0x3160
movq 0x8(%rsp), %r15
leaq 0x18(%rsp), %rsi
movq %r13, %rdi
callq 0x99a0
leaq 0x50(%rsp), %rsi
movq %rax, %rdi
callq 0x9fbc
movq %r15, (%rax)
movq 0x8(%rsp), %rdi
callq 0xa75a
testb %al, %al
jne 0x9038
movq 0x8(%rsp), %rdi
callq 0xa780
movl $0x118, %ecx            # imm = 0x118
testb %al, %al
je 0x9052
movq 0x8(%rsp), %rdi
callq 0xa75a
testb %al, %al
movl $0x130, %eax            # imm = 0x130
movl $0x148, %ecx            # imm = 0x148
cmovneq %rax, %rcx
addq %rcx, %r12
leaq 0x8(%rsp), %rsi
movq %r12, %rdi
callq 0x8ba0
testq %rbp, %rbp
je 0x9074
movq 0x8(%rsp), %rsi
movq %rbp, %rdi
callq 0x7860
movq 0x8(%rsp), %rsi
movq %r14, %rdi
callq 0x5d20
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdi
callq 0x5d36
leaq 0x50(%rsp), %rdi
callq 0x3150
leaq 0x18(%rsp), %rdi
callq 0x3150
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq 0x70(%rsp), %rdi
callq 0x9e92
jmp 0x90ea
jmp 0x90e7
jmp 0x90e7
movq %rax, %rbx
jmp 0x90f4
movq %rax, %rbx
jmp 0x90fe
movq %rax, %rbx
movl $0xc0, %esi
movq %r13, %rdi
callq 0x32d0
jmp 0x90fe
jmp 0x90e7
movq %rax, %rbx
leaq 0x50(%rsp), %rdi
callq 0x3150
leaq 0x18(%rsp), %rdi
callq 0x3150
movq %rbx, %rdi
callq 0x3540