// File: /workspace/github_cpp_makefile_star2_O3/yuanboli233[P]interdyck_graph_reduce/graphtest.cpp
// Function: mergeNodes(unsigned int, unsigned int, SummaryGraph&)
void mergeNodes(unsigned anodeID, unsigned bnodeID, SummaryGraph& sGraph){
    if(root(anodeID, sGraph) != anodeID || root(bnodeID, sGraph) != bnodeID)
        return mergeNodes(root(anodeID, sGraph), root(bnodeID, sGraph), sGraph);

    if(anodeID == bnodeID)
        return;

    SummaryNode* anode = sGraph.nodes[anodeID];
    SummaryNode* bnode = sGraph.nodes[bnodeID];

    bnode->belongto = anode->id;

    for(vector<NodewithEID>::iterator it = bnode->outRedEdgeNodes.begin(); it != bnode->outRedEdgeNodes.end(); it++){
        unsigned eid = it->edgeID;
        unsigned tonodeID = root(it->nodeID, sGraph);
        NodewithEID newEidNode(tonodeID, eid);
        // do not care duplicate
        anode->outRedEdgeNodes.push_back(newEidNode);
        //cout << "add new red edge " << anode->id << "->" << tonodeID << " with eid " << eid << endl;
    }
    bnode->outRedEdgeNodes.clear();

    for(vector<NodewithEID>::iterator it = bnode->outBlueEdgeNodes.begin(); it != bnode->outBlueEdgeNodes.end(); it++){
        unsigned eid = it->edgeID;
        unsigned tonodeID = root(it->nodeID, sGraph);
        NodewithEID newEidNode(tonodeID, eid);
        // do not care duplicate
        anode->outBlueEdgeNodes.push_back(newEidNode);
        //cout << "add new blue edge " << anode->id << "->" << tonodeID << " with eid " << eid << endl;
    }
    bnode->outBlueEdgeNodes.clear();

    //cout << "Merge " << anodeID << " with " << bnodeID << endl;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdx, %rbx
movl %esi, %ebp
movl %edi, %r14d
movl %r14d, %edi
movq %rbx, %rsi
callq 0x25cc
cmpl %r14d, %eax
jne 0x2920
movl %ebp, %edi
movq %rbx, %rsi
callq 0x25cc
cmpl %ebp, %eax
je 0x293c
movl %r14d, %edi
movq %rbx, %rsi
callq 0x25cc
movl %eax, %r14d
movl %ebp, %edi
movq %rbx, %rsi
callq 0x25cc
movl %eax, %ebp
jmp 0x2902
cmpl %ebp, %r14d
je 0x2a27
movl %r14d, %eax
movq 0x70(%rbx), %rcx
movq (%rcx,%rax,8), %r13
movl %ebp, %eax
movq (%rcx,%rax,8), %r12
movl (%r13), %eax
movl %eax, 0x68(%r12)
movq 0x20(%r12), %rbp
cmpq 0x28(%r12), %rbp
je 0x29c3
leaq 0x20(%r13), %r14
movl (%rbp), %edi
movl 0x4(%rbp), %r15d
movq %rbx, %rsi
callq 0x25cc
movl %eax, (%rsp)
movl %r15d, 0x4(%rsp)
movq 0x28(%r13), %rsi
cmpq 0x30(%r13), %rsi
je 0x299e
movq (%rsp), %rax
movq %rax, (%rsi)
addq $0x8, 0x28(%r13)
jmp 0x29a9
movq %r14, %rdi
movq %rsp, %rdx
callq 0x6070
addq $0x8, %rbp
cmpq 0x28(%r12), %rbp
jne 0x296f
movq 0x20(%r12), %rax
cmpq %rax, %rbp
je 0x29c3
movq %rax, 0x28(%r12)
movq 0x50(%r12), %rbp
cmpq 0x58(%r12), %rbp
je 0x2a27
leaq 0x50(%r13), %r14
movl (%rbp), %edi
movl 0x4(%rbp), %r15d
movq %rbx, %rsi
callq 0x25cc
movl %eax, (%rsp)
movl %r15d, 0x4(%rsp)
movq 0x58(%r13), %rsi
cmpq 0x60(%r13), %rsi
je 0x2a02
movq (%rsp), %rax
movq %rax, (%rsi)
addq $0x8, 0x58(%r13)
jmp 0x2a0d
movq %r14, %rdi
movq %rsp, %rdx
callq 0x6070
addq $0x8, %rbp
cmpq 0x58(%r12), %rbp
jne 0x29d3
movq 0x50(%r12), %rax
cmpq %rax, %rbp
je 0x2a27
movq %rax, 0x58(%r12)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq