// File: /workspace/github_cpp_makefile_star2_O1/fjamour[P]icentral/src/unit_tests.h
// Function: timing__Update_BC_graph(graph_t&, std::vector<std::pair<unsigned int, unsigned int>, std::allocator<std::pair<unsigned int, unsigned int>>>&, int, comp_type_t, bool, double, int, bool, operation_t)
void timing__Update_BC_graph(
            graph_t&        graph,
            vector<edge_t>& edge_vec,
            int             num_sources,
            comp_type_t     algo_flag,
            bool            do_brandes = true,
            double          brandes_time = 0.0,
            int             num_threads = 1,
            bool            del_edge = false,//in case the edges are already in the graph
            operation_t     op = INSERTION
        )
{
    int rank, size;
    MPI_Comm_rank(MPI_COMM_WORLD, &rank);
    MPI_Comm_size(MPI_COMM_WORLD, &size);
    MPI_Status    status;
    
    timer           tm;
    vector<double>  BC_vec;
    vector<double>  tm_vec;
    vector<double>  speedup_vec;
    
    BC_vec.resize(graph.size());
    if(do_brandes) {
        tm.start();
        //fast_brandes_BC(graph, BC_vec);
        BC_vec = brandes_bc(graph);
        tm.stop();
        brandes_time = tm.interval();
    }
    if(rank == 0) {
        printf("Graph[%s]  V[%d]  E[%d]  Brandes_tm[%.2f]\n",
                graph.graph_name.c_str(),
                graph.size(),
                graph.edge_set.size(),
                brandes_time);
    }
    for(int i = 0; i < edge_vec.size(); ++i) {
        edge_t e = edge_vec[i];
        if(del_edge) graph.remove_edge(e.first, e.second);
        tm.start();
        Update_BC(BC_vec, graph, algo_flag, e, num_threads, op);
        tm.stop();
        double e_time = tm.interval();
        tm_vec.push_back(e_time);
        double e_speedup = brandes_time/e_time;
        speedup_vec.push_back(e_speedup);
        
        if(rank == 0) {
            printf("e(%-6d,%-6d)  tm[%.2f]  sup[%.2f]\n",
                    e.first,
                    e.second,
                    e_time,
                    e_speedup);
        }
        if(del_edge) graph.insert_edge(e.first, e.second);
        //synchronization barrier so no one starts next edge before others
        MPI_Barrier(MPI_COMM_WORLD);
    }
    
    double tm_mean, tm_stddev, tm_median, tm_min, tm_max;
    double su_mean, su_stddev, su_median, su_min, su_max;
    simple_stats(tm_vec, tm_mean, tm_stddev, tm_median, tm_min, tm_max);
    simple_stats(speedup_vec, su_mean, su_stddev, su_median, su_min, su_max);
    
    if(rank == 0)
        printf("Avg.tm[%.2f]  Avg.sup[%.2f]\n\n", tm_mean, su_mean);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x138, %rsp            # imm = 0x138
movl %r9d, 0x5c(%rsp)
movsd %xmm0, 0x48(%rsp)
movl %r8d, %r12d
movl %ecx, 0x58(%rsp)
movq %rsi, %r14
movq %rdi, %r15
movq 0x1f95a(%rip), %r13     # 0x3ffc8
leaq 0xc(%rsp), %rsi
movq %r13, %rdi
callq 0x2300
leaq 0xfc(%rsp), %rsi
movq %r13, %rdi
callq 0x22a0
xorl %eax, %eax
movq %rax, 0x40(%rsp)
xorpd %xmm0, %xmm0
movapd %xmm0, 0x30(%rsp)
movq %rax, 0x90(%rsp)
movapd %xmm0, 0x80(%rsp)
movq %rax, 0x70(%rsp)
movapd %xmm0, 0x60(%rsp)
movq %r15, %rdi
callq 0x1e160
leaq 0x30(%rsp), %rdi
movq %rax, %rsi
callq 0x5c58
testb %r12b, %r12b
je 0x2079c
leaq 0xd8(%rsp), %rdi
xorl %esi, %esi
callq 0x2360
leaq 0x10(%rsp), %rdi
movq %r15, %rsi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0xaa17
movq 0x30(%rsp), %rdi
movq 0x40(%rsp), %rsi
movaps 0x10(%rsp), %xmm0
movaps %xmm0, 0x30(%rsp)
movq 0x20(%rsp), %rax
movq %rax, 0x40(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
movq $0x0, 0x20(%rsp)
testq %rdi, %rdi
je 0x20733
subq %rdi, %rsi
callq 0x2250
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x2074a
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x2250
leaq 0xe8(%rsp), %r12
movq %r12, %rdi
xorl %esi, %esi
callq 0x2360
xorps %xmm0, %xmm0
cvtsi2sdq -0x10(%r12), %xmm0
cvtsi2sdq -0x8(%r12), %xmm1
movsd 0x10a2b(%rip), %xmm2    # 0x311a0
divsd %xmm2, %xmm1
cvtsi2sdq (%r12), %xmm3
cvtsi2sdq 0x8(%r12), %xmm4
addsd %xmm0, %xmm1
divsd %xmm2, %xmm4
addsd %xmm3, %xmm4
subsd %xmm1, %xmm4
movsd %xmm4, 0x48(%rsp)
cmpl $0x0, 0xc(%rsp)
jne 0x207d0
movq 0x108(%r15), %r12
movq %r15, %rdi
callq 0x1e160
movq 0x58(%r15), %rcx
leaq 0x11512(%rip), %rdi     # 0x31ccf
movq %r12, %rsi
movq %rax, %rdx
movsd 0x48(%rsp), %xmm0
movb $0x1, %al
callq 0x2030
movq (%r14), %rax
cmpq %rax, 0x8(%r14)
je 0x2096e
movb 0x170(%rsp), %bl
xorl %ebp, %ebp
movl (%rax,%rbp,8), %r13d
movl 0x4(%rax,%rbp,8), %r12d
testb %bl, %bl
je 0x20801
movq %r15, %rdi
movl %r13d, %esi
movl %r12d, %edx
callq 0x1deda
leaq 0xd8(%rsp), %rdi
xorl %esi, %esi
callq 0x2360
movq %r12, %rcx
shlq $0x20, %rcx
orq %r13, %rcx
leaq 0x30(%rsp), %rdi
movq %r15, %rsi
movl 0x58(%rsp), %edx
movl 0x5c(%rsp), %r8d
movl 0x178(%rsp), %r9d
callq 0x3456
leaq 0xe8(%rsp), %rdi
xorl %esi, %esi
callq 0x2360
xorps %xmm1, %xmm1
cvtsi2sdq 0xd8(%rsp), %xmm1
xorps %xmm2, %xmm2
cvtsi2sdq 0xe0(%rsp), %xmm2
movsd 0x10937(%rip), %xmm4    # 0x311a0
divsd %xmm4, %xmm2
xorps %xmm3, %xmm3
cvtsi2sdq 0xe8(%rsp), %xmm3
xorps %xmm0, %xmm0
cvtsi2sdq 0xf0(%rsp), %xmm0
addsd %xmm1, %xmm2
divsd %xmm4, %xmm0
addsd %xmm3, %xmm0
subsd %xmm2, %xmm0
movsd %xmm0, 0x10(%rsp)
movq 0x88(%rsp), %rsi
cmpq 0x90(%rsp), %rsi
je 0x208c1
movsd %xmm0, (%rsi)
addq $0x8, %rsi
movq %rsi, 0x88(%rsp)
jmp 0x208d3
leaq 0x80(%rsp), %rdi
leaq 0x10(%rsp), %rdx
callq 0x1b82c
movsd 0x48(%rsp), %xmm0
divsd 0x10(%rsp), %xmm0
movsd %xmm0, 0x50(%rsp)
movq 0x68(%rsp), %rsi
cmpq 0x70(%rsp), %rsi
je 0x20900
movsd %xmm0, (%rsi)
addq $0x8, %rsi
movq %rsi, 0x68(%rsp)
jmp 0x2090f
leaq 0x60(%rsp), %rdi
leaq 0x50(%rsp), %rdx
callq 0x1b82c
cmpl $0x0, 0xc(%rsp)
jne 0x20936
movsd 0x10(%rsp), %xmm0
movsd 0x50(%rsp), %xmm1
leaq 0x113d1(%rip), %rdi     # 0x31cfa
movl %r13d, %esi
movl %r12d, %edx
movb $0x2, %al
callq 0x2030
testb %bl, %bl
je 0x20948
movq %r15, %rdi
movl %r13d, %esi
movl %r12d, %edx
callq 0x1de06
movq 0x1f679(%rip), %rdi     # 0x3ffc8
callq 0x21a0
incq %rbp
movq (%r14), %rax
movq 0x8(%r14), %rcx
subq %rax, %rcx
sarq $0x3, %rcx
cmpq %rbp, %rcx
ja 0x207e6
leaq 0xb8(%rsp), %rdi
leaq 0x80(%rsp), %rsi
callq 0x1b35e
leaq 0xb8(%rsp), %rdi
leaq 0x10(%rsp), %rsi
leaq 0x50(%rsp), %rdx
leaq 0x130(%rsp), %rcx
leaq 0x128(%rsp), %r8
leaq 0x120(%rsp), %r9
callq 0x2fae4
movq 0xb8(%rsp), %rdi
testq %rdi, %rdi
je 0x209cf
movq 0xc8(%rsp), %rsi
subq %rdi, %rsi
callq 0x2250
leaq 0xa0(%rsp), %rdi
leaq 0x60(%rsp), %rsi
callq 0x1b35e
leaq 0xa0(%rsp), %rdi
leaq 0xd0(%rsp), %rsi
leaq 0x118(%rsp), %rdx
leaq 0x110(%rsp), %rcx
leaq 0x108(%rsp), %r8
leaq 0x100(%rsp), %r9
callq 0x2fae4
movq 0xa0(%rsp), %rdi
testq %rdi, %rdi
je 0x20a33
movq 0xb0(%rsp), %rsi
subq %rdi, %rsi
callq 0x2250
cmpl $0x0, 0xc(%rsp)
jne 0x20a57
movsd 0x10(%rsp), %xmm0
movsd 0xd0(%rsp), %xmm1
leaq 0x112cd(%rip), %rdi     # 0x31d1d
movb $0x2, %al
callq 0x2030
movq 0x60(%rsp), %rdi
testq %rdi, %rdi
je 0x20a6e
movq 0x70(%rsp), %rsi
subq %rdi, %rsi
callq 0x2250
movq 0x80(%rsp), %rdi
testq %rdi, %rdi
je 0x20a8b
movq 0x90(%rsp), %rsi
subq %rdi, %rsi
callq 0x2250
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x20aa2
movq 0x40(%rsp), %rsi
subq %rdi, %rsi
callq 0x2250
addq $0x138, %rsp            # imm = 0x138
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x20afa
movq %rax, %rbx
movq 0xa0(%rsp), %rdi
testq %rdi, %rdi
je 0x20afd
movq 0xb0(%rsp), %rsi
jmp 0x20ae8
movq %rax, %rbx
movq 0xb8(%rsp), %rdi
testq %rdi, %rdi
je 0x20afd
movq 0xc8(%rsp), %rsi
subq %rdi, %rsi
callq 0x2250
jmp 0x20afd
jmp 0x20afa
jmp 0x20afa
jmp 0x20afa
jmp 0x20afa
movq %rax, %rbx
movq 0x60(%rsp), %rdi
testq %rdi, %rdi
je 0x20b14
movq 0x70(%rsp), %rsi
subq %rdi, %rsi
callq 0x2250
movq 0x80(%rsp), %rdi
testq %rdi, %rdi
je 0x20b31
movq 0x90(%rsp), %rsi
subq %rdi, %rsi
callq 0x2250
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x20b48
movq 0x40(%rsp), %rsi
subq %rdi, %rsi
callq 0x2250
movq %rbx, %rdi
callq 0x23b0