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

/* Variables and functions */
int rand();
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
struct link *tree_insert(struct link *, int);
struct link *init_tree(int num) {
  struct link *r = NULL;
  int i = 0;
  srand(time(NULL));
  for (i = 0; i < num; i++) {
    r = tree_insert(r, rand() % 100);
  }
  return r;
}


x86 assembly (clang, -O0):
<init_tree>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
movq   $0x0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1040 <time@plt>
mov    %eax,%edi
call   1030 <srand@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11b1 <init_tree+0x71>
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    $0x0,%al
call   1060 <rand@plt>
mov    -0x20(%rbp),%rdi
mov    $0x64,%ecx
cltd
idiv   %ecx
mov    %edx,%esi
call   1050 <tree_insert@plt>
mov    %rax,-0x10(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1171 <init_tree+0x31>
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<init_tree>:
push   %r14
push   %rbx
push   %rax
mov    %edi,%ebx
xor    %r14d,%r14d
xor    %edi,%edi
call   1040 <time@plt>
mov    %eax,%edi
call   1030 <srand@plt>
test   %ebx,%ebx
jle    1193 <init_tree+0x53>
xor    %r14d,%r14d
xchg   %ax,%ax
xor    %eax,%eax
call   1060 <rand@plt>
movslq %eax,%rsi
imul   $0x51eb851f,%rsi,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x25,%rax
add    %ecx,%eax
imul   $0x64,%eax,%eax
sub    %eax,%esi
mov    %r14,%rdi
call   1050 <tree_insert@plt>
mov    %rax,%r14
add    $0xffffffff,%ebx
jne    1160 <init_tree+0x20>
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
%struct.link = type { i32 }
define %struct.link* @init_tree(i32 %0) {
%2 = tail call i32 @time(i32* null)
%3 = tail call i32 @srand(i32 %2)
%4 = icmp sgt i32 %0, 0
br i1 %4, label %5, label %13
5: ; preds = %1, %5
%6 = phi i32 [ %11, %5 ], [ 0, %1 ]
%7 = phi %struct.link* [ %10, %5 ], [ null, %1 ]
%8 = tail call i32 (...) @rand()
%9 = srem i32 %8, 100
%10 = tail call %struct.link* @tree_insert(%struct.link* %7, i32 %9)
%11 = add nuw nsw i32 %6, 1
%12 = icmp eq i32 %11, %0
br i1 %12, label %13, label %5
13: ; preds = %5, %1
%14 = phi %struct.link* [ null, %1 ], [ %10, %5 ]
ret %struct.link* %14
}