// File: /workspace/github_cpp_makefile_star2_O2/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:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xf8, %rsp
movq %r9, 0x28(%rsp)
movq %r8, 0x48(%rsp)
movq %rsi, %r15
movq %rdi, %r13
leaq 0x18(%rsp), %rbp
movl %edx, (%rbp)
leaq 0x14(%rsp), %r14
movl %ecx, (%r14)
leaq 0x2d8(%rdi), %r12
leaq 0x338(%rdi), %rbx
movq %rbx, %rdi
movq %rbp, %rsi
callq 0x46f8
movl (%rax), %eax
movl %eax, (%rbp)
movq %rbx, %rdi
movq %r14, %rsi
callq 0x46f8
movl (%rax), %edx
movl %edx, (%r14)
movl (%rbp), %esi
movq %r12, %rdi
callq 0x2615e
xorpd %xmm0, %xmm0
leaq 0xb0(%rsp), %rbx
movapd %xmm0, (%rbx)
andq $0x0, 0x10(%rbx)
movapd %xmm0, 0x50(%rsp)
andq $0x0, 0x60(%rsp)
leaq 0xd8(%rsp), %rdi
callq 0xb094
movl (%rbp), %esi
movq %r12, %rdi
movq %rbx, %rdx
callq 0x26540
movl 0x14(%rsp), %esi
leaq 0x50(%rsp), %rdx
movq %r12, %rdi
callq 0x26540
movq %r12, 0xd0(%rsp)
leaq 0xd8(%rsp), %rbx
movq %rbx, %rdi
callq 0xb09c
movq %rbx, %rdi
callq 0xb0a8
movq 0x48(%rsp), %rax
movsd %xmm0, 0x48(%rax)
xorpd %xmm0, %xmm0
leaq 0x70(%rsp), %rax
movapd %xmm0, (%rax)
andq $0x0, 0x10(%rax)
leaq 0x90(%rsp), %r12
movapd %xmm0, (%r12)
andq $0x0, 0x10(%r12)
xorl %ebx, %ebx
pushq $0x18
popq %r14
leaq 0x44(%rsp), %rbp
movl $0x0, 0x1c(%rsp)
movq 0x2e0(%r13), %rax
subq 0x2d8(%r13), %rax
cqto
idivq %r14
cmpq %rbx, %rax
jbe 0xd00a
movl %ebx, 0x44(%rsp)
movq 0xb0(%rsp), %rax
movl (%rax,%rbx,4), %ecx
movq 0x50(%rsp), %rax
subl (%rax,%rbx,4), %ecx
movl %ecx, %eax
negl %eax
cmovsl %ecx, %eax
cmpl $0x1, %eax
je 0xcff8
movq %r12, %rdi
testl %eax, %eax
jne 0xcffd
incl 0x1c(%rsp)
jmp 0xd005
leaq 0x70(%rsp), %rdi
movq %rbp, %rsi
callq 0x478c
incq %rbx
jmp 0xcfb0
movq 0x78(%rsp), %rax
subq 0x70(%rsp), %rax
shrq $0x2, %rax
movq 0x28(%rsp), %rcx
cmpl %ecx, %eax
cmovll %eax, %ecx
movq 0x98(%rsp), %rax
subq 0x90(%rsp), %rax
shrq $0x2, %rax
movl 0x130(%rsp), %edx
cmpl %edx, %eax
cmovll %eax, %edx
movq %rdx, 0x20(%rsp)
xorl %r14d, %r14d
testl %ecx, %ecx
cmovlel %r14d, %ecx
movq %rcx, 0x28(%rsp)
leaq (,%rcx,4), %r12
xorpd %xmm0, %xmm0
movsd %xmm0, 0x38(%rsp)
leaq 0xd8(%rsp), %rbp
cmpq %r14, %r12
je 0xd0d6
movq 0x70(%rsp), %rax
movl (%rax,%r14), %ebx
movq %rbp, %rdi
callq 0xb094
movl 0x18(%rsp), %edx
movl 0x14(%rsp), %ecx
movq 0xb0(%rsp), %rax
movl (%rax,%rbx,4), %r8d
movq 0x50(%rsp), %rax
movl (%rax,%rbx,4), %r9d
movq %r15, (%rsp)
movq %r13, %rdi
movl %ebx, %esi
callq 0xcba8
movq %rbp, %rdi
callq 0xb09c
movq %rbp, %rdi
callq 0xb0a8
movsd 0x38(%rsp), %xmm1
addsd %xmm0, %xmm1
movsd %xmm1, 0x38(%rsp)
addq $0x4, %r14
jmp 0xd06f
xorl %r14d, %r14d
movq 0x20(%rsp), %rax
testl %eax, %eax
cmovlel %r14d, %eax
movq %rax, 0x20(%rsp)
leaq (,%rax,4), %r12
xorpd %xmm0, %xmm0
movsd %xmm0, 0x30(%rsp)
leaq 0xd8(%rsp), %rbp
cmpq %r14, %r12
je 0xd16d
movq 0x90(%rsp), %rax
movl (%rax,%r14), %ebx
movq %rbp, %rdi
callq 0xb094
movl 0x18(%rsp), %edx
movl 0x14(%rsp), %ecx
movq 0xb0(%rsp), %rax
movl (%rax,%rbx,4), %r8d
movq 0x50(%rsp), %rax
movl (%rax,%rbx,4), %r9d
movq %r15, (%rsp)
movq %r13, %rdi
movl %ebx, %esi
callq 0xcba8
movq %rbp, %rdi
callq 0xb09c
movq %rbp, %rdi
callq 0xb0a8
movsd 0x30(%rsp), %xmm1
addsd %xmm0, %xmm1
movsd %xmm1, 0x30(%rsp)
addq $0x4, %r14
jmp 0xd103
movl 0x18(%rsp), %esi
movl 0x14(%rsp), %edx
movq 0xd0(%rsp), %rdi
callq 0x260cc
movq 0x48(%rsp), %rax
movl 0x1c(%rsp), %ecx
movl %ecx, 0x10(%rax)
movq 0x28(%rsp), %rcx
movl %ecx, 0x14(%rax)
movq 0x20(%rsp), %rcx
movl %ecx, 0x18(%rax)
andq $0x0, 0x20(%rax)
movsd 0x38(%rsp), %xmm0
movsd %xmm0, 0x28(%rax)
movsd 0x30(%rsp), %xmm0
movsd %xmm0, 0x30(%rax)
leaq 0x90(%rsp), %rdi
callq 0x56ec
leaq 0x70(%rsp), %rdi
callq 0x56ec
leaq 0x50(%rsp), %rdi
callq 0x5720
leaq 0xb0(%rsp), %rdi
callq 0x5720
addq $0xf8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0xd204
movq %rax, %rbx
jmp 0xd21e
jmp 0xd204
jmp 0xd204
movq %rax, %rbx
leaq 0x90(%rsp), %rdi
callq 0x56ec
leaq 0x70(%rsp), %rdi
callq 0x56ec
leaq 0x50(%rsp), %rdi
callq 0x5720
leaq 0xb0(%rsp), %rdi
callq 0x5720
movq %rbx, %rdi
callq 0x23d0
nop