// File: DRSY[P]MyRBTree/main.cpp
// Function: RBTree::ascend_fatherIsRed(Node*, Node*)
void ascend_fatherIsRed(NodePtr_t inserted_node, NodePtr_t father) {
      NodePtr_t gf = father->father; // grand father must be black
      NodePtr_t uncle = (father==gf->left)?gf->right:gf->left;
      // uncle node is red
      if(uncle && isred(uncle)) {
          father->color = Color::black;
          uncle->color = Color::black;
          gf->color = Color::red;
          if(gf==this->root) { gf->color = Color::black; return;}
          else if(isblack(gf->father)) return;
          else ascend_fatherIsRed(gf, gf->father);
      }
      // uncle node is black
      else{
          // same direction
          if(inserted_node == father->left && father == gf->left) {
              father->color = Color::black;
              gf->color = Color::red;
              rotate_right(father, gf);
          }
          else if(inserted_node==father->right && father==gf->right) {
              father->color = Color::black;
              gf->color = Color::red;
              rotate_left(gf, father);
          }
          // not same direction
          else if(inserted_node==father->right && father==gf->left) {
              auto p = rotate_left(father, inserted_node);
              p->color = Color::black;
              gf->color = Color::red;
              rotate_right(p, gf);
          }
          else {
              auto p = rotate_right(inserted_node, father);
              p->color = Color::black;
              gf->color = Color::red;
              rotate_left(gf, p);
          }
      }
    }

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x20(%rbp)
movq -0x18(%rbp), %rax
movq -0x20(%rbp), %rcx
cmpq 0x10(%rcx), %rax
jne 0x3204
movq -0x20(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x48(%rbp)
jmp 0x3210
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rax
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
je 0x3296
movq -0x28(%rbp), %rax
cmpl $0x0, 0x4(%rax)
jne 0x3296
movq -0x40(%rbp), %rcx
movq -0x18(%rbp), %rax
movl $0x1, 0x4(%rax)
movq -0x28(%rbp), %rax
movl $0x1, 0x4(%rax)
movq -0x20(%rbp), %rax
movl $0x0, 0x4(%rax)
movq -0x20(%rbp), %rax
cmpq (%rcx), %rax
jne 0x3267
movq -0x20(%rbp), %rax
movl $0x1, 0x4(%rax)
jmp 0x33c2
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rax
cmpl $0x1, 0x4(%rax)
jne 0x327a
jmp 0x33c2
movq -0x40(%rbp), %rdi
movq -0x20(%rbp), %rsi
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rdx
callq 0x31c0
jmp 0x3291
jmp 0x33c2
movq -0x10(%rbp), %rax
movq -0x18(%rbp), %rcx
cmpq 0x10(%rcx), %rax
jne 0x32de
movq -0x18(%rbp), %rax
movq -0x20(%rbp), %rcx
cmpq 0x10(%rcx), %rax
jne 0x32de
movq -0x40(%rbp), %rdi
movq -0x18(%rbp), %rax
movl $0x1, 0x4(%rax)
movq -0x20(%rbp), %rax
movl $0x0, 0x4(%rax)
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rdx
callq 0x36d0
jmp 0x33c0
movq -0x10(%rbp), %rax
movq -0x18(%rbp), %rcx
cmpq 0x18(%rcx), %rax
jne 0x3326
movq -0x18(%rbp), %rax
movq -0x20(%rbp), %rcx
cmpq 0x18(%rcx), %rax
jne 0x3326
movq -0x40(%rbp), %rdi
movq -0x18(%rbp), %rax
movl $0x1, 0x4(%rax)
movq -0x20(%rbp), %rax
movl $0x0, 0x4(%rax)
movq -0x20(%rbp), %rsi
movq -0x18(%rbp), %rdx
callq 0x3780
jmp 0x33be
movq -0x10(%rbp), %rax
movq -0x18(%rbp), %rcx
cmpq 0x18(%rcx), %rax
jne 0x3380
movq -0x18(%rbp), %rax
movq -0x20(%rbp), %rcx
cmpq 0x10(%rcx), %rax
jne 0x3380
movq -0x40(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x10(%rbp), %rdx
callq 0x3780
movq -0x40(%rbp), %rdi
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
movl $0x1, 0x4(%rax)
movq -0x20(%rbp), %rax
movl $0x0, 0x4(%rax)
movq -0x30(%rbp), %rsi
movq -0x20(%rbp), %rdx
callq 0x36d0
jmp 0x33bc
movq -0x40(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
callq 0x36d0
movq -0x40(%rbp), %rdi
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
movl $0x1, 0x4(%rax)
movq -0x20(%rbp), %rax
movl $0x0, 0x4(%rax)
movq -0x20(%rbp), %rsi
movq -0x38(%rbp), %rdx
callq 0x3780
jmp 0x33be
jmp 0x33c0
jmp 0x33c2
addq $0x50, %rsp
popq %rbp
retq
nopl (%rax,%rax)