// File: fjamour[P]icentral/src/bcc_delta.cc
// Function: bcc_delta_t::compute_bc_maxiter_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_maxiter_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);
    vector<node_id_t> d1_s_vec, d2_s_vec;
    
    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);        
        switch(abs_diff) {
            case 0:  cnt_arr[0]++; break;
            case 1:  d1_s_vec.push_back(s); break;
            default: d2_s_vec.push_back(s);
        }
    }
    
    int d1_num_iter = min(max_iter_d1, (int)d1_s_vec.size());
    int d2_num_iter = min(max_iter_d2, (int)d2_s_vec.size());
    for(int i = 0; i < d1_num_iter; ++i) {
        node_id_t s = d1_s_vec[i];
        tm.start();
        i_iteration(s, src, dst, d_src_vec[s], d_dst_vec[s], bc_map);
        tm.stop();
        cnt_arr[1]++;
        tot_arr[1]+=tm.interval();
    }
    for(int i = 0; i < d2_num_iter; ++i) {
        node_id_t s = d2_s_vec[i];
        tm.start();
        i_iteration(s, src, dst, d_src_vec[s], d_dst_vec[s], bc_map);
        tm.stop();
        cnt_arr[2]++;
        tot_arr[2]+=tm.interval();
    }
    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 $0x198, %rsp            # imm = 0x198
movl 0x1a0(%rsp), %eax
movq %rdi, 0x190(%rsp)
movq %rsi, 0x188(%rsp)
movl %edx, 0x184(%rsp)
movl %ecx, 0x180(%rsp)
movq %r8, 0x178(%rsp)
movl %r9d, 0x174(%rsp)
movq 0x190(%rsp), %rdi
movq %rdi, 0x68(%rsp)
movq %rdi, %rax
addq $0x2d8, %rax            # imm = 0x2D8
movq %rax, 0x78(%rsp)
addq $0x338, %rdi            # imm = 0x338
movq %rdi, 0x70(%rsp)
leaq 0x184(%rsp), %rsi
callq 0xfab0
movq 0x70(%rsp), %rdi
movl (%rax), %eax
movl %eax, 0x184(%rsp)
leaq 0x180(%rsp), %rsi
callq 0xfab0
movq 0x78(%rsp), %rdi
movl (%rax), %eax
movl %eax, 0x180(%rsp)
movl 0x184(%rsp), %esi
movl 0x180(%rsp), %edx
callq 0x77220
leaq 0x138(%rsp), %rdi
callq 0xfc40
leaq 0x120(%rsp), %rdi
callq 0xfc40
leaq 0x150(%rsp), %rdi
callq 0x2d430
jmp 0x351a5
movq 0x68(%rsp), %rdi
addq $0x2d8, %rdi            # imm = 0x2D8
movl 0x184(%rsp), %esi
leaq 0x138(%rsp), %rdx
callq 0x77ae0
jmp 0x351c7
movq 0x68(%rsp), %rdi
addq $0x2d8, %rdi            # imm = 0x2D8
movl 0x180(%rsp), %esi
leaq 0x120(%rsp), %rdx
callq 0x77ae0
jmp 0x351e9
leaq 0x150(%rsp), %rdi
callq 0x2d450
jmp 0x351f8
leaq 0x150(%rsp), %rdi
callq 0x2d470
movsd %xmm0, 0x60(%rsp)
jmp 0x3520d
movsd 0x60(%rsp), %xmm0
movq 0x178(%rsp), %rax
movsd %xmm0, 0x48(%rax)
leaq 0xf8(%rsp), %rdi
callq 0xfcd0
leaq 0xe0(%rsp), %rdi
callq 0xfcd0
leaq 0xd4(%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)
movq 0x68(%rsp), %rdi
movslq 0xac(%rsp), %rax
movq %rax, 0x58(%rsp)
addq $0x2d8, %rdi            # imm = 0x2D8
callq 0x1ac90
movq %rax, %rcx
movq 0x58(%rsp), %rax
cmpq %rcx, %rax
jae 0x353c8
movl 0xac(%rsp), %eax
movl %eax, 0xa8(%rsp)
movl 0xa8(%rsp), %eax
movl %eax, %esi
leaq 0x138(%rsp), %rdi
callq 0xfc50
movl (%rax), %eax
movl %eax, 0x50(%rsp)
movl 0xa8(%rsp), %eax
movl %eax, %esi
leaq 0x120(%rsp), %rdi
callq 0xfc50
movq %rax, %rcx
movl 0x50(%rsp), %eax
movl (%rcx), %ecx
subl %ecx, %eax
movl %eax, 0xa4(%rsp)
movl 0xa4(%rsp), %eax
movl %eax, %ecx
negl %ecx
cmovnsl %ecx, %eax
movl %eax, 0xa0(%rsp)
movl 0xa0(%rsp), %eax
movl %eax, 0x54(%rsp)
testl %eax, %eax
je 0x35338
jmp 0x35314
movl 0x54(%rsp), %eax
subl $0x1, %eax
je 0x3534b
jmp 0x35397
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x118(%rsp)
movl %eax, 0x114(%rsp)
jmp 0x35769
movl 0xd4(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xd4(%rsp)
jmp 0x353b0
leaq 0xf8(%rsp), %rdi
leaq 0xa8(%rsp), %rsi
callq 0xfce0
jmp 0x35362
jmp 0x353b0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x118(%rsp)
movl %eax, 0x114(%rsp)
leaq 0xe0(%rsp), %rdi
callq 0x10520
leaq 0xf8(%rsp), %rdi
callq 0x10520
jmp 0x35769
leaq 0xe0(%rsp), %rdi
leaq 0xa8(%rsp), %rsi
callq 0xfce0
jmp 0x353ae
jmp 0x353b0
jmp 0x353b2
movl 0xac(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xac(%rsp)
jmp 0x3526d
leaq 0xf8(%rsp), %rdi
callq 0xfd50
movl %eax, 0x98(%rsp)
leaq 0x174(%rsp), %rdi
leaq 0x98(%rsp), %rsi
callq 0x2d1a0
movq %rax, 0x48(%rsp)
jmp 0x353f8
movq 0x48(%rsp), %rax
movl (%rax), %eax
movl %eax, 0x9c(%rsp)
leaq 0xe0(%rsp), %rdi
callq 0xfd50
movl %eax, 0x90(%rsp)
leaq 0x1a0(%rsp), %rdi
leaq 0x90(%rsp), %rsi
callq 0x2d1a0
movq %rax, 0x40(%rsp)
jmp 0x35436
movq 0x40(%rsp), %rax
movl (%rax), %eax
movl %eax, 0x94(%rsp)
movl $0x0, 0x8c(%rsp)
movl 0x8c(%rsp), %eax
cmpl 0x9c(%rsp), %eax
jge 0x3556c
movslq 0x8c(%rsp), %rsi
leaq 0xf8(%rsp), %rdi
callq 0xfbc0
movl (%rax), %eax
movl %eax, 0x88(%rsp)
leaq 0x150(%rsp), %rdi
callq 0x2d430
jmp 0x35490
movl 0x88(%rsp), %eax
movl %eax, 0x30(%rsp)
movl 0x184(%rsp), %ecx
movl %ecx, 0x34(%rsp)
movl 0x180(%rsp), %ecx
movl %ecx, 0x38(%rsp)
movl %eax, %esi
leaq 0x138(%rsp), %rdi
callq 0xfc50
movl (%rax), %eax
movl %eax, 0x3c(%rsp)
movl 0x88(%rsp), %eax
movl %eax, %esi
leaq 0x120(%rsp), %rdi
callq 0xfc50
movq 0x68(%rsp), %rdi
movl 0x30(%rsp), %esi
movl 0x34(%rsp), %edx
movl 0x38(%rsp), %ecx
movl 0x3c(%rsp), %r8d
movl (%rax), %r9d
movq 0x188(%rsp), %r10
movq %rsp, %rax
movq %r10, (%rax)
callq 0x34b10
jmp 0x3550a
leaq 0x150(%rsp), %rdi
callq 0x2d450
jmp 0x35519
movl 0xd8(%rsp), %eax
incl %eax
movl %eax, 0xd8(%rsp)
leaq 0x150(%rsp), %rdi
callq 0x2d470
movsd %xmm0, 0x28(%rsp)
jmp 0x3553e
movsd 0x28(%rsp), %xmm0
addsd 0xb8(%rsp), %xmm0
movsd %xmm0, 0xb8(%rsp)
movl 0x8c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x8c(%rsp)
jmp 0x3544f
movl $0x0, 0x84(%rsp)
movl 0x84(%rsp), %eax
cmpl 0x94(%rsp), %eax
jge 0x35694
movslq 0x84(%rsp), %rsi
leaq 0xe0(%rsp), %rdi
callq 0xfbc0
movl (%rax), %eax
movl %eax, 0x80(%rsp)
leaq 0x150(%rsp), %rdi
callq 0x2d430
jmp 0x355b8
movl 0x80(%rsp), %eax
movl %eax, 0x18(%rsp)
movl 0x184(%rsp), %ecx
movl %ecx, 0x1c(%rsp)
movl 0x180(%rsp), %ecx
movl %ecx, 0x20(%rsp)
movl %eax, %esi
leaq 0x138(%rsp), %rdi
callq 0xfc50
movl (%rax), %eax
movl %eax, 0x24(%rsp)
movl 0x80(%rsp), %eax
movl %eax, %esi
leaq 0x120(%rsp), %rdi
callq 0xfc50
movq 0x68(%rsp), %rdi
movl 0x18(%rsp), %esi
movl 0x1c(%rsp), %edx
movl 0x20(%rsp), %ecx
movl 0x24(%rsp), %r8d
movl (%rax), %r9d
movq 0x188(%rsp), %r10
movq %rsp, %rax
movq %r10, (%rax)
callq 0x34b10
jmp 0x35632
leaq 0x150(%rsp), %rdi
callq 0x2d450
jmp 0x35641
movl 0xdc(%rsp), %eax
incl %eax
movl %eax, 0xdc(%rsp)
leaq 0x150(%rsp), %rdi
callq 0x2d470
movsd %xmm0, 0x10(%rsp)
jmp 0x35666
movsd 0x10(%rsp), %xmm0
addsd 0xc0(%rsp), %xmm0
movsd %xmm0, 0xc0(%rsp)
movl 0x84(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x84(%rsp)
jmp 0x35577
movq 0x68(%rsp), %rdi
addq $0x2d8, %rdi            # imm = 0x2D8
movl 0x184(%rsp), %esi
movl 0x180(%rsp), %edx
callq 0x770e0
jmp 0x356b5
movl 0xd4(%rsp), %ecx
movq 0x178(%rsp), %rax
movl %ecx, 0x10(%rax)
movl 0xd8(%rsp), %ecx
movq 0x178(%rsp), %rax
movl %ecx, 0x14(%rax)
movl 0xdc(%rsp), %ecx
movq 0x178(%rsp), %rax
movl %ecx, 0x18(%rax)
movsd 0xb0(%rsp), %xmm0
movq 0x178(%rsp), %rax
movsd %xmm0, 0x20(%rax)
movsd 0xb8(%rsp), %xmm0
movq 0x178(%rsp), %rax
movsd %xmm0, 0x28(%rax)
movsd 0xc0(%rsp), %xmm0
movq 0x178(%rsp), %rax
movsd %xmm0, 0x30(%rax)
leaq 0xe0(%rsp), %rdi
callq 0x10520
leaq 0xf8(%rsp), %rdi
callq 0x10520
leaq 0x120(%rsp), %rdi
callq 0xfc70
leaq 0x138(%rsp), %rdi
callq 0xfc70
addq $0x198, %rsp            # imm = 0x198
retq
leaq 0x120(%rsp), %rdi
callq 0xfc70
leaq 0x138(%rsp), %rdi
callq 0xfc70
movq 0x118(%rsp), %rdi
callq 0x9cf0