// File: fjamour[P]icentral/src/unit_tests.h
// Function: timing__Update_BC_mem_graph(graph_t&, std::vector<std::pair<unsigned int, unsigned int>, std::allocator<std::pair<unsigned int, unsigned int>>>&, int, int, bool, double)
void timing__Update_BC_mem_graph(
            graph_t&        graph,
            vector<edge_t>& edge_vec,
            int             num_sources,
            int             algo_flag,
            bool            do_brandes = true,
            double          brandes_time = 0.0
        )
{
    timer           tm;
    vector<double>  BC_vec;
    vector<double>  tm_vec;
    vector<double>  speedup_vec;
    
    
    if(do_brandes) {
        tm.start();
        //fast_brandes_BC(graph, BC_vec);
        BC_vec = brandes_bc(graph);
        tm.stop();
        brandes_time = tm.interval();
    }
    
    
    
    vector<iter_info_t> iter_info_vec;
    component_t comp;
    comp.comp_type = GRAPH;
    comp.subgraph.fill_graph(graph);
    for (node_id_t s = 0; s < graph.size(); ++s) {
        iter_info_t iter_info;
        iter_info.init_all(graph.size());
        BBFS(iter_info, comp, s);
        iter_info_vec.push_back(iter_info);
    }
           
    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];
        tm.start();
        Update_BC_mem(BC_vec, graph, GRAPH, e, iter_info_vec);
        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);
        
        printf("e(%-6d,%-6d)  tm[%.2f]  sup[%.2f]\n",
                e.first,
                e.second,
                e_time,
                e_speedup);
    }
    
    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);
    
    printf("Avg.tm[%.2f]  Avg.sup[%.2f]\n\n", tm_mean, su_mean);
}

// Assembly:
subq $0x518, %rsp            # imm = 0x518
movb %r8b, %al
movq %rdi, 0x510(%rsp)
movq %rsi, 0x508(%rsp)
movl %edx, 0x504(%rsp)
movl %ecx, 0x500(%rsp)
andb $0x1, %al
movb %al, 0x4ff(%rsp)
movsd %xmm0, 0x4f0(%rsp)
leaq 0x4b8(%rsp), %rdi
callq 0xfa00
leaq 0x4a0(%rsp), %rdi
callq 0xfa00
leaq 0x488(%rsp), %rdi
callq 0xfa00
testb $0x1, 0x4ff(%rsp)
je 0x5b28c
leaq 0x4d0(%rsp), %rdi
callq 0x2d430
jmp 0x5b1fe
movq 0x510(%rsp), %rsi
leaq 0x460(%rsp), %rdi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x28720
jmp 0x5b21a
leaq 0x4b8(%rsp), %rdi
leaq 0x460(%rsp), %rsi
movq %rsi, 0x48(%rsp)
callq 0x58bf0
movq 0x48(%rsp), %rdi
callq 0xfa50
leaq 0x4d0(%rsp), %rdi
callq 0x2d450
jmp 0x5b24d
leaq 0x4d0(%rsp), %rdi
callq 0x2d470
movsd %xmm0, 0x40(%rsp)
jmp 0x5b262
movsd 0x40(%rsp), %xmm0
movsd %xmm0, 0x4f0(%rsp)
jmp 0x5b28c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x480(%rsp)
movl %eax, 0x47c(%rsp)
jmp 0x5b721
leaq 0x448(%rsp), %rdi
callq 0x5f200
leaq 0x218(%rsp), %rdi
callq 0xf7c0
jmp 0x5b2a8
movl $0x2, 0x440(%rsp)
movq 0x510(%rsp), %rsi
leaq 0x218(%rsp), %rdi
callq 0x78110
jmp 0x5b2ca
movl $0x0, 0x214(%rsp)
movl 0x214(%rsp), %eax
movq %rax, 0x30(%rsp)
movq 0x510(%rsp), %rdi
callq 0x56b40
movq %rax, 0x38(%rsp)
jmp 0x5b2f5
movq 0x30(%rsp), %rax
movq 0x38(%rsp), %rcx
cmpq %rcx, %rax
jae 0x5b3ed
leaq 0xf8(%rsp), %rdi
callq 0xf850
movq 0x510(%rsp), %rdi
callq 0x56b40
movq %rax, 0x28(%rsp)
jmp 0x5b329
movq 0x28(%rsp), %rsi
leaq 0xf8(%rsp), %rdi
callq 0x59910
jmp 0x5b33d
movl 0x214(%rsp), %edx
leaq 0xf8(%rsp), %rdi
leaq 0x218(%rsp), %rsi
callq 0xb790
jmp 0x5b35b
leaq 0x448(%rsp), %rdi
leaq 0xf8(%rsp), %rsi
callq 0x5f210
jmp 0x5b372
leaq 0xf8(%rsp), %rdi
callq 0xf910
movl 0x214(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x214(%rsp)
jmp 0x5b2d5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x480(%rsp)
movl %eax, 0x47c(%rsp)
jmp 0x5b714
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x480(%rsp)
movl %eax, 0x47c(%rsp)
jmp 0x5b707
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x480(%rsp)
movl %eax, 0x47c(%rsp)
leaq 0xf8(%rsp), %rdi
callq 0xf910
jmp 0x5b707
movq 0x510(%rsp), %rdi
addq $0x108, %rdi            # imm = 0x108
callq 0x9250
movq %rax, 0x18(%rsp)
movq 0x510(%rsp), %rdi
callq 0x56b40
movq %rax, 0x20(%rsp)
jmp 0x5b41a
movq 0x510(%rsp), %rdi
addq $0x30, %rdi
callq 0x4dbe0
movq 0x18(%rsp), %rsi
movq 0x20(%rsp), %rdx
movq %rax, %rcx
movsd 0x4f0(%rsp), %xmm0
leaq 0x20927(%rip), %rdi     # 0x7bd6f
movb $0x1, %al
callq 0x9040
jmp 0x5b451
movl $0x0, 0xf4(%rsp)
movslq 0xf4(%rsp), %rax
movq %rax, 0x10(%rsp)
movq 0x508(%rsp), %rdi
callq 0x47680
movq %rax, %rcx
movq 0x10(%rsp), %rax
cmpq %rcx, %rax
jae 0x5b5ba
movq 0x508(%rsp), %rdi
movslq 0xf4(%rsp), %rsi
callq 0x4dbc0
movq (%rax), %rax
movq %rax, 0xe8(%rsp)
leaq 0x4d0(%rsp), %rdi
callq 0x2d430
jmp 0x5b4b6
movq 0x510(%rsp), %rsi
movq 0xe8(%rsp), %rax
movq %rax, 0xe0(%rsp)
movq 0xe0(%rsp), %rcx
leaq 0x4b8(%rsp), %rdi
movl $0x2, %edx
leaq 0x448(%rsp), %r8
callq 0x1fb10
jmp 0x5b4f2
leaq 0x4d0(%rsp), %rdi
callq 0x2d450
jmp 0x5b501
leaq 0x4d0(%rsp), %rdi
callq 0x2d470
movsd %xmm0, 0x8(%rsp)
jmp 0x5b516
movsd 0x8(%rsp), %xmm0
movsd %xmm0, 0xd8(%rsp)
leaq 0x4a0(%rsp), %rdi
leaq 0xd8(%rsp), %rsi
callq 0x4de20
jmp 0x5b53c
movsd 0x4f0(%rsp), %xmm0
movsd 0xd8(%rsp), %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, 0xd0(%rsp)
leaq 0x488(%rsp), %rdi
leaq 0xd0(%rsp), %rsi
callq 0x4de20
jmp 0x5b572
movl 0xe8(%rsp), %esi
movl 0xec(%rsp), %edx
movsd 0xd8(%rsp), %xmm0
movsd 0xd0(%rsp), %xmm1
leaq 0x20801(%rip), %rdi     # 0x7bd9a
movb $0x2, %al
callq 0x9040
jmp 0x5b5a2
jmp 0x5b5a4
movl 0xf4(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xf4(%rsp)
jmp 0x5b45c
leaq 0x68(%rsp), %rdi
leaq 0x4a0(%rsp), %rsi
callq 0x4de90
jmp 0x5b5ce
leaq 0x68(%rsp), %rdi
leaq 0xc8(%rsp), %rsi
leaq 0xc0(%rsp), %rdx
leaq 0xb8(%rsp), %rcx
leaq 0xb0(%rsp), %r8
leaq 0xa8(%rsp), %r9
callq 0x78710
jmp 0x5b602
leaq 0x68(%rsp), %rdi
callq 0xfa50
leaq 0x50(%rsp), %rdi
leaq 0x488(%rsp), %rsi
callq 0x4de90
jmp 0x5b620
leaq 0x50(%rsp), %rdi
leaq 0xa0(%rsp), %rsi
leaq 0x98(%rsp), %rdx
leaq 0x90(%rsp), %rcx
leaq 0x88(%rsp), %r8
leaq 0x80(%rsp), %r9
callq 0x78710
jmp 0x5b654
leaq 0x50(%rsp), %rdi
callq 0xfa50
movsd 0xc8(%rsp), %xmm0
movsd 0xa0(%rsp), %xmm1
leaq 0x20746(%rip), %rdi     # 0x7bdbd
movb $0x2, %al
callq 0x9040
jmp 0x5b680
leaq 0x218(%rsp), %rdi
callq 0xf9d0
leaq 0x448(%rsp), %rdi
callq 0x5f290
leaq 0x488(%rsp), %rdi
callq 0xfa50
leaq 0x4a0(%rsp), %rdi
callq 0xfa50
leaq 0x4b8(%rsp), %rdi
callq 0xfa50
addq $0x518, %rsp            # imm = 0x518
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x480(%rsp)
movl %eax, 0x47c(%rsp)
leaq 0x68(%rsp), %rdi
callq 0xfa50
jmp 0x5b707
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x480(%rsp)
movl %eax, 0x47c(%rsp)
leaq 0x50(%rsp), %rdi
callq 0xfa50
leaq 0x218(%rsp), %rdi
callq 0xf9d0
leaq 0x448(%rsp), %rdi
callq 0x5f290
leaq 0x488(%rsp), %rdi
callq 0xfa50
leaq 0x4a0(%rsp), %rdi
callq 0xfa50
leaq 0x4b8(%rsp), %rdi
callq 0xfa50
movq 0x480(%rsp), %rdi
callq 0x9cf0
nopw %cs:(%rax,%rax)