// File: fjamour[P]icentral/src/paper_exp.cc
// Function: exp_inc_brandes_p(graph_t&, int, std::vector<std::pair<unsigned int, unsigned int>, std::allocator<std::pair<unsigned int, unsigned int>>>, double)
void    exp_inc_brandes_p(graph_t& graph,
            int num_iter,
            vector<edge_t> rand_edge_vec,
            double brandes_time)
{
    printf("==========================================================\n");
    printf("Graph: \t\t\t%s\n", graph.graph_name.c_str());
    printf("Graph # nodes: \t\t%d\n", graph.size());
    printf("Graph # edges: \t\t%d\n", graph.edge_set.size());
    timer tm;
    vector<edge_stat_t> edge_stat_vec;
    
    vector<double> bc_vec;
    bc_vec.resize(graph.size());
 
    vector<vector<int> >    cnt_vec2;
    vector<vector<double> > time_vec2;
    
    for(int i = 0; i < rand_edge_vec.size(); ++i) {
        //printf("Inserting edge [%d]...\n", i);
        edge_t rand_edge = rand_edge_vec[i];
        
        vector<int> cnt_vec;
        vector<double> time_vec;
        cnt_vec.resize(3);
        time_vec.resize(3);
        
        
        incremental_brandes_experimental(graph,
                rand_edge.first, 
                rand_edge.second, 
                bc_vec,
                time_vec,
                cnt_vec);
        cnt_vec2.push_back(cnt_vec);
        time_vec2.push_back(time_vec);
    }

    int tot_cnt_arr[] = {0, 0, 0};
    double tot_time_arr[] = {0, 0, 0};
    
    for(int i = 0; i < cnt_vec2.size(); ++i) {
        tot_cnt_arr[0] += cnt_vec2[i][0];
        tot_cnt_arr[1] += cnt_vec2[i][1];
        tot_cnt_arr[2] += cnt_vec2[i][2];
        
        tot_time_arr[0] += time_vec2[i][0];
        tot_time_arr[1] += time_vec2[i][1];
        tot_time_arr[2] += time_vec2[i][2];
    }
    double tot_speedup = 0;
    for(int i = 0; i < cnt_vec2.size(); ++i) {
        double inc_br_time = time_vec2[i][0] + time_vec2[i][1] + time_vec2[i][2];
        tot_speedup += (brandes_time/inc_br_time);
    }
    
    double inc_tot_time = tot_time_arr[0] + tot_time_arr[1] + tot_time_arr[2];
    double inc_avg_time = inc_tot_time/rand_edge_vec.size();
    printf("Incremental-Brandes avg. runtime:\t%f\n", inc_avg_time);
    double avg_d1_tm = tot_time_arr[1]/tot_cnt_arr[1];
    double avg_d2_tm = tot_time_arr[2]/tot_cnt_arr[2];
    double avg_br_tm = brandes_time/graph.size();
    //the prints below is for the total iterations for all the inserted edges
    //they don't make sense if not reported per edge
//    printf("Tot d0 BFS:\t\t\t\t%d/%d\n", tot_cnt_arr[0], graph.size());
//    printf("Tot d1 BFS:\t\t\t\t%d/%d\n", tot_cnt_arr[1], graph.size());
//    printf("Tot d2 BFS:\t\t\t\t%d/%d\n", tot_cnt_arr[2], graph.size());
    printf("Avg d1 BFS time:\t\t\t%f (%f)\n", avg_d1_tm, avg_d1_tm/avg_br_tm);
    printf("Avg d2 BFS time:\t\t\t%f (%f)\n", avg_d2_tm, avg_d2_tm/avg_br_tm);
    printf("[[Avg. speedup (inc_brandes): %f]]\n", brandes_time/inc_avg_time);
    printf("[[Avg. speedup (inc_brandes)(proper): %f]]\n", tot_speedup/rand_edge_vec.size());
}

// Assembly:
subq $0x1c8, %rsp            # imm = 0x1C8
movq %rdx, 0x50(%rsp)
movq %rdi, 0x1c0(%rsp)
movl %esi, 0x1bc(%rsp)
movq %rdx, 0x1b0(%rsp)
movsd %xmm0, 0x1a8(%rsp)
leaq 0x16e1d(%rip), %rdi     # 0x7b2e0
xorl %eax, %eax
movb %al, 0x5f(%rsp)
callq 0x9040
movq 0x1c0(%rsp), %rdi
addq $0x108, %rdi            # imm = 0x108
callq 0x9250
movq %rax, %rsi
movb 0x5f(%rsp), %al
leaq 0x16e2c(%rip), %rdi     # 0x7b31c
callq 0x9040
movq 0x1c0(%rsp), %rdi
callq 0x56b40
movq %rax, %rsi
movb 0x5f(%rsp), %al
leaq 0x16e1a(%rip), %rdi     # 0x7b32a
callq 0x9040
movq 0x1c0(%rsp), %rdi
addq $0x30, %rdi
callq 0x4dbe0
movq %rax, %rsi
movb 0x5f(%rsp), %al
leaq 0x16e0b(%rip), %rdi     # 0x7b33f
callq 0x9040
leaq 0x170(%rsp), %rdi
callq 0x4dca0
leaq 0x158(%rsp), %rdi
callq 0xfa00
movq 0x1c0(%rsp), %rdi
callq 0x56b40
movq %rax, 0x60(%rsp)
jmp 0x64567
movq 0x60(%rsp), %rsi
leaq 0x158(%rsp), %rdi
callq 0xf680
jmp 0x6457b
leaq 0x130(%rsp), %rdi
callq 0x2cf10
leaq 0x118(%rsp), %rdi
callq 0x101b0
movl $0x0, 0x114(%rsp)
movq 0x50(%rsp), %rdi
movslq 0x114(%rsp), %rax
movq %rax, 0x48(%rsp)
callq 0x47680
movq %rax, %rcx
movq 0x48(%rsp), %rax
cmpq %rcx, %rax
jae 0x64708
movq 0x50(%rsp), %rdi
movslq 0x114(%rsp), %rsi
callq 0x4dbc0
movq (%rax), %rax
movq %rax, 0x108(%rsp)
leaq 0xf0(%rsp), %rdi
movq %rdi, 0x40(%rsp)
callq 0xfc40
leaq 0xd8(%rsp), %rdi
callq 0xfa00
movq 0x40(%rsp), %rdi
movl $0x3, %esi
callq 0x2cfc0
jmp 0x64615
leaq 0xd8(%rsp), %rdi
movl $0x3, %esi
callq 0xf680
jmp 0x64629
movq 0x1c0(%rsp), %rdi
movl 0x108(%rsp), %esi
movl 0x10c(%rsp), %edx
leaq 0x158(%rsp), %rcx
leaq 0xd8(%rsp), %r8
leaq 0xf0(%rsp), %r9
callq 0x2bfc0
jmp 0x6465e
leaq 0x130(%rsp), %rdi
leaq 0xf0(%rsp), %rsi
callq 0x4dfb0
jmp 0x64675
leaq 0x118(%rsp), %rdi
leaq 0xd8(%rsp), %rsi
callq 0x4e020
jmp 0x6468c
leaq 0xd8(%rsp), %rdi
callq 0xfa50
leaq 0xf0(%rsp), %rdi
callq 0xfc70
movl 0x114(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x114(%rsp)
jmp 0x645a0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x150(%rsp)
movl %eax, 0x14c(%rsp)
jmp 0x64c23
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x150(%rsp)
movl %eax, 0x14c(%rsp)
leaq 0xd8(%rsp), %rdi
callq 0xfa50
leaq 0xf0(%rsp), %rdi
callq 0xfc70
jmp 0x64c09
leaq 0xcc(%rsp), %rdi
xorl %esi, %esi
movl $0xc, %edx
callq 0x9350
leaq 0xb0(%rsp), %rdi
xorl %esi, %esi
movl $0x18, %edx
callq 0x9350
movl $0x0, 0xac(%rsp)
movslq 0xac(%rsp), %rax
movq %rax, 0x38(%rsp)
leaq 0x130(%rsp), %rdi
callq 0x2d120
movq %rax, %rcx
movq 0x38(%rsp), %rax
cmpq %rcx, %rax
jae 0x648b8
movslq 0xac(%rsp), %rsi
leaq 0x130(%rsp), %rdi
callq 0x2d100
movq %rax, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0xfc50
movl (%rax), %eax
addl 0xcc(%rsp), %eax
movl %eax, 0xcc(%rsp)
movslq 0xac(%rsp), %rsi
leaq 0x130(%rsp), %rdi
callq 0x2d100
movq %rax, %rdi
movl $0x1, %esi
callq 0xfc50
movl (%rax), %eax
addl 0xd0(%rsp), %eax
movl %eax, 0xd0(%rsp)
movslq 0xac(%rsp), %rsi
leaq 0x130(%rsp), %rdi
callq 0x2d100
movq %rax, %rdi
movl $0x2, %esi
callq 0xfc50
movl (%rax), %eax
addl 0xd4(%rsp), %eax
movl %eax, 0xd4(%rsp)
movslq 0xac(%rsp), %rsi
leaq 0x118(%rsp), %rdi
callq 0x10260
movq %rax, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0xfa30
movsd (%rax), %xmm0
addsd 0xb0(%rsp), %xmm0
movsd %xmm0, 0xb0(%rsp)
movslq 0xac(%rsp), %rsi
leaq 0x118(%rsp), %rdi
callq 0x10260
movq %rax, %rdi
movl $0x1, %esi
callq 0xfa30
movsd (%rax), %xmm0
addsd 0xb8(%rsp), %xmm0
movsd %xmm0, 0xb8(%rsp)
movslq 0xac(%rsp), %rsi
leaq 0x118(%rsp), %rdi
callq 0x10260
movq %rax, %rdi
movl $0x2, %esi
callq 0xfa30
movsd (%rax), %xmm0
addsd 0xc0(%rsp), %xmm0
movsd %xmm0, 0xc0(%rsp)
movl 0xac(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xac(%rsp)
jmp 0x6473b
xorps %xmm0, %xmm0
movsd %xmm0, 0xa0(%rsp)
movl $0x0, 0x9c(%rsp)
movslq 0x9c(%rsp), %rax
movq %rax, 0x30(%rsp)
leaq 0x130(%rsp), %rdi
callq 0x2d120
movq %rax, %rcx
movq 0x30(%rsp), %rax
cmpq %rcx, %rax
jae 0x649c6
movslq 0x9c(%rsp), %rsi
leaq 0x118(%rsp), %rdi
callq 0x10260
movq %rax, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0xfa30
movsd (%rax), %xmm0
movsd %xmm0, 0x20(%rsp)
movslq 0x9c(%rsp), %rsi
leaq 0x118(%rsp), %rdi
callq 0x10260
movq %rax, %rdi
movl $0x1, %esi
callq 0xfa30
movsd 0x20(%rsp), %xmm0
addsd (%rax), %xmm0
movsd %xmm0, 0x28(%rsp)
movslq 0x9c(%rsp), %rsi
leaq 0x118(%rsp), %rdi
callq 0x10260
movq %rax, %rdi
movl $0x2, %esi
callq 0xfa30
movsd 0x28(%rsp), %xmm0
addsd (%rax), %xmm0
movsd %xmm0, 0x90(%rsp)
movsd 0x1a8(%rsp), %xmm0
divsd 0x90(%rsp), %xmm0
addsd 0xa0(%rsp), %xmm0
movsd %xmm0, 0xa0(%rsp)
movl 0x9c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x9c(%rsp)
jmp 0x648cf
movq 0x50(%rsp), %rdi
movsd 0xb0(%rsp), %xmm0
movsd 0xb8(%rsp), %xmm1
addsd %xmm1, %xmm0
movsd 0xc0(%rsp), %xmm1
addsd %xmm1, %xmm0
movsd %xmm0, 0x88(%rsp)
movsd 0x88(%rsp), %xmm0
movsd %xmm0, 0x18(%rsp)
callq 0x47680
movsd 0x18(%rsp), %xmm0
movq %rax, %xmm1
movaps 0x16893(%rip), %xmm2    # 0x7b2b0
punpckldq %xmm2, %xmm1    # xmm1 = xmm1[0],xmm2[0],xmm1[1],xmm2[1]
movapd 0x16897(%rip), %xmm2    # 0x7b2c0
subpd %xmm2, %xmm1
movaps %xmm1, %xmm2
unpckhpd %xmm1, %xmm1            # xmm1 = xmm1[1,1]
addsd %xmm2, %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, 0x80(%rsp)
movsd 0x80(%rsp), %xmm0
leaq 0x177b3(%rip), %rdi     # 0x7c208
movb $0x1, %al
callq 0x9040
jmp 0x64a5e
movsd 0xb8(%rsp), %xmm0
cvtsi2sdl 0xd0(%rsp), %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, 0x78(%rsp)
movsd 0xc0(%rsp), %xmm0
cvtsi2sdl 0xd4(%rsp), %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, 0x70(%rsp)
movsd 0x1a8(%rsp), %xmm0
movsd %xmm0, 0x8(%rsp)
movq 0x1c0(%rsp), %rdi
callq 0x56b40
movq %rax, 0x10(%rsp)
jmp 0x64ab9
movsd 0x8(%rsp), %xmm0
movq 0x10(%rsp), %rax
movq %rax, %xmm1
movaps 0x167e0(%rip), %xmm2    # 0x7b2b0
punpckldq %xmm2, %xmm1    # xmm1 = xmm1[0],xmm2[0],xmm1[1],xmm2[1]
movapd 0x167e4(%rip), %xmm2    # 0x7b2c0
subpd %xmm2, %xmm1
movaps %xmm1, %xmm2
unpckhpd %xmm1, %xmm1            # xmm1 = xmm1[1,1]
addsd %xmm2, %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, 0x68(%rsp)
movsd 0x78(%rsp), %xmm0
movsd 0x68(%rsp), %xmm2
movaps %xmm0, %xmm1
divsd %xmm2, %xmm1
leaq 0x1771f(%rip), %rdi     # 0x7c22e
movb $0x2, %al
callq 0x9040
jmp 0x64b18
movsd 0x70(%rsp), %xmm0
movsd 0x68(%rsp), %xmm2
movaps %xmm0, %xmm1
divsd %xmm2, %xmm1
leaq 0x17718(%rip), %rdi     # 0x7c24a
movb $0x2, %al
callq 0x9040
jmp 0x64b3b
movsd 0x1a8(%rsp), %xmm0
movsd 0x80(%rsp), %xmm1
divsd %xmm1, %xmm0
leaq 0x1770e(%rip), %rdi     # 0x7c266
movb $0x1, %al
callq 0x9040
jmp 0x64b61
movq 0x50(%rsp), %rdi
movsd 0xa0(%rsp), %xmm0
movsd %xmm0, (%rsp)
callq 0x47680
movsd (%rsp), %xmm0
movq %rax, %xmm1
movaps 0x16726(%rip), %xmm2    # 0x7b2b0
punpckldq %xmm2, %xmm1    # xmm1 = xmm1[0],xmm2[0],xmm1[1],xmm2[1]
movapd 0x1672a(%rip), %xmm2    # 0x7b2c0
subpd %xmm2, %xmm1
movaps %xmm1, %xmm2
unpckhpd %xmm1, %xmm1            # xmm1 = xmm1[1,1]
addsd %xmm2, %xmm1
divsd %xmm1, %xmm0
leaq 0x176da(%rip), %rdi     # 0x7c28a
movb $0x1, %al
callq 0x9040
jmp 0x64bb9
leaq 0x118(%rsp), %rdi
callq 0x10400
leaq 0x130(%rsp), %rdi
callq 0x2d140
leaq 0x158(%rsp), %rdi
callq 0xfa50
leaq 0x170(%rsp), %rdi
callq 0x4dd90
addq $0x1c8, %rsp            # imm = 0x1C8
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x150(%rsp)
movl %eax, 0x14c(%rsp)
leaq 0x118(%rsp), %rdi
callq 0x10400
leaq 0x130(%rsp), %rdi
callq 0x2d140
leaq 0x158(%rsp), %rdi
callq 0xfa50
leaq 0x170(%rsp), %rdi
callq 0x4dd90
movq 0x150(%rsp), %rdi
callq 0x9cf0
nopw (%rax,%rax)