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

/* Variables and functions */
struct btree *btree_create(int);
int /*<<< orphan*/ btree_graph(struct btree *);
int /*<<< orphan*/ btree_insert(struct btree *, int);
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int main(void) {
  int i;
  struct btree *tree = btree_create(4);
  srand(time(NULL));
  for (i = 0; i < 128; i++) {
    btree_insert(tree, i);
  }
  btree_graph(tree);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x4,%edi
call   1060 <btree_create@plt>
mov    %rax,-0x10(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1050 <time@plt>
mov    %eax,%edi
call   1040 <srand@plt>
movl   $0x0,-0x8(%rbp)
cmpl   $0x80,-0x8(%rbp)
jge    11ab <main+0x5b>
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%esi
call   1030 <btree_insert@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1184 <main+0x34>
mov    -0x10(%rbp),%rdi
call   1070 <btree_graph@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
mov    $0x4,%edi
call   1060 <btree_create@plt>
mov    %rax,%r14
xor    %ebx,%ebx
xor    %edi,%edi
call   1050 <time@plt>
mov    %eax,%edi
call   1040 <srand@plt>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %ebx,%esi
call   1030 <btree_insert@plt>
add    $0x1,%ebx
cmp    $0x80,%ebx
jne    1180 <main+0x30>
mov    %r14,%rdi
call   1070 <btree_graph@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.btree = type { i32 }
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca %struct.btree*
store i32 0, i32* %1
%4 = call %struct.btree* @btree_create(i32 4)
store %struct.btree* %4, %struct.btree** %3
%5 = call i32 @time(i32* null)
%6 = call i32 @srand(i32 %5)
store i32 0, i32* %2
br label %7
7: ; preds = %14, %0
%8 = load i32, i32* %2
%9 = icmp slt i32 %8, 128
br i1 %9, label %10, label %17
10: ; preds = %7
%11 = load %struct.btree*, %struct.btree** %3
%12 = load i32, i32* %2
%13 = call i32 @btree_insert(%struct.btree* %11, i32 %12)
br label %14
14: ; preds = %10
%15 = load i32, i32* %2
%16 = add nsw i32 %15, 1
store i32 %16, i32* %2
br label %7
17: ; preds = %7
%18 = load %struct.btree*, %struct.btree** %3
%19 = call i32 @btree_graph(%struct.btree* %18)
ret i32 0
}

LLVM IR (-O2):
%struct.btree = type { i32 }
define i32 @main() {
%1 = tail call %struct.btree* @btree_create(i32 4)
%2 = tail call i32 @time(i32* null)
%3 = tail call i32 @srand(i32 %2)
br label %4
4: ; preds = %0, %4
%5 = phi i32 [ 0, %0 ], [ %7, %4 ]
%6 = tail call i32 @btree_insert(%struct.btree* %1, i32 %5)
%7 = add nuw nsw i32 %5, 1
%8 = icmp eq i32 %7, 128
br i1 %8, label %9, label %4
9: ; preds = %4
%10 = tail call i32 @btree_graph(%struct.btree* %1)
ret i32 0
}