// File: /workspace/github_cpp_makefile_star2_O1/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 0x25dc
cmpl %r14d, %eax
jne 0x297b
movl %ebp, %edi
movq %rbx, %rsi
callq 0x25dc
cmpl %ebp, %eax
je 0x2997
movl %r14d, %edi
movq %rbx, %rsi
callq 0x25dc
movl %eax, %r14d
movl %ebp, %edi
movq %rbx, %rsi
callq 0x25dc
movl %eax, %ebp
jmp 0x295d
cmpl %ebp, %r14d
je 0x2a8e
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
movq 0x28(%r12), %rax
cmpq %rax, %rbp
je 0x2a15
leaq 0x20(%r13), %r14
movl (%rbp), %edi
movl 0x4(%rbp), %r15d
movq %rbx, %rsi
callq 0x25dc
movl %eax, (%rsp)
movl %r15d, 0x4(%rsp)
movq 0x28(%r13), %rsi
cmpq 0x30(%r13), %rsi
je 0x29fc
movq (%rsp), %rax
movq %rax, (%rsi)
addq $0x8, 0x28(%r13)
jmp 0x2a07
movq %r14, %rdi
movq %rsp, %rdx
callq 0x61c0
addq $0x8, %rbp
movq 0x28(%r12), %rax
cmpq %rax, %rbp
jne 0x29cd
movq 0x20(%r12), %rcx
cmpq %rcx, %rax
je 0x2a24
movq %rcx, 0x28(%r12)
movq 0x50(%r12), %rbp
movq 0x58(%r12), %rax
cmpq %rax, %rbp
je 0x2a7f
leaq 0x50(%r13), %r14
movl (%rbp), %edi
movl 0x4(%rbp), %r15d
movq %rbx, %rsi
callq 0x25dc
movl %eax, (%rsp)
movl %r15d, 0x4(%rsp)
movq 0x58(%r13), %rsi
cmpq 0x60(%r13), %rsi
je 0x2a66
movq (%rsp), %rax
movq %rax, (%rsi)
addq $0x8, 0x58(%r13)
jmp 0x2a71
movq %r14, %rdi
movq %rsp, %rdx
callq 0x61c0
addq $0x8, %rbp
movq 0x58(%r12), %rax
cmpq %rax, %rbp
jne 0x2a37
movq 0x50(%r12), %rcx
cmpq %rcx, %rax
je 0x2a8e
movq %rcx, 0x58(%r12)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq