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

/* Variables and functions */
int /*<<< orphan*/ insertSortedBinaryTree(int, struct binaryTree **);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
void fillTree(struct binaryTree **treeToFill) {
  int number;
  printf("Constructing tree\n\n\n");
  scanf("%d", &number);
  while (number != 0) {
    insertSortedBinaryTree(number, treeToFill);
    if (0)
      printf("%d inserted\n", number);
    scanf("%d", &number);
  }
  printf("\n\nTree constructed\n\n\n");
}


x86 assembly (clang, -O0):
<fillTree>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
lea    0xebd(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xec4(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1050 <scanf@plt>
cmpl   $0x0,-0xc(%rbp)
je     1185 <fillTree+0x55>
mov    -0xc(%rbp),%edi
mov    -0x8(%rbp),%rsi
call   1040 <insertSortedBinaryTree@plt>
lea    0xe9e(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1050 <scanf@plt>
jmp    115a <fillTree+0x2a>
lea    0xe8c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fillTree>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
lea    0xec0(%rip),%rdi
call   1030 <puts@plt>
lea    0xeb1(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1050 <scanf@plt>
mov    0xc(%rsp),%edi
test   %edi,%edi
je     118b <fillTree+0x5b>
lea    0xe98(%rip),%r14
lea    0xc(%rsp),%r15
nopl   (%rax)
mov    %rbx,%rsi
call   1040 <insertSortedBinaryTree@plt>
mov    %r14,%rdi
mov    %r15,%rsi
call   1050 <scanf@plt>
mov    0xc(%rsp),%edi
test   %edi,%edi
jne    1170 <fillTree+0x40>
lea    0xe85(%rip),%rdi
call   1030 <puts@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.binaryTree = type { i32 }
@.str = [21 x i8] c"Constructing tree\0A\0A\0A\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [22 x i8] c"\0A\0ATree constructed\0A\0A\0A\00"
define void @fillTree(%struct.binaryTree** %0) {
%2 = alloca %struct.binaryTree**
%3 = alloca i32
store %struct.binaryTree** %0, %struct.binaryTree*** %2
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
br label %6
6: ; preds = %9, %1
%7 = load i32, i32* %3
%8 = icmp ne i32 %7, 0
br i1 %8, label %9, label %14
9: ; preds = %6
%10 = load i32, i32* %3
%11 = load %struct.binaryTree**, %struct.binaryTree*** %2
%12 = call i32 @insertSortedBinaryTree(i32 %10, %struct.binaryTree** %11)
%13 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
br label %6
14: ; preds = %6
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
%struct.binaryTree = type { i32 }
@.str.1 = [3 x i8] c"%d\00"
@str = [20 x i8] c"Constructing tree\0A\0A\00"
@str.3 = [21 x i8] c"\0A\0ATree constructed\0A\0A\00"
define void @fillTree(%struct.binaryTree** %0) {
%2 = alloca i32
%3 = bitcast i32* %2 to i8*
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str, i64 0, i64 0))
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%6 = load i32, i32* %2
%7 = icmp eq i32 %6, 0
br i1 %7, label %14, label %8
8: ; preds = %1, %8
%9 = phi i32 [ %12, %8 ], [ %6, %1 ]
%10 = call i32 @insertSortedBinaryTree(i32 %9, %struct.binaryTree** %0)
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%12 = load i32, i32* %2
%13 = icmp eq i32 %12, 0
br i1 %13, label %14, label %8
14: ; preds = %8, %1
%15 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str.3, i64 0, i64 0))
ret void
}