#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 */
struct cl_node *cl_node_left(struct cl_node *);
struct cl_node *cl_node_right(struct cl_node *);
scalar_t__ cl_tree_is_leaf(struct cl_tree *, struct cl_node *);
int /*<<< orphan*/ cl_tree_print_node(struct cl_tree *, struct cl_node *, int);
void cl_tree_print_sub(struct cl_tree *tree, struct cl_node *n, int depth) {
  if (cl_tree_is_leaf(tree, n))
    return;
  cl_tree_print_sub(tree, cl_node_left(n), depth + 1);
  cl_tree_print_node(tree, n, depth);
  cl_tree_print_sub(tree, cl_node_right(n), depth + 1);
}


x86 assembly (clang, -O0):
<cl_tree_print_sub>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1070 <cl_tree_is_leaf@plt>
cmp    $0x0,%rax
je     117f <cl_tree_print_sub+0x2f>
jmp    11d5 <cl_tree_print_sub+0x85>
mov    -0x8(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
call   1060 <cl_node_left@plt>
mov    -0x28(%rbp),%rdi
mov    %rax,%rsi
mov    -0x14(%rbp),%edx
add    $0x1,%edx
call   1040 <cl_tree_print_sub@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   1050 <cl_tree_print_node@plt>
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <cl_node_right@plt>
mov    -0x20(%rbp),%rdi
mov    %rax,%rsi
mov    -0x14(%rbp),%edx
add    $0x1,%edx
call   1040 <cl_tree_print_sub@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cl_tree_print_sub>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edx,%r15d
mov    %rsi,%rbx
mov    %rdi,%r14
call   1070 <cl_tree_is_leaf@plt>
test   %rax,%rax
jne    11b5 <cl_tree_print_sub+0x65>
nopw   0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   1060 <cl_node_left@plt>
lea    0x1(%r15),%ebp
mov    %r14,%rdi
mov    %rax,%rsi
mov    %ebp,%edx
call   1040 <cl_tree_print_sub@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %r15d,%edx
call   1050 <cl_tree_print_node@plt>
mov    %rbx,%rdi
call   1030 <cl_node_right@plt>
mov    %rax,%rbx
mov    %r14,%rdi
mov    %rax,%rsi
call   1070 <cl_tree_is_leaf@plt>
mov    %ebp,%r15d
test   %rax,%rax
je     1170 <cl_tree_print_sub+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.cl_tree = type { i32 }
%struct.cl_node = type { i32 }
define void @cl_tree_print_sub(%struct.cl_tree* %0, %struct.cl_node* %1, i32 %2) {
%4 = alloca %struct.cl_tree*
%5 = alloca %struct.cl_node*
%6 = 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
%7 = load %struct.cl_tree*, %struct.cl_tree** %4
%8 = load %struct.cl_node*, %struct.cl_node** %5
%9 = call i64 @cl_tree_is_leaf(%struct.cl_tree* %7, %struct.cl_node* %8)
%10 = icmp ne i64 %9, 0
br i1 %10, label %11, label %12
11: ; preds = %3
br label %27
12: ; preds = %3
%13 = load %struct.cl_tree*, %struct.cl_tree** %4
%14 = load %struct.cl_node*, %struct.cl_node** %5
%15 = call %struct.cl_node* @cl_node_left(%struct.cl_node* %14)
%16 = load i32, i32* %6
%17 = add nsw i32 %16, 1
%18 = load %struct.cl_tree*, %struct.cl_tree** %4
%19 = load %struct.cl_node*, %struct.cl_node** %5
%20 = load i32, i32* %6
%21 = call i32 @cl_tree_print_node(%struct.cl_tree* %18, %struct.cl_node* %19, i32 %20)
%22 = load %struct.cl_tree*, %struct.cl_tree** %4
%23 = load %struct.cl_node*, %struct.cl_node** %5
%24 = call %struct.cl_node* @cl_node_right(%struct.cl_node* %23)
%25 = load i32, i32* %6
%26 = add nsw i32 %25, 1
br label %27
27: ; preds = %12, %11
ret void
}

LLVM IR (-O2):
%struct.cl_tree = type { i32 }
%struct.cl_node = type { i32 }
define void @cl_tree_print_sub(%struct.cl_tree* %0, %struct.cl_node* %1, i32 %2) {
%4 = tail call i64 @cl_tree_is_leaf(%struct.cl_tree* %0, %struct.cl_node* %1)
%5 = icmp eq i64 %4, 0
br i1 %5, label %6, label %15
6: ; preds = %3, %6
%7 = phi i32 [ %10, %6 ], [ %2, %3 ]
%8 = phi %struct.cl_node* [ %12, %6 ], [ %1, %3 ]
%9 = tail call %struct.cl_node* @cl_node_left(%struct.cl_node* %8)
%10 = add nsw i32 %7, 1
tail call void @cl_tree_print_sub(%struct.cl_tree* %0, %struct.cl_node* %9, i32 %10)
%11 = tail call i32 @cl_tree_print_node(%struct.cl_tree* %0, %struct.cl_node* %8, i32 %7)
%12 = tail call %struct.cl_node* @cl_node_right(%struct.cl_node* %8)
%13 = tail call i64 @cl_tree_is_leaf(%struct.cl_tree* %0, %struct.cl_node* %12)
%14 = icmp eq i64 %13, 0
br i1 %14, label %6, label %15
15: ; preds = %6, %3
ret void
}