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

/* Variables and functions */
int /*<<< orphan*/ addList(struct linkedList *, int);
struct linkedList *createLinkedList();
int /*<<< orphan*/ deleteLinkedList(struct linkedList *);
double getMilliseconds();
int /*<<< orphan*/ printf(char *, int, double);
int /*<<< orphan*/ removeList(struct linkedList *, int);
int main(int argc, char *argv[]) {
  struct linkedList *b;
  int n, i;
  double t1, t2;
  for (n = 1000; n < 200000; n = n * 2) {
    b = createLinkedList();
    for (i = 0; i < n; i++) {
      addList(b, (int)i);
    }
    t1 = getMilliseconds();
    for (i = 0; i < n; i++) {
      removeList(b, i);
    }
    t2 = getMilliseconds();
    printf("Time for running contains() on %d elements: %g ms\n", n, t2 - t1);
    deleteLinkedList(b);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x3e8,-0x1c(%rbp)
cmpl   $0x30d40,-0x1c(%rbp)
jge    1237 <main+0xd7>
mov    $0x0,%al
call   1030 <createLinkedList@plt>
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    11c2 <main+0x62>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%esi
call   1070 <addList@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    119c <main+0x3c>
mov    $0x0,%al
call   1050 <getMilliseconds@plt>
movsd  %xmm0,-0x28(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    11fb <main+0x9b>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%esi
call   1060 <removeList@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    11d5 <main+0x75>
mov    $0x0,%al
call   1050 <getMilliseconds@plt>
movsd  %xmm0,-0x30(%rbp)
mov    -0x1c(%rbp),%esi
movsd  -0x30(%rbp),%xmm0
subsd  -0x28(%rbp),%xmm0
lea    0xde5(%rip),%rdi
call   1040 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1080 <deleteLinkedList@plt>
mov    -0x1c(%rbp),%eax
shl    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    117d <main+0x1d>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    $0x3e8,%r15d
lea    0xe8c(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
xor    %eax,%eax
call   1030 <createLinkedList@plt>
mov    %rax,%rbx
xor    %ebp,%ebp
nopl   0x0(%rax)
mov    %rbx,%rdi
mov    %ebp,%esi
call   1070 <addList@plt>
add    $0x1,%ebp
cmp    %ebp,%r15d
jne    1190 <main+0x30>
xor    %ebp,%ebp
xor    %eax,%eax
call   1050 <getMilliseconds@plt>
movsd  %xmm0,(%rsp)
mov    %rbx,%rdi
mov    %ebp,%esi
call   1060 <removeList@plt>
add    $0x1,%ebp
cmp    %ebp,%r15d
jne    11b0 <main+0x50>
xor    %eax,%eax
call   1050 <getMilliseconds@plt>
subsd  (%rsp),%xmm0
mov    %r14,%rdi
mov    %r15d,%esi
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1080 <deleteLinkedList@plt>
add    %r15d,%r15d
cmp    $0x30d40,%r15d
jb     1180 <main+0x20>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.linkedList = type { i32 }
@.str = [51 x i8] c"Time for running contains() on %d elements: %g ms\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %struct.linkedList*
%7 = alloca i32
%8 = alloca i32
%9 = alloca double
%10 = alloca double
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 1000, i32* %7
br label %11
11: ; preds = %49, %2
%12 = load i32, i32* %7
%13 = icmp slt i32 %12, 200000
br i1 %13, label %14, label %52
14: ; preds = %11
%15 = call %struct.linkedList* (...) @createLinkedList()
store %struct.linkedList* %15, %struct.linkedList** %6
store i32 0, i32* %8
br label %16
16: ; preds = %24, %14
%17 = load i32, i32* %8
%18 = load i32, i32* %7
%19 = icmp slt i32 %17, %18
br i1 %19, label %20, label %27
20: ; preds = %16
%21 = load %struct.linkedList*, %struct.linkedList** %6
%22 = load i32, i32* %8
%23 = call i32 @addList(%struct.linkedList* %21, i32 %22)
br label %24
24: ; preds = %20
%25 = load i32, i32* %8
%26 = add nsw i32 %25, 1
store i32 %26, i32* %8
br label %16
27: ; preds = %16
%28 = call double (...) @getMilliseconds()
store double %28, double* %9
store i32 0, i32* %8
br label %29
29: ; preds = %37, %27
%30 = load i32, i32* %8
%31 = load i32, i32* %7
%32 = icmp slt i32 %30, %31
br i1 %32, label %33, label %40
33: ; preds = %29
%34 = load %struct.linkedList*, %struct.linkedList** %6
%35 = load i32, i32* %8
%36 = call i32 @removeList(%struct.linkedList* %34, i32 %35)
br label %37
37: ; preds = %33
%38 = load i32, i32* %8
%39 = add nsw i32 %38, 1
store i32 %39, i32* %8
br label %29
40: ; preds = %29
%41 = call double (...) @getMilliseconds()
store double %41, double* %10
%42 = load i32, i32* %7
%43 = load double, double* %10
%44 = load double, double* %9
%45 = fsub double %43, %44
%46 = call i32 @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str, i64 0, i64 0), i32 %42, double %45)
%47 = load %struct.linkedList*, %struct.linkedList** %6
%48 = call i32 @deleteLinkedList(%struct.linkedList* %47)
br label %49
49: ; preds = %40
%50 = load i32, i32* %7
%51 = mul nsw i32 %50, 2
store i32 %51, i32* %7
br label %11
52: ; preds = %11
ret i32 0
}

LLVM IR (-O2):
%struct.linkedList = type { i32 }
@.str = [51 x i8] c"Time for running contains() on %d elements: %g ms\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
br label %3
3: ; preds = %2, %18
%4 = phi i32 [ 1000, %2 ], [ %23, %18 ]
%5 = tail call %struct.linkedList* (...) @createLinkedList()
br label %6
6: ; preds = %3, %6
%7 = phi i32 [ 0, %3 ], [ %9, %6 ]
%8 = tail call i32 @addList(%struct.linkedList* %5, i32 %7)
%9 = add nuw i32 %7, 1
%10 = icmp eq i32 %9, %4
br i1 %10, label %11, label %6
11: ; preds = %6
%12 = tail call double (...) @getMilliseconds()
br label %13
13: ; preds = %11, %13
%14 = phi i32 [ 0, %11 ], [ %16, %13 ]
%15 = tail call i32 @removeList(%struct.linkedList* %5, i32 %14)
%16 = add nuw i32 %14, 1
%17 = icmp eq i32 %16, %4
br i1 %17, label %18, label %13
18: ; preds = %13
%19 = tail call double (...) @getMilliseconds()
%20 = fsub double %19, %12
%21 = tail call i32 @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str, i64 0, i64 0), i32 %4, double %20)
%22 = tail call i32 @deleteLinkedList(%struct.linkedList* %5)
%23 = shl nsw i32 %4, 1
%24 = icmp ult i32 %23, 200000
br i1 %24, label %3, label %25
25: ; preds = %18
ret i32 0
}