// File: /workspace/github_cpp_makefile_star2_O1/cjc12[P]ezSTL/src/../include/rbtree.h
// Function: ezSTL::rbtree<int, ezSTL::less<int>, ezSTL::allocator<ezSTL::__rbtree_node<int>>>::delete_fixup(ezSTL::__rbtree_node<int>*, ezSTL::__rbtree_node<int>*)
void rbtree<T, Compare, Alloc>::delete_fixup(link_type father, link_type son) {
		while (son != root() && (!son || son->color == __rbtree_black)) {
			link_type brother = nullptr;
			if (son == father->left) {
				brother = father->right;
				// case 1: color of brother is red
				if (brother->color == __rbtree_red) {
					brother->color = __rbtree_black;
					father->color = __rbtree_red;
					left_rotate(father);
					brother = father->right;
				}
				// case 2: color of brother's sons are both black
				if ((!brother->left || brother->left->color == __rbtree_black) &&
					(!brother->right || brother->right->color == __rbtree_black)) {
					brother->color = __rbtree_red;
					son = father;
					father = father->parent;
				}
				else {
					// case 3: color of brother's right son is black
					if (!brother->right || brother->right->color == __rbtree_black) {
						brother->color = __rbtree_red;
						if (brother->left)
							brother->left->color = __rbtree_black;
						right_rotate(brother);
						brother = father->right;
					}
					// case 4: color of brother's left son is black
					brother->color = father->color;
					father->color = __rbtree_black;
					if (brother->right)
						brother->right->color = __rbtree_black;
					left_rotate(father);
					break;
				}
			}
			// similar as above, only change left to right, change right to left
			else {
				brother = father->left;
				if (brother->color == __rbtree_red) {
					brother->color = __rbtree_black;
					father->color = __rbtree_red;
					right_rotate(father);
					brother = father->left;
				}
				if ((!brother->right || brother->right->color == __rbtree_black) &&
					(!brother->left || brother->left->color == __rbtree_black)) {
					brother->color = __rbtree_red;
					son = father;
					father = father->parent;
				}
				else {
					if (!brother->left || brother->left->color == __rbtree_black) {
						brother->color = __rbtree_red;
						if (brother->right)
							brother->right->color = __rbtree_black;
						left_rotate(brother);
						brother = father->left;
					}
					brother->color = father->color;
					father->color = __rbtree_black;
					if (brother->left)
						brother->left->color = __rbtree_black;
					right_rotate(father);
					break;
				}
			}
		}
		if (son)
			son->color = __rbtree_black;
	}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rdx, %r15
movq %rsi, %r14
movq %rdi, %rbx
movq 0x8(%rbx), %rax
cmpq 0x8(%rax), %r15
je 0xaa62
testq %r15, %r15
je 0xa92b
cmpb $0x1, (%r15)
jne 0xaa62
movq 0x10(%r14), %rsi
cmpq %rsi, %r15
je 0xa9c1
cmpb $0x0, (%rsi)
jne 0xa953
movb $0x1, (%rsi)
movb $0x0, (%r14)
movq %rbx, %rdi
movq %r14, %rsi
callq 0xa8ac
movq 0x10(%r14), %rsi
movq 0x18(%rsi), %rax
testq %rax, %rax
je 0xa961
cmpb $0x1, (%rax)
jne 0xa977
movq 0x10(%rsi), %rcx
testq %rcx, %rcx
je 0xa9fc
cmpb $0x0, (%rcx)
jne 0xa9fc
movq 0x10(%rsi), %rcx
testq %rcx, %rcx
je 0xa985
cmpb $0x1, (%rcx)
jne 0xa99c
movb $0x0, (%rsi)
testq %rax, %rax
je 0xa990
movb $0x1, (%rax)
movq %rbx, %rdi
callq 0xa858
movq 0x10(%r14), %rsi
movb (%r14), %al
movb %al, (%rsi)
movb $0x1, (%r14)
movq 0x10(%rsi), %rax
testq %rax, %rax
je 0xa9b1
movb $0x1, (%rax)
movq %rbx, %rdi
movq %r14, %rsi
callq 0xa8ac
jmp 0xaa4c
movq 0x18(%r14), %rsi
cmpb $0x0, (%rsi)
jne 0xa9e0
movb $0x1, (%rsi)
movb $0x0, (%r14)
movq %rbx, %rdi
movq %r14, %rsi
callq 0xa858
movq 0x18(%r14), %rsi
movq 0x10(%rsi), %rax
testq %rax, %rax
je 0xa9ee
cmpb $0x1, (%rax)
jne 0xaa07
movq 0x18(%rsi), %rcx
testq %rcx, %rcx
je 0xa9fc
cmpb $0x0, (%rcx)
je 0xaa07
movb $0x0, (%rsi)
movq 0x8(%r14), %rcx
movb $0x1, %al
jmp 0xaa54
movq 0x18(%rsi), %rcx
testq %rcx, %rcx
je 0xaa15
cmpb $0x1, (%rcx)
jne 0xaa2c
movb $0x0, (%rsi)
testq %rax, %rax
je 0xaa20
movb $0x1, (%rax)
movq %rbx, %rdi
callq 0xa8ac
movq 0x18(%r14), %rsi
movb (%r14), %al
movb %al, (%rsi)
movb $0x1, (%r14)
movq 0x18(%rsi), %rax
testq %rax, %rax
je 0xaa41
movb $0x1, (%rax)
movq %rbx, %rdi
movq %r14, %rsi
callq 0xa858
xorl %eax, %eax
movq %r14, %rcx
movq %r15, %r14
movq %r14, %r15
movq %rcx, %r14
testb %al, %al
jne 0xa90e
testq %r15, %r15
je 0xaa6b
movb $0x1, (%r15)
popq %rbx
popq %r14
popq %r15
retq
nop