// File: /workspace/github_cpp_makefile_star2_O2/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:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x258, %rsp            # imm = 0x258
movl %r9d, %ebp
movl %r8d, %r14d
movq %rcx, %r15
movq %rsi, %r12
movq %rdi, %rbx
movq %rcx, 0x8(%rsp)
testl %edx, %edx
je 0x2909
cmpl $0x2, %edx
jne 0x2a8c
leaq 0x28(%rsp), %r13
movq %r13, %rdi
callq 0x4622
movl $0x2, 0x228(%r13)
movq %r13, %rdi
movq %r12, %rsi
callq 0x26858
xorpd %xmm0, %xmm0
movapd %xmm0, 0x10(%rsp)
andq $0x0, 0x20(%rsp)
cmpl $0x1, %r14d
jne 0x293d
leaq 0x10(%rsp), %rdi
leaq 0x28(%rsp), %rsi
movq %r15, %rdx
movl %ebp, %ecx
callq 0x2ac6
jmp 0x2955
leaq 0x28(%rsp), %r13
movq %r13, %rdi
callq 0x4622
andl $0x0, 0x228(%r13)
cmpl $0x1, %ebp
je 0x2988
testl %ebp, %ebp
jne 0x29bb
leaq 0x28(%rsp), %rsi
movq %r12, %rdi
movq %r15, %rdx
callq 0x1963a
jmp 0x29bb
leaq 0x10(%rsp), %rdi
leaq 0x28(%rsp), %rsi
movq %r15, %rdx
movl %r14d, %ecx
movl %ebp, %r8d
callq 0x2c02
movq 0x10(%rsp), %rax
movq 0x18(%rsp), %rcx
subq %rax, %rcx
sarq $0x3, %rcx
movq (%rbx), %rdx
xorl %esi, %esi
cmpq %rsi, %rcx
jbe 0x2a78
movsd (%rax,%rsi,8), %xmm0
addsd (%rdx,%rsi,8), %xmm0
movsd %xmm0, (%rdx,%rsi,8)
incq %rsi
jmp 0x296b
movq %r15, %r13
shrq $0x20, %r13
movq %r12, %rdi
movl %r15d, %esi
movl %r13d, %edx
callq 0x18bfe
leaq 0x28(%rsp), %rsi
movq %r12, %rdi
movq %r15, %rdx
callq 0x1963a
movq %r12, %rdi
movl %r15d, %esi
movl %r13d, %edx
callq 0x18b56
leaq 0x88(%rsp), %r15
leaq 0x8(%rsp), %rsi
movq %r15, %rdi
callq 0x46f8
movl (%rax), %eax
leaq 0xc(%rsp), %rsi
movl %eax, -0x4(%rsi)
movq %r15, %rdi
callq 0x46f8
movl (%rax), %edx
movl %edx, 0xc(%rsp)
cmpl $0x1, %ebp
jne 0x29fb
movl 0x8(%rsp), %esi
leaq 0x28(%rsp), %rdi
callq 0x260cc
andq $0x0, 0x20(%rsp)
xorpd %xmm0, %xmm0
movapd %xmm0, 0x10(%rsp)
movq 0x8(%rsp), %rdx
cmpl $0x1, %r14d
jne 0x2a29
leaq 0x10(%rsp), %rdi
leaq 0x28(%rsp), %rsi
movl %ebp, %ecx
callq 0x2ac6
jmp 0x2a3e
leaq 0x10(%rsp), %rdi
leaq 0x28(%rsp), %rsi
movl %r14d, %ecx
movl %ebp, %r8d
callq 0x2c02
movq 0x10(%rsp), %rax
movq 0x18(%rsp), %rcx
subq %rax, %rcx
sarq $0x3, %rcx
movq 0x70(%rsp), %rdx
movq (%rbx), %rsi
xorl %edi, %edi
cmpq %rdi, %rcx
jbe 0x2a78
movl (%rdx,%rdi,4), %r8d
movsd (%rax,%rdi,8), %xmm0
addsd (%rsi,%r8,8), %xmm0
movsd %xmm0, (%rsi,%r8,8)
incq %rdi
jmp 0x2a59
leaq 0x10(%rsp), %rdi
callq 0x5754
leaq 0x28(%rsp), %rdi
callq 0x46de
addq $0x258, %rsp            # imm = 0x258
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x2aa0
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x5754
jmp 0x2ab4
jmp 0x2ab1
movq %rax, %rbx
leaq 0x28(%rsp), %rdi
callq 0x46de
movq %rbx, %rdi
callq 0x23d0