// File: dtsaras[P]GCW/rwgraph.cpp
// Function: Graph::calculate_tsim(int)
double Graph::calculate_tsim(int P){
    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 total_sim = 0;
    double max_weight;
    for (int v = 1; v <= getSize(); ++v){
        max_weight = 0;
        for (int p = 0; p < P; ++p){
            if (aware_all_ev[p][v] != 0 && similarities[v][p] > max_weight){
                max_weight = similarities[v][p];
            }
        }
        total_sim += max_weight;
    }

    for (int p = 0; p < P; ++p){
        delete [] aware_all_ev[p];
    }
    delete [] aware_all_ev;

    return total_sim;
}

// Assembly:
subq $0x68, %rsp
movq %rdi, 0x60(%rsp)
movl %esi, 0x5c(%rsp)
movq 0x60(%rsp), %rax
movq %rax, 0x18(%rsp)
movslq 0x5c(%rsp), %rax
movl $0x8, %ecx
mulq %rcx
movq %rax, %rdi
seto %cl
movq $-0x1, %rax
testb $0x1, %cl
cmovneq %rax, %rdi
callq 0x4030
movq %rax, 0x50(%rsp)
movl $0x0, 0x4c(%rsp)
movl 0x4c(%rsp), %eax
cmpl 0x5c(%rsp), %eax
jge 0x22387
movq 0x18(%rsp), %rdi
callq 0x1db70
addl $0x1, %eax
cltq
movl $0x4, %ecx
mulq %rcx
movq %rax, %rdi
seto %cl
movq $-0x1, %rax
testb $0x1, %cl
cmovneq %rax, %rdi
callq 0x4030
movq %rax, %rdx
movq 0x50(%rsp), %rax
movslq 0x4c(%rsp), %rcx
movq %rdx, (%rax,%rcx,8)
movl $0x0, 0x48(%rsp)
movq 0x18(%rsp), %rdi
movl 0x48(%rsp), %eax
movl %eax, 0x14(%rsp)
callq 0x1db70
movl %eax, %ecx
movl 0x14(%rsp), %eax
cmpl %ecx, %eax
jg 0x22375
movq 0x50(%rsp), %rax
movslq 0x4c(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movslq 0x48(%rsp), %rcx
xorps %xmm0, %xmm0
movss %xmm0, (%rax,%rcx,4)
movl 0x48(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x48(%rsp)
jmp 0x22331
jmp 0x22377
movl 0x4c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x4c(%rsp)
jmp 0x222da
movl $0x0, 0x44(%rsp)
movl 0x44(%rsp), %eax
cmpl 0x5c(%rsp), %eax
jge 0x223e8
movq 0x18(%rsp), %rax
cmpl $0x0, 0xa60(%rax)
jne 0x223c6
movq 0x18(%rsp), %rdi
callq 0x21590
movq 0x18(%rsp), %rdi
movl 0x44(%rsp), %esi
movq 0x50(%rsp), %rdx
callq 0x21a80
jmp 0x223d9
movq 0x18(%rsp), %rdi
movl 0x44(%rsp), %esi
movq 0x50(%rsp), %rdx
callq 0x21610
jmp 0x223db
movl 0x44(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x44(%rsp)
jmp 0x2238f
xorps %xmm0, %xmm0
movsd %xmm0, 0x38(%rsp)
movl $0x1, 0x2c(%rsp)
movq 0x18(%rsp), %rdi
movl 0x2c(%rsp), %eax
movl %eax, 0x10(%rsp)
callq 0x1db70
movl %eax, %ecx
movl 0x10(%rsp), %eax
cmpl %ecx, %eax
jg 0x224ec
xorps %xmm0, %xmm0
movsd %xmm0, 0x30(%rsp)
movl $0x0, 0x28(%rsp)
movl 0x28(%rsp), %eax
cmpl 0x5c(%rsp), %eax
jge 0x224ca
movq 0x50(%rsp), %rax
movslq 0x28(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movslq 0x2c(%rsp), %rcx
movss (%rax,%rcx,4), %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jne 0x2245c
jp 0x2245c
jmp 0x224b8
movq 0x18(%rsp), %rdi
addq $0xae0, %rdi            # imm = 0xAE0
movslq 0x2c(%rsp), %rsi
callq 0xf180
movq %rax, %rdi
movslq 0x28(%rsp), %rsi
callq 0xeb00
movsd (%rax), %xmm0
ucomisd 0x30(%rsp), %xmm0
jbe 0x224b8
movq 0x18(%rsp), %rdi
addq $0xae0, %rdi            # imm = 0xAE0
movslq 0x2c(%rsp), %rsi
callq 0xf180
movq %rax, %rdi
movslq 0x28(%rsp), %rsi
callq 0xeb00
movsd (%rax), %xmm0
movsd %xmm0, 0x30(%rsp)
jmp 0x224ba
movl 0x28(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x28(%rsp)
jmp 0x2242a
movsd 0x30(%rsp), %xmm0
addsd 0x38(%rsp), %xmm0
movsd %xmm0, 0x38(%rsp)
movl 0x2c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x2c(%rsp)
jmp 0x223f9
movl $0x0, 0x24(%rsp)
movl 0x24(%rsp), %eax
cmpl 0x5c(%rsp), %eax
jge 0x22530
movq 0x50(%rsp), %rax
movslq 0x24(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, 0x8(%rsp)
cmpq $0x0, %rax
je 0x22521
movq 0x8(%rsp), %rdi
callq 0x44c0
jmp 0x22523
movl 0x24(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x24(%rsp)
jmp 0x224f4
movq 0x50(%rsp), %rax
movq %rax, (%rsp)
cmpq $0x0, %rax
je 0x22548
movq (%rsp), %rdi
callq 0x44c0
movsd 0x38(%rsp), %xmm0
addq $0x68, %rsp
retq
nopw %cs:(%rax,%rax)