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

/* Variables and functions */
scalar_t__ cbt_add(struct cbtree **, int /*<<< orphan*/, char);
struct cbtree *cbt_new(int);
int /*<<< orphan*/ print_cbt(struct cbtree *);
int /*<<< orphan*/ printf(char *);
int main() {
  struct cbtree *tree = cbt_new(5);
  printf("Emtpy tree\n");
  print_cbt(tree);
  if (cbt_add(&tree, 0, 'a')) {
    printf("Error adding a at 0\n");
    print_cbt(tree);
    return 1;
  }
  printf("Added a at 0\n");
  print_cbt(tree);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x5,%edi
call   1040 <cbt_new@plt>
mov    %rax,-0x10(%rbp)
lea    0xe9c(%rip),%rdi
call   1030 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1060 <print_cbt@plt>
lea    -0x10(%rbp),%rdi
xor    %esi,%esi
mov    $0x61,%edx
call   1050 <cbt_add@plt>
cmp    $0x0,%rax
je     11ad <main+0x6d>
lea    0xe79(%rip),%rdi
call   1030 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1060 <print_cbt@plt>
movl   $0x1,-0x4(%rbp)
jmp    11c2 <main+0x82>
lea    0xe6d(%rip),%rdi
call   1030 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1060 <print_cbt@plt>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
mov    $0x5,%edi
call   1040 <cbt_new@plt>
mov    %rax,%rbx
mov    %rax,0x8(%rsp)
lea    0xea2(%rip),%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
call   1060 <print_cbt@plt>
lea    0x8(%rsp),%rdi
xor    %esi,%esi
mov    $0x61,%edx
call   1050 <cbt_add@plt>
xor    %ebx,%ebx
test   %rax,%rax
setne  %bl
lea    0xe80(%rip),%rax
lea    0xe86(%rip),%rdi
cmove  %rax,%rdi
call   1030 <puts@plt>
mov    0x8(%rsp),%rdi
call   1060 <print_cbt@plt>
mov    %ebx,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.cbtree = type { i32 }
@.str = [12 x i8] c"Emtpy tree\0A\00"
@.str.1 = [21 x i8] c"Error adding a at 0\0A\00"
@.str.2 = [14 x i8] c"Added a at 0\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca %struct.cbtree*
store i32 0, i32* %1
%3 = call %struct.cbtree* @cbt_new(i32 5)
store %struct.cbtree* %3, %struct.cbtree** %2
%4 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%5 = load %struct.cbtree*, %struct.cbtree** %2
%6 = call i32 @print_cbt(%struct.cbtree* %5)
%7 = call i64 @cbt_add(%struct.cbtree** %2, i32 0, i8 signext 97)
%8 = icmp ne i64 %7, 0
br i1 %8, label %9, label %13
9: ; preds = %0
%10 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0))
%11 = load %struct.cbtree*, %struct.cbtree** %2
%12 = call i32 @print_cbt(%struct.cbtree* %11)
store i32 1, i32* %1
br label %17
13: ; preds = %0
%14 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0))
%15 = load %struct.cbtree*, %struct.cbtree** %2
%16 = call i32 @print_cbt(%struct.cbtree* %15)
br label %17
17: ; preds = %13, %9
%18 = load i32, i32* %1
ret i32 %18
}

LLVM IR (-O2):
%struct.cbtree = type { i32 }
@str = [11 x i8] c"Emtpy tree\00"
@str.3 = [13 x i8] c"Added a at 0\00"
@str.4 = [20 x i8] c"Error adding a at 0\00"
define i32 @main() {
%1 = alloca %struct.cbtree*
%2 = bitcast %struct.cbtree** %1 to i8*
%3 = tail call %struct.cbtree* @cbt_new(i32 5)
store %struct.cbtree* %3, %struct.cbtree** %1
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str, i64 0, i64 0))
%5 = tail call i32 @print_cbt(%struct.cbtree* %3)
%6 = call i64 @cbt_add(%struct.cbtree** %1, i32 0, i8 signext 97)
%7 = icmp eq i64 %6, 0
%8 = select i1 %7, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @str.3, i64 0, i64 0), i8* getelementptr inbounds ([20 x i8], [20 x i8]* @str.4, i64 0, i64 0)
%9 = xor i1 %7, true
%10 = zext i1 %9 to i32
%11 = call i32 @puts(i8* dereferenceable(1) %8)
%12 = load %struct.cbtree*, %struct.cbtree** %1
%13 = call i32 @print_cbt(%struct.cbtree* %12)
ret i32 %10
}