#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 */
typedef int time_t;

/* Variables and functions */
double difftime(int, int);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ insert(char *);
int /*<<< orphan*/ printf(char *, unsigned long, int, int, double);
char *rnd_string();
int /*<<< orphan*/ time(int *);
void insert_performance() {
  unsigned long i;
  for (i = 1; i < 10000000 + 1; i++) {
    char *s = rnd_string();
    if (i % 10000 == 0) {
      time_t start, end;
      time(&start);
      insert(s);
      time(&end);
      printf("Nodes: %d, Start: %d, End: %d, Time: %f\n", i, start, end,
             difftime(end, start));
    } else {
      insert(s);
    }
    free(s);
  }
}


x86 assembly (clang, -O0):
<insert_performance>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movq   $0x1,-0x8(%rbp)
cmpq   $0x989681,-0x8(%rbp)
jae    1219 <insert_performance+0xb9>
mov    $0x0,%al
call   1080 <rnd_string@plt>
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    $0x2710,%ecx
xor    %edx,%edx
div    %rcx
cmp    $0x0,%rdx
jne    11f6 <insert_performance+0x96>
lea    -0x14(%rbp),%rdi
call   1060 <time@plt>
mov    -0x10(%rbp),%rdi
call   1070 <insert@plt>
lea    -0x18(%rbp),%rdi
call   1060 <time@plt>
mov    -0x8(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%edi
mov    -0x14(%rbp),%esi
call   1050 <difftime@plt>
mov    -0x28(%rbp),%rsi
mov    -0x20(%rbp),%edx
mov    -0x1c(%rbp),%ecx
lea    0xe14(%rip),%rdi
call   1040 <printf@plt>
jmp    11ff <insert_performance+0x9f>
mov    -0x10(%rbp),%rdi
call   1070 <insert@plt>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    1170 <insert_performance+0x10>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<insert_performance>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    $0x1,%ebx
mov    $0xd1b71759,%r15d
lea    0xe83(%rip),%r12
jmp    119d <insert_performance+0x3d>
nop
mov    %r13,%rdi
call   1070 <insert@plt>
mov    %r13,%rdi
call   1030 <free@plt>
add    $0x1,%rbx
cmp    $0x989681,%rbx
je     11f9 <insert_performance+0x99>
mov    %ebx,%eax
imul   %r15,%rax
shr    $0x2d,%rax
imul   $0xffffd8f0,%eax,%ebp
xor    %eax,%eax
call   1080 <rnd_string@plt>
mov    %rax,%r13
add    %ebx,%ebp
jne    1180 <insert_performance+0x20>
lea    0x4(%rsp),%rdi
call   1060 <time@plt>
mov    %r13,%rdi
call   1070 <insert@plt>
mov    %rsp,%rdi
call   1060 <time@plt>
mov    0x4(%rsp),%ebp
mov    (%rsp),%r14d
mov    %r14d,%edi
mov    %ebp,%esi
call   1050 <difftime@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
mov    %ebp,%edx
mov    %r14d,%ecx
call   1040 <printf@plt>
jmp    1188 <insert_performance+0x28>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [41 x i8] c"Nodes: %d, Start: %d, End: %d, Time: %f\0A\00"
define void @insert_performance() {
%1 = alloca i64
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
store i64 1, i64* %1
br label %5
5: ; preds = %31, %0
%6 = load i64, i64* %1
%7 = icmp ult i64 %6, 10000001
br i1 %7, label %8, label %34
8: ; preds = %5
%9 = call i8* (...) @rnd_string()
store i8* %9, i8** %2
%10 = load i64, i64* %1
%11 = urem i64 %10, 10000
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %25
13: ; preds = %8
%14 = call i32 @time(i32* %3)
%15 = load i8*, i8** %2
%16 = call i32 @insert(i8* %15)
%17 = call i32 @time(i32* %4)
%18 = load i64, i64* %1
%19 = load i32, i32* %3
%20 = load i32, i32* %4
%21 = load i32, i32* %4
%22 = load i32, i32* %3
%23 = call double @difftime(i32 %21, i32 %22)
%24 = call i32 @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0), i64 %18, i32 %19, i32 %20, double %23)
br label %28
25: ; preds = %8
%26 = load i8*, i8** %2
%27 = call i32 @insert(i8* %26)
br label %28
28: ; preds = %25, %13
%29 = load i8*, i8** %2
%30 = call i32 @free(i8* %29)
br label %31
31: ; preds = %28
%32 = load i64, i64* %1
%33 = add i64 %32, 1
store i64 %33, i64* %1
br label %5
34: ; preds = %5
ret void
}

LLVM IR (-O2):
@.str = [41 x i8] c"Nodes: %d, Start: %d, End: %d, Time: %f\0A\00"
define void @insert_performance() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
%4 = bitcast i32* %2 to i8*
br label %5
5: ; preds = %0, %21
%6 = phi i64 [ 1, %0 ], [ %23, %21 ]
%7 = call i8* (...) @rnd_string()
%8 = trunc i64 %6 to i32
%9 = urem i32 %8, 10000
%10 = icmp eq i32 %9, 0
br i1 %10, label %11, label %19
11: ; preds = %5
%12 = call i32 @time(i32* %1)
%13 = call i32 @insert(i8* %7)
%14 = call i32 @time(i32* %2)
%15 = load i32, i32* %1
%16 = load i32, i32* %2
%17 = call double @difftime(i32 %16, i32 %15)
%18 = call i32 @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0), i64 %6, i32 %15, i32 %16, double %17)
br label %21
19: ; preds = %5
%20 = call i32 @insert(i8* %7)
br label %21
21: ; preds = %19, %11
%22 = call i32 @free(i8* %7)
%23 = add nuw nsw i64 %6, 1
%24 = icmp eq i64 %23, 10000001
br i1 %24, label %25, label %5
25: ; preds = %21
ret void
}