// File: /workspace/github_cpp_makefile_star2_O3/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, 0xd0(%rsp)
movq %rdx, 0x8(%rsp)
movq %rdi, %rbx
leaq 0xb3e5(%rip), %rdi      # 0x30b40
callq 0x2350
movq 0x108(%rbx), %rsi
leaq 0xaae2(%rip), %rdi      # 0x30250
xorl %eax, %eax
callq 0x2030
movq %rbx, %rdi
callq 0x1dfcc
leaq 0xaada(%rip), %rdi      # 0x3025e
movq %rax, %rsi
xorl %eax, %eax
callq 0x2030
movq 0x58(%rbx), %rsi
leaq 0xaada(%rip), %rdi      # 0x30273
xorl %eax, %eax
callq 0x2030
xorpd %xmm0, %xmm0
movapd %xmm0, 0x10(%rsp)
movq $0x0, 0x20(%rsp)
movq %rbx, 0x30(%rsp)
movq %rbx, %rdi
callq 0x1dfcc
leaq 0x10(%rsp), %rdi
movq %rax, %rsi
callq 0x5be8
xorpd %xmm4, %xmm4
movapd %xmm4, 0xa0(%rsp)
xorl %eax, %eax
movq %rax, 0xb0(%rsp)
movq %rax, 0x90(%rsp)
movapd %xmm4, 0x80(%rsp)
movq 0x8(%rsp), %rax
movq (%rax), %rcx
movq 0x8(%rax), %rax
xorpd %xmm0, %xmm0
subq %rcx, %rax
je 0x259b6
xorl %r14d, %r14d
leaq 0x60(%rsp), %r15
leaq 0x40(%rsp), %r12
xorl %ebx, %ebx
movl (%rcx,%rbx,8), %r13d
movl 0x4(%rcx,%rbx,8), %ebp
movq %r14, 0x70(%rsp)
xorpd %xmm0, %xmm0
movapd %xmm0, 0x60(%rsp)
movq %r14, 0x50(%rsp)
movapd %xmm0, 0x40(%rsp)
movl $0x3, %esi
movq %r15, %rdi
callq 0xd848
movl $0x3, %esi
movq %r12, %rdi
callq 0x5be8
movq 0x30(%rsp), %rdi
movl %r13d, %esi
movl %ebp, %edx
leaq 0x10(%rsp), %rcx
movq %r12, %r8
movq %r15, %r9
callq 0xceaf
leaq 0xa0(%rsp), %rdi
movq %r15, %rsi
callq 0x1b338
leaq 0x80(%rsp), %rdi
movq %r12, %rsi
callq 0x1b364
movq 0x40(%rsp), %rdi
testq %rdi, %rdi
je 0x258aa
movq 0x50(%rsp), %rsi
subq %rdi, %rsi
callq 0x2250
movq 0x60(%rsp), %rdi
testq %rdi, %rdi
je 0x258c1
movq 0x70(%rsp), %rsi
subq %rdi, %rsi
callq 0x2250
incq %rbx
movq 0x8(%rsp), %rax
movq (%rax), %rcx
movq 0x8(%rax), %rax
subq %rcx, %rax
sarq $0x3, %rax
cmpq %rbx, %rax
ja 0x2581d
movq 0xa0(%rsp), %rdx
movq 0xa8(%rsp), %rsi
movq %rsi, %rdi
subq %rdx, %rdi
je 0x259d2
sarq $0x3, %rdi
movabsq $-0x5555555555555555, %rcx # imm = 0xAAAAAAAAAAAAAAAB
imulq %rdi, %rcx
movq 0x80(%rsp), %rdi
cmpq $0x1, %rcx
movq %rcx, %r8
adcq $0x0, %r8
pxor %xmm2, %xmm2
xorpd %xmm4, %xmm4
xorpd %xmm0, %xmm0
xorl %r9d, %r9d
movq (%rdx,%r9), %r10
movq 0x4(%r10), %xmm1
paddd %xmm1, %xmm2
movq (%rdi,%r9), %r10
addsd (%r10), %xmm0
movupd 0x8(%r10), %xmm1
addpd %xmm1, %xmm4
addq $0x18, %r9
decq %r8
jne 0x25930
cvtdq2pd %xmm2, %xmm1
movapd %xmm1, 0xc0(%rsp)
cmpq %rdx, %rsi
movapd 0xd0(%rsp), %xmm2
je 0x259f2
movq 0x80(%rsp), %rdx
cmpq $0x1, %rcx
adcq $0x0, %rcx
xorpd %xmm5, %xmm5
movq (%rdx), %rsi
movsd (%rsi), %xmm3
addsd 0x8(%rsi), %xmm3
addsd 0x10(%rsi), %xmm3
movapd %xmm2, %xmm1
divsd %xmm3, %xmm1
addsd %xmm1, %xmm5
addq $0x18, %rdx
decq %rcx
jne 0x25989
movsd %xmm5, (%rsp)
jmp 0x259fb
sarq $0x3, %rax
xorpd %xmm1, %xmm1
movsd %xmm1, (%rsp)
xorpd %xmm1, %xmm1
movapd %xmm1, 0xc0(%rsp)
jmp 0x259fb
xorpd %xmm4, %xmm4
xorpd %xmm0, %xmm0
movsd %xmm0, (%rsp)
xorpd %xmm0, %xmm0
movapd %xmm0, 0xc0(%rsp)
xorpd %xmm0, %xmm0
jmp 0x259fb
xorpd %xmm1, %xmm1
movsd %xmm1, (%rsp)
movapd %xmm4, 0x100(%rsp)
addsd %xmm4, %xmm0
movapd %xmm4, %xmm1
unpckhpd %xmm4, %xmm1            # xmm1 = xmm1[1],xmm4[1]
movapd %xmm1, 0xe0(%rsp)
addsd %xmm1, %xmm0
movq %rax, %xmm2
punpckldq 0xa7f6(%rip), %xmm2 # xmm2 = xmm2[0],mem[0],xmm2[1],mem[1]
subpd 0xa7fe(%rip), %xmm2     # 0x30230
movapd %xmm2, %xmm1
unpckhpd %xmm2, %xmm1            # xmm1 = xmm1[1],xmm2[1]
addsd %xmm2, %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, 0xf8(%rsp)
leaq 0xb6f8(%rip), %rdi      # 0x3114a
movb $0x1, %al
callq 0x2030
movq 0x30(%rsp), %rdi
callq 0x1dfcc
movapd 0xc0(%rsp), %xmm2
movapd %xmm2, %xmm0
unpckhpd %xmm2, %xmm0            # xmm0 = xmm0[1],xmm2[1]
movapd 0xe0(%rsp), %xmm1
divsd %xmm0, %xmm1
movapd %xmm1, 0xe0(%rsp)
movq %rax, %xmm0
punpckldq 0xa789(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0xa791(%rip), %xmm0     # 0x30230
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addpd %xmm0, %xmm1
movapd 0x100(%rsp), %xmm0
unpcklpd 0xd0(%rsp), %xmm0       # xmm0 = xmm0[0],mem[0]
unpcklpd %xmm1, %xmm2            # xmm2 = xmm2[0],xmm1[0]
divpd %xmm2, %xmm0
movapd %xmm0, %xmm2
unpckhpd %xmm0, %xmm2            # xmm2 = xmm2[1],xmm0[1]
movapd %xmm2, 0x30(%rsp)
movapd %xmm0, %xmm1
divsd %xmm2, %xmm1
leaq 0xb68e(%rip), %rdi      # 0x31170
movb $0x2, %al
callq 0x2030
movapd 0xe0(%rsp), %xmm0
movapd %xmm0, %xmm1
divsd 0x30(%rsp), %xmm1
leaq 0xb689(%rip), %rdi      # 0x3118c
movb $0x2, %al
callq 0x2030
movapd 0xd0(%rsp), %xmm0
divsd 0xf8(%rsp), %xmm0
leaq 0xb685(%rip), %rdi      # 0x311a8
movb $0x1, %al
callq 0x2030
movq 0x8(%rsp), %rcx
movq 0x8(%rcx), %rax
subq (%rcx), %rax
sarq $0x3, %rax
movq %rax, %xmm0
punpckldq 0xa6d9(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0xa6e1(%rip), %xmm0     # 0x30230
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
movsd (%rsp), %xmm0
divsd %xmm1, %xmm0
leaq 0xb661(%rip), %rdi      # 0x311cc
movb $0x1, %al
callq 0x2030
leaq 0x80(%rsp), %rdi
callq 0x5fa4
leaq 0xa0(%rsp), %rdi
callq 0xd87a
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x25ba3
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x2250
addq $0x118, %rsp            # imm = 0x118
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
jmp 0x25bf0
movq %rax, %rbx
jmp 0x25c0a
movq %rax, %rbx
movq 0x40(%rsp), %rdi
testq %rdi, %rdi
je 0x25bd9
movq 0x50(%rsp), %rsi
subq %rdi, %rsi
callq 0x2250
movq 0x60(%rsp), %rdi
testq %rdi, %rdi
je 0x25bf0
movq 0x70(%rsp), %rsi
subq %rdi, %rsi
callq 0x2250
leaq 0x80(%rsp), %rdi
callq 0x5fa4
leaq 0xa0(%rsp), %rdi
callq 0xd87a
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x25c21
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x2250
movq %rbx, %rdi
callq 0x23b0