// File: fjamour[P]icentral/src/graph_t.cc
// Function: graph_t::find_edge_bcc(component_t&, std::pair<unsigned int, unsigned int>)
void graph_t::find_edge_bcc(
                component_t&    comp,
                edge_t          e
                )
{
    //a. find the bcc subgraph
    //b. find the articulation points in bcc
    //c. find the sizes of the subgraphs connected to each art point
    if(has_edge(e)) {
        printf("WARNING: inserted duplicate edge!\n");
    }
    insert_edge(e.first, e.second);
    graph_hash_t g;
    find_edge_bcc_subgraph(g, e.first, e.second);
    //g.remove_edge(e.first, e.second); //TODO: make sure it's okay! [NO, needed below]
    vector<node_id_t> art_pt_vec;
    find_art_points(art_pt_vec);
    set<node_id_t> art_pt_set;//to make art points unique
    for(int i = 0; i < art_pt_vec.size(); ++i) {
        art_pt_set.insert(art_pt_vec[i]);
    }
    
    graph_hash_t::nodes_map_t::iterator it;
    for(it = g.nodes_map.begin();
        it != g.nodes_map.end();
        ++it) {
        node_id_t v = it->first;
        if(art_pt_set.find(v) != art_pt_set.end()) {
            // the node is an articulation point and it belongs to the bcc
            // of interest, so it must be added to the art point of this bcc
            // along with the sizes of the subgraphs it connects the bcc to
            vector<int> subgraph_sz_vec;
            vector<bool> visited_vec;
            visited_vec.resize(size());
            fill(visited_vec.begin(), visited_vec.end(), false);
            visited_vec[v] = true;
            vector<node_id_t> v_nbr_vec = get_nbrs(v);
            for(int i = 0; i < v_nbr_vec.size(); ++i) {
                node_id_t u = v_nbr_vec[i];
                if(!g.has_edge(v, u) && !visited_vec[u]) {
                    //do a dfs from this guy to figure out the size
                    //of the connected component connected to the bcc through v
                    //and this edge
                    int cnt = 0;
                    stack<node_id_t> S;
                    S.push(u);
                    visited_vec[u] = true;
                    while(!S.empty()) {
                        node_id_t vv = S.top();
                        S.pop();
                        cnt++;
                        vector<node_id_t> nbr_vec = get_nbrs(vv);
                        for(int i = 0; i < nbr_vec.size(); ++i) {
                            node_id_t nbr = nbr_vec[i];
                            if(!visited_vec[nbr]) {
                                visited_vec[nbr] = true;
                                S.push(nbr);
                            }
                        }
                    }
                    subgraph_sz_vec.push_back(cnt);
                    //printf("---%d, %d", v, cnt);
                }
            }
            comp.art_pt_map.insert(make_pair(v, subgraph_sz_vec));
        }
    }
    //fix art_pt_map
    g.remove_edge(e.first, e.second);
    comp.subgraph.fill_graph(g);
    
    component_t::art_pt_map_t new_art_pt_map;
    for(component_t::art_pt_map_t::iterator it = comp.art_pt_map.begin();
            it != comp.art_pt_map.end();
            ++it) {
        node_id_t new_v = comp.subgraph.outin_label_map[it->first];
        new_art_pt_map.insert(make_pair(new_v, it->second));
    }
    comp.art_pt_map = new_art_pt_map;
    
    remove_edge(e.first, e.second);
}

// Assembly:
subq $0x748, %rsp            # imm = 0x748
movq %rdx, 0x740(%rsp)
movq %rdi, 0x738(%rsp)
movq %rsi, 0x730(%rsp)
movq 0x738(%rsp), %rdi
movq %rdi, 0x140(%rsp)
leaq 0x740(%rsp), %rsi
callq 0x57340
testb $0x1, %al
jne 0x57be2
jmp 0x57bf0
leaq 0x240c8(%rip), %rdi     # 0x7bcb1
movb $0x0, %al
callq 0x9040
movq 0x140(%rsp), %rdi
movl 0x740(%rsp), %esi
movl 0x744(%rsp), %edx
callq 0x56720
leaq 0x488(%rsp), %rdi
movq %rdi, 0x138(%rsp)
callq 0x41780
movq 0x140(%rsp), %rdi
movq 0x138(%rsp), %rsi
movl 0x740(%rsp), %edx
movl 0x744(%rsp), %ecx
callq 0x409c0
jmp 0x57c45
leaq 0x460(%rsp), %rdi
movq %rdi, 0x130(%rsp)
callq 0xfcd0
movq 0x140(%rsp), %rdi
movq 0x130(%rsp), %rsi
callq 0x3f970
jmp 0x57c71
leaq 0x430(%rsp), %rdi
callq 0x3ad20
movl $0x0, 0x42c(%rsp)
movslq 0x42c(%rsp), %rax
movq %rax, 0x128(%rsp)
leaq 0x460(%rsp), %rdi
callq 0xfd50
movq %rax, %rcx
movq 0x128(%rsp), %rax
cmpq %rcx, %rax
jae 0x57d6f
movslq 0x42c(%rsp), %rsi
leaq 0x460(%rsp), %rdi
callq 0xfbc0
movq %rax, %rsi
leaq 0x430(%rsp), %rdi
callq 0x3ad30
movb %dl, 0x11f(%rsp)
movq %rax, 0x120(%rsp)
jmp 0x57cf0
movb 0x11f(%rsp), %al
movq 0x120(%rsp), %rcx
movq %rcx, 0x418(%rsp)
movb %al, 0x420(%rsp)
movl 0x42c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x42c(%rsp)
jmp 0x57c89
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x480(%rsp)
movl %eax, 0x47c(%rsp)
jmp 0x588a7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x480(%rsp)
movl %eax, 0x47c(%rsp)
jmp 0x5889a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x480(%rsp)
movl %eax, 0x47c(%rsp)
jmp 0x5888d
leaq 0x408(%rsp), %rdi
callq 0x3ad90
jmp 0x57d7e
leaq 0x488(%rsp), %rdi
callq 0x2d6b0
movq %rdx, 0x108(%rsp)
movq %rax, 0x110(%rsp)
jmp 0x57d9d
movq 0x108(%rsp), %rax
movq 0x110(%rsp), %rcx
movq %rcx, 0x3f8(%rsp)
movq %rax, 0x400(%rsp)
movq 0x3f8(%rsp), %rax
movq %rax, 0x408(%rsp)
movq 0x400(%rsp), %rax
movq %rax, 0x410(%rsp)
leaq 0x488(%rsp), %rdi
callq 0x2d710
movq %rdx, 0xf8(%rsp)
movq %rax, 0x100(%rsp)
jmp 0x57dfc
movq 0xf8(%rsp), %rax
movq 0x100(%rsp), %rcx
movq %rcx, 0x3e8(%rsp)
movq %rax, 0x3f0(%rsp)
leaq 0x408(%rsp), %rdi
leaq 0x3e8(%rsp), %rsi
callq 0x2d6f0
movb %al, 0xf7(%rsp)
jmp 0x57e3a
movb 0xf7(%rsp), %al
testb $0x1, %al
jne 0x57e4a
jmp 0x5858d
leaq 0x408(%rsp), %rdi
callq 0x2d750
movq %rax, 0xe8(%rsp)
jmp 0x57e61
movq 0xe8(%rsp), %rax
movl (%rax), %eax
movl %eax, 0x3e4(%rsp)
leaq 0x430(%rsp), %rdi
leaq 0x3e4(%rsp), %rsi
callq 0x3add0
movq %rax, 0xe0(%rsp)
jmp 0x57e91
movq 0xe0(%rsp), %rax
movq %rax, 0x3d8(%rsp)
leaq 0x430(%rsp), %rdi
callq 0x3ae10
movq %rax, 0x3d0(%rsp)
leaq 0x3d8(%rsp), %rdi
leaq 0x3d0(%rsp), %rsi
callq 0x3adb0
testb $0x1, %al
jne 0x57ed4
jmp 0x58577
leaq 0x3b8(%rsp), %rdi
callq 0xfc40
leaq 0x390(%rsp), %rdi
movq %rdi, 0xd8(%rsp)
callq 0x15640
movq 0x140(%rsp), %rdi
callq 0x56b40
movq 0xd8(%rsp), %rdi
movq %rax, %rsi
xorl %edx, %edx
callq 0x24c90
jmp 0x57f17
leaq 0x390(%rsp), %rdi
movq %rdi, 0xd0(%rsp)
callq 0x1f400
movq 0xd0(%rsp), %rdi
movl %edx, 0x378(%rsp)
movq %rax, 0x370(%rsp)
movl 0x378(%rsp), %eax
movl %eax, 0x388(%rsp)
movq 0x370(%rsp), %rax
movq %rax, 0x380(%rsp)
callq 0x21fd0
movl %edx, 0x358(%rsp)
movq %rax, 0x350(%rsp)
movl 0x358(%rsp), %eax
movl %eax, 0x368(%rsp)
movq 0x350(%rsp), %rax
movq %rax, 0x360(%rsp)
movb $0x0, 0x34f(%rsp)
movq 0x380(%rsp), %rdi
movl 0x388(%rsp), %esi
movq 0x360(%rsp), %rdx
movl 0x368(%rsp), %ecx
leaq 0x34f(%rsp), %r8
callq 0x21f60
jmp 0x57fc8
movl 0x3e4(%rsp), %eax
movl %eax, %esi
leaq 0x390(%rsp), %rdi
callq 0x10a70
movq %rdx, 0xc0(%rsp)
movq %rax, 0xc8(%rsp)
jmp 0x57ff0
movq 0xc0(%rsp), %rax
movq 0xc8(%rsp), %rcx
movq %rcx, 0x338(%rsp)
movq %rax, 0x340(%rsp)
leaq 0x338(%rsp), %rdi
movl $0x1, %esi
callq 0x10ad0
movq 0x140(%rsp), %rdi
movl 0x3e4(%rsp), %esi
callq 0x566f0
movq %rax, %rsi
leaq 0x320(%rsp), %rdi
callq 0x10b20
jmp 0x58048
movl $0x0, 0x31c(%rsp)
movslq 0x31c(%rsp), %rax
movq %rax, 0xb8(%rsp)
leaq 0x320(%rsp), %rdi
callq 0xfd50
movq %rax, %rcx
movq 0xb8(%rsp), %rax
cmpq %rcx, %rax
jae 0x5845f
movslq 0x31c(%rsp), %rsi
leaq 0x320(%rsp), %rdi
callq 0xfbc0
movl (%rax), %eax
movl %eax, 0x318(%rsp)
movl 0x3e4(%rsp), %esi
movl 0x318(%rsp), %edx
leaq 0x488(%rsp), %rdi
callq 0x52960
movb %al, 0xb7(%rsp)
jmp 0x580c6
movb 0xb7(%rsp), %cl
xorl %eax, %eax
testb $0x1, %cl
movb %al, 0xb6(%rsp)
jne 0x5813b
jmp 0x580dd
movl 0x318(%rsp), %eax
movl %eax, %esi
leaq 0x390(%rsp), %rdi
callq 0x10a70
movq %rdx, 0xa0(%rsp)
movq %rax, 0xa8(%rsp)
jmp 0x58105
movq 0xa0(%rsp), %rax
movq 0xa8(%rsp), %rcx
movq %rcx, 0x308(%rsp)
movq %rax, 0x310(%rsp)
leaq 0x308(%rsp), %rdi
callq 0x10c20
xorb $-0x1, %al
movb %al, 0xb6(%rsp)
movb 0xb6(%rsp), %al
testb $0x1, %al
jne 0x5814b
jmp 0x58447
movl $0x0, 0x304(%rsp)
leaq 0x2b0(%rsp), %rdi
callq 0x21da0
jmp 0x58165
leaq 0x2b0(%rsp), %rdi
leaq 0x318(%rsp), %rsi
callq 0x21d50
jmp 0x5817c
movl 0x318(%rsp), %eax
movl %eax, %esi
leaq 0x390(%rsp), %rdi
callq 0x10a70
movq %rdx, 0x90(%rsp)
movq %rax, 0x98(%rsp)
jmp 0x581a4
movq 0x90(%rsp), %rax
movq 0x98(%rsp), %rcx
movq %rcx, 0x2a0(%rsp)
movq %rax, 0x2a8(%rsp)
leaq 0x2a0(%rsp), %rdi
movl $0x1, %esi
callq 0x10ad0
leaq 0x2b0(%rsp), %rdi
callq 0x21ee0
movb %al, 0x8f(%rsp)
jmp 0x581ec
movb 0x8f(%rsp), %al
xorb $-0x1, %al
testb $0x1, %al
jne 0x581fe
jmp 0x5840f
leaq 0x2b0(%rsp), %rdi
callq 0x21f00
movq %rax, 0x80(%rsp)
jmp 0x58215
movq 0x80(%rsp), %rax
movl (%rax), %eax
movl %eax, 0x29c(%rsp)
leaq 0x2b0(%rsp), %rdi
callq 0x21f10
jmp 0x58235
movq 0x140(%rsp), %rdi
movl 0x304(%rsp), %eax
incl %eax
movl %eax, 0x304(%rsp)
movl 0x29c(%rsp), %esi
callq 0x566f0
movq %rax, %rsi
leaq 0x280(%rsp), %rdi
callq 0x10b20
jmp 0x5826b
movl $0x0, 0x27c(%rsp)
movslq 0x27c(%rsp), %rax
movq %rax, 0x78(%rsp)
leaq 0x280(%rsp), %rdi
callq 0xfd50
movq %rax, %rcx
movq 0x78(%rsp), %rax
cmpq %rcx, %rax
jae 0x583fd
movslq 0x27c(%rsp), %rsi
leaq 0x280(%rsp), %rdi
callq 0xfbc0
movl (%rax), %eax
movl %eax, 0x278(%rsp)
movl 0x278(%rsp), %eax
movl %eax, %esi
leaq 0x390(%rsp), %rdi
callq 0x10a70
movq %rdx, 0x68(%rsp)
movq %rax, 0x70(%rsp)
jmp 0x582e1
movq 0x68(%rsp), %rax
movq 0x70(%rsp), %rcx
movq %rcx, 0x268(%rsp)
movq %rax, 0x270(%rsp)
leaq 0x268(%rsp), %rdi
callq 0x10c20
xorb $-0x1, %al
testb $0x1, %al
jne 0x58313
jmp 0x583e5
movl 0x278(%rsp), %eax
movl %eax, %esi
leaq 0x390(%rsp), %rdi
callq 0x10a70
movq %rdx, 0x58(%rsp)
movq %rax, 0x60(%rsp)
jmp 0x58335
movq 0x58(%rsp), %rax
movq 0x60(%rsp), %rcx
movq %rcx, 0x258(%rsp)
movq %rax, 0x260(%rsp)
leaq 0x258(%rsp), %rdi
movl $0x1, %esi
callq 0x10ad0
leaq 0x2b0(%rsp), %rdi
leaq 0x278(%rsp), %rsi
callq 0x21d50
jmp 0x58378
jmp 0x583e5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x480(%rsp)
movl %eax, 0x47c(%rsp)
jmp 0x58558
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x480(%rsp)
movl %eax, 0x47c(%rsp)
jmp 0x5854b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x480(%rsp)
movl %eax, 0x47c(%rsp)
jmp 0x58435
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x480(%rsp)
movl %eax, 0x47c(%rsp)
leaq 0x280(%rsp), %rdi
callq 0x10520
jmp 0x58435
jmp 0x583e7
movl 0x27c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x27c(%rsp)
jmp 0x58276
leaq 0x280(%rsp), %rdi
callq 0x10520
jmp 0x581d6
leaq 0x3b8(%rsp), %rdi
leaq 0x304(%rsp), %rsi
callq 0x3ae40
jmp 0x58426
leaq 0x2b0(%rsp), %rdi
callq 0x21e40
jmp 0x58447
leaq 0x2b0(%rsp), %rdi
callq 0x21e40
jmp 0x5854b
jmp 0x58449
movl 0x31c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x31c(%rsp)
jmp 0x58053
movq 0x730(%rsp), %rax
addq $0x1f8, %rax            # imm = 0x1F8
movq %rax, 0x50(%rsp)
leaq 0x218(%rsp), %rdi
leaq 0x3e4(%rsp), %rsi
leaq 0x3b8(%rsp), %rdx
callq 0x3aee0
jmp 0x58491
leaq 0x238(%rsp), %rdi
leaq 0x218(%rsp), %rsi
callq 0x1e5b0
jmp 0x584a8
movq 0x50(%rsp), %rsi
leaq 0x200(%rsp), %rdi
leaq 0x238(%rsp), %rdx
callq 0x3aeb0
jmp 0x584c4
leaq 0x238(%rsp), %rdi
callq 0x16f10
leaq 0x218(%rsp), %rdi
callq 0x1e600
leaq 0x320(%rsp), %rdi
callq 0x10520
leaq 0x390(%rsp), %rdi
callq 0x15650
leaq 0x3b8(%rsp), %rdi
callq 0xfc70
jmp 0x58577
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x480(%rsp)
movl %eax, 0x47c(%rsp)
jmp 0x5853e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x480(%rsp)
movl %eax, 0x47c(%rsp)
leaq 0x238(%rsp), %rdi
callq 0x16f10
leaq 0x218(%rsp), %rdi
callq 0x1e600
leaq 0x320(%rsp), %rdi
callq 0x10520
leaq 0x390(%rsp), %rdi
callq 0x15650
leaq 0x3b8(%rsp), %rdi
callq 0xfc70
jmp 0x5888d
jmp 0x58579
leaq 0x408(%rsp), %rdi
callq 0x2d760
jmp 0x58588
jmp 0x57ddd
movl 0x740(%rsp), %esi
movl 0x744(%rsp), %edx
leaq 0x488(%rsp), %rdi
callq 0x52580
jmp 0x585aa
movq 0x730(%rsp), %rdi
leaq 0x488(%rsp), %rsi
callq 0x77eb0
jmp 0x585c1
leaq 0x1cd(%rsp), %rdi
movq %rdi, 0x48(%rsp)
callq 0x15450
movq 0x48(%rsp), %r8
leaq 0x1d0(%rsp), %rdi
movl $0xa, %esi
leaq 0x1cf(%rsp), %rdx
leaq 0x1ce(%rsp), %rcx
callq 0x15460
jmp 0x585fc
leaq 0x1cd(%rsp), %rdi
callq 0x154a0
movq 0x730(%rsp), %rdi
addq $0x1f8, %rdi            # imm = 0x1F8
callq 0x3acb0
movq %rdx, 0x38(%rsp)
movq %rax, 0x40(%rsp)
jmp 0x58629
movq 0x38(%rsp), %rax
movq 0x40(%rsp), %rcx
movq %rcx, 0x1b8(%rsp)
movq %rax, 0x1c0(%rsp)
movq 0x730(%rsp), %rdi
addq $0x1f8, %rdi            # imm = 0x1F8
callq 0x10710
movq %rdx, 0x28(%rsp)
movq %rax, 0x30(%rsp)
jmp 0x58663
movq 0x28(%rsp), %rax
movq 0x30(%rsp), %rcx
movq %rcx, 0x1a8(%rsp)
movq %rax, 0x1b0(%rsp)
leaq 0x1b8(%rsp), %rdi
leaq 0x1a8(%rsp), %rsi
callq 0x10630
movb %al, 0x27(%rsp)
jmp 0x58698
movb 0x27(%rsp), %al
testb $0x1, %al
jne 0x586a5
jmp 0x58809
movq 0x730(%rsp), %rax
addq $0x60, %rax
movq %rax, 0x10(%rsp)
leaq 0x1b8(%rsp), %rdi
callq 0x1e5f0
movq %rax, 0x18(%rsp)
jmp 0x586ca
movq 0x18(%rsp), %rsi
movq 0x10(%rsp), %rdi
callq 0xfab0
movq %rax, 0x8(%rsp)
jmp 0x586e0
movq 0x8(%rsp), %rax
movl (%rax), %eax
movl %eax, 0x1a4(%rsp)
leaq 0x1b8(%rsp), %rdi
callq 0x1e5f0
movq %rax, (%rsp)
jmp 0x58701
movq (%rsp), %rdx
addq $0x8, %rdx
leaq 0x160(%rsp), %rdi
leaq 0x1a4(%rsp), %rsi
callq 0x3aee0
jmp 0x58720
leaq 0x180(%rsp), %rdi
leaq 0x160(%rsp), %rsi
callq 0x1e5b0
jmp 0x58737
leaq 0x148(%rsp), %rdi
leaq 0x1d0(%rsp), %rsi
leaq 0x180(%rsp), %rdx
callq 0x3aeb0
jmp 0x58756
leaq 0x180(%rsp), %rdi
callq 0x16f10
leaq 0x160(%rsp), %rdi
callq 0x1e600
leaq 0x1b8(%rsp), %rdi
callq 0x3acf0
jmp 0x5877f
jmp 0x58643
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x480(%rsp)
movl %eax, 0x47c(%rsp)
leaq 0x1cd(%rsp), %rdi
callq 0x154a0
jmp 0x5888d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x480(%rsp)
movl %eax, 0x47c(%rsp)
jmp 0x58880
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x480(%rsp)
movl %eax, 0x47c(%rsp)
jmp 0x587fa
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x480(%rsp)
movl %eax, 0x47c(%rsp)
leaq 0x180(%rsp), %rdi
callq 0x16f10
leaq 0x160(%rsp), %rdi
callq 0x1e600
jmp 0x58880
movq 0x730(%rsp), %rdi
addq $0x1f8, %rdi            # imm = 0x1F8
leaq 0x1d0(%rsp), %rsi
callq 0x3af20
jmp 0x58827
movq 0x140(%rsp), %rdi
movl 0x740(%rsp), %esi
movl 0x744(%rsp), %edx
callq 0x56850
jmp 0x58844
leaq 0x1d0(%rsp), %rdi
callq 0x16bf0
leaq 0x430(%rsp), %rdi
callq 0x3af50
leaq 0x460(%rsp), %rdi
callq 0x10520
leaq 0x488(%rsp), %rdi
callq 0x41f20
addq $0x748, %rsp            # imm = 0x748
retq
leaq 0x1d0(%rsp), %rdi
callq 0x16bf0
leaq 0x430(%rsp), %rdi
callq 0x3af50
leaq 0x460(%rsp), %rdi
callq 0x10520
leaq 0x488(%rsp), %rdi
callq 0x41f20
movq 0x480(%rsp), %rdi
callq 0x9cf0
nopw %cs:(%rax,%rax)
nopl (%rax,%rax)