#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */
struct rb3_head {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ rb3_connect(struct rb3_head *, int, struct rb3_head *, int);
int /*<<< orphan*/ rb3_connect_null(struct rb3_head *, int, struct rb3_head *,
                                    int);
struct rb3_head *rb3_get_child(struct rb3_head *, int);
int rb3_get_color_bit(struct rb3_head *, int);
struct rb3_head *rb3_get_parent(struct rb3_head *);
int rb3_get_parent_dir(struct rb3_head *);
scalar_t__ rb3_is_red(struct rb3_head *, int);
int /*<<< orphan*/ rb3_set_black(struct rb3_head *, int);
int /*<<< orphan*/ rb3_set_red(struct rb3_head *, int);
__attribute__((no)) void rb3_delete_rebalance(struct rb3_head *head) {
  struct rb3_head *pnt;
  struct rb3_head *gpnt;
  struct rb3_head *sibling;
  struct rb3_head *sleft;
  struct rb3_head *sleftleft;
  struct rb3_head *sleftright;
  int left;
  int right;
  int gdir;
  if (!rb3_get_parent(head))
    return;
  if (!rb3_get_parent(rb3_get_parent(head)))
    return;
  pnt = rb3_get_parent(head);
  left = rb3_get_parent_dir(head);
  right = !rb3_get_parent_dir(head);
  gpnt = rb3_get_parent(pnt);
  gdir = rb3_get_parent_dir(pnt);
  sibling = rb3_get_child(pnt, right);
  sleft = rb3_get_child(sibling, left);
  if (rb3_is_red(pnt, right)) {
    rb3_connect(pnt, right, sleft, (0));
    rb3_connect(sibling, left, pnt, ((1 << 1)));
    rb3_connect(gpnt, gdir, sibling, (0));
    rb3_delete_rebalance(head);
  } else if (rb3_is_red(sibling, right)) {
    rb3_connect_null(pnt, right, sleft, rb3_get_color_bit(sibling, left));
    rb3_connect(sibling, left, pnt, (0));
    rb3_connect(gpnt, gdir, sibling, rb3_get_color_bit(gpnt, gdir));
    rb3_set_black(sibling, right);
  } else if (rb3_is_red(sibling, left)) {
    sleftleft = rb3_get_child(sleft, left);
    sleftright = rb3_get_child(sleft, right);
    rb3_connect_null(pnt, right, sleftleft, (0));
    rb3_connect_null(sibling, left, sleftright, (0));
    rb3_connect(sleft, left, pnt, (0));
    rb3_connect(sleft, right, sibling, (0));
    rb3_connect(gpnt, gdir, sleft, rb3_get_color_bit(gpnt, gdir));
  } else if (rb3_is_red(gpnt, gdir)) {
    rb3_set_red(pnt, right);
    rb3_set_black(gpnt, gdir);
  } else {
    rb3_set_red(pnt, right);
    rb3_delete_rebalance(pnt);
  }
}


x86 assembly (clang, -O0):
<rb3_delete_rebalance>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <rb3_get_parent@plt>
cmp    $0x0,%rax
jne    11c7 <rb3_delete_rebalance+0x27>
jmp    146a <rb3_delete_rebalance+0x2ca>
mov    -0x8(%rbp),%rdi
call   1030 <rb3_get_parent@plt>
mov    %rax,%rdi
call   1030 <rb3_get_parent@plt>
cmp    $0x0,%rax
jne    11e7 <rb3_delete_rebalance+0x47>
jmp    146a <rb3_delete_rebalance+0x2ca>
mov    -0x8(%rbp),%rdi
call   1030 <rb3_get_parent@plt>
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   10a0 <rb3_get_parent_dir@plt>
mov    %eax,-0x3c(%rbp)
mov    -0x8(%rbp),%rdi
call   10a0 <rb3_get_parent_dir@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x40(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <rb3_get_parent@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   10a0 <rb3_get_parent_dir@plt>
mov    %eax,-0x44(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x40(%rbp),%esi
call   1080 <rb3_get_child@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x3c(%rbp),%esi
call   1080 <rb3_get_child@plt>
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x40(%rbp),%esi
call   10b0 <rb3_is_red@plt>
cmp    $0x0,%rax
je     12af <rb3_delete_rebalance+0x10f>
mov    -0x10(%rbp),%rdi
mov    -0x40(%rbp),%esi
mov    -0x28(%rbp),%rdx
xor    %ecx,%ecx
call   1090 <rb3_connect@plt>
mov    -0x20(%rbp),%rdi
mov    -0x3c(%rbp),%esi
mov    -0x10(%rbp),%rdx
mov    $0x2,%ecx
call   1090 <rb3_connect@plt>
mov    -0x18(%rbp),%rdi
mov    -0x44(%rbp),%esi
mov    -0x20(%rbp),%rdx
xor    %ecx,%ecx
call   1090 <rb3_connect@plt>
mov    -0x8(%rbp),%rdi
call   1070 <rb3_delete_rebalance@plt>
jmp    146a <rb3_delete_rebalance+0x2ca>
mov    -0x20(%rbp),%rdi
mov    -0x40(%rbp),%esi
call   10b0 <rb3_is_red@plt>
cmp    $0x0,%rax
je     1350 <rb3_delete_rebalance+0x1b0>
mov    -0x10(%rbp),%rax
mov    %rax,-0x78(%rbp)
mov    -0x40(%rbp),%eax
mov    %eax,-0x6c(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x68(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x3c(%rbp),%esi
call   10c0 <rb3_get_color_bit@plt>
mov    -0x78(%rbp),%rdi
mov    -0x6c(%rbp),%esi
mov    -0x68(%rbp),%rdx
mov    %eax,%ecx
call   1040 <rb3_connect_null@plt>
mov    -0x20(%rbp),%rdi
mov    -0x3c(%rbp),%esi
mov    -0x10(%rbp),%rdx
xor    %ecx,%ecx
call   1090 <rb3_connect@plt>
mov    -0x18(%rbp),%rax
mov    %rax,-0x60(%rbp)
mov    -0x44(%rbp),%eax
mov    %eax,-0x54(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x50(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x44(%rbp),%esi
call   10c0 <rb3_get_color_bit@plt>
mov    -0x60(%rbp),%rdi
mov    -0x54(%rbp),%esi
mov    -0x50(%rbp),%rdx
mov    %eax,%ecx
call   1090 <rb3_connect@plt>
mov    -0x20(%rbp),%rdi
mov    -0x40(%rbp),%esi
call   1060 <rb3_set_black@plt>
jmp    1465 <rb3_delete_rebalance+0x2c5>
mov    -0x20(%rbp),%rdi
mov    -0x3c(%rbp),%esi
call   10b0 <rb3_is_red@plt>
cmp    $0x0,%rax
je     1413 <rb3_delete_rebalance+0x273>
mov    -0x28(%rbp),%rdi
mov    -0x3c(%rbp),%esi
call   1080 <rb3_get_child@plt>
mov    %rax,-0x30(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x40(%rbp),%esi
call   1080 <rb3_get_child@plt>
mov    %rax,-0x38(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x40(%rbp),%esi
mov    -0x30(%rbp),%rdx
xor    %ecx,%ecx
call   1040 <rb3_connect_null@plt>
mov    -0x20(%rbp),%rdi
mov    -0x3c(%rbp),%esi
mov    -0x38(%rbp),%rdx
xor    %ecx,%ecx
call   1040 <rb3_connect_null@plt>
mov    -0x28(%rbp),%rdi
mov    -0x3c(%rbp),%esi
mov    -0x10(%rbp),%rdx
xor    %ecx,%ecx
call   1090 <rb3_connect@plt>
mov    -0x28(%rbp),%rdi
mov    -0x40(%rbp),%esi
mov    -0x20(%rbp),%rdx
xor    %ecx,%ecx
call   1090 <rb3_connect@plt>
mov    -0x18(%rbp),%rax
mov    %rax,-0x90(%rbp)
mov    -0x44(%rbp),%eax
mov    %eax,-0x84(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x80(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x44(%rbp),%esi
call   10c0 <rb3_get_color_bit@plt>
mov    -0x90(%rbp),%rdi
mov    -0x84(%rbp),%esi
mov    -0x80(%rbp),%rdx
mov    %eax,%ecx
call   1090 <rb3_connect@plt>
jmp    1460 <rb3_delete_rebalance+0x2c0>
mov    -0x18(%rbp),%rdi
mov    -0x44(%rbp),%esi
call   10b0 <rb3_is_red@plt>
cmp    $0x0,%rax
je     1446 <rb3_delete_rebalance+0x2a6>
mov    -0x10(%rbp),%rdi
mov    -0x40(%rbp),%esi
call   1050 <rb3_set_red@plt>
mov    -0x18(%rbp),%rdi
mov    -0x44(%rbp),%esi
call   1060 <rb3_set_black@plt>
jmp    145b <rb3_delete_rebalance+0x2bb>
mov    -0x10(%rbp),%rdi
mov    -0x40(%rbp),%esi
call   1050 <rb3_set_red@plt>
mov    -0x10(%rbp),%rdi
call   1070 <rb3_delete_rebalance@plt>
jmp    1460 <rb3_delete_rebalance+0x2c0>
jmp    1465 <rb3_delete_rebalance+0x2c5>
jmp    146a <rb3_delete_rebalance+0x2ca>
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rb3_delete_rebalance>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %rdi,%rbx
call   1030 <rb3_get_parent@plt>
test   %rax,%rax
je     12fd <rb3_delete_rebalance+0x16d>
mov    %rbx,0x10(%rsp)
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %rbx,%rdi
call   1030 <rb3_get_parent@plt>
mov    %rax,%rdi
call   1030 <rb3_get_parent@plt>
test   %rax,%rax
je     12fd <rb3_delete_rebalance+0x16d>
mov    %rbx,%rdi
call   1030 <rb3_get_parent@plt>
mov    %rax,%r15
mov    %rbx,%rdi
call   1090 <rb3_get_parent_dir@plt>
mov    %eax,%r14d
mov    %rbx,%rdi
call   1090 <rb3_get_parent_dir@plt>
xor    %r12d,%r12d
test   %eax,%eax
sete   %r12b
mov    %r15,%rdi
call   1030 <rb3_get_parent@plt>
mov    %rax,0x18(%rsp)
mov    %r15,%rdi
call   1090 <rb3_get_parent_dir@plt>
mov    %eax,%r13d
mov    %r15,%rdi
mov    %r12d,%esi
call   1070 <rb3_get_child@plt>
mov    %rax,%rbp
mov    %rax,%rdi
mov    %r14d,%esi
call   1070 <rb3_get_child@plt>
mov    %rax,%rbx
mov    %r15,%rdi
mov    %r12d,%esi
call   10a0 <rb3_is_red@plt>
test   %rax,%rax
je     12a0 <rb3_delete_rebalance+0x110>
mov    %r15,%rdi
mov    %r12d,%esi
mov    %rbx,%rdx
xor    %ecx,%ecx
call   1080 <rb3_connect@plt>
mov    %rbp,%rdi
mov    %r14d,%esi
mov    %r15,%rdx
mov    $0x2,%ecx
call   1080 <rb3_connect@plt>
mov    0x18(%rsp),%rdi
mov    %r13d,%esi
mov    %rbp,%rdx
xor    %ecx,%ecx
call   1080 <rb3_connect@plt>
mov    0x10(%rsp),%rbx
mov    %rbx,%rdi
call   1030 <rb3_get_parent@plt>
test   %rax,%rax
jne    11c0 <rb3_delete_rebalance+0x30>
jmp    12fd <rb3_delete_rebalance+0x16d>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r15,0x10(%rsp)
mov    0x18(%rsp),%r15
mov    %rbp,%rdi
mov    %r12d,%esi
call   10a0 <rb3_is_red@plt>
mov    %rbp,%rdi
test   %rax,%rax
jne    130c <rb3_delete_rebalance+0x17c>
mov    %r14d,%esi
call   10a0 <rb3_is_red@plt>
test   %rax,%rax
jne    1365 <rb3_delete_rebalance+0x1d5>
mov    %r15,%rdi
mov    %r13d,%esi
call   10a0 <rb3_is_red@plt>
mov    %rax,%r14
mov    0x10(%rsp),%rbx
mov    %rbx,%rdi
mov    %r12d,%esi
call   1050 <rb3_set_red@plt>
test   %r14,%r14
jne    1407 <rb3_delete_rebalance+0x277>
mov    %rbx,%rdi
jmp    11a1 <rb3_delete_rebalance+0x11>
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %r14d,0xc(%rsp)
mov    %r14d,%esi
call   10b0 <rb3_get_color_bit@plt>
mov    0x10(%rsp),%r14
mov    %r14,%rdi
mov    %r12d,%esi
mov    %rbx,%rdx
mov    %eax,%ecx
call   1040 <rb3_connect_null@plt>
mov    %rbp,%rdi
mov    0xc(%rsp),%esi
mov    %r14,%rdx
xor    %ecx,%ecx
call   1080 <rb3_connect@plt>
mov    %r15,%rdi
mov    %r13d,%esi
call   10b0 <rb3_get_color_bit@plt>
mov    %r15,%rdi
mov    %r13d,%esi
mov    %rbp,%rdx
mov    %eax,%ecx
call   1080 <rb3_connect@plt>
mov    %rbp,%rdi
mov    %r12d,%esi
jmp    140d <rb3_delete_rebalance+0x27d>
mov    %rbx,0x30(%rsp)
mov    %rbx,%rdi
mov    %r14d,%esi
call   1070 <rb3_get_child@plt>
mov    %r14d,0xc(%rsp)
mov    %rax,0x20(%rsp)
mov    %rbx,%rdi
mov    %r12d,%esi
call   1070 <rb3_get_child@plt>
mov    %rax,0x28(%rsp)
mov    0x10(%rsp),%rbx
mov    %rbx,%rdi
mov    %r12d,%esi
mov    0x20(%rsp),%rdx
xor    %ecx,%ecx
call   1040 <rb3_connect_null@plt>
mov    %rbp,%rdi
mov    %r14d,%esi
mov    0x28(%rsp),%rdx
xor    %ecx,%ecx
call   1040 <rb3_connect_null@plt>
mov    0x30(%rsp),%r14
mov    %r14,%rdi
mov    0xc(%rsp),%esi
mov    %rbx,%rdx
xor    %ecx,%ecx
call   1080 <rb3_connect@plt>
mov    %r14,%rdi
mov    %r12d,%esi
mov    %rbp,%rdx
xor    %ecx,%ecx
call   1080 <rb3_connect@plt>
mov    %r15,%rdi
mov    %r13d,%esi
call   10b0 <rb3_get_color_bit@plt>
mov    %r15,%rdi
mov    %r13d,%esi
mov    %r14,%rdx
mov    %eax,%ecx
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1080 <rb3_connect@plt>
mov    %r15,%rdi
mov    %r13d,%esi
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1060 <rb3_set_black@plt>

LLVM IR (-O0):
%struct.rb3_head = type { i32 }
define void @rb3_delete_rebalance(%struct.rb3_head* %0) {
%2 = alloca %struct.rb3_head*
%3 = alloca %struct.rb3_head*
%4 = alloca %struct.rb3_head*
%5 = alloca %struct.rb3_head*
%6 = alloca %struct.rb3_head*
%7 = alloca %struct.rb3_head*
%8 = alloca %struct.rb3_head*
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
store %struct.rb3_head* %0, %struct.rb3_head** %2
%12 = load %struct.rb3_head*, %struct.rb3_head** %2
%13 = call %struct.rb3_head* @rb3_get_parent(%struct.rb3_head* %12)
%14 = icmp ne %struct.rb3_head* %13, null
br i1 %14, label %16, label %15
15: ; preds = %1
br label %142
16: ; preds = %1
%17 = load %struct.rb3_head*, %struct.rb3_head** %2
%18 = call %struct.rb3_head* @rb3_get_parent(%struct.rb3_head* %17)
%19 = call %struct.rb3_head* @rb3_get_parent(%struct.rb3_head* %18)
%20 = icmp ne %struct.rb3_head* %19, null
br i1 %20, label %22, label %21
21: ; preds = %16
br label %142
22: ; preds = %16
%23 = load %struct.rb3_head*, %struct.rb3_head** %2
%24 = call %struct.rb3_head* @rb3_get_parent(%struct.rb3_head* %23)
store %struct.rb3_head* %24, %struct.rb3_head** %3
%25 = load %struct.rb3_head*, %struct.rb3_head** %2
%26 = call i32 @rb3_get_parent_dir(%struct.rb3_head* %25)
store i32 %26, i32* %9
%27 = load %struct.rb3_head*, %struct.rb3_head** %2
%28 = call i32 @rb3_get_parent_dir(%struct.rb3_head* %27)
%29 = icmp ne i32 %28, 0
%30 = xor i1 %29, true
%31 = zext i1 %30 to i32
store i32 %31, i32* %10
%32 = load %struct.rb3_head*, %struct.rb3_head** %3
%33 = call %struct.rb3_head* @rb3_get_parent(%struct.rb3_head* %32)
store %struct.rb3_head* %33, %struct.rb3_head** %4
%34 = load %struct.rb3_head*, %struct.rb3_head** %3
%35 = call i32 @rb3_get_parent_dir(%struct.rb3_head* %34)
store i32 %35, i32* %11
%36 = load %struct.rb3_head*, %struct.rb3_head** %3
%37 = load i32, i32* %10
%38 = call %struct.rb3_head* @rb3_get_child(%struct.rb3_head* %36, i32 %37)
store %struct.rb3_head* %38, %struct.rb3_head** %5
%39 = load %struct.rb3_head*, %struct.rb3_head** %5
%40 = load i32, i32* %9
%41 = call %struct.rb3_head* @rb3_get_child(%struct.rb3_head* %39, i32 %40)
store %struct.rb3_head* %41, %struct.rb3_head** %6
%42 = load %struct.rb3_head*, %struct.rb3_head** %3
%43 = load i32, i32* %10
%44 = call i64 @rb3_is_red(%struct.rb3_head* %42, i32 %43)
%45 = icmp ne i64 %44, 0
br i1 %45, label %46, label %60
46: ; preds = %22
%47 = load %struct.rb3_head*, %struct.rb3_head** %3
%48 = load i32, i32* %10
%49 = load %struct.rb3_head*, %struct.rb3_head** %6
%50 = call i32 @rb3_connect(%struct.rb3_head* %47, i32 %48, %struct.rb3_head* %49, i32 0)
%51 = load %struct.rb3_head*, %struct.rb3_head** %5
%52 = load i32, i32* %9
%53 = load %struct.rb3_head*, %struct.rb3_head** %3
%54 = call i32 @rb3_connect(%struct.rb3_head* %51, i32 %52, %struct.rb3_head* %53, i32 2)
%55 = load %struct.rb3_head*, %struct.rb3_head** %4
%56 = load i32, i32* %11
%57 = load %struct.rb3_head*, %struct.rb3_head** %5
%58 = call i32 @rb3_connect(%struct.rb3_head* %55, i32 %56, %struct.rb3_head* %57, i32 0)
%59 = load %struct.rb3_head*, %struct.rb3_head** %2
br label %142
60: ; preds = %22
%61 = load %struct.rb3_head*, %struct.rb3_head** %5
%62 = load i32, i32* %10
%63 = call i64 @rb3_is_red(%struct.rb3_head* %61, i32 %62)
%64 = icmp ne i64 %63, 0
br i1 %64, label %65, label %87
65: ; preds = %60
%66 = load %struct.rb3_head*, %struct.rb3_head** %3
%67 = load i32, i32* %10
%68 = load %struct.rb3_head*, %struct.rb3_head** %6
%69 = load %struct.rb3_head*, %struct.rb3_head** %5
%70 = load i32, i32* %9
%71 = call i32 @rb3_get_color_bit(%struct.rb3_head* %69, i32 %70)
%72 = call i32 @rb3_connect_null(%struct.rb3_head* %66, i32 %67, %struct.rb3_head* %68, i32 %71)
%73 = load %struct.rb3_head*, %struct.rb3_head** %5
%74 = load i32, i32* %9
%75 = load %struct.rb3_head*, %struct.rb3_head** %3
%76 = call i32 @rb3_connect(%struct.rb3_head* %73, i32 %74, %struct.rb3_head* %75, i32 0)
%77 = load %struct.rb3_head*, %struct.rb3_head** %4
%78 = load i32, i32* %11
%79 = load %struct.rb3_head*, %struct.rb3_head** %5
%80 = load %struct.rb3_head*, %struct.rb3_head** %4
%81 = load i32, i32* %11
%82 = call i32 @rb3_get_color_bit(%struct.rb3_head* %80, i32 %81)
%83 = call i32 @rb3_connect(%struct.rb3_head* %77, i32 %78, %struct.rb3_head* %79, i32 %82)
%84 = load %struct.rb3_head*, %struct.rb3_head** %5
%85 = load i32, i32* %10
%86 = call i32 @rb3_set_black(%struct.rb3_head* %84, i32 %85)
br label %141
87: ; preds = %60
%88 = load %struct.rb3_head*, %struct.rb3_head** %5
%89 = load i32, i32* %9
%90 = call i64 @rb3_is_red(%struct.rb3_head* %88, i32 %89)
%91 = icmp ne i64 %90, 0
br i1 %91, label %92, label %122
92: ; preds = %87
%93 = load %struct.rb3_head*, %struct.rb3_head** %6
%94 = load i32, i32* %9
%95 = call %struct.rb3_head* @rb3_get_child(%struct.rb3_head* %93, i32 %94)
store %struct.rb3_head* %95, %struct.rb3_head** %7
%96 = load %struct.rb3_head*, %struct.rb3_head** %6
%97 = load i32, i32* %10
%98 = call %struct.rb3_head* @rb3_get_child(%struct.rb3_head* %96, i32 %97)
store %struct.rb3_head* %98, %struct.rb3_head** %8
%99 = load %struct.rb3_head*, %struct.rb3_head** %3
%100 = load i32, i32* %10
%101 = load %struct.rb3_head*, %struct.rb3_head** %7
%102 = call i32 @rb3_connect_null(%struct.rb3_head* %99, i32 %100, %struct.rb3_head* %101, i32 0)
%103 = load %struct.rb3_head*, %struct.rb3_head** %5
%104 = load i32, i32* %9
%105 = load %struct.rb3_head*, %struct.rb3_head** %8
%106 = call i32 @rb3_connect_null(%struct.rb3_head* %103, i32 %104, %struct.rb3_head* %105, i32 0)
%107 = load %struct.rb3_head*, %struct.rb3_head** %6
%108 = load i32, i32* %9
%109 = load %struct.rb3_head*, %struct.rb3_head** %3
%110 = call i32 @rb3_connect(%struct.rb3_head* %107, i32 %108, %struct.rb3_head* %109, i32 0)
%111 = load %struct.rb3_head*, %struct.rb3_head** %6
%112 = load i32, i32* %10
%113 = load %struct.rb3_head*, %struct.rb3_head** %5
%114 = call i32 @rb3_connect(%struct.rb3_head* %111, i32 %112, %struct.rb3_head* %113, i32 0)
%115 = load %struct.rb3_head*, %struct.rb3_head** %4
%116 = load i32, i32* %11
%117 = load %struct.rb3_head*, %struct.rb3_head** %6
%118 = load %struct.rb3_head*, %struct.rb3_head** %4
%119 = load i32, i32* %11
%120 = call i32 @rb3_get_color_bit(%struct.rb3_head* %118, i32 %119)
%121 = call i32 @rb3_connect(%struct.rb3_head* %115, i32 %116, %struct.rb3_head* %117, i32 %120)
br label %140
122: ; preds = %87
%123 = load %struct.rb3_head*, %struct.rb3_head** %4
%124 = load i32, i32* %11
%125 = call i64 @rb3_is_red(%struct.rb3_head* %123, i32 %124)
%126 = icmp ne i64 %125, 0
br i1 %126, label %127, label %134
127: ; preds = %122
%128 = load %struct.rb3_head*, %struct.rb3_head** %3
%129 = load i32, i32* %10
%130 = call i32 @rb3_set_red(%struct.rb3_head* %128, i32 %129)
%131 = load %struct.rb3_head*, %struct.rb3_head** %4
%132 = load i32, i32* %11
%133 = call i32 @rb3_set_black(%struct.rb3_head* %131, i32 %132)
br label %139
134: ; preds = %122
%135 = load %struct.rb3_head*, %struct.rb3_head** %3
%136 = load i32, i32* %10
%137 = call i32 @rb3_set_red(%struct.rb3_head* %135, i32 %136)
%138 = load %struct.rb3_head*, %struct.rb3_head** %3
br label %139
139: ; preds = %134, %127
br label %140
140: ; preds = %139, %92
br label %141
141: ; preds = %140, %65
br label %142
142: ; preds = %15, %21, %141, %46
ret void
}

LLVM IR (-O2):
%struct.rb3_head = type { i32 }
define void @rb3_delete_rebalance(%struct.rb3_head* %0) {
%2 = tail call %struct.rb3_head* @rb3_get_parent(%struct.rb3_head* %0)
%3 = icmp eq %struct.rb3_head* %2, null
br i1 %3, label %59, label %4
4: ; preds = %1, %56
%5 = phi %struct.rb3_head* [ %11, %56 ], [ %0, %1 ]
br label %6
6: ; preds = %4, %22
%7 = tail call %struct.rb3_head* @rb3_get_parent(%struct.rb3_head* %5)
%8 = tail call %struct.rb3_head* @rb3_get_parent(%struct.rb3_head* %7)
%9 = icmp eq %struct.rb3_head* %8, null
br i1 %9, label %59, label %10
10: ; preds = %6
%11 = tail call %struct.rb3_head* @rb3_get_parent(%struct.rb3_head* %5)
%12 = tail call i32 @rb3_get_parent_dir(%struct.rb3_head* %5)
%13 = tail call i32 @rb3_get_parent_dir(%struct.rb3_head* %5)
%14 = icmp eq i32 %13, 0
%15 = zext i1 %14 to i32
%16 = tail call %struct.rb3_head* @rb3_get_parent(%struct.rb3_head* %11)
%17 = tail call i32 @rb3_get_parent_dir(%struct.rb3_head* %11)
%18 = tail call %struct.rb3_head* @rb3_get_child(%struct.rb3_head* %11, i32 %15)
%19 = tail call %struct.rb3_head* @rb3_get_child(%struct.rb3_head* %18, i32 %12)
%20 = tail call i64 @rb3_is_red(%struct.rb3_head* %11, i32 %15)
%21 = icmp eq i64 %20, 0
br i1 %21, label %28, label %22
22: ; preds = %10
%23 = tail call i32 @rb3_connect(%struct.rb3_head* %11, i32 %15, %struct.rb3_head* %19, i32 0)
%24 = tail call i32 @rb3_connect(%struct.rb3_head* %18, i32 %12, %struct.rb3_head* %11, i32 2)
%25 = tail call i32 @rb3_connect(%struct.rb3_head* %16, i32 %17, %struct.rb3_head* %18, i32 0)
%26 = tail call %struct.rb3_head* @rb3_get_parent(%struct.rb3_head* %5)
%27 = icmp eq %struct.rb3_head* %26, null
br i1 %27, label %59, label %6
28: ; preds = %10
%29 = tail call i64 @rb3_is_red(%struct.rb3_head* %18, i32 %15)
%30 = icmp eq i64 %29, 0
br i1 %30, label %38, label %31
31: ; preds = %28
%32 = tail call i32 @rb3_get_color_bit(%struct.rb3_head* %18, i32 %12)
%33 = tail call i32 @rb3_connect_null(%struct.rb3_head* %11, i32 %15, %struct.rb3_head* %19, i32 %32)
%34 = tail call i32 @rb3_connect(%struct.rb3_head* %18, i32 %12, %struct.rb3_head* %11, i32 0)
%35 = tail call i32 @rb3_get_color_bit(%struct.rb3_head* %16, i32 %17)
%36 = tail call i32 @rb3_connect(%struct.rb3_head* %16, i32 %17, %struct.rb3_head* %18, i32 %35)
%37 = tail call i32 @rb3_set_black(%struct.rb3_head* %18, i32 %15)
br label %59
38: ; preds = %28
%39 = tail call i64 @rb3_is_red(%struct.rb3_head* %18, i32 %12)
%40 = icmp eq i64 %39, 0
br i1 %40, label %50, label %41
41: ; preds = %38
%42 = tail call %struct.rb3_head* @rb3_get_child(%struct.rb3_head* %19, i32 %12)
%43 = tail call %struct.rb3_head* @rb3_get_child(%struct.rb3_head* %19, i32 %15)
%44 = tail call i32 @rb3_connect_null(%struct.rb3_head* %11, i32 %15, %struct.rb3_head* %42, i32 0)
%45 = tail call i32 @rb3_connect_null(%struct.rb3_head* %18, i32 %12, %struct.rb3_head* %43, i32 0)
%46 = tail call i32 @rb3_connect(%struct.rb3_head* %19, i32 %12, %struct.rb3_head* %11, i32 0)
%47 = tail call i32 @rb3_connect(%struct.rb3_head* %19, i32 %15, %struct.rb3_head* %18, i32 0)
%48 = tail call i32 @rb3_get_color_bit(%struct.rb3_head* %16, i32 %17)
%49 = tail call i32 @rb3_connect(%struct.rb3_head* %16, i32 %17, %struct.rb3_head* %19, i32 %48)
br label %59
50: ; preds = %38
%51 = tail call i64 @rb3_is_red(%struct.rb3_head* %16, i32 %17)
%52 = icmp eq i64 %51, 0
%53 = tail call i32 @rb3_set_red(%struct.rb3_head* %11, i32 %15)
br i1 %52, label %56, label %54
54: ; preds = %50
%55 = tail call i32 @rb3_set_black(%struct.rb3_head* %16, i32 %17)
br label %59
56: ; preds = %50
%57 = tail call %struct.rb3_head* @rb3_get_parent(%struct.rb3_head* %11)
%58 = icmp eq %struct.rb3_head* %57, null
br i1 %58, label %59, label %4
59: ; preds = %56, %22, %6, %1, %41, %54, %31
ret void
}