// File: /workspace/github_c_makefile_star2_O0/stonezwr[P]SpiKL-IP/neuron.C
// Function: Neuron::CollectPreSynAct(double&, double&, int&)
void Neuron::CollectPreSynAct(double& p_n, double& avg_i_n, int& max_i_n){
    if(_presyn_act.empty()){
        cout<<"Do you forget to record the pre-synaptic firing activities??\n"
            <<"Or do you mistakenly clear the vector<bool> _presyn_act ?"<<endl;
        assert(!_presyn_act.empty());
    }

    int sum_intvl = 0, cnt_f = 0, max_i = 0;
    int start = -1;
    for(int i = 0; i < _presyn_act.size(); ++i){
        if(_presyn_act[i]){
            ++cnt_f;
            max_i = max(max_i, i - start - 1);
            sum_intvl += i - start - 1;
            start = i;
        }
    }
    max_i = max(max_i, (int)_presyn_act.size() - start - 1);
    sum_intvl += _presyn_act.size() - start - 1;

    p_n = ((double)cnt_f)/((double)_presyn_act.size());
    avg_i_n = ((double)sum_intvl)/(cnt_f+1);
    max_i_n = max_i;
    // clear the presynaptic neuron activity vector after visiting it!
    _presyn_act.clear();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0x58(%rbp)
addq $0x60, %rdi
callq 0x126a0
testb $0x1, %al
jne 0xcf1f
jmp 0xcf88
movq 0x400a2(%rip), %rdi     # 0x4cfc8
leaq 0x2784a(%rip), %rsi     # 0x34777
callq 0x4360
movq %rax, %rdi
leaq 0x27879(%rip), %rsi     # 0x347b5
callq 0x4360
movq %rax, %rdi
movq 0x4006d(%rip), %rsi     # 0x4cfb8
callq 0x43b0
movq -0x58(%rbp), %rdi
addq $0x60, %rdi
callq 0x126a0
xorb $-0x1, %al
testb $0x1, %al
jne 0xcf65
jmp 0xcf67
jmp 0xcf86
leaq 0x27881(%rip), %rdi     # 0x347ef
leaq 0x2772c(%rip), %rsi     # 0x346a1
movl $0x1c9, %edx            # imm = 0x1C9
leaq 0x27883(%rip), %rcx     # 0x34804
callq 0x4210
jmp 0xcf88
movl $0x0, -0x24(%rbp)
movl $0x0, -0x28(%rbp)
movl $0x0, -0x2c(%rbp)
movl $0xffffffff, -0x30(%rbp) # imm = 0xFFFFFFFF
movl $0x0, -0x34(%rbp)
movq -0x58(%rbp), %rdi
movslq -0x34(%rbp), %rax
movq %rax, -0x60(%rbp)
addq $0x60, %rdi
callq 0x12720
movq %rax, %rcx
movq -0x60(%rbp), %rax
cmpq %rcx, %rax
jae 0xd040
movq -0x58(%rbp), %rdi
addq $0x60, %rdi
movslq -0x34(%rbp), %rsi
callq 0x127a0
movq %rax, -0x48(%rbp)
movq %rdx, -0x40(%rbp)
leaq -0x48(%rbp), %rdi
callq 0x12800
testb $0x1, %al
jne 0xcff4
jmp 0xd030
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
movl -0x34(%rbp), %eax
subl -0x30(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x4c(%rbp)
leaq -0x2c(%rbp), %rdi
leaq -0x4c(%rbp), %rsi
callq 0x8c70
movl (%rax), %eax
movl %eax, -0x2c(%rbp)
movl -0x34(%rbp), %eax
subl -0x30(%rbp), %eax
subl $0x1, %eax
addl -0x24(%rbp), %eax
movl %eax, -0x24(%rbp)
movl -0x34(%rbp), %eax
movl %eax, -0x30(%rbp)
jmp 0xd032
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0xcfab
movq -0x58(%rbp), %rdi
addq $0x60, %rdi
movq %rdi, -0x70(%rbp)
callq 0x12720
movl %eax, %ecx
movl -0x30(%rbp), %eax
notl %eax
addl %ecx, %eax
movl %eax, -0x50(%rbp)
leaq -0x2c(%rbp), %rdi
leaq -0x50(%rbp), %rsi
callq 0x8c70
movq -0x70(%rbp), %rdi
movl (%rax), %eax
movl %eax, -0x2c(%rbp)
callq 0x12720
movq -0x70(%rbp), %rdi
movl -0x30(%rbp), %ecx
notl %ecx
addl %eax, %ecx
movl -0x24(%rbp), %eax
addl %ecx, %eax
movl %eax, -0x24(%rbp)
cvtsi2sdl -0x28(%rbp), %xmm0
movsd %xmm0, -0x68(%rbp)
callq 0x12720
movsd -0x68(%rbp), %xmm0
movq -0x58(%rbp), %rdi
movq %rax, %xmm1
movaps 0x27581(%rip), %xmm2    # 0x34630
punpckldq %xmm2, %xmm1    # xmm1 = xmm1[0],xmm2[0],xmm1[1],xmm2[1]
movapd 0x27585(%rip), %xmm2    # 0x34640
subpd %xmm2, %xmm1
movaps %xmm1, %xmm2
unpckhpd %xmm1, %xmm1            # xmm1 = xmm1[1,1]
addsd %xmm2, %xmm1
divsd %xmm1, %xmm0
movq -0x10(%rbp), %rax
movsd %xmm0, (%rax)
cvtsi2sdl -0x24(%rbp), %xmm0
movl -0x28(%rbp), %eax
addl $0x1, %eax
cvtsi2sd %eax, %xmm1
divsd %xmm1, %xmm0
movq -0x18(%rbp), %rax
movsd %xmm0, (%rax)
movl -0x2c(%rbp), %ecx
movq -0x20(%rbp), %rax
movl %ecx, (%rax)
addq $0x60, %rdi
callq 0x12830
addq $0x70, %rsp
popq %rbp
retq
nopl (%rax)