// File: /workspace/github_cpp_makefile_star2_O1/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 $0x108, %rsp            # imm = 0x108
movdqa %xmm0, 0xa0(%rsp)
movq %rdx, 0x8(%rsp)
movq %rdi, %rbx
leaq 0xc1c0(%rip), %rdi      # 0x31b40
callq 0x2350
movq 0x108(%rbx), %rsi
leaq 0xb8bd(%rip), %rdi      # 0x31250
xorl %eax, %eax
callq 0x2030
movq %rbx, %rdi
callq 0x1e160
leaq 0xb8b5(%rip), %rdi      # 0x3125e
movq %rax, %rsi
xorl %eax, %eax
callq 0x2030
movq 0x58(%rbx), %rsi
leaq 0xb8b5(%rip), %rdi      # 0x31273
xorl %eax, %eax
callq 0x2030
pxor %xmm0, %xmm0
movdqa %xmm0, 0x30(%rsp)
movq $0x0, 0x40(%rsp)
movq %rbx, 0x50(%rsp)
movq %rbx, %rdi
callq 0x1e160
leaq 0x30(%rsp), %rdi
movq %rax, %rsi
callq 0x5c58
xorpd %xmm3, %xmm3
movapd %xmm3, 0x80(%rsp)
xorl %eax, %eax
movq %rax, 0x90(%rsp)
movq %rax, 0x70(%rsp)
movapd %xmm3, 0x60(%rsp)
movq 0x8(%rsp), %rax
movq (%rax), %rcx
movq 0x8(%rax), %rax
subq %rcx, %rax
je 0x25b09
xorl %r14d, %r14d
leaq 0xb0(%rsp), %r15
leaq 0x10(%rsp), %r12
xorl %ebx, %ebx
movl (%rcx,%rbx,8), %r13d
movl 0x4(%rcx,%rbx,8), %ebp
movq %r14, 0xc0(%rsp)
movapd %xmm3, 0xb0(%rsp)
movq %r14, 0x20(%rsp)
movapd %xmm3, 0x10(%rsp)
movl $0x3, %esi
movq %r15, %rdi
callq 0xd7da
movl $0x3, %esi
movq %r12, %rdi
callq 0x5c58
movq 0x50(%rsp), %rdi
movl %r13d, %esi
movl %ebp, %edx
leaq 0x30(%rsp), %rcx
movq %r12, %r8
movq %r15, %r9
callq 0xceaf
leaq 0x80(%rsp), %rdi
movq %r15, %rsi
callq 0x1b3de
leaq 0x60(%rsp), %rdi
movq %r12, %rsi
callq 0x1b40a
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x25ac7
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x2250
movq 0xb0(%rsp), %rdi
testq %rdi, %rdi
je 0x25ae4
movq 0xc0(%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
xorpd %xmm3, %xmm3
ja 0x25a3b
jmp 0x25b0d
sarq $0x3, %rax
movq 0x80(%rsp), %rdx
movq 0x88(%rsp), %rsi
movq %rsi, %rdi
subq %rdx, %rdi
sarq $0x3, %rdi
movabsq $-0x5555555555555555, %rcx # imm = 0xAAAAAAAAAAAAAAAB
imulq %rdi, %rcx
xorpd %xmm4, %xmm4
xorpd %xmm5, %xmm5
pxor %xmm0, %xmm0
cmpq %rdx, %rsi
movapd 0xa0(%rsp), %xmm2
je 0x25b90
movq 0x60(%rsp), %rdi
cmpq $0x1, %rcx
movq %rcx, %r8
adcq $0x0, %r8
xorl %r9d, %r9d
movq (%rdx,%r9), %r10
movq 0x4(%r10), %xmm1
paddd %xmm1, %xmm0
movq (%rdi,%r9), %r10
movupd (%r10), %xmm1
addpd %xmm1, %xmm3
addsd 0x10(%r10), %xmm5
addq $0x18, %r9
decq %r8
jne 0x25b62
cvtdq2pd %xmm0, %xmm0
movdqa %xmm0, 0xf0(%rsp)
cmpq %rdx, %rsi
je 0x25bd5
movq 0x60(%rsp), %rdx
cmpq $0x1, %rcx
adcq $0x0, %rcx
xorpd %xmm4, %xmm4
movq (%rdx), %rsi
movsd (%rsi), %xmm0
addsd 0x8(%rsi), %xmm0
addsd 0x10(%rsi), %xmm0
movapd %xmm2, %xmm1
divsd %xmm0, %xmm1
addsd %xmm1, %xmm4
addq $0x18, %rdx
decq %rcx
jne 0x25baf
movsd %xmm4, 0xc8(%rsp)
movapd %xmm3, %xmm0
unpckhpd %xmm3, %xmm0            # xmm0 = xmm0[1],xmm3[1]
addsd %xmm3, %xmm0
addsd %xmm5, %xmm0
movq %rax, %xmm2
punpckldq 0xb625(%rip), %xmm2 # xmm2 = xmm2[0],mem[0],xmm2[1],mem[1]
subpd 0xb62d(%rip), %xmm2     # 0x31230
movapd %xmm2, %xmm1
unpckhpd %xmm2, %xmm1            # xmm1 = xmm1[1],xmm2[1]
addsd %xmm2, %xmm1
divsd %xmm1, %xmm0
leaq 0xc530(%rip), %rdi      # 0x3214a
movapd %xmm0, 0xe0(%rsp)
movb $0x1, %al
movapd %xmm3, 0xd0(%rsp)
movsd %xmm5, (%rsp)
callq 0x2030
movq 0x50(%rsp), %rdi
callq 0x1e160
movapd 0xf0(%rsp), %xmm2
movapd %xmm2, %xmm0
unpckhpd %xmm2, %xmm0            # xmm0 = xmm0[1],xmm2[1]
movsd (%rsp), %xmm1
divsd %xmm0, %xmm1
movsd %xmm1, (%rsp)
movq %rax, %xmm0
punpckldq 0xb5b2(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0xb5ba(%rip), %xmm0     # 0x31230
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addpd %xmm0, %xmm1
movapd 0xd0(%rsp), %xmm0
shufpd $0x1, 0xa0(%rsp), %xmm0 # xmm0 = xmm0[1],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, 0x50(%rsp)
movapd %xmm0, %xmm1
divsd %xmm2, %xmm1
leaq 0xc4b6(%rip), %rdi      # 0x32170
movb $0x2, %al
callq 0x2030
movsd (%rsp), %xmm0
movapd %xmm0, %xmm1
divsd 0x50(%rsp), %xmm1
leaq 0xc4b5(%rip), %rdi      # 0x3218c
movb $0x2, %al
callq 0x2030
movapd 0xa0(%rsp), %xmm0
divsd 0xe0(%rsp), %xmm0
leaq 0xc4b1(%rip), %rdi      # 0x321a8
movb $0x1, %al
callq 0x2030
movq 0x8(%rsp), %rcx
movq 0x8(%rcx), %rax
subq (%rcx), %rax
sarq $0x3, %rax
movq %rax, %xmm0
punpckldq 0xb505(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0xb50d(%rip), %xmm0     # 0x31230
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
movsd 0xc8(%rsp), %xmm0
divsd %xmm1, %xmm0
leaq 0xc489(%rip), %rdi      # 0x321cc
movb $0x1, %al
callq 0x2030
leaq 0x60(%rsp), %rdi
callq 0x602e
leaq 0x80(%rsp), %rdi
callq 0xd80c
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x25d78
movq 0x40(%rsp), %rsi
subq %rdi, %rsi
callq 0x2250
addq $0x108, %rsp            # imm = 0x108
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
jmp 0x25dc0
movq %rax, %rbx
jmp 0x25dd7
movq %rax, %rbx
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x25dae
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x2250
leaq 0x10(%rsp), %rdi
leaq 0xb0(%rsp), %rsi
callq 0x2cdc
leaq 0x60(%rsp), %rdi
callq 0x602e
leaq 0x80(%rsp), %rdi
callq 0xd80c
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x25dee
movq 0x40(%rsp), %rsi
subq %rdi, %rsi
callq 0x2250
movq %rbx, %rdi
callq 0x23b0