// File: /workspace/github_cpp_makefile_star2_O2/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:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x118, %rsp            # imm = 0x118
movapd %xmm0, 0x20(%rsp)
movq %rdx, 0x8(%rsp)
movq %rdi, %rbx
leaq 0xa32d(%rip), %rdi      # 0x28b00
callq 0x2360
movq 0x108(%rbx), %rsi
leaq 0x9a2a(%rip), %rdi      # 0x28210
xorl %eax, %eax
callq 0x2030
movq %rbx, %rdi
callq 0x18d3c
leaq 0x9a22(%rip), %rdi      # 0x2821e
movq %rax, %rsi
xorl %eax, %eax
callq 0x2030
movq 0x58(%rbx), %rsi
leaq 0x9a22(%rip), %rdi      # 0x28233
xorl %eax, %eax
callq 0x2030
xorpd %xmm0, %xmm0
movapd %xmm0, 0xd0(%rsp)
andq $0x0, 0xe0(%rsp)
movapd %xmm0, 0x50(%rsp)
andq $0x0, 0x60(%rsp)
movq %rbx, 0x10(%rsp)
movq %rbx, %rdi
callq 0x18d3c
leaq 0x50(%rsp), %rdi
movq %rax, %rsi
callq 0x45f0
leaq 0x30(%rsp), %rax
andq $0x0, 0x10(%rax)
xorpd %xmm0, %xmm0
movapd %xmm0, (%rax)
leaq 0x70(%rsp), %rax
movapd %xmm0, (%rax)
andq $0x0, 0x10(%rax)
xorl %ebx, %ebx
leaq 0xb0(%rsp), %r13
pushq $0x3
popq %rbp
leaq 0x90(%rsp), %r14
movq 0x8(%rsp), %rcx
movq (%rcx), %rax
movq 0x8(%rcx), %rcx
subq %rax, %rcx
sarq $0x3, %rcx
cmpq %rbx, %rcx
jbe 0x1e939
movl (%rax,%rbx,8), %r12d
movl 0x4(%rax,%rbx,8), %r15d
xorpd %xmm0, %xmm0
movapd %xmm0, 0xb0(%rsp)
andq $0x0, 0xc0(%rsp)
movapd %xmm0, 0x90(%rsp)
andq $0x0, 0xa0(%rsp)
movq %r13, %rdi
movq %rbp, %rsi
callq 0xafb8
movq %r14, %rdi
movq %rbp, %rsi
callq 0x45f0
movq 0x10(%rsp), %rdi
movl %r12d, %esi
movl %r15d, %edx
leaq 0x50(%rsp), %rcx
movq %r14, %r8
movq %r13, %r9
callq 0xa87e
leaq 0x30(%rsp), %rdi
movq %r13, %rsi
callq 0x16414
leaq 0x70(%rsp), %rdi
movq %r14, %rsi
callq 0x16440
movq %r14, %rdi
callq 0x5754
movq %r13, %rdi
callq 0x5720
incq %rbx
jmp 0x1e889
movq 0x30(%rsp), %rsi
movq 0x38(%rsp), %rax
subq %rsi, %rax
pushq $0x18
popq %rdi
cqto
idivq %rdi
xorpd %xmm3, %xmm3
xorl %edi, %edi
xorpd %xmm2, %xmm2
movq 0x70(%rsp), %rdx
movq %rax, %r8
xorl %r14d, %r14d
xorl %ebp, %ebp
subq $0x1, %r8
jb 0x1e990
movq (%rsi,%rdi), %r9
addl 0x4(%r9), %ebp
addl 0x8(%r9), %r14d
movq (%rdx,%rdi), %r9
movupd (%r9), %xmm0
addpd %xmm0, %xmm3
addsd 0x10(%r9), %xmm2
addq $0x18, %rdi
jmp 0x1e965
xorpd %xmm4, %xmm4
subq $0x1, %rax
jb 0x1e9bf
movq (%rdx), %rsi
movsd (%rsi), %xmm0
addsd 0x8(%rsi), %xmm0
addsd 0x10(%rsi), %xmm0
movapd 0x20(%rsp), %xmm1
divsd %xmm0, %xmm1
addsd %xmm1, %xmm4
addq $0x18, %rdx
jmp 0x1e994
movsd %xmm4, 0x68(%rsp)
movapd %xmm3, %xmm0
unpckhpd %xmm3, %xmm0            # xmm0 = xmm0[1],xmm3[1]
addsd %xmm3, %xmm0
addsd %xmm2, %xmm0
movq %rcx, %xmm4
punpckldq 0x980e(%rip), %xmm4 # xmm4 = xmm4[0],mem[0],xmm4[1],mem[1]
subpd 0x9816(%rip), %xmm4     # 0x28200
movapd %xmm4, %xmm1
unpckhpd %xmm4, %xmm1            # xmm1 = xmm1[1],xmm4[1]
addsd %xmm4, %xmm1
divsd %xmm1, %xmm0
leaq 0xa709(%rip), %rdi      # 0x2910a
movapd %xmm0, 0x100(%rsp)
movb $0x1, %al
movsd %xmm2, (%rsp)
movapd %xmm3, 0xf0(%rsp)
callq 0x2030
movq 0x10(%rsp), %rdi
callq 0x18d3c
cvtsi2sd %r14d, %xmm0
cvtsi2sd %ebp, %xmm1
movsd (%rsp), %xmm2
divsd %xmm0, %xmm2
movsd %xmm2, (%rsp)
movq %rax, %xmm0
punpckldq 0x97a3(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0x97ab(%rip), %xmm0     # 0x28200
movapd %xmm0, %xmm2
unpckhpd %xmm0, %xmm2            # xmm2 = xmm2[1],xmm0[1]
addpd %xmm0, %xmm2
unpcklpd %xmm2, %xmm1            # xmm1 = xmm1[0],xmm2[0]
movapd 0xf0(%rsp), %xmm0
shufpd $0x1, 0x20(%rsp), %xmm0 # xmm0 = xmm0[1],mem[0]
divpd %xmm1, %xmm0
movapd %xmm0, %xmm2
unpckhpd %xmm0, %xmm2            # xmm2 = xmm2[1],xmm0[1]
movapd %xmm2, 0x10(%rsp)
movapd %xmm0, %xmm1
divsd %xmm2, %xmm1
leaq 0xa69a(%rip), %rdi      # 0x29130
movb $0x2, %al
callq 0x2030
movsd (%rsp), %xmm0
movapd %xmm0, %xmm1
divsd 0x10(%rsp), %xmm1
leaq 0xa699(%rip), %rdi      # 0x2914c
movb $0x2, %al
callq 0x2030
movapd 0x20(%rsp), %xmm0
divsd 0x100(%rsp), %xmm0
leaq 0xa698(%rip), %rdi      # 0x29168
movb $0x1, %al
callq 0x2030
movq 0x8(%rsp), %rcx
movq 0x8(%rcx), %rax
subq (%rcx), %rax
sarq $0x3, %rax
movq %rax, %xmm0
punpckldq 0x96fc(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0x9704(%rip), %xmm0     # 0x28200
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
movsd 0x68(%rsp), %xmm0
divsd %xmm1, %xmm0
leaq 0xa673(%rip), %rdi      # 0x2918c
movb $0x1, %al
callq 0x2030
leaq 0x70(%rsp), %rdi
callq 0x49da
leaq 0x30(%rsp), %rdi
callq 0xafea
leaq 0x50(%rsp), %rdi
callq 0x5754
leaq 0xd0(%rsp), %rdi
callq 0x16772
addq $0x118, %rsp            # imm = 0x118
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
jmp 0x1eb84
movq %rax, %rbx
jmp 0x1eb98
movq %rax, %rbx
leaq 0x90(%rsp), %rdi
callq 0x5754
leaq 0xb0(%rsp), %rdi
callq 0x5720
leaq 0x70(%rsp), %rdi
callq 0x49da
leaq 0x30(%rsp), %rdi
callq 0xafea
leaq 0x50(%rsp), %rdi
callq 0x5754
leaq 0xd0(%rsp), %rdi
callq 0x16772
movq %rbx, %rdi
callq 0x23d0