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

/* Variables and functions */
int /*<<< orphan*/ destroy_tree(struct node *);
int /*<<< orphan*/ insert(int, struct node **);
int /*<<< orphan*/ print_leaves(struct node *);
int /*<<< orphan*/ scanf(char *, int *);
int main(int argc, char *argv[]) {
  int n;
  int input;
  struct node *root = NULL;
  scanf("%d", &n);
  while (n--) {
    scanf("%d", &input);
    insert(input, &root);
  }
  print_leaves(root);
  destroy_tree(root);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x20(%rbp)
lea    0xe9b(%rip),%rdi
lea    -0x14(%rbp),%rsi
call   1050 <scanf@plt>
mov    -0x14(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x14(%rbp)
cmp    $0x0,%eax
je     11a3 <main+0x63>
lea    0xe77(%rip),%rdi
lea    -0x18(%rbp),%rsi
call   1050 <scanf@plt>
mov    -0x18(%rbp),%edi
lea    -0x20(%rbp),%rsi
call   1060 <insert@plt>
jmp    116e <main+0x2e>
mov    -0x20(%rbp),%rdi
call   1030 <print_leaves@plt>
mov    -0x20(%rbp),%rdi
call   1040 <destroy_tree@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x20,%rsp
movq   $0x0,0x10(%rsp)
lea    0xea7(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1050 <scanf@plt>
subl   $0x1,0xc(%rsp)
jae    116e <main+0x2e>
xor    %edi,%edi
jmp    11a3 <main+0x63>
lea    0xe8b(%rip),%r14
lea    0x1c(%rsp),%r15
lea    0x10(%rsp),%rbx
nop
mov    %r14,%rdi
mov    %r15,%rsi
call   1050 <scanf@plt>
mov    0x1c(%rsp),%edi
mov    %rbx,%rsi
call   1060 <insert@plt>
subl   $0x1,0xc(%rsp)
jae    1180 <main+0x40>
mov    0x10(%rsp),%rdi
call   1030 <print_leaves@plt>
mov    0x10(%rsp),%rdi
call   1040 <destroy_tree@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.node = type { i32 }
@.str = [3 x i8] c"%d\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca %struct.node*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store %struct.node* null, %struct.node** %8
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %6)
br label %10
10: ; preds = %14, %2
%11 = load i32, i32* %6
%12 = add nsw i32 %11, -1
store i32 %12, i32* %6
%13 = icmp ne i32 %11, 0
br i1 %13, label %14, label %18
14: ; preds = %10
%15 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %7)
%16 = load i32, i32* %7
%17 = call i32 @insert(i32 %16, %struct.node** %8)
br label %10
18: ; preds = %10
%19 = load %struct.node*, %struct.node** %8
%20 = call i32 @print_leaves(%struct.node* %19)
%21 = load %struct.node*, %struct.node** %8
%22 = call i32 @destroy_tree(%struct.node* %21)
ret i32 0
}

LLVM IR (-O2):
%struct.node = type { i32 }
@.str = [3 x i8] c"%d\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca %struct.node*
%6 = bitcast i32* %3 to i8*
%7 = bitcast i32* %4 to i8*
%8 = bitcast %struct.node** %5 to i8*
store %struct.node* null, %struct.node** %5
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %3)
%10 = load i32, i32* %3
%11 = add nsw i32 %10, -1
store i32 %11, i32* %3
%12 = icmp eq i32 %10, 0
br i1 %12, label %22, label %13
13: ; preds = %2, %13
%14 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %4)
%15 = load i32, i32* %4
%16 = call i32 @insert(i32 %15, %struct.node** %5)
%17 = load i32, i32* %3
%18 = add nsw i32 %17, -1
store i32 %18, i32* %3
%19 = icmp eq i32 %17, 0
br i1 %19, label %20, label %13
20: ; preds = %13
%21 = load %struct.node*, %struct.node** %5
br label %22
22: ; preds = %20, %2
%23 = phi %struct.node* [ %21, %20 ], [ null, %2 ]
%24 = call i32 @print_leaves(%struct.node* %23)
%25 = load %struct.node*, %struct.node** %5
%26 = call i32 @destroy_tree(%struct.node* %25)
ret i32 0
}