#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*/ inorder_iterative(struct node *);
int /*<<< orphan*/ insert(int, struct node **);
int /*<<< orphan*/ scanf(char *, int *);
int main(int argc, char *argv[]) {
  struct node *root = NULL;
  int n;
  int input;
  scanf("%d", &n);
  while (n--) {
    scanf("%d", &input);
    insert(input, &root);
  }
  inorder_iterative(root);
  destroy_tree(root);
  root = NULL;
  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,-0x18(%rbp)
lea    0xe9b(%rip),%rdi
lea    -0x1c(%rbp),%rsi
call   1050 <scanf@plt>
mov    -0x1c(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x1c(%rbp)
cmp    $0x0,%eax
je     11a3 <main+0x63>
lea    0xe77(%rip),%rdi
lea    -0x20(%rbp),%rsi
call   1050 <scanf@plt>
mov    -0x20(%rbp),%edi
lea    -0x18(%rbp),%rsi
call   1060 <insert@plt>
jmp    116e <main+0x2e>
mov    -0x18(%rbp),%rdi
call   1040 <inorder_iterative@plt>
mov    -0x18(%rbp),%rdi
call   1030 <destroy_tree@plt>
movq   $0x0,-0x18(%rbp)
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   1040 <inorder_iterative@plt>
mov    0x10(%rsp),%rdi
call   1030 <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 %struct.node*
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store %struct.node* null, %struct.node** %6
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %7)
br label %10
10: ; preds = %14, %2
%11 = load i32, i32* %7
%12 = add nsw i32 %11, -1
store i32 %12, i32* %7
%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* %8)
%16 = load i32, i32* %8
%17 = call i32 @insert(i32 %16, %struct.node** %6)
br label %10
18: ; preds = %10
%19 = load %struct.node*, %struct.node** %6
%20 = call i32 @inorder_iterative(%struct.node* %19)
%21 = load %struct.node*, %struct.node** %6
%22 = call i32 @destroy_tree(%struct.node* %21)
store %struct.node* null, %struct.node** %6
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 %struct.node*
%4 = alloca i32
%5 = alloca i32
%6 = bitcast %struct.node** %3 to i8*
store %struct.node* null, %struct.node** %3
%7 = bitcast i32* %4 to i8*
%8 = bitcast i32* %5 to i8*
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %4)
%10 = load i32, i32* %4
%11 = add nsw i32 %10, -1
store i32 %11, i32* %4
%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* %5)
%15 = load i32, i32* %5
%16 = call i32 @insert(i32 %15, %struct.node** %3)
%17 = load i32, i32* %4
%18 = add nsw i32 %17, -1
store i32 %18, i32* %4
%19 = icmp eq i32 %17, 0
br i1 %19, label %20, label %13
20: ; preds = %13
%21 = load %struct.node*, %struct.node** %3
br label %22
22: ; preds = %20, %2
%23 = phi %struct.node* [ %21, %20 ], [ null, %2 ]
%24 = call i32 @inorder_iterative(%struct.node* %23)
%25 = load %struct.node*, %struct.node** %3
%26 = call i32 @destroy_tree(%struct.node* %25)
ret i32 0
}