// File: /workspace/github_cpp_makefile_star2_O1/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 %r12
pushq %rbx
subq $0x260, %rsp            # imm = 0x260
movl %r9d, %ebp
movl %r8d, %r15d
movq %rsi, %r12
movq %rdi, %rbx
movq %rcx, 0x8(%rsp)
testl %edx, %edx
je 0x351a
cmpl $0x2, %edx
jne 0x3712
leaq 0x30(%rsp), %rdi
callq 0x6220
leaq 0x228(%rsp), %r14
leaq 0x3(%rsp), %rax
leaq 0x6(%rsp), %r10
leaq 0x5(%rsp), %rdx
leaq 0x10(%rsp), %rcx
leaq 0x7(%rsp), %r8
leaq 0x4(%rsp), %r9
movl $0xa, %esi
movq %r14, %rdi
pushq %rax
pushq %r10
callq 0x67d6
addq $0x10, %rsp
leaq 0x30(%rsp), %rdi
movl $0x2, 0x228(%rdi)
movq %r12, %rsi
callq 0x2f63a
xorpd %xmm0, %xmm0
movapd %xmm0, 0x10(%rsp)
movq $0x0, 0x20(%rsp)
movq 0x8(%rsp), %rdx
cmpl $0x1, %r15d
jne 0x3591
leaq 0x10(%rsp), %rdi
leaq 0x30(%rsp), %rsi
movl %ebp, %ecx
callq 0x3783
jmp 0x35a6
leaq 0x30(%rsp), %rdi
callq 0x6220
leaq 0x228(%rsp), %r14
leaq 0x3(%rsp), %rax
leaq 0x6(%rsp), %r10
leaq 0x5(%rsp), %rdx
leaq 0x10(%rsp), %rcx
leaq 0x7(%rsp), %r8
leaq 0x4(%rsp), %r9
movl $0xa, %esi
movq %r14, %rdi
pushq %rax
pushq %r10
callq 0x67d6
addq $0x10, %rsp
movl $0x0, 0x258(%rsp)
cmpl $0x1, %ebp
je 0x35f4
testl %ebp, %ebp
jne 0x3626
movq 0x8(%rsp), %rdx
leaq 0x30(%rsp), %rsi
movq %r12, %rdi
callq 0x1eef2
jmp 0x3626
leaq 0x10(%rsp), %rdi
leaq 0x30(%rsp), %rsi
movl %r15d, %ecx
movl %ebp, %r8d
callq 0x391e
movq 0x10(%rsp), %rdi
movq 0x18(%rsp), %rax
subq %rdi, %rax
je 0x35dd
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 0x35c6
testq %rdi, %rdi
je 0x35ef
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x2250
jmp 0x3700
movl 0x8(%rsp), %esi
movl 0xc(%rsp), %edx
movq %r12, %rdi
callq 0x1deda
movq 0x8(%rsp), %rdx
leaq 0x30(%rsp), %rsi
movq %r12, %rdi
callq 0x1eef2
movl 0x8(%rsp), %esi
movl 0xc(%rsp), %edx
movq %r12, %rdi
callq 0x1de06
leaq 0x90(%rsp), %r12
leaq 0x8(%rsp), %rsi
movq %r12, %rdi
callq 0x5d84
movl (%rax), %eax
leaq 0xc(%rsp), %rsi
movl %eax, -0x4(%rsi)
movq %r12, %rdi
callq 0x5d84
movl (%rax), %edx
movl %edx, 0xc(%rsp)
cmpl $0x1, %ebp
jne 0x3666
movl 0x8(%rsp), %esi
leaq 0x30(%rsp), %rdi
callq 0x2eb74
xorpd %xmm0, %xmm0
movapd %xmm0, 0x10(%rsp)
movq $0x0, 0x20(%rsp)
movq 0x8(%rsp), %rdx
cmpl $0x1, %r15d
jne 0x3697
leaq 0x10(%rsp), %rdi
leaq 0x30(%rsp), %rsi
movl %ebp, %ecx
callq 0x3783
jmp 0x36ac
leaq 0x10(%rsp), %rdi
leaq 0x30(%rsp), %rsi
movl %r15d, %ecx
movl %ebp, %r8d
callq 0x391e
movq 0x10(%rsp), %rdi
movq 0x18(%rsp), %rax
subq %rdi, %rax
je 0x36ee
sarq $0x3, %rax
movq 0x78(%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 0x36d1
testq %rdi, %rdi
je 0x3700
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x2250
movq %r14, %rdi
callq 0x68e6
leaq 0x30(%rsp), %rdi
callq 0x6460
addq $0x260, %rsp            # imm = 0x260
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x3769
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x2250
jmp 0x3769
movq %rax, %rbx
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x375d
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x2250
jmp 0x375d
movq %rax, %rbx
jmp 0x3769
jmp 0x3761
movq %rax, %rbx
jmp 0x3771
movq %rax, %rbx
movq %r14, %rdi
callq 0x68e6
leaq 0x30(%rsp), %rdi
callq 0x6460
movq %rbx, %rdi
callq 0x23b0