#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 rb_node {
  int dummy;
};

/* Variables and functions */
struct rb_node *rb_grandparent(struct rb_node *);
struct rb_node *rb_parent(struct rb_node *);
struct rb_node *rb_sibling(struct rb_node *);
struct rb_node *rb_uncle(struct rb_node *node) {
  struct rb_node *parent = rb_parent(node);
  struct rb_node *grandparent = rb_grandparent(node);
  if (grandparent == NULL)
    return NULL;
  return rb_sibling(parent);
}


x86 assembly (clang, -O0):
<rb_uncle>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <rb_parent@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <rb_grandparent@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    116e <rb_uncle+0x3e>
movq   $0x0,-0x8(%rbp)
jmp    117b <rb_uncle+0x4b>
mov    -0x18(%rbp),%rdi
call   1040 <rb_sibling@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rb_uncle>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
call   1030 <rb_parent@plt>
mov    %rax,%r14
mov    %rbx,%rdi
call   1050 <rb_grandparent@plt>
test   %rax,%rax
je     115b <rb_uncle+0x2b>
mov    %r14,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1040 <rb_sibling@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.rb_node = type { i32 }
define %struct.rb_node* @rb_uncle(%struct.rb_node* %0) {
%2 = alloca %struct.rb_node*
%3 = alloca %struct.rb_node*
%4 = alloca %struct.rb_node*
%5 = alloca %struct.rb_node*
store %struct.rb_node* %0, %struct.rb_node** %3
%6 = load %struct.rb_node*, %struct.rb_node** %3
%7 = call %struct.rb_node* @rb_parent(%struct.rb_node* %6)
store %struct.rb_node* %7, %struct.rb_node** %4
%8 = load %struct.rb_node*, %struct.rb_node** %3
%9 = call %struct.rb_node* @rb_grandparent(%struct.rb_node* %8)
store %struct.rb_node* %9, %struct.rb_node** %5
%10 = load %struct.rb_node*, %struct.rb_node** %5
%11 = icmp eq %struct.rb_node* %10, null
br i1 %11, label %12, label %13
12: ; preds = %1
store %struct.rb_node* null, %struct.rb_node** %2
br label %16
13: ; preds = %1
%14 = load %struct.rb_node*, %struct.rb_node** %4
%15 = call %struct.rb_node* @rb_sibling(%struct.rb_node* %14)
store %struct.rb_node* %15, %struct.rb_node** %2
br label %16
16: ; preds = %13, %12
%17 = load %struct.rb_node*, %struct.rb_node** %2
ret %struct.rb_node* %17
}

LLVM IR (-O2):
%struct.rb_node = type { i32 }
define %struct.rb_node* @rb_uncle(%struct.rb_node* %0) {
%2 = tail call %struct.rb_node* @rb_parent(%struct.rb_node* %0)
%3 = tail call %struct.rb_node* @rb_grandparent(%struct.rb_node* %0)
%4 = icmp eq %struct.rb_node* %3, null
br i1 %4, label %7, label %5
5: ; preds = %1
%6 = tail call %struct.rb_node* @rb_sibling(%struct.rb_node* %2)
br label %7
7: ; preds = %1, %5
%8 = phi %struct.rb_node* [ %6, %5 ], [ null, %1 ]
ret %struct.rb_node* %8
}