// File: tomfunkhouser[P]gaps/pkgs/R3Graphics/R3SceneNode.cpp
// Function: gaps::R3SceneNode::~R3SceneNode()
R3SceneNode::
~R3SceneNode(void)
{
  // Remove elements
  for (int i = 0; i < elements.NEntries(); i++) {
    R3SceneElement *element = elements.Kth(i);
    RemoveElement(element);
  }

  // Remove references
  for (int i = 0; i < references.NEntries(); i++) {
    R3SceneReference *reference = references.Kth(i);
    RemoveReference(reference);
  }

  // Remove children
  for (int i = 0; i < children.NEntries(); i++) {
    R3SceneNode *child = children.Kth(i);
    RemoveChild(child);
  }

  // Remove node from parent
  if (parent) {
    parent->RemoveChild(this);
  }

  // Remove node from scene
  if (scene) {
    scene->RemoveNode(this);
  }

  // Delete name
  if (name) free(name);
}

// Assembly:
subq $0x78, %rsp
movq %rdi, 0x70(%rsp)
movq 0x70(%rsp), %rax
movq %rax, 0x38(%rsp)
movl $0x0, 0x6c(%rsp)
movq 0x38(%rsp), %rdi
movl 0x6c(%rsp), %eax
movl %eax, 0x30(%rsp)
addq $0x30, %rdi
callq 0x2b8b0
movl %eax, 0x34(%rsp)
jmp 0x55a97
movl 0x30(%rsp), %eax
movl 0x34(%rsp), %ecx
cmpl %ecx, %eax
jge 0x55ae6
movq 0x38(%rsp), %rdi
addq $0x30, %rdi
movl 0x6c(%rsp), %esi
callq 0x2bd50
movq %rax, 0x28(%rsp)
jmp 0x55abc
movq 0x38(%rsp), %rdi
movq 0x28(%rsp), %rax
movq %rax, 0x60(%rsp)
movq 0x60(%rsp), %rsi
callq 0x55c90
jmp 0x55ad7
jmp 0x55ad9
movl 0x6c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x6c(%rsp)
jmp 0x55a7b
movl $0x0, 0x5c(%rsp)
movq 0x38(%rsp), %rdi
movl 0x5c(%rsp), %eax
movl %eax, 0x20(%rsp)
addq $0x40, %rdi
callq 0x2b8b0
movl %eax, 0x24(%rsp)
jmp 0x55b0a
movl 0x20(%rsp), %eax
movl 0x24(%rsp), %ecx
cmpl %ecx, %eax
jge 0x55b59
movq 0x38(%rsp), %rdi
addq $0x40, %rdi
movl 0x5c(%rsp), %esi
callq 0x2bd30
movq %rax, 0x18(%rsp)
jmp 0x55b2f
movq 0x38(%rsp), %rdi
movq 0x18(%rsp), %rax
movq %rax, 0x50(%rsp)
movq 0x50(%rsp), %rsi
callq 0x55cd0
jmp 0x55b4a
jmp 0x55b4c
movl 0x5c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x5c(%rsp)
jmp 0x55aee
movl $0x0, 0x4c(%rsp)
movq 0x38(%rsp), %rdi
movl 0x4c(%rsp), %eax
movl %eax, 0x10(%rsp)
addq $0x20, %rdi
callq 0x2b8b0
movl %eax, 0x14(%rsp)
jmp 0x55b7d
movl 0x10(%rsp), %eax
movl 0x14(%rsp), %ecx
cmpl %ecx, %eax
jge 0x55bcc
movq 0x38(%rsp), %rdi
addq $0x20, %rdi
movl 0x4c(%rsp), %esi
callq 0x2bd10
movq %rax, 0x8(%rsp)
jmp 0x55ba2
movq 0x38(%rsp), %rdi
movq 0x8(%rsp), %rax
movq %rax, 0x40(%rsp)
movq 0x40(%rsp), %rsi
callq 0x55d10
jmp 0x55bbd
jmp 0x55bbf
movl 0x4c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x4c(%rsp)
jmp 0x55b61
movq 0x38(%rsp), %rax
cmpq $0x0, 0x10(%rax)
je 0x55bea
movq 0x38(%rsp), %rsi
movq 0x10(%rsi), %rdi
callq 0x55d10
jmp 0x55be8
jmp 0x55bea
movq 0x38(%rsp), %rax
cmpq $0x0, (%rax)
je 0x55c06
movq 0x38(%rsp), %rsi
movq (%rsi), %rdi
callq 0x2ca20
jmp 0x55c04
jmp 0x55c06
movq 0x38(%rsp), %rax
cmpq $0x0, 0x1a0(%rax)
je 0x55c26
movq 0x38(%rsp), %rax
movq 0x1a0(%rax), %rdi
callq 0x22c30
movq 0x38(%rsp), %rdi
addq $0x168, %rdi            # imm = 0x168
callq 0x2c1a0
movq 0x38(%rsp), %rdi
addq $0x58, %rdi
callq 0xc1b00
movq 0x38(%rsp), %rdi
addq $0x50, %rdi
callq 0x481b0
movq 0x38(%rsp), %rdi
addq $0x40, %rdi
callq 0x58310
movq 0x38(%rsp), %rdi
addq $0x30, %rdi
callq 0x58320
movq 0x38(%rsp), %rdi
addq $0x20, %rdi
callq 0x48210
addq $0x78, %rsp
retq
movq %rax, %rdi
callq 0x49a50
nopw (%rax,%rax)