// File: /workspace/github_cpp_makefile_star2_O3/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, %rbp
movl %edx, 0x10(%rsp)
movl %esi, %ebx
movq %rdi, %r12
movl %esi, %r15d
leaq (,%r15,8), %rdi
testl %esi, %esi
movq $-0x1, %r13
cmovsq %r13, %rdi
callq 0x3030
movl %ebx, %r11d
movq %rax, %r14
testl %ebx, %ebx
jle 0x11181
movl %r11d, 0x8(%rsp)
movq %rbp, 0x20(%rsp)
movl 0x9c8(%r12), %ebp
leal 0x1(%rbp), %eax
movslq %eax, %rbx
shlq $0x2, %rbx
cmpl $-0x1, %ebp
cmovlq %r13, %rbx
shlq $0x2, %rax
movq %rax, 0x18(%rsp)
xorl %r13d, %r13d
movq %rbx, %rdi
callq 0x3030
movq %rax, (%r14,%r13,8)
testl %ebp, %ebp
js 0x1112d
movq %rax, %rdi
xorl %esi, %esi
movq 0x18(%rsp), %rdx
callq 0x31c0
incq %r13
cmpq %r13, %r15
jne 0x1110e
movl 0x8(%rsp), %r11d
testl %r11d, %r11d
movq 0x20(%rsp), %rbp
jle 0x11181
xorl %ebx, %ebx
cmpl $0x0, 0xa60(%r12)
je 0x11160
movq %r12, %rdi
movl %ebx, %esi
movq %r14, %rdx
callq 0x10660
jmp 0x11175
movq %r12, %rdi
callq 0x105e0
movq %r12, %rdi
movl %ebx, %esi
movq %r14, %rdx
callq 0x10a02
incl %ebx
movl 0x8(%rsp), %r11d
cmpl %ebx, %r11d
jne 0x11146
movl 0x9c8(%r12), %eax
testl %eax, %eax
jle 0x1123d
movq 0xae0(%r12), %rcx
movl 0x10(%rsp), %ebx
movl %ebx, %edx
incq %rax
xorpd %xmm5, %xmm5
movl $0x1, %esi
movss 0x5f09(%rip), %xmm0     # 0x170bc
xorpd %xmm6, %xmm6
xorpd %xmm7, %xmm7
testl %r11d, %r11d
jle 0x1121b
leaq (%rsi,%rsi,2), %r8
leaq (%rcx,%r8,8), %r8
xorpd %xmm1, %xmm1
xorl %r9d, %r9d
xorpd %xmm3, %xmm3
movq (%r14,%r9,8), %r10
movss (%r10,%rsi,4), %xmm2
ucomiss %xmm0, %xmm2
jne 0x11209
jp 0x11209
movq (%r8), %r10
movsd (%r10,%r9,8), %xmm2
cmpq %r9, %rdx
je 0x111fe
movapd %xmm2, %xmm4
maxsd %xmm1, %xmm4
movapd %xmm4, %xmm1
ucomisd %xmm3, %xmm2
jbe 0x11209
movl %r9d, %edi
jmp 0x1120d
movapd %xmm3, %xmm2
incq %r9
movapd %xmm2, %xmm3
cmpq %r9, %r15
jne 0x111d3
jmp 0x11223
xorpd %xmm2, %xmm2
xorpd %xmm1, %xmm1
cmpl %ebx, %edi
jne 0x1122b
addsd %xmm2, %xmm7
addsd %xmm2, %xmm5
addsd %xmm1, %xmm6
incq %rsi
cmpq %rax, %rsi
jne 0x111bb
jmp 0x11249
xorpd %xmm7, %xmm7
xorpd %xmm6, %xmm6
xorpd %xmm5, %xmm5
movsd %xmm7, 0x10(%rsp)
movsd %xmm6, 0x18(%rsp)
movsd %xmm5, 0x8(%rsp)
testl %r11d, %r11d
jle 0x11278
xorl %ebx, %ebx
movq (%r14,%rbx,8), %rdi
testq %rdi, %rdi
je 0x11270
callq 0x3410
incq %rbx
cmpq %rbx, %r15
jne 0x11262
movq %r14, %rdi
callq 0x3410
movsd 0x8(%rsp), %xmm0
movsd %xmm0, (%rbp)
movsd 0x10(%rsp), %xmm0
movsd %xmm0, 0x8(%rbp)
movsd 0x18(%rsp), %xmm0
movsd %xmm0, 0x10(%rbp)
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq