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

/* Variables and functions */
struct BSTree *insert(struct BSTree *, int);
int scanf(char *, int *);
char read_data(struct BSTree **Tr) {
  int n = 0;
  if (scanf("%d", &n) != 1) {
    return 1;
  }
  int key;
  for (int i = 0; i < n; i++) {
    if (scanf("%d", &key) != 1) {
      return 1;
    }
    *Tr = insert(*Tr, key);
  }
  return 0;
}


x86 assembly (clang, -O0):
<read_data>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
lea    0xec6(%rip),%rdi
lea    -0x14(%rbp),%rsi
call   1030 <scanf@plt>
cmp    $0x1,%eax
je     1155 <read_data+0x35>
movb   $0x1,-0x1(%rbp)
jmp    11b5 <read_data+0x95>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11b1 <read_data+0x91>
lea    0xe91(%rip),%rdi
lea    -0x18(%rbp),%rsi
call   1030 <scanf@plt>
cmp    $0x1,%eax
je     118a <read_data+0x6a>
movb   $0x1,-0x1(%rbp)
jmp    11b5 <read_data+0x95>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
mov    -0x18(%rbp),%esi
call   1040 <insert@plt>
mov    %rax,%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    115c <read_data+0x3c>
movb   $0x0,-0x1(%rbp)
movsbl -0x1(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_data>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r14
movl   $0x0,(%rsp)
lea    0xec7(%rip),%rdi
mov    %rsp,%rsi
call   1030 <scanf@plt>
mov    $0x1,%bl
cmp    $0x1,%eax
jne    118d <read_data+0x6d>
xor    %ebx,%ebx
cmpl   $0x0,(%rsp)
jle    118d <read_data+0x6d>
lea    0xea9(%rip),%r15
lea    0x4(%rsp),%r12
nopl   0x0(%rax)
mov    %r15,%rdi
mov    %r12,%rsi
call   1030 <scanf@plt>
cmp    $0x1,%eax
jne    118b <read_data+0x6b>
mov    (%r14),%rdi
mov    0x4(%rsp),%esi
call   1040 <insert@plt>
mov    %rax,(%r14)
add    $0x1,%ebx
cmp    (%rsp),%ebx
jl     1160 <read_data+0x40>
xor    %ebx,%ebx
jmp    118d <read_data+0x6d>
mov    $0x1,%bl
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

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