// File: fjamour[P]icentral/src/bcc_delta.cc
// Function: bcc_delta_t::compute_bc_exp(std::tr1::unordered_map<unsigned int, double, std::tr1::hash<unsigned int>, std::equal_to<unsigned int>, std::allocator<std::pair<unsigned int const, double>>>&, unsigned int, unsigned int, bcc_stat_t&, int, int)
void bcc_delta_t::compute_bc_exp(tr1_map_t(double)& bc_map,
                        node_id_t src,
                        node_id_t dst,
                        bcc_stat_t& bcc_stat,
                        int max_iter_d1,
                        int max_iter_d2)
{
    src = bcc_fast_subgraph.outin_label_map[src];
    dst = bcc_fast_subgraph.outin_label_map[dst];
    
    timer tm;
    //bc_map will have for each vertex in the muc it's betweenness centrality
    bcc_fast_subgraph.remove_edge(src, dst);
    vector<int> d_src_vec, d_dst_vec;
    tm.start();
    bcc_fast_subgraph.find_sssp(src, d_src_vec);
    bcc_fast_subgraph.find_sssp(dst, d_dst_vec);
    tm.stop();
    bcc_stat.sssp_tm = tm.interval();
    
    //this must be commented in general.. if it's there it makes bc_map contain deltas
    //bcc_subgraph.i_fill_map<double>(bc_map, 0);
    
    int    cnt_arr[] = {0,0,0};
    double tot_arr[] = {0,0,0};
    for(int i = 0; i < bcc_fast_subgraph.nodes_vec.size(); ++i) {
        node_id_t s = i;
        int diff = d_src_vec[s] - d_dst_vec[s];
        int abs_diff = abs(diff);
        tm.start();
        if(d_src_vec[s] != d_dst_vec[s]) {
            i_iteration(s, src, dst, d_src_vec[s], d_dst_vec[s], bc_map);
        }
        tm.stop();
        switch(abs_diff) {
            case 0:
                cnt_arr[0]++;
                tot_arr[0]+=tm.interval();
                break;
            case 1:
                cnt_arr[1]++;
                tot_arr[1]+=tm.interval();
                break;
            default:
                cnt_arr[2]++;
                tot_arr[2]+=tm.interval();
        }
        if(tot_arr[1] == max_iter_d1 && tot_arr[2] == max_iter_d2)
            break;
    }
    bcc_fast_subgraph.insert_edge(src, dst);
    
    bcc_stat.num_d0_iter = cnt_arr[0];
    bcc_stat.num_d1_iter = cnt_arr[1];
    bcc_stat.num_d2_iter = cnt_arr[2];
    bcc_stat.tot_d0_tm   = tot_arr[0];
    bcc_stat.tot_d1_tm   = tot_arr[1];
    bcc_stat.tot_d2_tm   = tot_arr[2];
}

// Assembly:
subq $0x128, %rsp            # imm = 0x128
movl 0x130(%rsp), %eax
movq %rdi, 0x120(%rsp)
movq %rsi, 0x118(%rsp)
movl %edx, 0x114(%rsp)
movl %ecx, 0x110(%rsp)
movq %r8, 0x108(%rsp)
movl %r9d, 0x104(%rsp)
movq 0x120(%rsp), %rdi
movq %rdi, 0x58(%rsp)
movq %rdi, %rax
addq $0x2d8, %rax            # imm = 0x2D8
movq %rax, 0x68(%rsp)
addq $0x338, %rdi            # imm = 0x338
movq %rdi, 0x60(%rsp)
leaq 0x114(%rsp), %rsi
callq 0xfab0
movq 0x60(%rsp), %rdi
movl (%rax), %eax
movl %eax, 0x114(%rsp)
leaq 0x110(%rsp), %rsi
callq 0xfab0
movq 0x68(%rsp), %rdi
movl (%rax), %eax
movl %eax, 0x110(%rsp)
movl 0x114(%rsp), %esi
movl 0x110(%rsp), %edx
callq 0x77220
leaq 0xc8(%rsp), %rdi
callq 0xfc40
leaq 0xb0(%rsp), %rdi
callq 0xfc40
leaq 0xe0(%rsp), %rdi
callq 0x2d430
jmp 0x34cb5
movq 0x58(%rsp), %rdi
addq $0x2d8, %rdi            # imm = 0x2D8
movl 0x114(%rsp), %esi
leaq 0xc8(%rsp), %rdx
callq 0x77ae0
jmp 0x34cd7
movq 0x58(%rsp), %rdi
addq $0x2d8, %rdi            # imm = 0x2D8
movl 0x110(%rsp), %esi
leaq 0xb0(%rsp), %rdx
callq 0x77ae0
jmp 0x34cf9
leaq 0xe0(%rsp), %rdi
callq 0x2d450
jmp 0x34d08
leaq 0xe0(%rsp), %rdi
callq 0x2d470
movsd %xmm0, 0x50(%rsp)
jmp 0x34d1d
movsd 0x50(%rsp), %xmm0
movq 0x108(%rsp), %rax
movsd %xmm0, 0x48(%rax)
leaq 0x98(%rsp), %rdi
xorl %esi, %esi
movl $0xc, %edx
callq 0x9350
leaq 0x80(%rsp), %rdi
xorl %esi, %esi
movl $0x18, %edx
callq 0x9350
movl $0x0, 0x7c(%rsp)
movq 0x58(%rsp), %rdi
movslq 0x7c(%rsp), %rax
movq %rax, 0x48(%rsp)
addq $0x2d8, %rdi            # imm = 0x2D8
callq 0x1ac90
movq %rax, %rcx
movq 0x48(%rsp), %rax
cmpq %rcx, %rax
jae 0x34ffc
movl 0x7c(%rsp), %eax
movl %eax, 0x78(%rsp)
movl 0x78(%rsp), %eax
movl %eax, %esi
leaq 0xc8(%rsp), %rdi
callq 0xfc50
movl (%rax), %eax
movl %eax, 0x44(%rsp)
movl 0x78(%rsp), %eax
movl %eax, %esi
leaq 0xb0(%rsp), %rdi
callq 0xfc50
movq %rax, %rcx
movl 0x44(%rsp), %eax
movl (%rcx), %ecx
subl %ecx, %eax
movl %eax, 0x74(%rsp)
movl 0x74(%rsp), %eax
movl %eax, %ecx
negl %ecx
cmovnsl %ecx, %eax
movl %eax, 0x70(%rsp)
leaq 0xe0(%rsp), %rdi
callq 0x2d430
jmp 0x34ded
movl 0x78(%rsp), %eax
movl %eax, %esi
leaq 0xc8(%rsp), %rdi
callq 0xfc50
movl (%rax), %eax
movl %eax, 0x40(%rsp)
movl 0x78(%rsp), %eax
movl %eax, %esi
leaq 0xb0(%rsp), %rdi
callq 0xfc50
movq %rax, %rcx
movl 0x40(%rsp), %eax
cmpl (%rcx), %eax
je 0x34ed1
movl 0x78(%rsp), %eax
movl %eax, 0x30(%rsp)
movl 0x114(%rsp), %ecx
movl %ecx, 0x34(%rsp)
movl 0x110(%rsp), %ecx
movl %ecx, 0x38(%rsp)
movl %eax, %esi
leaq 0xc8(%rsp), %rdi
callq 0xfc50
movl (%rax), %eax
movl %eax, 0x3c(%rsp)
movl 0x78(%rsp), %eax
movl %eax, %esi
leaq 0xb0(%rsp), %rdi
callq 0xfc50
movq 0x58(%rsp), %rdi
movl 0x30(%rsp), %esi
movl 0x34(%rsp), %edx
movl 0x38(%rsp), %ecx
movl 0x3c(%rsp), %r8d
movl (%rax), %r9d
movq 0x118(%rsp), %r10
movq %rsp, %rax
movq %r10, (%rax)
callq 0x34b10
jmp 0x34e9c
jmp 0x34ed1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xa8(%rsp)
movl %eax, 0xa4(%rsp)
leaq 0xb0(%rsp), %rdi
callq 0xfc70
leaq 0xc8(%rsp), %rdi
callq 0xfc70
jmp 0x350b7
leaq 0xe0(%rsp), %rdi
callq 0x2d450
jmp 0x34ee0
movl 0x70(%rsp), %eax
movl %eax, 0x2c(%rsp)
testl %eax, %eax
je 0x34ef9
jmp 0x34eee
movl 0x2c(%rsp), %eax
subl $0x1, %eax
je 0x34f38
jmp 0x34f77
movl 0x98(%rsp), %eax
incl %eax
movl %eax, 0x98(%rsp)
leaq 0xe0(%rsp), %rdi
callq 0x2d470
movsd %xmm0, 0x20(%rsp)
jmp 0x34f1e
movsd 0x20(%rsp), %xmm0
addsd 0x80(%rsp), %xmm0
movsd %xmm0, 0x80(%rsp)
jmp 0x34fb4
movl 0x9c(%rsp), %eax
incl %eax
movl %eax, 0x9c(%rsp)
leaq 0xe0(%rsp), %rdi
callq 0x2d470
movsd %xmm0, 0x18(%rsp)
jmp 0x34f5d
movsd 0x18(%rsp), %xmm0
addsd 0x88(%rsp), %xmm0
movsd %xmm0, 0x88(%rsp)
jmp 0x34fb4
movl 0xa0(%rsp), %eax
incl %eax
movl %eax, 0xa0(%rsp)
leaq 0xe0(%rsp), %rdi
callq 0x2d470
movsd %xmm0, 0x10(%rsp)
jmp 0x34f9c
movsd 0x10(%rsp), %xmm0
addsd 0x90(%rsp), %xmm0
movsd %xmm0, 0x90(%rsp)
movsd 0x88(%rsp), %xmm0
cvtsi2sdl 0x104(%rsp), %xmm1
ucomisd %xmm1, %xmm0
jne 0x34fea
jp 0x34fea
movsd 0x90(%rsp), %xmm0
cvtsi2sdl 0x130(%rsp), %xmm1
ucomisd %xmm1, %xmm0
jne 0x34fea
jp 0x34fea
jmp 0x34ffc
jmp 0x34fec
movl 0x7c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x7c(%rsp)
jmp 0x34d60
movq 0x58(%rsp), %rdi
addq $0x2d8, %rdi            # imm = 0x2D8
movl 0x114(%rsp), %esi
movl 0x110(%rsp), %edx
callq 0x770e0
jmp 0x3501d
movl 0x98(%rsp), %ecx
movq 0x108(%rsp), %rax
movl %ecx, 0x10(%rax)
movl 0x9c(%rsp), %ecx
movq 0x108(%rsp), %rax
movl %ecx, 0x14(%rax)
movl 0xa0(%rsp), %ecx
movq 0x108(%rsp), %rax
movl %ecx, 0x18(%rax)
movsd 0x80(%rsp), %xmm0
movq 0x108(%rsp), %rax
movsd %xmm0, 0x20(%rax)
movsd 0x88(%rsp), %xmm0
movq 0x108(%rsp), %rax
movsd %xmm0, 0x28(%rax)
movsd 0x90(%rsp), %xmm0
movq 0x108(%rsp), %rax
movsd %xmm0, 0x30(%rax)
leaq 0xb0(%rsp), %rdi
callq 0xfc70
leaq 0xc8(%rsp), %rdi
callq 0xfc70
addq $0x128, %rsp            # imm = 0x128
retq
movq 0xa8(%rsp), %rdi
callq 0x9cf0
nopw %cs:(%rax,%rax)