// File: /workspace/github_cpp_makefile_star2_O1/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 $0x38, %rsp
movq %rcx, 0x28(%rsp)
movq %rdx, 0x30(%rsp)
movq %rdi, %r15
testl %esi, %esi
je 0x1226e
cmpl $0x1, %esi
jne 0x12375
cmpw $0x0, 0x6a(%r15)
je 0x12249
xorl %ebp, %ebp
xorl %r13d, %r13d
xorl %r12d, %r12d
testl %r13d, %r13d
setne %r12b
shll $0x4, %r12d
movq $0x0, (%rsp)
movq 0x48(%r15,%r12), %rcx
movq %rcx, 0x8(%rsp)
testq %rcx, %rcx
je 0x12190
movl 0x8(%rcx), %eax
testl %eax, %eax
je 0x12181
leal 0x1(%rax), %edx
lock
cmpxchgl %edx, 0x8(%rcx)
jne 0x12171
jmp 0x12183
xorl %eax, %eax
testl %eax, %eax
jne 0x12190
movq $0x0, 0x8(%rsp)
orq $0x40, %r12
cmpq $0x0, 0x8(%rsp)
je 0x121a4
movq (%r15,%r12), %rax
movq %rax, (%rsp)
movq (%rsp), %rbx
movq 0x30(%rsp), %rax
movq (%rax), %r14
leaq 0x8(%rsp), %rdi
callq 0x10dec
cmpq %r14, %rbx
je 0x121c4
incl %r13d
jmp 0x1222b
movq 0x28(%rsp), %rcx
movq (%rcx), %rax
movq %rax, 0x10(%rsp)
movq 0x8(%rcx), %rcx
movq %rcx, 0x18(%rsp)
testq %rcx, %rcx
je 0x121e3
lock
incl 0xc(%rcx)
movq %rax, (%rsp)
movq 0x18(%rsp), %rcx
movq %rcx, 0x8(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
movq (%r15,%r12), %rdx
movq %rdx, (%rsp)
movq %rax, (%r15,%r12)
movq 0x8(%r15,%r12), %rax
movq %rcx, 0x8(%r15,%r12)
movq %rax, 0x8(%rsp)
leaq 0x8(%rsp), %rdi
callq 0x153ec
leaq 0x18(%rsp), %rdi
callq 0x153ec
movb $0x1, %bpl
testb $0x1, %bpl
jne 0x1223f
movzwl 0x6a(%r15), %eax
cmpl %eax, %r13d
jb 0x12149
testb $0x1, %bpl
jne 0x12375
movl $0x8, %edi
callq 0x3100
leaq 0x7390(%rip), %rcx      # 0x195ea
movq %rcx, (%rax)
movq 0xdd4c(%rip), %rsi      # 0x1ffb0
movq %rax, %rdi
xorl %edx, %edx
callq 0x33d0
cmpw $0x0, 0x68(%r15)
je 0x12375
xorl %ebp, %ebp
xorl %r13d, %r13d
xorl %r12d, %r12d
testl %r13d, %r13d
setne %r12b
shll $0x4, %r12d
movq $0x0, (%rsp)
movq 0x28(%r15,%r12), %rcx
movq %rcx, 0x8(%rsp)
testq %rcx, %rcx
je 0x122c6
movl 0x8(%rcx), %eax
testl %eax, %eax
je 0x122b7
leal 0x1(%rax), %edx
lock
cmpxchgl %edx, 0x8(%rcx)
jne 0x122a7
jmp 0x122b9
xorl %eax, %eax
testl %eax, %eax
jne 0x122c6
movq $0x0, 0x8(%rsp)
orq $0x20, %r12
cmpq $0x0, 0x8(%rsp)
je 0x122da
movq (%r15,%r12), %rax
movq %rax, (%rsp)
movq (%rsp), %rbx
movq 0x30(%rsp), %rax
movq (%rax), %r14
leaq 0x8(%rsp), %rdi
callq 0x10dec
cmpq %r14, %rbx
je 0x122fa
incl %r13d
jmp 0x12361
movq 0x28(%rsp), %rcx
movq (%rcx), %rax
movq %rax, 0x10(%rsp)
movq 0x8(%rcx), %rcx
movq %rcx, 0x18(%rsp)
testq %rcx, %rcx
je 0x12319
lock
incl 0xc(%rcx)
movq %rax, (%rsp)
movq 0x18(%rsp), %rcx
movq %rcx, 0x8(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
movq (%r15,%r12), %rdx
movq %rdx, (%rsp)
movq %rax, (%r15,%r12)
movq 0x8(%r15,%r12), %rax
movq %rcx, 0x8(%r15,%r12)
movq %rax, 0x8(%rsp)
leaq 0x8(%rsp), %rdi
callq 0x153ec
leaq 0x18(%rsp), %rdi
callq 0x153ec
movb $0x1, %bpl
testb $0x1, %bpl
jne 0x12375
movzwl 0x68(%r15), %eax
cmpl %eax, %r13d
jb 0x1227f
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq