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

/* Variables and functions */
int /*<<< orphan*/ inorder(struct btreenode *);
int /*<<< orphan*/ insert(struct btreenode **, int);
int /*<<< orphan*/ printf(char *, ...);
int main() {
  struct btreenode *bt;
  int i, n = 10;
  int arr[10] = {11, 2, 9, 13, 57, 25, 17, 1, 90, 3};
  bt = NULL;
  printf("Binary tree sort.\n");
  printf("\nArray:\n");
  for (i = 0; i < n; i++)
    printf("%d\t", arr[i]);
  for (i = 0; i < n; i++)
    insert(&bt, arr[i]);
  printf("\nIn-order traversal of binary tree:\n");
  inorder(bt);
  printf("\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0xa,-0x18(%rbp)
lea    -0x40(%rbp),%rdi
lea    0xe9f(%rip),%rsi
mov    $0x28,%edx
call   1050 <memcpy@plt>
movq   $0x0,-0x10(%rbp)
lea    0xeae(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeb3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    11c6 <main+0x86>
movslq -0x14(%rbp),%rax
mov    -0x40(%rbp,%rax,4),%esi
lea    0xe93(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1196 <main+0x56>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    11f8 <main+0xb8>
movslq -0x14(%rbp),%rax
mov    -0x40(%rbp,%rax,4),%esi
lea    -0x10(%rbp),%rdi
call   1060 <insert@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11cd <main+0x8d>
lea    0xe49(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1040 <inorder@plt>
lea    0xe23(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
movq   $0x0,0x8(%rsp)
lea    0xe9f(%rip),%rdi
call   1040 <puts@plt>
lea    0xea5(%rip),%rdi
call   1040 <puts@plt>
lea    0xe83(%rip),%rbx
mov    %rbx,%rdi
mov    $0xb,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    $0x2,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    $0x9,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    $0xd,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    $0x39,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    $0x19,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    $0x11,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    $0x1,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    $0x5a,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    $0x3,%esi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0x8(%rsp),%rbx
mov    %rbx,%rdi
mov    $0xb,%esi
call   1070 <insert@plt>
mov    %rbx,%rdi
mov    $0x2,%esi
call   1070 <insert@plt>
mov    %rbx,%rdi
mov    $0x9,%esi
call   1070 <insert@plt>
mov    %rbx,%rdi
mov    $0xd,%esi
call   1070 <insert@plt>
mov    %rbx,%rdi
mov    $0x39,%esi
call   1070 <insert@plt>
mov    %rbx,%rdi
mov    $0x19,%esi
call   1070 <insert@plt>
mov    %rbx,%rdi
mov    $0x11,%esi
call   1070 <insert@plt>
mov    %rbx,%rdi
mov    $0x1,%esi
call   1070 <insert@plt>
mov    %rbx,%rdi
mov    $0x5a,%esi
call   1070 <insert@plt>
mov    %rbx,%rdi
mov    $0x3,%esi
call   1070 <insert@plt>
lea    0xd7d(%rip),%rdi
call   1040 <puts@plt>
mov    0x8(%rsp),%rdi
call   1060 <inorder@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.btreenode = type { i32 }
@__const.main.arr = [10 x i32] [i32 11, i32 2, i32 9, i32 13, i32 57, i32 25, i32 17, i32 1, i32 90, i32 3]
@.str = [19 x i8] c"Binary tree sort.\0A\00"
@.str.1 = [9 x i8] c"\0AArray:\0A\00"
@.str.2 = [4 x i8] c"%d\09\00"
@.str.3 = [37 x i8] c"\0AIn-order traversal of binary tree:\0A\00"
@.str.4 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca %struct.btreenode*
%3 = alloca i32
%4 = alloca i32
%5 = alloca [10 x i32]
store i32 0, i32* %1
store i32 10, i32* %4
%6 = bitcast [10 x i32]* %5 to i8*
store %struct.btreenode* null, %struct.btreenode** %2
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %3
br label %9
9: ; preds = %19, %0
%10 = load i32, i32* %3
%11 = load i32, i32* %4
%12 = icmp slt i32 %10, %11
br i1 %12, label %13, label %22
13: ; preds = %9
%14 = load i32, i32* %3
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds [10 x i32], [10 x i32]* %5, i64 0, i64 %15
%17 = load i32, i32* %16
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %17)
br label %19
19: ; preds = %13
%20 = load i32, i32* %3
%21 = add nsw i32 %20, 1
store i32 %21, i32* %3
br label %9
22: ; preds = %9
store i32 0, i32* %3
br label %23
23: ; preds = %33, %22
%24 = load i32, i32* %3
%25 = load i32, i32* %4
%26 = icmp slt i32 %24, %25
br i1 %26, label %27, label %36
27: ; preds = %23
%28 = load i32, i32* %3
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds [10 x i32], [10 x i32]* %5, i64 0, i64 %29
%31 = load i32, i32* %30
%32 = call i32 @insert(%struct.btreenode** %2, i32 %31)
br label %33
33: ; preds = %27
%34 = load i32, i32* %3
%35 = add nsw i32 %34, 1
store i32 %35, i32* %3
br label %23
36: ; preds = %23
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.3, i64 0, i64 0))
%38 = load %struct.btreenode*, %struct.btreenode** %2
%39 = call i32 @inorder(%struct.btreenode* %38)
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
%struct.btreenode = type { i32 }
@.str.2 = [4 x i8] c"%d\09\00"
@str = [18 x i8] c"Binary tree sort.\00"
@str.5 = [8 x i8] c"\0AArray:\00"
@str.6 = [36 x i8] c"\0AIn-order traversal of binary tree:\00"
define i32 @main() {
%1 = alloca %struct.btreenode*
%2 = bitcast %struct.btreenode** %1 to i8*
store %struct.btreenode* null, %struct.btreenode** %1
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str, i64 0, i64 0))
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @str.5, i64 0, i64 0))
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 11)
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 2)
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 9)
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 13)
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 57)
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 25)
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 17)
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 1)
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 90)
%14 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 3)
%15 = call i32 @insert(%struct.btreenode** %1, i32 11)
%16 = call i32 @insert(%struct.btreenode** %1, i32 2)
%17 = call i32 @insert(%struct.btreenode** %1, i32 9)
%18 = call i32 @insert(%struct.btreenode** %1, i32 13)
%19 = call i32 @insert(%struct.btreenode** %1, i32 57)
%20 = call i32 @insert(%struct.btreenode** %1, i32 25)
%21 = call i32 @insert(%struct.btreenode** %1, i32 17)
%22 = call i32 @insert(%struct.btreenode** %1, i32 1)
%23 = call i32 @insert(%struct.btreenode** %1, i32 90)
%24 = call i32 @insert(%struct.btreenode** %1, i32 3)
%25 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @str.6, i64 0, i64 0))
%26 = load %struct.btreenode*, %struct.btreenode** %1
%27 = call i32 @inorder(%struct.btreenode* %26)
%28 = call i32 @putchar(i32 10)
ret i32 0
}