// File: /workspace/github_cpp_makefile_star2_O2/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, %ebx
movl %esi, %r14d
movq %rdi, %r12
movl %esi, %edi
shlq $0x3, %rdi
xorl %ebp, %ebp
testl %esi, %esi
pushq $-0x1
popq %rax
cmovsq %rax, %rdi
cmovlel %ebp, %r14d
callq 0x3030
movq %rax, %r15
movslq 0x9c8(%r12), %r13
cmpq $-0x1, %r13
leaq 0x4(,%r13,4), %rax
pushq $-0x1
popq %rcx
cmovlq %rcx, %rax
movq %rax, 0x8(%rsp)
movl %ebx, %ebx
cmpq %r14, %rbp
je 0xddb4
movq 0x8(%rsp), %rdi
callq 0x3030
movq %rax, (%r15,%rbp,8)
xorl %ecx, %ecx
cmpq %r13, %rcx
jg 0xddaf
andl $0x0, (%rax,%rcx,4)
incq %rcx
jmp 0xdda1
incq %rbp
jmp 0xdd8c
xorl %ebp, %ebp
cmpl %ebp, %r14d
je 0xddee
cmpl $0x0, 0xa60(%r12)
je 0xddd5
movq %r12, %rdi
movl %ebp, %esi
movq %r15, %rdx
callq 0xd716
jmp 0xddea
movq %r12, %rdi
callq 0xd6da
movq %r12, %rdi
movl %ebp, %esi
movq %r15, %rdx
callq 0xd8f2
incl %ebp
jmp 0xddb6
movl 0x9c8(%r12), %eax
movq 0xae0(%r12), %rcx
xorl %edx, %edx
testl %eax, %eax
cmovlel %edx, %eax
incl %eax
xorps %xmm0, %xmm0
movsd %xmm0, 0x8(%rsp)
pushq $0x1
popq %rdx
movss 0x5271(%rip), %xmm0     # 0x1308c
xorpd %xmm5, %xmm5
xorpd %xmm6, %xmm6
cmpq %rax, %rdx
je 0xdea3
imulq $0x18, %rdx, %rdi
addq %rcx, %rdi
xorpd %xmm2, %xmm2
xorl %r8d, %r8d
xorpd %xmm1, %xmm1
cmpq %r8, %r14
je 0xde82
movq (%r15,%r8,8), %r9
movss (%r9,%rdx,4), %xmm3
ucomiss %xmm0, %xmm3
jne 0xde75
jp 0xde75
movq (%rdi), %r9
movsd (%r9,%r8,8), %xmm3
cmpq %r8, %rbx
je 0xde6a
movapd %xmm3, %xmm4
maxsd %xmm1, %xmm4
movapd %xmm4, %xmm1
ucomisd %xmm2, %xmm3
jbe 0xde75
movl %r8d, %esi
jmp 0xde79
movapd %xmm2, %xmm3
incq %r8
movapd %xmm3, %xmm2
jmp 0xde3a
cmpl %ebx, %esi
jne 0xde96
movsd 0x8(%rsp), %xmm3
addsd %xmm2, %xmm3
movsd %xmm3, 0x8(%rsp)
addsd %xmm2, %xmm6
addsd %xmm1, %xmm5
incq %rdx
jmp 0xde23
xorl %ebx, %ebx
movsd %xmm5, 0x18(%rsp)
movsd %xmm6, 0x10(%rsp)
cmpq %rbx, %r14
je 0xdec9
movq (%r15,%rbx,8), %rdi
testq %rdi, %rdi
je 0xdec4
callq 0x33f0
incq %rbx
jmp 0xdeb1
movq %r15, %rdi
callq 0x33f0
movq 0x20(%rsp), %rax
movsd 0x10(%rsp), %xmm0
movsd %xmm0, (%rax)
movsd 0x8(%rsp), %xmm0
movsd %xmm0, 0x8(%rax)
movsd 0x18(%rsp), %xmm0
movsd %xmm0, 0x10(%rax)
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop