// File: /workspace/github_c_makefile_star2_O3/mrkite[P]regs/docmaker/avl.cc
// Function: AVL::insertOnce(std::shared_ptr<AVLNode_>, unsigned int)
AVLNode AVL::insertOnce(AVLNode node, uint32_t key) {
  if (node == nullptr) {
    node = std::make_shared<AVLNode_>();
    node->key = key;
    node->left = nullptr;
    node->right = nullptr;
    node->down = nullptr;
    node->height = 1;
    node->matched = false;
    return node;
  }
  if (key < node->key) {
    node->left = insertOnce(node->left, key);
  } else if (key > node->key) {
    node->right = insertOnce(node->right, key);
  } else {  // key already exists
    return node;
  }
  node->height = 1 + max(Height(node->left), Height(node->right));
  int balance = getBalance(node);
  if (balance > 1 && key < node->left->key) {
    return rotateRight(node);
  }
  if (balance < -1 && key > node->right->key) {
    return rotateLeft(node);
  }
  if (balance > 1 && key > node->left->key) {
    node->left = rotateLeft(node->left);
    return rotateRight(node);
  }
  if (balance < -1 && key < node->right->key) {
    node->right = rotateRight(node->right);
    return rotateLeft(node);
  }
  return node;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xa8, %rsp
movl %ecx, %ebp
movq %rdx, %r14
movq %rdi, %rbx
movq (%rdx), %rax
testq %rax, %rax
je 0x7bd0
cmpl %ebp, (%rax)
jbe 0x7c81
movq 0x8(%rax), %rcx
movq %rcx, 0x38(%rsp)
movq 0x10(%rax), %rax
movq %rax, 0x40(%rsp)
testq %rax, %rax
je 0x7cb3
movq 0x6409(%rip), %rcx      # 0xdfc8
cmpb $0x0, (%rcx)
je 0x7caf
incl 0x8(%rax)
jmp 0x7cb3
movl $0x50, %edi
callq 0x31f0
movabsq $0x100000001, %rcx      # imm = 0x100000001
movq %rcx, 0x8(%rax)
leaq 0x6149(%rip), %rcx      # 0xdd38
movq %rcx, (%rax)
leaq 0x10(%rax), %rcx
xorps %xmm0, %xmm0
movups %xmm0, 0x10(%rax)
movups %xmm0, 0x20(%rax)
movups %xmm0, 0x30(%rax)
movups %xmm0, 0x40(%rax)
movq %rcx, (%r14)
movq 0x8(%r14), %rdi
movq %rax, 0x8(%r14)
testq %rdi, %rdi
je 0x7c24
callq 0x77a6
xorps %xmm0, %xmm0
movq (%r14), %rcx
movl %ebp, (%rcx)
movq 0x10(%rcx), %rdi
movups %xmm0, 0x8(%rcx)
testq %rdi, %rdi
je 0x7c38
callq 0x77a6
movq (%r14), %rax
xorl %ecx, %ecx
movq %rcx, 0x18(%rax)
movq 0x20(%rax), %rdi
movq %rcx, 0x20(%rax)
testq %rdi, %rdi
je 0x7c53
callq 0x77a6
movq (%r14), %rax
xorl %ecx, %ecx
movq %rcx, 0x28(%rax)
movq 0x30(%rax), %rdi
movq %rcx, 0x30(%rax)
testq %rdi, %rdi
je 0x7c6e
callq 0x77a6
movq (%r14), %rax
movl $0x1, 0x38(%rax)
movb $0x0, 0x3c(%rax)
jmp 0x7f61
jae 0x7f61
movq 0x18(%rax), %rcx
movq %rcx, 0x28(%rsp)
movq 0x20(%rax), %rax
movq %rax, 0x30(%rsp)
testq %rax, %rax
je 0x7ce9
movq 0x6323(%rip), %rcx      # 0xdfc8
cmpb $0x0, (%rcx)
je 0x7ce5
incl 0x8(%rax)
jmp 0x7ce9
lock
incl 0x8(%rax)
leaq 0x10(%rsp), %rdi
leaq 0x38(%rsp), %rdx
movl %ebp, %ecx
callq 0x7b74
movq (%r14), %rax
movq 0x10(%rax), %rdi
movaps 0x10(%rsp), %xmm0
movups %xmm0, 0x8(%rax)
testq %rdi, %rdi
je 0x7cde
callq 0x77a6
movq 0x40(%rsp), %rdi
jmp 0x7d19
lock
incl 0x8(%rax)
leaq 0x10(%rsp), %rdi
leaq 0x28(%rsp), %rdx
movl %ebp, %ecx
callq 0x7b74
movq (%r14), %rax
movq 0x20(%rax), %rdi
movaps 0x10(%rsp), %xmm0
movups %xmm0, 0x18(%rax)
testq %rdi, %rdi
je 0x7d14
callq 0x77a6
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x7d23
callq 0x77a6
movq (%r14), %rcx
movq 0x8(%rcx), %rax
movq 0x10(%rcx), %r15
testq %r15, %r15
je 0x7d4a
movq 0x628e(%rip), %rcx      # 0xdfc8
cmpb $0x0, (%rcx)
je 0x7d45
incl 0x8(%r15)
jmp 0x7d4a
lock
incl 0x8(%r15)
testq %rax, %rax
je 0x7d54
movl 0x38(%rax), %eax
jmp 0x7d56
xorl %eax, %eax
movq (%r14), %rdx
movq 0x18(%rdx), %rcx
movq 0x20(%rdx), %rdi
testq %rdi, %rdi
je 0x7d7b
movq 0x625b(%rip), %rdx      # 0xdfc8
cmpb $0x0, (%rdx)
je 0x7d77
incl 0x8(%rdi)
jmp 0x7d7b
lock
incl 0x8(%rdi)
testq %rcx, %rcx
je 0x7d85
movl 0x38(%rcx), %ecx
jmp 0x7d87
xorl %ecx, %ecx
cmpl %ecx, %eax
cmovgl %eax, %ecx
incl %ecx
movq (%r14), %rax
movl %ecx, 0x38(%rax)
testq %rdi, %rdi
je 0x7d9e
callq 0x77a6
testq %r15, %r15
je 0x7dab
movq %r15, %rdi
callq 0x77a6
movq (%r14), %rax
movq 0x8(%r14), %r15
testq %r15, %r15
je 0x7dce
movq 0x620a(%rip), %rcx      # 0xdfc8
cmpb $0x0, (%rcx)
je 0x7dc9
incl 0x8(%r15)
jmp 0x7dce
lock
incl 0x8(%r15)
testq %rax, %rax
je 0x7df3
movq 0x8(%rax), %rcx
movq 0x10(%rax), %r12
testq %r12, %r12
je 0x7dfe
movq 0x61e1(%rip), %rdx      # 0xdfc8
cmpb $0x0, (%rdx)
je 0x7df8
incl 0x8(%r12)
jmp 0x7dfe
xorl %r13d, %r13d
jmp 0x7e62
lock
incl 0x8(%r12)
testq %rcx, %rcx
je 0x7e09
movl 0x38(%rcx), %r13d
jmp 0x7e0c
xorl %r13d, %r13d
movq 0x18(%rax), %rcx
movq 0x20(%rax), %rdi
testq %rdi, %rdi
je 0x7e2e
movq 0x61a8(%rip), %rax      # 0xdfc8
cmpb $0x0, (%rax)
je 0x7e2a
incl 0x8(%rdi)
jmp 0x7e2e
lock
incl 0x8(%rdi)
movl %ebp, 0xc(%rsp)
movq %rbx, %rbp
testq %rcx, %rcx
je 0x7e3f
movl 0x38(%rcx), %ebx
jmp 0x7e41
xorl %ebx, %ebx
testq %rdi, %rdi
je 0x7e4b
callq 0x77a6
subl %ebx, %r13d
testq %r12, %r12
je 0x7e5b
movq %r12, %rdi
callq 0x77a6
movq %rbp, %rbx
movl 0xc(%rsp), %ebp
testq %r15, %r15
je 0x7e6f
movq %r15, %rdi
callq 0x77a6
cmpl $0x2, %r13d
jl 0x7eb5
movq (%r14), %rax
movq 0x8(%rax), %rcx
cmpl %ebp, (%rcx)
jbe 0x7eff
movq %rax, 0x98(%rsp)
movq 0x8(%r14), %rax
movq %rax, 0xa0(%rsp)
testq %rax, %rax
je 0x7f8e
movq 0x6124(%rip), %rcx      # 0xdfc8
cmpb $0x0, (%rcx)
je 0x7f8a
incl 0x8(%rax)
jmp 0x7f8e
movq (%r14), %rax
cmpl $-0x2, %r13d
jg 0x7f61
movq 0x18(%rax), %rcx
cmpl %ebp, (%rcx)
jae 0x7f30
movq %rax, 0x88(%rsp)
movq 0x8(%r14), %rax
movq %rax, 0x90(%rsp)
testq %rax, %rax
je 0x7f9f
movq 0x60da(%rip), %rcx      # 0xdfc8
cmpb $0x0, (%rcx)
je 0x7f9b
incl 0x8(%rax)
jmp 0x7f9f
jae 0x7f61
movq %rcx, 0x58(%rsp)
movq 0x10(%rax), %rax
movq %rax, 0x60(%rsp)
testq %rax, %rax
je 0x7fb0
movq 0x60a9(%rip), %rcx      # 0xdfc8
cmpb $0x0, (%rcx)
je 0x7fac
incl 0x8(%rax)
jmp 0x7fb0
jbe 0x7f61
movq %rcx, 0x48(%rsp)
movq 0x20(%rax), %rax
movq %rax, 0x50(%rsp)
testq %rax, %rax
je 0x802e
movq 0x6078(%rip), %rcx      # 0xdfc8
cmpb $0x0, (%rcx)
je 0x802a
incl 0x8(%rax)
jmp 0x802e
movq %rax, (%rbx)
movq 0x8(%r14), %rax
xorl %ecx, %ecx
movq %rcx, 0x8(%r14)
movq %rax, 0x8(%rbx)
movq %rcx, (%r14)
movq %rbx, %rax
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
lock
incl 0x8(%rax)
leaq 0x98(%rsp), %r14
jmp 0x801d
lock
incl 0x8(%rax)
leaq 0x88(%rsp), %r14
jmp 0x8098
lock
incl 0x8(%rax)
leaq 0x10(%rsp), %r15
leaq 0x58(%rsp), %rsi
movq %r15, %rdi
callq 0x82a6
movq (%r14), %rax
movq 0x10(%rax), %rdi
movaps (%r15), %xmm0
movups %xmm0, 0x8(%rax)
testq %rdi, %rdi
je 0x7fdb
callq 0x77a6
movq 0x60(%rsp), %rdi
testq %rdi, %rdi
je 0x7fea
callq 0x77a6
movq (%r14), %rax
movq %rax, 0x78(%rsp)
movq 0x8(%r14), %rax
movq %rax, 0x80(%rsp)
testq %rax, %rax
je 0x8018
movq 0x5fbe(%rip), %rcx      # 0xdfc8
cmpb $0x0, (%rcx)
je 0x8014
incl 0x8(%rax)
jmp 0x8018
lock
incl 0x8(%rax)
leaq 0x78(%rsp), %r14
movq %rbx, %rdi
movq %r14, %rsi
callq 0x80de
jmp 0x80a3
lock
incl 0x8(%rax)
leaq 0x10(%rsp), %r15
leaq 0x48(%rsp), %rsi
movq %r15, %rdi
callq 0x80de
movq (%r14), %rax
movq 0x20(%rax), %rdi
movaps (%r15), %xmm0
movups %xmm0, 0x18(%rax)
testq %rdi, %rdi
je 0x8059
callq 0x77a6
movq 0x50(%rsp), %rdi
testq %rdi, %rdi
je 0x8068
callq 0x77a6
movq (%r14), %rax
movq %rax, 0x68(%rsp)
movq 0x8(%r14), %rax
movq %rax, 0x70(%rsp)
testq %rax, %rax
je 0x8093
movq 0x5f43(%rip), %rcx      # 0xdfc8
cmpb $0x0, (%rcx)
je 0x808f
incl 0x8(%rax)
jmp 0x8093
lock
incl 0x8(%rax)
leaq 0x68(%rsp), %r14
movq %rbx, %rdi
movq %r14, %rsi
callq 0x82a6
movq 0x8(%r14), %rdi
testq %rdi, %rdi
je 0x7f75
callq 0x77a6
jmp 0x7f75
movq %rax, %rbx
movq 0x30(%rsp), %rdi
jmp 0x80cc
movq %rax, %rbx
movq 0x40(%rsp), %rdi
testq %rdi, %rdi
je 0x80d6
callq 0x77a6
movq %rbx, %rdi
callq 0x33d0