#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 atoi(char *);
struct node *insert(struct node *, int);
int /*<<< orphan*/ printLevelOrder(struct node *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int main(int argc, char **argv) {
  struct node *head = NULL;
  if (argc != 2) {
    printf("Usage : %s <number_of_elements>\n", argv[0]);
    return -1;
  }
  int n = atoi(argv[1]);
  int val, i;
  printf("Please input %d numbers\n", n);
  for (i = 0; i < n; i++) {
    scanf("%d", &val);
    head = insert(head, val);
  }
  printLevelOrder(head);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     1199 <main+0x49>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe7a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    120b <main+0xbb>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1070 <atoi@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%esi
lea    0xe6e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    11fb <main+0xab>
lea    0xe66(%rip),%rdi
lea    -0x20(%rbp),%rsi
call   1050 <scanf@plt>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%esi
call   1060 <insert@plt>
mov    %rax,-0x18(%rbp)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    11c1 <main+0x71>
mov    -0x18(%rbp),%rdi
call   1040 <printLevelOrder@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
cmp    $0x2,%edi
jne    11c9 <main+0x79>
mov    0x8(%rsi),%rdi
call   1070 <atoi@plt>
mov    %eax,%ebp
lea    0xeae(%rip),%rdi
xor    %r14d,%r14d
mov    %eax,%esi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %ebx,%ebx
test   %ebp,%ebp
jle    11bf <main+0x6f>
lea    0xeae(%rip),%r15
lea    0xc(%rsp),%r12
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r15,%rdi
mov    %r12,%rsi
call   1050 <scanf@plt>
mov    0xc(%rsp),%esi
mov    %rbx,%rdi
call   1060 <insert@plt>
mov    %rax,%rbx
add    $0xffffffff,%ebp
jne    11a0 <main+0x50>
mov    %rbx,%rdi
call   1040 <printLevelOrder@plt>
jmp    11e0 <main+0x90>
mov    (%rsi),%rsi
lea    0xe2d(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0xffffffff,%r14d
mov    %r14d,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.node = type { i32 }
@.str = [33 x i8] c"Usage : %s <number_of_elements>\0A\00"
@.str.1 = [25 x i8] c"Please input %d numbers\0A\00"
@.str.2 = [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
%9 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store %struct.node* null, %struct.node** %6
%10 = load i32, i32* %4
%11 = icmp ne i32 %10, 2
br i1 %11, label %12, label %17
12: ; preds = %2
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 0
%15 = load i8*, i8** %14
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i8* %15)
store i32 -1, i32* %3
br label %39
17: ; preds = %2
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 1
%20 = load i8*, i8** %19
%21 = call i32 @atoi(i8* %20)
store i32 %21, i32* %7
%22 = load i32, i32* %7
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i32 %22)
store i32 0, i32* %9
br label %24
24: ; preds = %33, %17
%25 = load i32, i32* %9
%26 = load i32, i32* %7
%27 = icmp slt i32 %25, %26
br i1 %27, label %28, label %36
28: ; preds = %24
%29 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %8)
%30 = load %struct.node*, %struct.node** %6
%31 = load i32, i32* %8
%32 = call %struct.node* @insert(%struct.node* %30, i32 %31)
store %struct.node* %32, %struct.node** %6
br label %33
33: ; preds = %28
%34 = load i32, i32* %9
%35 = add nsw i32 %34, 1
store i32 %35, i32* %9
br label %24
36: ; preds = %24
%37 = load %struct.node*, %struct.node** %6
%38 = call i32 @printLevelOrder(%struct.node* %37)
store i32 0, i32* %3
br label %39
39: ; preds = %36, %12
%40 = load i32, i32* %3
ret i32 %40
}

LLVM IR (-O2):
%struct.node = type { i32 }
@.str = [33 x i8] c"Usage : %s <number_of_elements>\0A\00"
@.str.1 = [25 x i8] c"Please input %d numbers\0A\00"
@.str.2 = [3 x i8] c"%d\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = icmp eq i32 %0, 2
br i1 %4, label %8, label %5
5: ; preds = %2
%6 = load i8*, i8** %1
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i8* %6)
br label %26
8: ; preds = %2
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = tail call i32 @atoi(i8* %10)
%12 = bitcast i32* %3 to i8*
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i32 %11)
%14 = icmp sgt i32 %11, 0
br i1 %14, label %15, label %23
15: ; preds = %8, %15
%16 = phi i32 [ %21, %15 ], [ 0, %8 ]
%17 = phi %struct.node* [ %20, %15 ], [ null, %8 ]
%18 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %3)
%19 = load i32, i32* %3
%20 = call %struct.node* @insert(%struct.node* %17, i32 %19)
%21 = add nuw nsw i32 %16, 1
%22 = icmp eq i32 %21, %11
br i1 %22, label %23, label %15
23: ; preds = %15, %8
%24 = phi %struct.node* [ null, %8 ], [ %20, %15 ]
%25 = call i32 @printLevelOrder(%struct.node* %24)
br label %26
26: ; preds = %23, %5
%27 = phi i32 [ -1, %5 ], [ 0, %23 ]
ret i32 %27
}