#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 rbtree {
  int dummy;
};
struct rbnode {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ rb_begin(struct rbtree *);
struct rbnode *rb_next(struct rbtree *);
int rb_node_keyi(struct rbnode *);
void rb_dbg_print_tree(struct rbtree *tree) {
  struct rbnode *node;
  rb_begin(tree);
  while ((node = rb_next(tree))) {
    printf("%d ", rb_node_keyi(node));
  }
  printf("\n");
}


x86 assembly (clang, -O0):
<rb_dbg_print_tree>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <rb_begin@plt>
mov    -0x8(%rbp),%rdi
call   1060 <rb_next@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
je     118a <rb_dbg_print_tree+0x4a>
mov    -0x10(%rbp),%rdi
call   1030 <rb_node_keyi@plt>
mov    %eax,%esi
lea    0xe82(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1155 <rb_dbg_print_tree+0x15>
lea    0xe73(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rb_dbg_print_tree>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
call   1060 <rb_begin@plt>
mov    %rbx,%rdi
call   1070 <rb_next@plt>
test   %rax,%rax
je     1191 <rb_dbg_print_tree+0x41>
lea    0xe90(%rip),%r14
mov    %rax,%rdi
call   1030 <rb_node_keyi@plt>
mov    %r14,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
call   1070 <rb_next@plt>
test   %rax,%rax
jne    1170 <rb_dbg_print_tree+0x20>
mov    $0xa,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1040 <putchar@plt>

LLVM IR (-O0):
%struct.rbtree = type { i32 }
%struct.rbnode = type { i32 }
@.str = [4 x i8] c"%d \00"
@.str.1 = [2 x i8] c"\0A\00"
define void @rb_dbg_print_tree(%struct.rbtree* %0) {
%2 = alloca %struct.rbtree*
%3 = alloca %struct.rbnode*
store %struct.rbtree* %0, %struct.rbtree** %2
%4 = load %struct.rbtree*, %struct.rbtree** %2
%5 = call i32 @rb_begin(%struct.rbtree* %4)
br label %6
6: ; preds = %10, %1
%7 = load %struct.rbtree*, %struct.rbtree** %2
%8 = call %struct.rbnode* @rb_next(%struct.rbtree* %7)
store %struct.rbnode* %8, %struct.rbnode** %3
%9 = icmp ne %struct.rbnode* %8, null
br i1 %9, label %10, label %14
10: ; preds = %6
%11 = load %struct.rbnode*, %struct.rbnode** %3
%12 = call i32 @rb_node_keyi(%struct.rbnode* %11)
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %12)
br label %6
14: ; preds = %6
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
%struct.rbtree = type { i32 }
%struct.rbnode = type { i32 }
@.str = [4 x i8] c"%d \00"
define void @rb_dbg_print_tree(%struct.rbtree* %0) {
%2 = tail call i32 @rb_begin(%struct.rbtree* %0)
%3 = tail call %struct.rbnode* @rb_next(%struct.rbtree* %0)
%4 = icmp eq %struct.rbnode* %3, null
br i1 %4, label %11, label %5
5: ; preds = %1, %5
%6 = phi %struct.rbnode* [ %9, %5 ], [ %3, %1 ]
%7 = tail call i32 @rb_node_keyi(%struct.rbnode* %6)
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %7)
%9 = tail call %struct.rbnode* @rb_next(%struct.rbtree* %0)
%10 = icmp eq %struct.rbnode* %9, null
br i1 %10, label %11, label %5
11: ; preds = %5, %1
%12 = tail call i32 @putchar(i32 10)
ret void
}