// File: /workspace/github_cpp_makefile_star2_O3/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, %rbx
movq 0x8(%rdi), %rax
cmpq %rdx, 0x8(%rax)
je 0xa9f0
movq %rdi, %r15
movq %rsi, %r14
testq %rbx, %rbx
je 0xa8a2
cmpb $0x1, (%rbx)
jne 0xa93c
movq 0x10(%r14), %rsi
cmpq %rsi, %rbx
je 0xa8e4
cmpb $0x0, (%rsi)
jne 0xa8c6
movb $0x1, (%rsi)
movb $0x0, (%r14)
movq %r15, %rdi
movq %r14, %rsi
callq 0xa826
movq 0x10(%r14), %rsi
movq 0x18(%rsi), %rax
testq %rax, %rax
je 0xa8d4
cmpb $0x1, (%rax)
jne 0xa944
movq 0x10(%rsi), %rcx
testq %rcx, %rcx
je 0xa91f
cmpb $0x0, (%rcx)
jne 0xa91f
jmp 0xa94d
movq 0x18(%r14), %rsi
cmpb $0x0, (%rsi)
jne 0xa903
movb $0x1, (%rsi)
movb $0x0, (%r14)
movq %r15, %rdi
movq %r14, %rsi
callq 0xa7d4
movq 0x18(%r14), %rsi
movq 0x10(%rsi), %rax
testq %rax, %rax
je 0xa911
cmpb $0x1, (%rax)
jne 0xa967
movq 0x18(%rsi), %rcx
testq %rcx, %rcx
je 0xa91f
cmpb $0x0, (%rcx)
je 0xa970
movb $0x0, (%rsi)
movq 0x8(%r14), %rsi
movq 0x8(%r15), %rax
movq %r14, %rbx
cmpq 0x8(%rax), %r14
jne 0xa891
jmp 0xa9f8
movq %rbx, %r14
jmp 0xa9f8
movq 0x10(%rsi), %rcx
testq %rcx, %rcx
je 0xa98a
cmpb $0x0, (%rcx)
je 0xa95c
movb $0x0, (%rsi)
testq %rax, %rax
jne 0xa98d
jmp 0xa990
movb (%r14), %al
movb %al, (%rsi)
movb $0x1, (%r14)
jmp 0xa9ae
movq 0x18(%rsi), %rcx
testq %rcx, %rcx
je 0xa9be
cmpb $0x0, (%rcx)
je 0xa97f
movb $0x0, (%rsi)
testq %rax, %rax
jne 0xa9c1
jmp 0xa9c4
movb (%r14), %al
movb %al, (%rsi)
movb $0x1, (%r14)
jmp 0xa9e2
movb $0x0, (%rsi)
movb $0x1, (%rax)
movq %r15, %rdi
callq 0xa7d4
movq 0x10(%r14), %rax
movq 0x10(%rax), %rcx
movb (%r14), %dl
movb %dl, (%rax)
movb $0x1, (%r14)
testq %rcx, %rcx
je 0xa9b1
movb $0x1, (%rcx)
movq %r15, %rdi
movq %r14, %rsi
callq 0xa826
jmp 0xa9f0
movb $0x0, (%rsi)
movb $0x1, (%rax)
movq %r15, %rdi
callq 0xa826
movq 0x18(%r14), %rax
movq 0x18(%rax), %rcx
movb (%r14), %dl
movb %dl, (%rax)
movb $0x1, (%r14)
testq %rcx, %rcx
je 0xa9e5
movb $0x1, (%rcx)
movq %r15, %rdi
movq %r14, %rsi
callq 0xa7d4
movq %rbx, %r14
testq %rbx, %rbx
je 0xa9fc
movb $0x1, (%r14)
popq %rbx
popq %r14
popq %r15
retq