#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 cl_tree {
  int dummy;
};
struct cl_node {
  int dummy;
};

/* Variables and functions */
scalar_t__ cl_node_is_red(struct cl_node *);
int /*<<< orphan*/ cl_node_key(struct cl_node *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ stderr;
void cl_tree_print_node(struct cl_tree *tree, struct cl_node *n, int depth) {
  int i;
  fprintf(stderr, "%10p", cl_node_key(n));
  for (i = 0; i <= depth; i++)
    fprintf(stderr, " - ");
  if (cl_node_is_red(n))
    fprintf(stderr, "red\n");
  else
    fprintf(stderr, "black\n");
}


x86 assembly (clang, -O0):
<cl_tree_print_node>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    0x2e96(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <cl_node_key@plt>
mov    -0x1c(%rbp),%edi
mov    %eax,%edx
lea    0xe9c(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jg     11a3 <cl_tree_print_node+0x73>
mov    0x2e5b(%rip),%rax
mov    (%rax),%edi
lea    0xe77(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1172 <cl_tree_print_node+0x42>
mov    -0x10(%rbp),%rdi
call   1030 <cl_node_is_red@plt>
cmp    $0x0,%rax
je     11d2 <cl_tree_print_node+0xa2>
mov    0x2e23(%rip),%rax
mov    (%rax),%edi
lea    0xe43(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
jmp    11e9 <cl_tree_print_node+0xb9>
mov    0x2e07(%rip),%rax
mov    (%rax),%edi
lea    0xe2c(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cl_tree_print_node>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edx,%ebp
mov    %rsi,%r14
mov    0x2e9d(%rip),%r15
mov    (%r15),%ebx
mov    %rsi,%rdi
call   1040 <cl_node_key@plt>
lea    0xeab(%rip),%rsi
mov    %ebx,%edi
mov    %eax,%edx
xor    %eax,%eax
call   1050 <fprintf@plt>
test   %ebp,%ebp
js     1182 <cl_tree_print_node+0x52>
add    $0x1,%ebp
lea    0xe97(%rip),%rbx
xchg   %ax,%ax
mov    (%r15),%edi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
add    $0xffffffff,%ebp
jne    1170 <cl_tree_print_node+0x40>
mov    %r14,%rdi
call   1030 <cl_node_is_red@plt>
test   %rax,%rax
mov    (%r15),%edi
lea    0xe77(%rip),%rax
lea    0xe6b(%rip),%rsi
cmove  %rax,%rsi
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1050 <fprintf@plt>

LLVM IR (-O0):
%struct.cl_tree = type { i32 }
%struct.cl_node = type { i32 }
@stderr = global i32 0
@.str = [5 x i8] c"%10p\00"
@.str.1 = [4 x i8] c" - \00"
@.str.2 = [5 x i8] c"red\0A\00"
@.str.3 = [7 x i8] c"black\0A\00"
define void @cl_tree_print_node(%struct.cl_tree* %0, %struct.cl_node* %1, i32 %2) {
%4 = alloca %struct.cl_tree*
%5 = alloca %struct.cl_node*
%6 = alloca i32
%7 = alloca i32
store %struct.cl_tree* %0, %struct.cl_tree** %4
store %struct.cl_node* %1, %struct.cl_node** %5
store i32 %2, i32* %6
%8 = load i32, i32* @stderr
%9 = load %struct.cl_node*, %struct.cl_node** %5
%10 = call i32 @cl_node_key(%struct.cl_node* %9)
%11 = call i32 (i32, i8*, ...) @fprintf(i32 %8, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %10)
store i32 0, i32* %7
br label %12
12: ; preds = %19, %3
%13 = load i32, i32* %7
%14 = load i32, i32* %6
%15 = icmp sle i32 %13, %14
br i1 %15, label %16, label %22
16: ; preds = %12
%17 = load i32, i32* @stderr
%18 = call i32 (i32, i8*, ...) @fprintf(i32 %17, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
br label %19
19: ; preds = %16
%20 = load i32, i32* %7
%21 = add nsw i32 %20, 1
store i32 %21, i32* %7
br label %12
22: ; preds = %12
%23 = load %struct.cl_node*, %struct.cl_node** %5
%24 = call i64 @cl_node_is_red(%struct.cl_node* %23)
%25 = icmp ne i64 %24, 0
br i1 %25, label %26, label %29
26: ; preds = %22
%27 = load i32, i32* @stderr
%28 = call i32 (i32, i8*, ...) @fprintf(i32 %27, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
br label %32
29: ; preds = %22
%30 = load i32, i32* @stderr
%31 = call i32 (i32, i8*, ...) @fprintf(i32 %30, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
br label %32
32: ; preds = %29, %26
ret void
}

LLVM IR (-O2):
%struct.cl_tree = type { i32 }
%struct.cl_node = type { i32 }
@stderr = global i32 0
@.str = [5 x i8] c"%10p\00"
@.str.1 = [4 x i8] c" - \00"
@.str.2 = [5 x i8] c"red\0A\00"
@.str.3 = [7 x i8] c"black\0A\00"
define void @cl_tree_print_node(%struct.cl_tree* nocapture readnone %0, %struct.cl_node* %1, i32 %2) {
%4 = load i32, i32* @stderr
%5 = tail call i32 @cl_node_key(%struct.cl_node* %1)
%6 = tail call i32 (i32, i8*, ...) @fprintf(i32 %4, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %5)
%7 = icmp slt i32 %2, 0
br i1 %7, label %14, label %8
8: ; preds = %3, %8
%9 = phi i32 [ %12, %8 ], [ 0, %3 ]
%10 = load i32, i32* @stderr
%11 = tail call i32 (i32, i8*, ...) @fprintf(i32 %10, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%12 = add nuw i32 %9, 1
%13 = icmp eq i32 %9, %2
br i1 %13, label %14, label %8
14: ; preds = %8, %3
%15 = tail call i64 @cl_node_is_red(%struct.cl_node* %1)
%16 = icmp eq i64 %15, 0
%17 = load i32, i32* @stderr
%18 = select i1 %16, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0)
%19 = tail call i32 (i32, i8*, ...) @fprintf(i32 %17, i8* %18)
ret void
}