// File: tomfunkhouser[P]gaps/pkgs/R3Utils/R3Segmentation.cpp
// Function: gaps::R3SegmentationPair::~R3SegmentationPair()
R3SegmentationPair::
~R3SegmentationPair(void)
{
  // Remove this pair from first cluster
  if (clusters[0]) {
    assert(cluster_index[0] >= 0);
    RNArrayEntry *entry = clusters[0]->pairs.KthEntry(cluster_index[0]);
    R3SegmentationPair *tail = clusters[0]->pairs.Tail();
    if (tail->clusters[0] == clusters[0]) tail->cluster_index[0] = cluster_index[0];
    else if (tail->clusters[1] == clusters[0]) tail->cluster_index[1] = cluster_index[0];
    clusters[0]->pairs.EntryContents(entry) = tail;
    clusters[0]->pairs.RemoveTail();
  }

  // Remove this pair from second cluster
  if (clusters[1]) {
    assert(cluster_index[1] >= 0);
    RNArrayEntry *entry = clusters[1]->pairs.KthEntry(cluster_index[1]);
    R3SegmentationPair *tail = clusters[1]->pairs.Tail();
    if (tail->clusters[0] == clusters[1]) tail->cluster_index[0] = cluster_index[1];
    else if (tail->clusters[1] == clusters[1]) tail->cluster_index[1] = cluster_index[1];
    clusters[1]->pairs.EntryContents(entry) = tail;
    clusters[1]->pairs.RemoveTail();
  }
}

// Assembly:
subq $0x78, %rsp
movq %rdi, 0x70(%rsp)
movq 0x70(%rsp), %rax
movq %rax, 0x48(%rsp)
cmpq $0x0, (%rax)
je 0x42136
movq 0x48(%rsp), %rax
movq (%rax), %rdi
addq $0x30, %rdi
movl 0x10(%rax), %esi
callq 0x27f10
movq %rax, 0x40(%rsp)
jmp 0x42078
movq 0x48(%rsp), %rax
movq 0x40(%rsp), %rcx
movq %rcx, 0x68(%rsp)
movq (%rax), %rdi
addq $0x30, %rdi
callq 0x47ad0
movq %rax, 0x38(%rsp)
jmp 0x4209a
movq 0x48(%rsp), %rcx
movq 0x38(%rsp), %rax
movq %rax, 0x60(%rsp)
movq 0x60(%rsp), %rax
movq (%rax), %rax
cmpq (%rcx), %rax
jne 0x420c8
movq 0x48(%rsp), %rax
movl 0x10(%rax), %ecx
movq 0x60(%rsp), %rax
movl %ecx, 0x10(%rax)
jmp 0x420ed
movq 0x48(%rsp), %rcx
movq 0x60(%rsp), %rax
movq 0x8(%rax), %rax
cmpq (%rcx), %rax
jne 0x420eb
movq 0x48(%rsp), %rax
movl 0x10(%rax), %ecx
movq 0x60(%rsp), %rax
movl %ecx, 0x14(%rax)
jmp 0x420ed
movq 0x48(%rsp), %rax
movq 0x60(%rsp), %rcx
movq %rcx, 0x28(%rsp)
movq (%rax), %rdi
addq $0x30, %rdi
movq 0x68(%rsp), %rsi
callq 0x47ae0
movq %rax, 0x30(%rsp)
jmp 0x42114
movq 0x48(%rsp), %rax
movq 0x30(%rsp), %rcx
movq 0x28(%rsp), %rdx
movq %rdx, (%rcx)
movq (%rax), %rdi
addq $0x30, %rdi
callq 0x27f50
jmp 0x42134
jmp 0x42136
movq 0x48(%rsp), %rax
cmpq $0x0, 0x8(%rax)
je 0x42225
movq 0x48(%rsp), %rax
movq 0x8(%rax), %rdi
addq $0x30, %rdi
movl 0x14(%rax), %esi
callq 0x27f10
movq %rax, 0x20(%rsp)
jmp 0x42162
movq 0x48(%rsp), %rax
movq 0x20(%rsp), %rcx
movq %rcx, 0x58(%rsp)
movq 0x8(%rax), %rdi
addq $0x30, %rdi
callq 0x47ad0
movq %rax, 0x18(%rsp)
jmp 0x42185
movq 0x48(%rsp), %rcx
movq 0x18(%rsp), %rax
movq %rax, 0x50(%rsp)
movq 0x50(%rsp), %rax
movq (%rax), %rax
cmpq 0x8(%rcx), %rax
jne 0x421b4
movq 0x48(%rsp), %rax
movl 0x14(%rax), %ecx
movq 0x50(%rsp), %rax
movl %ecx, 0x10(%rax)
jmp 0x421da
movq 0x48(%rsp), %rcx
movq 0x50(%rsp), %rax
movq 0x8(%rax), %rax
cmpq 0x8(%rcx), %rax
jne 0x421d8
movq 0x48(%rsp), %rax
movl 0x14(%rax), %ecx
movq 0x50(%rsp), %rax
movl %ecx, 0x14(%rax)
jmp 0x421da
movq 0x48(%rsp), %rax
movq 0x50(%rsp), %rcx
movq %rcx, 0x8(%rsp)
movq 0x8(%rax), %rdi
addq $0x30, %rdi
movq 0x58(%rsp), %rsi
callq 0x47ae0
movq %rax, 0x10(%rsp)
jmp 0x42202
movq 0x48(%rsp), %rax
movq 0x10(%rsp), %rcx
movq 0x8(%rsp), %rdx
movq %rdx, (%rcx)
movq 0x8(%rax), %rdi
addq $0x30, %rdi
callq 0x27f50
jmp 0x42223
jmp 0x42225
addq $0x78, %rsp
retq
movq %rax, %rdi
callq 0x27cf0
nopw %cs:(%rax,%rax)