// File: fjamour[P]icentral/src/_bc.cc
// Function: Update_BC(std::vector<double, std::allocator<double>>&, graph_t&, comp_type_t, std::pair<unsigned int, unsigned int>, int, operation_t)
void Update_BC(
        vector<double>&  BC_vec,
        graph_t&         graph,
        comp_type_t      comp_type,
        edge_t           e,
        int              num_threads,
        operation_t      op
        )
{
    if(comp_type == GRAPH) {
        component_t comp;
        comp.comp_type = GRAPH;
        comp.subgraph.fill_graph(graph);
        vector<double> dBC_vec;
        if(num_threads == 1)
            iCentral(dBC_vec, comp, e, op);
        else
            parallel_iCentral(dBC_vec, comp, e, num_threads, op);
        for(int i = 0; i < dBC_vec.size(); ++i) {
            BC_vec[i] += dBC_vec[i];
        }
    } else if(comp_type == BCC) {
        component_t comp;
        comp.comp_type = BCC;
        if(op == INSERTION) {
            //IMP: assumes @e is not in @graph, @e will not be in @comp
            graph.find_edge_bcc(comp, e);
        } else if(op == DELETION) {
            
            //IMP: assumes @e is not in @graph, @e will not be in @comp
            //     (remove @e from @graph)
            graph.remove_edge(e.first, e.second);
            graph.find_edge_bcc(comp, e);
            graph.insert_edge(e.first, e.second);
        }
            
        //DEBUG
        //printf("BCC # vertices [%d], # edges [%d] \n", comp.subgraph.size(), comp.subgraph.edge_set.size());
        
        //map @e to the new edge
        e.first  = comp.subgraph.outin_label_map[e.first];
        e.second = comp.subgraph.outin_label_map[e.second];
        if(op == DELETION) {
            comp.subgraph.insert_edge(e.first, e.second);
        }
        vector<double> dBC_vec;
        //comp.print();
        if(num_threads == 1)
            iCentral(dBC_vec, comp, e, op);
        else
            parallel_iCentral(dBC_vec, comp, e, num_threads, op);
        for(int i = 0; i < dBC_vec.size(); ++i) {
            node_id_t actual_node_id = comp.subgraph.inout_label_map[i];
            BC_vec[actual_node_id] += dBC_vec[i];
        }
    } else if(comp_type == MUC) {
        //TO BE IMPLEMENTED
    }
   
    
}

// Assembly:
subq $0x548, %rsp            # imm = 0x548
movq %rcx, 0x540(%rsp)
movq %rdi, 0x538(%rsp)
movq %rsi, 0x530(%rsp)
movl %edx, 0x52c(%rsp)
movl %r8d, 0x528(%rsp)
movl %r9d, 0x524(%rsp)
cmpl $0x2, 0x52c(%rsp)
jne 0xa6db
leaq 0x2f0(%rsp), %rdi
movq %rdi, 0x38(%rsp)
callq 0xf7c0
movq 0x38(%rsp), %rdi
movl $0x2, 0x518(%rsp)
movq 0x530(%rsp), %rsi
callq 0x78110
jmp 0xa555
leaq 0x2c8(%rsp), %rdi
callq 0xfa00
cmpl $0x1, 0x528(%rsp)
jne 0xa5e3
movq 0x540(%rsp), %rax
movq %rax, 0x2c0(%rsp)
movl 0x524(%rsp), %ecx
movq 0x2c0(%rsp), %rdx
leaq 0x2c8(%rsp), %rdi
leaq 0x2f0(%rsp), %rsi
callq 0xa9c0
jmp 0xa5a2
jmp 0xa623
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x2e8(%rsp)
movl %eax, 0x2e4(%rsp)
jmp 0xa6c9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x2e8(%rsp)
movl %eax, 0x2e4(%rsp)
leaq 0x2c8(%rsp), %rdi
callq 0xfa50
jmp 0xa6c9
movq 0x540(%rsp), %rax
movq %rax, 0x2b8(%rsp)
movl 0x528(%rsp), %ecx
movl 0x524(%rsp), %r8d
movq 0x2b8(%rsp), %rdx
leaq 0x2c8(%rsp), %rdi
leaq 0x2f0(%rsp), %rsi
callq 0xac10
jmp 0xa621
jmp 0xa623
movl $0x0, 0x2b4(%rsp)
movslq 0x2b4(%rsp), %rax
movq %rax, 0x30(%rsp)
leaq 0x2c8(%rsp), %rdi
callq 0xfa10
movq %rax, %rcx
movq 0x30(%rsp), %rax
cmpq %rcx, %rax
jae 0xa6aa
movslq 0x2b4(%rsp), %rsi
leaq 0x2c8(%rsp), %rdi
callq 0xfa30
movsd (%rax), %xmm0
movsd %xmm0, 0x28(%rsp)
movq 0x538(%rsp), %rdi
movslq 0x2b4(%rsp), %rsi
callq 0xfa30
movsd 0x28(%rsp), %xmm0
addsd (%rax), %xmm0
movsd %xmm0, (%rax)
movl 0x2b4(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x2b4(%rsp)
jmp 0xa62e
leaq 0x2c8(%rsp), %rdi
callq 0xfa50
leaq 0x2f0(%rsp), %rdi
callq 0xf9d0
jmp 0xa9a4
leaq 0x2f0(%rsp), %rdi
callq 0xf9d0
jmp 0xa9ac
cmpl $0x0, 0x52c(%rsp)
jne 0xa994
leaq 0x80(%rsp), %rdi
callq 0xf7c0
movl $0x0, 0x2a8(%rsp)
cmpl $0x0, 0x524(%rsp)
jne 0xa752
movq 0x530(%rsp), %rdi
movq 0x540(%rsp), %rax
movq %rax, 0x78(%rsp)
movq 0x78(%rsp), %rdx
leaq 0x80(%rsp), %rsi
callq 0x57ba0
jmp 0xa734
jmp 0xa7c3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x2e8(%rsp)
movl %eax, 0x2e4(%rsp)
jmp 0xa985
cmpl $0x1, 0x524(%rsp)
jne 0xa7c1
movq 0x530(%rsp), %rdi
movl 0x540(%rsp), %esi
movl 0x544(%rsp), %edx
callq 0x56850
jmp 0xa779
movq 0x530(%rsp), %rdi
movq 0x540(%rsp), %rax
movq %rax, 0x70(%rsp)
movq 0x70(%rsp), %rdx
leaq 0x80(%rsp), %rsi
callq 0x57ba0
jmp 0xa7a2
movq 0x530(%rsp), %rdi
movl 0x540(%rsp), %esi
movl 0x544(%rsp), %edx
callq 0x56720
jmp 0xa7bf
jmp 0xa7c1
jmp 0xa7c3
leaq 0xe0(%rsp), %rdi
leaq 0x540(%rsp), %rsi
callq 0xfab0
movq %rax, 0x20(%rsp)
jmp 0xa7df
movq 0x20(%rsp), %rax
movl (%rax), %eax
movl %eax, 0x540(%rsp)
leaq 0xe0(%rsp), %rdi
leaq 0x544(%rsp), %rsi
callq 0xfab0
movq %rax, 0x18(%rsp)
jmp 0xa809
movq 0x18(%rsp), %rax
movl (%rax), %eax
movl %eax, 0x544(%rsp)
cmpl $0x1, 0x524(%rsp)
jne 0xa840
movl 0x540(%rsp), %esi
movl 0x544(%rsp), %edx
leaq 0x80(%rsp), %rdi
callq 0x770e0
jmp 0xa83e
jmp 0xa840
leaq 0x58(%rsp), %rdi
callq 0xfa00
cmpl $0x1, 0x528(%rsp)
jne 0xa8a6
movq 0x540(%rsp), %rax
movq %rax, 0x50(%rsp)
movl 0x524(%rsp), %ecx
movq 0x50(%rsp), %rdx
leaq 0x58(%rsp), %rdi
leaq 0x80(%rsp), %rsi
callq 0xa9c0
jmp 0xa881
jmp 0xa8dd
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x2e8(%rsp)
movl %eax, 0x2e4(%rsp)
leaq 0x58(%rsp), %rdi
callq 0xfa50
jmp 0xa985
movq 0x540(%rsp), %rax
movq %rax, 0x48(%rsp)
movl 0x528(%rsp), %ecx
movl 0x524(%rsp), %r8d
movq 0x48(%rsp), %rdx
leaq 0x58(%rsp), %rdi
leaq 0x80(%rsp), %rsi
callq 0xac10
jmp 0xa8db
jmp 0xa8dd
movl $0x0, 0x44(%rsp)
movslq 0x44(%rsp), %rax
movq %rax, 0x10(%rsp)
leaq 0x58(%rsp), %rdi
callq 0xfa10
movq %rax, %rcx
movq 0x10(%rsp), %rax
cmpq %rcx, %rax
jae 0xa96c
leaq 0x80(%rsp), %rdi
addq $0x48, %rdi
movslq 0x44(%rsp), %rsi
callq 0xfbc0
movl (%rax), %eax
movl %eax, 0x40(%rsp)
movslq 0x44(%rsp), %rsi
leaq 0x58(%rsp), %rdi
callq 0xfa30
movsd (%rax), %xmm0
movsd %xmm0, 0x8(%rsp)
movq 0x538(%rsp), %rdi
movl 0x40(%rsp), %eax
movl %eax, %esi
callq 0xfa30
movsd 0x8(%rsp), %xmm0
addsd (%rax), %xmm0
movsd %xmm0, (%rax)
movl 0x44(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x44(%rsp)
jmp 0xa8e5
leaq 0x58(%rsp), %rdi
callq 0xfa50
leaq 0x80(%rsp), %rdi
callq 0xf9d0
jmp 0xa9a2
leaq 0x80(%rsp), %rdi
callq 0xf9d0
jmp 0xa9ac
cmpl $0x1, 0x52c(%rsp)
jne 0xa9a0
jmp 0xa9a0
jmp 0xa9a2
jmp 0xa9a4
addq $0x548, %rsp            # imm = 0x548
retq
movq 0x2e8(%rsp), %rdi
callq 0x9cf0
nopl (%rax)