// File: /workspace/github_cpp_makefile_star2_O3/gchen98[P]macs/datastructures.cpp
// Function: Node::replaceOldWithNewEdge(Node::EdgeLocation, boost::shared_ptr<Edge>&, boost::shared_ptr<Edge>&)
void Node::replaceOldWithNewEdge(EdgeLocation iLocation,
EdgePtr & oldEdge,EdgePtr & newEdge){
    bool found = false;
    unsigned int i=0;
    if (iLocation==Node::TOP_EDGE){
        while(!found && i<this->topEdgeSize){
            WeakEdgePtr & topEdge = i?topEdge2:topEdge1;
            if (topEdge.lock()==oldEdge){
                topEdge=WeakEdgePtr(newEdge);
                found = true;
            }else{
                ++i;
            }
        }
        #ifdef DIAG
        if (!found) throw "Can't find top edge in replace edge";
        #endif
    }else if (iLocation==Node::BOTTOM_EDGE){
        while(!found && i<this->bottomEdgeSize){
            WeakEdgePtr & bottomEdge = i?bottomEdge2:bottomEdge1;
            if (bottomEdge.lock()==oldEdge){
                bottomEdge = WeakEdgePtr(newEdge);
                found = true;
            }else{
                ++i;
            }
        }
        if (!found) throw "Can't find bottom edge in replace edge";
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rcx, 0x20(%rsp)
movq %rdx, %r15
movq %rdi, %rbx
testl %esi, %esi
je 0x12163
cmpl $0x1, %esi
jne 0x1223a
cmpw $0x0, 0x6a(%rbx)
je 0x1213e
xorl %r13d, %r13d
xorl %r12d, %r12d
testl %r13d, %r13d
setne %r12b
shll $0x4, %r12d
movq $0x0, (%rsp)
movq 0x48(%rbx,%r12), %rcx
orq $0x40, %r12
movq %rcx, 0x8(%rsp)
testq %rcx, %rcx
je 0x12119
movl 0x8(%rcx), %eax
testl %eax, %eax
je 0x12110
leal 0x1(%rax), %edx
lock
cmpxchgl %edx, 0x8(%rcx)
jne 0x120f8
movq (%rbx,%r12), %r14
movq %r14, (%rsp)
jmp 0x1211c
movq $0x0, 0x8(%rsp)
xorl %r14d, %r14d
movq (%r15), %rbp
leaq 0x8(%rsp), %rdi
callq 0x10d5e
cmpq %rbp, %r14
je 0x121e1
incl %r13d
movzwl 0x6a(%rbx), %eax
cmpl %eax, %r13d
jb 0x120cc
movl $0x8, %edi
callq 0x3100
leaq 0x74fb(%rip), %rcx      # 0x1964a
movq %rcx, (%rax)
movq 0xde57(%rip), %rsi      # 0x1ffb0
movq %rax, %rdi
xorl %edx, %edx
callq 0x33d0
cmpw $0x0, 0x68(%rbx)
je 0x1223a
xorl %r13d, %r13d
xorl %r12d, %r12d
testl %r13d, %r13d
setne %r12b
shll $0x4, %r12d
movq $0x0, (%rsp)
movq 0x28(%rbx,%r12), %rcx
orq $0x20, %r12
movq %rcx, 0x8(%rsp)
testq %rcx, %rcx
je 0x121be
movl 0x8(%rcx), %eax
testl %eax, %eax
je 0x121b5
leal 0x1(%rax), %edx
lock
cmpxchgl %edx, 0x8(%rcx)
jne 0x1219d
movq (%rbx,%r12), %r14
movq %r14, (%rsp)
jmp 0x121c1
movq $0x0, 0x8(%rsp)
xorl %r14d, %r14d
movq (%r15), %rbp
leaq 0x8(%rsp), %rdi
callq 0x10d5e
cmpq %rbp, %r14
je 0x121e1
incl %r13d
movzwl 0x68(%rbx), %eax
cmpl %eax, %r13d
jb 0x12171
jmp 0x1223a
movq 0x20(%rsp), %rcx
movq (%rcx), %rax
movq %rax, 0x10(%rsp)
movq 0x8(%rcx), %rcx
movq %rcx, 0x18(%rsp)
testq %rcx, %rcx
je 0x12207
lock
incl 0xc(%rcx)
movq 0x18(%rsp), %rcx
jmp 0x12209
xorl %ecx, %ecx
leaq 0x18(%rsp), %r14
leaq 0x8(%rsp), %rdi
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
movups (%rbx,%r12), %xmm0
movq %rax, (%rbx,%r12)
movq %rcx, 0x8(%rbx,%r12)
movaps %xmm0, (%rsp)
callq 0x1528c
movq %r14, %rdi
callq 0x1528c
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop