// File: /workspace/github_cpp_makefile_star2_O3/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 $0x268, %rsp            # imm = 0x268
movl %r9d, %ebp
movl %r8d, %r15d
movq %rcx, %r12
movq %rsi, %r13
movq %rdi, %rbx
movq %rcx, 0x30(%rsp)
testl %edx, %edx
je 0x355d
cmpl $0x2, %edx
jne 0x3763
leaq 0x38(%rsp), %rdi
callq 0x6192
leaq 0x230(%rsp), %r14
leaq 0xb(%rsp), %rax
leaq 0xe(%rsp), %r10
leaq 0xd(%rsp), %rdx
leaq 0x10(%rsp), %rcx
leaq 0xf(%rsp), %r8
leaq 0xc(%rsp), %r9
movl $0xa, %esi
movq %r14, %rdi
pushq %rax
pushq %r10
callq 0x6748
addq $0x10, %rsp
leaq 0x38(%rsp), %rdi
movl $0x2, 0x228(%rdi)
movq %r13, %rsi
callq 0x2f2b8
xorpd %xmm0, %xmm0
movapd %xmm0, 0x10(%rsp)
movq $0x0, 0x20(%rsp)
cmpl $0x1, %r15d
jne 0x35cf
leaq 0x10(%rsp), %rdi
leaq 0x38(%rsp), %rsi
movq %r12, %rdx
movl %ebp, %ecx
callq 0x37de
jmp 0x35e7
leaq 0x38(%rsp), %rdi
callq 0x6192
leaq 0x230(%rsp), %rdi
leaq 0xb(%rsp), %rax
leaq 0xe(%rsp), %r10
leaq 0xd(%rsp), %rdx
leaq 0x10(%rsp), %rcx
leaq 0xf(%rsp), %r8
leaq 0xc(%rsp), %r9
movl $0xa, %esi
pushq %rax
pushq %r10
callq 0x6748
addq $0x10, %rsp
movl $0x0, 0x260(%rsp)
cmpl $0x1, %ebp
je 0x363a
testl %ebp, %ebp
jne 0x366d
leaq 0x38(%rsp), %rsi
movq %r13, %rdi
movq %r12, %rdx
callq 0x1edae
jmp 0x366d
leaq 0x10(%rsp), %rdi
leaq 0x38(%rsp), %rsi
movq %r12, %rdx
movl %r15d, %ecx
movl %ebp, %r8d
callq 0x3979
movq 0x10(%rsp), %rdi
movq 0x18(%rsp), %rax
subq %rdi, %rax
je 0x3620
sarq $0x3, %rax
movq (%rbx), %rcx
cmpq $0x1, %rax
adcq $0x0, %rax
xorl %edx, %edx
movsd (%rdi,%rdx,8), %xmm0
addsd (%rcx,%rdx,8), %xmm0
movsd %xmm0, (%rcx,%rdx,8)
incq %rdx
cmpq %rdx, %rax
jne 0x3607
jmp 0x3625
testq %rdi, %rdi
je 0x3632
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x2250
movq %r14, %rdi
jmp 0x3754
movq %r12, %r14
shrq $0x20, %r14
movq %r13, %rdi
movl %r12d, %esi
movl %r14d, %edx
callq 0x1dd70
leaq 0x38(%rsp), %rsi
movq %r13, %rdi
movq %r12, %rdx
callq 0x1edae
movq %r13, %rdi
movl %r12d, %esi
movl %r14d, %edx
callq 0x1dc86
leaq 0x98(%rsp), %r14
leaq 0x30(%rsp), %rsi
movq %r14, %rdi
callq 0x5d14
movl (%rax), %eax
leaq 0x34(%rsp), %rsi
movl %eax, -0x4(%rsi)
movq %r14, %rdi
callq 0x5d14
movl (%rax), %edx
movl %edx, 0x34(%rsp)
cmpl $0x1, %ebp
jne 0x36ad
movl 0x30(%rsp), %esi
leaq 0x38(%rsp), %rdi
callq 0x2e844
xorpd %xmm0, %xmm0
movapd %xmm0, 0x10(%rsp)
movq $0x0, 0x20(%rsp)
movq 0x30(%rsp), %rdx
cmpl $0x1, %r15d
jne 0x36de
leaq 0x10(%rsp), %rdi
leaq 0x38(%rsp), %rsi
movl %ebp, %ecx
callq 0x37de
jmp 0x36f3
leaq 0x10(%rsp), %rdi
leaq 0x38(%rsp), %rsi
movl %r15d, %ecx
movl %ebp, %r8d
callq 0x3979
movq 0x10(%rsp), %rdi
movq 0x18(%rsp), %rax
subq %rdi, %rax
je 0x373a
sarq $0x3, %rax
movq 0x80(%rsp), %rcx
movq (%rbx), %rdx
cmpq $0x1, %rax
adcq $0x0, %rax
xorl %esi, %esi
movl (%rcx,%rsi,4), %r8d
movsd (%rdi,%rsi,8), %xmm0
addsd (%rdx,%r8,8), %xmm0
movsd %xmm0, (%rdx,%r8,8)
incq %rsi
cmpq %rsi, %rax
jne 0x371b
jmp 0x373f
testq %rdi, %rdi
je 0x374c
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x2250
leaq 0x230(%rsp), %rdi
callq 0x6858
leaq 0x38(%rsp), %rdi
callq 0x63d2
addq $0x268, %rsp            # imm = 0x268
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x37bf
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x2250
jmp 0x37bf
movq %rax, %rbx
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x37b0
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x2250
jmp 0x37b0
movq %rax, %rbx
movq %r14, %rdi
jmp 0x37c7
jmp 0x37b7
movq %rax, %rbx
jmp 0x37cc
movq %rax, %rbx
leaq 0x230(%rsp), %rdi
callq 0x6858
leaq 0x38(%rsp), %rdi
callq 0x63d2
movq %rbx, %rdi
callq 0x23b0