// File: /workspace/github_cpp_makefile_star2_O1/dtsaras[P]GCW/rwgraph.cpp
// Function: Graph::calculate_sim_stats(int, int, double*)
void Graph::calculate_sim_stats(int P, int ev, double * stats){
    float** aware_all_ev = new float*[P];
    for (int p = 0; p < P; ++p){
        aware_all_ev[p] = new float[getSize() + 1];
        for(int v = 0; v <= getSize(); v++){
            aware_all_ev[p][v] = 0;
        }
    }

    for (int ev = 0; ev < P; ev++){
        if (model == 0){
            rand_LT();
            BFS_LT(ev, aware_all_ev);
        }
        else
            BFS_IC(ev, aware_all_ev);
    }
    double similarity_Sj = 0;
    double similarity_S_Sj = 0;
    double total_sim  = 0;
    double max_weight;
    double max_weight_not_ev;
    int max_event;
    for (int v = 1; v <= getSize(); ++v){
        // if (aware_all_ev[ev][v] == 1){
        //     similarity_Sj += similarities[v][ev];
        // }
        max_weight = 0;
        max_weight_not_ev = 0;
        for (int p = 0; p < P; ++p){
            if (aware_all_ev[p][v] == 1 && similarities[v][p] > max_weight_not_ev && p != ev){
                max_weight_not_ev = similarities[v][p];
            }
            if (aware_all_ev[p][v] == 1 && similarities[v][p] > max_weight){
                max_weight = similarities[v][p];
                max_event = p;
            }
        }
        if (max_event == ev){
            similarity_Sj += max_weight;
        }
        total_sim += max_weight;
        similarity_S_Sj += max_weight_not_ev;
    }
    for (int p = 0; p < P; ++p){
        delete [] aware_all_ev[p];
    }
    delete [] aware_all_ev;

    stats[0] = total_sim;
    stats[1] = similarity_Sj;
    stats[2] = similarity_S_Sj;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rcx, 0x20(%rsp)
movl %edx, (%rsp)
movl %esi, %ebp
movq %rdi, %r12
movslq %esi, %r13
leaq (,%r13,8), %rdi
testl %r13d, %r13d
movq $-0x1, %rbx
cmovsq %rbx, %rdi
callq 0x3030
movq %rax, %r14
movl %ebp, 0x14(%rsp)
movl %ebp, %r15d
testl %r13d, %r13d
jle 0x1136d
movslq 0x9c8(%r12), %rbp
cmpq $-0x1, %rbp
leaq 0x4(,%rbp,4), %r13
cmovlq %rbx, %r13
leal 0x1(%rbp), %eax
shlq $0x2, %rax
movq %rax, 0x8(%rsp)
xorl %ebx, %ebx
movq %r13, %rdi
callq 0x3030
movq %rax, (%r14,%rbx,8)
testl %ebp, %ebp
js 0x11365
movq %rax, %rdi
xorl %esi, %esi
movq 0x8(%rsp), %rdx
callq 0x31c0
incq %rbx
cmpq %rbx, %r15
jne 0x11346
movl 0x14(%rsp), %ebp
testl %ebp, %ebp
jle 0x113ac
xorl %ebx, %ebx
cmpl $0x0, 0xa60(%r12)
je 0x11391
movq %r12, %rdi
movl %ebx, %esi
movq %r14, %rdx
callq 0x10858
jmp 0x113a6
movq %r12, %rdi
callq 0x107d0
movq %r12, %rdi
movl %ebx, %esi
movq %r14, %rdx
callq 0x10c22
incl %ebx
cmpl %ebx, %ebp
jne 0x11377
movl 0x9c8(%r12), %eax
testl %eax, %eax
jle 0x11475
movq 0xae0(%r12), %rcx
movl (%rsp), %r11d
movl %r11d, %edx
incq %rax
xorpd %xmm5, %xmm5
movl $0x1, %esi
movss 0x6cdd(%rip), %xmm0     # 0x180bc
xorpd %xmm6, %xmm6
xorpd %xmm7, %xmm7
testl %ebp, %ebp
jle 0x1144e
leaq (%rsi,%rsi,2), %r8
leaq (%rcx,%r8,8), %r8
xorpd %xmm1, %xmm1
xorl %r9d, %r9d
xorpd %xmm2, %xmm2
movq (%r14,%r9,8), %r10
movss (%r10,%rsi,4), %xmm3
ucomiss %xmm0, %xmm3
jne 0x11427
jp 0x11427
cmpq %r9, %rdx
je 0x11427
movq (%r8), %r10
movsd (%r10,%r9,8), %xmm4
ucomisd %xmm1, %xmm4
jbe 0x11427
movapd %xmm4, %xmm1
ucomiss %xmm0, %xmm3
jne 0x11444
jp 0x11444
movq (%r8), %r10
movsd (%r10,%r9,8), %xmm3
ucomisd %xmm2, %xmm3
jbe 0x11444
movapd %xmm3, %xmm2
movl %r9d, %edi
incq %r9
cmpq %r9, %r15
jne 0x113fe
jmp 0x11456
xorpd %xmm2, %xmm2
xorpd %xmm1, %xmm1
cmpl %r11d, %edi
jne 0x1145f
addsd %xmm2, %xmm7
addsd %xmm2, %xmm5
addsd %xmm1, %xmm6
incq %rsi
cmpq %rax, %rsi
jne 0x113e7
jmp 0x11481
xorpd %xmm7, %xmm7
xorpd %xmm6, %xmm6
xorpd %xmm5, %xmm5
movsd %xmm7, 0x18(%rsp)
movsd %xmm6, (%rsp)
movsd %xmm5, 0x8(%rsp)
testl %ebp, %ebp
jle 0x114ae
xorl %ebx, %ebx
movq (%r14,%rbx,8), %rdi
testq %rdi, %rdi
je 0x114a6
callq 0x3410
incq %rbx
cmpq %rbx, %r15
jne 0x11498
movq %r14, %rdi
callq 0x3410
movq 0x20(%rsp), %rax
movsd 0x8(%rsp), %xmm0
movsd %xmm0, (%rax)
movsd 0x18(%rsp), %xmm0
movsd %xmm0, 0x8(%rax)
movsd (%rsp), %xmm0
movsd %xmm0, 0x10(%rax)
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop