#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 timeval {
  int tv_sec;
  int tv_usec;
};
struct skipnode {
  int dummy;
};
struct skiplist {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ gettimeofday(struct timeval *, int /*<<< orphan*/ *);
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ random();
int /*<<< orphan*/ skiplist_delete(struct skiplist *);
int /*<<< orphan*/ skiplist_insert(struct skiplist *, int, int);
struct skiplist *skiplist_new();
int /*<<< orphan*/ skiplist_remove(struct skiplist *, int);
struct skipnode *skiplist_search_by_key(struct skiplist *, int);
struct skipnode *skiplist_search_by_rank(struct skiplist *, int);
int /*<<< orphan*/ srandom(int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int main(void) {
  int i;
  struct timeval start, end;
  int *key = (int *)malloc(1024 * 1024 * 2 * sizeof(int));
  if (key == NULL) {
    exit(-1);
  }
  struct skiplist *list = skiplist_new();
  if (list == NULL) {
    exit(-1);
  }
  printf("Test start!\n");
  printf("Add %d nodes...\n", 1024 * 1024 * 2);
  srandom(time(NULL));
  gettimeofday(&start, NULL);
  for (i = 0; i < 1024 * 1024 * 2; i++) {
    int value = key[i] = (int)random();
    skiplist_insert(list, key[i], value);
  }
  gettimeofday(&end, NULL);
  printf("time span: %ldms\n", (end.tv_sec - start.tv_sec) * 1000 +
                                   (end.tv_usec - start.tv_usec) / 1000);
  printf("Now search each node by key...\n");
  gettimeofday(&start, NULL);
  for (i = 0; i < 1024 * 1024 * 2; i++) {
    struct skipnode *node = skiplist_search_by_key(list, key[i]);
    if (node != NULL) {
    } else {
      printf("Not found:0x%08x\n", key[i]);
    }
  }
  gettimeofday(&end, NULL);
  printf("time span: %ldms\n", (end.tv_sec - start.tv_sec) * 1000 +
                                   (end.tv_usec - start.tv_usec) / 1000);
  printf("Now search each node by rank...\n");
  gettimeofday(&start, NULL);
  for (i = 0; i < 1024 * 1024 * 2; i++) {
    struct skipnode *node = skiplist_search_by_rank(list, i + 1);
    if (node != NULL) {
    } else {
      printf("Not found:%d\n", i + 1);
    }
  }
  gettimeofday(&end, NULL);
  printf("time span: %ldms\n", (end.tv_sec - start.tv_sec) * 1000 +
                                   (end.tv_usec - start.tv_usec) / 1000);
  printf("Now remove all nodes...\n");
  gettimeofday(&start, NULL);
  for (i = 0; i < 1024 * 1024 * 2; i++) {
    skiplist_remove(list, key[i]);
  }
  gettimeofday(&end, NULL);
  printf("time span: %ldms\n", (end.tv_sec - start.tv_sec) * 1000 +
                                   (end.tv_usec - start.tv_usec) / 1000);
  printf("End of Test.\n");
  skiplist_delete(list);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x800000,%edi
call   10d0 <malloc@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1202 <main+0x32>
mov    $0xffffffff,%edi
call   10f0 <exit@plt>
mov    $0x0,%al
call   1090 <skiplist_new@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    1222 <main+0x52>
mov    $0xffffffff,%edi
call   10f0 <exit@plt>
lea    0xdd7(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    0xdd6(%rip),%rdi
mov    $0x200000,%esi
mov    $0x0,%al
call   1070 <printf@plt>
xor    %eax,%eax
mov    %eax,%edi
call   10a0 <time@plt>
mov    %eax,%edi
call   1040 <srandom@plt>
lea    -0x10(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1080 <gettimeofday@plt>
movl   $0x0,-0x8(%rbp)
cmpl   $0x200000,-0x8(%rbp)
jge    12ae <main+0xde>
mov    $0x0,%al
call   10c0 <random@plt>
mov    -0x20(%rbp),%rcx
movslq -0x8(%rbp),%rdx
mov    %eax,(%rcx,%rdx,4)
mov    %eax,-0x2c(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x20(%rbp),%rax
movslq -0x8(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
mov    -0x2c(%rbp),%edx
call   1060 <skiplist_insert@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1267 <main+0x97>
lea    -0x18(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1080 <gettimeofday@plt>
mov    -0x18(%rbp),%eax
sub    -0x10(%rbp),%eax
imul   $0x3e8,%eax,%esi
mov    -0x14(%rbp),%eax
sub    -0xc(%rbp),%eax
mov    $0x3e8,%ecx
cltd
idiv   %ecx
add    %eax,%esi
lea    0xd40(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    0xd44(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    -0x10(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1080 <gettimeofday@plt>
movl   $0x0,-0x8(%rbp)
cmpl   $0x200000,-0x8(%rbp)
jge    1368 <main+0x198>
mov    -0x28(%rbp),%rdi
mov    -0x20(%rbp),%rax
movslq -0x8(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
call   1030 <skiplist_search_by_key@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
je     133c <main+0x16c>
jmp    1355 <main+0x185>
mov    -0x20(%rbp),%rax
movslq -0x8(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xd02(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
jmp    135a <main+0x18a>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1307 <main+0x137>
lea    -0x18(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1080 <gettimeofday@plt>
mov    -0x18(%rbp),%eax
sub    -0x10(%rbp),%eax
imul   $0x3e8,%eax,%esi
mov    -0x14(%rbp),%eax
sub    -0xc(%rbp),%eax
mov    $0x3e8,%ecx
cltd
idiv   %ecx
add    %eax,%esi
lea    0xc86(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    0xcbc(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    -0x10(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1080 <gettimeofday@plt>
movl   $0x0,-0x8(%rbp)
cmpl   $0x200000,-0x8(%rbp)
jge    1418 <main+0x248>
mov    -0x28(%rbp),%rdi
mov    -0x8(%rbp),%esi
add    $0x1,%esi
call   10e0 <skiplist_search_by_rank@plt>
mov    %rax,-0x40(%rbp)
cmpq   $0x0,-0x40(%rbp)
je     13f1 <main+0x221>
jmp    1405 <main+0x235>
mov    -0x8(%rbp),%esi
add    $0x1,%esi
lea    0xc85(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
jmp    140a <main+0x23a>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    13c1 <main+0x1f1>
lea    -0x18(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1080 <gettimeofday@plt>
mov    -0x18(%rbp),%eax
sub    -0x10(%rbp),%eax
imul   $0x3e8,%eax,%esi
mov    -0x14(%rbp),%eax
sub    -0xc(%rbp),%eax
mov    $0x3e8,%ecx
cltd
idiv   %ecx
add    %eax,%esi
lea    0xbd6(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    0xc3b(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    -0x10(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1080 <gettimeofday@plt>
movl   $0x0,-0x8(%rbp)
cmpl   $0x200000,-0x8(%rbp)
jge    14a0 <main+0x2d0>
mov    -0x28(%rbp),%rdi
mov    -0x20(%rbp),%rax
movslq -0x8(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
call   1050 <skiplist_remove@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1471 <main+0x2a1>
lea    -0x18(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1080 <gettimeofday@plt>
mov    -0x18(%rbp),%eax
sub    -0x10(%rbp),%eax
imul   $0x3e8,%eax,%esi
mov    -0x14(%rbp),%eax
sub    -0xc(%rbp),%eax
mov    $0x3e8,%ecx
cltd
idiv   %ecx
add    %eax,%esi
lea    0xb4e(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    0xbcc(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x28(%rbp),%rdi
call   10b0 <skiplist_delete@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    $0x800000,%edi
call   10e0 <malloc@plt>
test   %rax,%rax
je     1493 <main+0x2b3>
mov    %rax,%r14
xor    %eax,%eax
call   10a0 <skiplist_new@plt>
test   %rax,%rax
je     1493 <main+0x2b3>
mov    %rax,%rbx
lea    0xe29(%rip),%rdi
call   1050 <puts@plt>
lea    0xdda(%rip),%rdi
mov    $0x200000,%esi
xor    %eax,%eax
call   1080 <printf@plt>
xor    %edi,%edi
call   10b0 <time@plt>
mov    %eax,%edi
call   1040 <srandom@plt>
lea    0x10(%rsp),%rdi
xor    %esi,%esi
call   1090 <gettimeofday@plt>
xor    %ebp,%ebp
xchg   %ax,%ax
xor    %eax,%eax
call   10d0 <random@plt>
mov    %eax,(%r14,%rbp,4)
mov    %rbx,%rdi
mov    %eax,%esi
mov    %eax,%edx
call   1070 <skiplist_insert@plt>
add    $0x1,%rbp
cmp    $0x200000,%rbp
jne    1250 <main+0x70>
lea    0x8(%rsp),%rdi
xor    %esi,%esi
call   1090 <gettimeofday@plt>
mov    0x8(%rsp),%eax
mov    0xc(%rsp),%ecx
sub    0x10(%rsp),%eax
imul   $0x3e8,%eax,%eax
sub    0x14(%rsp),%ecx
movslq %ecx,%rcx
imul   $0x10624dd3,%rcx,%rsi
mov    %rsi,%rcx
shr    $0x3f,%rcx
sar    $0x26,%rsi
add    %ecx,%esi
add    %eax,%esi
lea    0xd5b(%rip),%rdi
xor    %eax,%eax
call   1080 <printf@plt>
lea    0xd8b(%rip),%rdi
call   1050 <puts@plt>
lea    0x10(%rsp),%rdi
xor    %esi,%esi
call   1090 <gettimeofday@plt>
lea    0xd47(%rip),%r15
xor    %ebp,%ebp
jmp    12ed <main+0x10d>
add    $0x1,%rbp
cmp    $0x200000,%rbp
je     130e <main+0x12e>
mov    (%r14,%rbp,4),%esi
mov    %rbx,%rdi
call   1030 <skiplist_search_by_key@plt>
test   %rax,%rax
jne    12e0 <main+0x100>
mov    (%r14,%rbp,4),%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1080 <printf@plt>
jmp    12e0 <main+0x100>
lea    0x8(%rsp),%rdi
xor    %esi,%esi
call   1090 <gettimeofday@plt>
mov    0x8(%rsp),%eax
mov    0xc(%rsp),%ecx
sub    0x10(%rsp),%eax
imul   $0x3e8,%eax,%eax
sub    0x14(%rsp),%ecx
movslq %ecx,%rcx
imul   $0x10624dd3,%rcx,%rsi
mov    %rsi,%rcx
shr    $0x3f,%rcx
sar    $0x26,%rsi
add    %ecx,%esi
add    %eax,%esi
lea    0xcc1(%rip),%rdi
xor    %eax,%eax
call   1080 <printf@plt>
lea    0xd10(%rip),%rdi
call   1050 <puts@plt>
lea    0x10(%rsp),%rdi
xor    %esi,%esi
call   1090 <gettimeofday@plt>
mov    $0x1,%ebp
lea    0xcba(%rip),%r15
jmp    138b <main+0x1ab>
nopl   (%rax)
add    $0x1,%ebp
cmp    $0x200001,%ebp
je     13a8 <main+0x1c8>
mov    %rbx,%rdi
mov    %ebp,%esi
call   10f0 <skiplist_search_by_rank@plt>
test   %rax,%rax
jne    1380 <main+0x1a0>
mov    %r15,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1080 <printf@plt>
jmp    1380 <main+0x1a0>
xor    %ebp,%ebp
lea    0x8(%rsp),%rdi
xor    %esi,%esi
call   1090 <gettimeofday@plt>
mov    0x8(%rsp),%eax
mov    0xc(%rsp),%ecx
sub    0x10(%rsp),%eax
imul   $0x3e8,%eax,%eax
sub    0x14(%rsp),%ecx
movslq %ecx,%rcx
imul   $0x10624dd3,%rcx,%rsi
mov    %rsi,%rcx
shr    $0x3f,%rcx
sar    $0x26,%rsi
add    %ecx,%esi
add    %eax,%esi
lea    0xc25(%rip),%rdi
xor    %eax,%eax
call   1080 <printf@plt>
lea    0xc94(%rip),%rdi
call   1050 <puts@plt>
lea    0x10(%rsp),%rdi
xor    %esi,%esi
call   1090 <gettimeofday@plt>
nopl   0x0(%rax,%rax,1)
mov    (%r14,%rbp,4),%esi
mov    %rbx,%rdi
call   1060 <skiplist_remove@plt>
add    $0x1,%rbp
cmp    $0x200000,%rbp
jne    1410 <main+0x230>
lea    0x8(%rsp),%rdi
xor    %esi,%esi
call   1090 <gettimeofday@plt>
mov    0x8(%rsp),%eax
mov    0xc(%rsp),%ecx
sub    0x10(%rsp),%eax
imul   $0x3e8,%eax,%eax
sub    0x14(%rsp),%ecx
movslq %ecx,%rcx
imul   $0x10624dd3,%rcx,%rsi
mov    %rsi,%rcx
shr    $0x3f,%rcx
sar    $0x26,%rsi
add    %ecx,%esi
add    %eax,%esi
lea    0xba6(%rip),%rdi
xor    %eax,%eax
call   1080 <printf@plt>
lea    0xc2d(%rip),%rdi
call   1050 <puts@plt>
mov    %rbx,%rdi
call   10c0 <skiplist_delete@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
mov    $0xffffffff,%edi
call   1100 <exit@plt>

LLVM IR (-O0):
%struct.timeval = type { i32, i32 }
%struct.skiplist = type { i32 }
%struct.skipnode = type { i32 }
@.str = [13 x i8] c"Test start!\0A\00"
@.str.1 = [17 x i8] c"Add %d nodes...\0A\00"
@.str.2 = [18 x i8] c"time span: %ldms\0A\00"
@.str.3 = [32 x i8] c"Now search each node by key...\0A\00"
@.str.4 = [18 x i8] c"Not found:0x%08x\0A\00"
@.str.5 = [33 x i8] c"Now search each node by rank...\0A\00"
@.str.6 = [14 x i8] c"Not found:%d\0A\00"
@.str.7 = [25 x i8] c"Now remove all nodes...\0A\00"
@.str.8 = [14 x i8] c"End of Test.\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca %struct.timeval
%4 = alloca %struct.timeval
%5 = alloca i32*
%6 = alloca %struct.skiplist*
%7 = alloca i32
%8 = alloca %struct.skipnode*
%9 = alloca %struct.skipnode*
store i32 0, i32* %1
%10 = call i64 @malloc(i32 8388608)
%11 = inttoptr i64 %10 to i32*
store i32* %11, i32** %5
%12 = load i32*, i32** %5
%13 = icmp eq i32* %12, null
br i1 %13, label %14, label %16
14: ; preds = %0
%15 = call i32 @exit(i32 -1)
unreachable
16: ; preds = %0
%17 = call %struct.skiplist* (...) @skiplist_new()
store %struct.skiplist* %17, %struct.skiplist** %6
%18 = load %struct.skiplist*, %struct.skiplist** %6
%19 = icmp eq %struct.skiplist* %18, null
br i1 %19, label %20, label %22
20: ; preds = %16
%21 = call i32 @exit(i32 -1)
unreachable
22: ; preds = %16
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i32 2097152)
%25 = call i32 @time(i32* null)
%26 = call i32 @srandom(i32 %25)
%27 = call i32 @gettimeofday(%struct.timeval* %3, i32* null)
store i32 0, i32* %2
br label %28
28: ; preds = %46, %22
%29 = load i32, i32* %2
%30 = icmp slt i32 %29, 2097152
br i1 %30, label %31, label %49
31: ; preds = %28
%32 = call i64 (...) @random()
%33 = trunc i64 %32 to i32
%34 = load i32*, i32** %5
%35 = load i32, i32* %2
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds i32, i32* %34, i64 %36
store i32 %33, i32* %37
store i32 %33, i32* %7
%38 = load %struct.skiplist*, %struct.skiplist** %6
%39 = load i32*, i32** %5
%40 = load i32, i32* %2
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds i32, i32* %39, i64 %41
%43 = load i32, i32* %42
%44 = load i32, i32* %7
%45 = call i32 @skiplist_insert(%struct.skiplist* %38, i32 %43, i32 %44)
br label %46
46: ; preds = %31
%47 = load i32, i32* %2
%48 = add nsw i32 %47, 1
store i32 %48, i32* %2
br label %28
49: ; preds = %28
%50 = call i32 @gettimeofday(%struct.timeval* %4, i32* null)
%51 = getelementptr inbounds %struct.timeval, %struct.timeval* %4, i32 0, i32 0
%52 = load i32, i32* %51
%53 = getelementptr inbounds %struct.timeval, %struct.timeval* %3, i32 0, i32 0
%54 = load i32, i32* %53
%55 = sub nsw i32 %52, %54
%56 = mul nsw i32 %55, 1000
%57 = getelementptr inbounds %struct.timeval, %struct.timeval* %4, i32 0, i32 1
%58 = load i32, i32* %57
%59 = getelementptr inbounds %struct.timeval, %struct.timeval* %3, i32 0, i32 1
%60 = load i32, i32* %59
%61 = sub nsw i32 %58, %60
%62 = sdiv i32 %61, 1000
%63 = add nsw i32 %56, %62
%64 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i32 %63)
%65 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0))
%66 = call i32 @gettimeofday(%struct.timeval* %3, i32* null)
store i32 0, i32* %2
br label %67
67: ; preds = %89, %49
%68 = load i32, i32* %2
%69 = icmp slt i32 %68, 2097152
br i1 %69, label %70, label %92
70: ; preds = %67
%71 = load %struct.skiplist*, %struct.skiplist** %6
%72 = load i32*, i32** %5
%73 = load i32, i32* %2
%74 = sext i32 %73 to i64
%75 = getelementptr inbounds i32, i32* %72, i64 %74
%76 = load i32, i32* %75
%77 = call %struct.skipnode* @skiplist_search_by_key(%struct.skiplist* %71, i32 %76)
store %struct.skipnode* %77, %struct.skipnode** %8
%78 = load %struct.skipnode*, %struct.skipnode** %8
%79 = icmp ne %struct.skipnode* %78, null
br i1 %79, label %80, label %81
80: ; preds = %70
br label %88
81: ; preds = %70
%82 = load i32*, i32** %5
%83 = load i32, i32* %2
%84 = sext i32 %83 to i64
%85 = getelementptr inbounds i32, i32* %82, i64 %84
%86 = load i32, i32* %85
%87 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0), i32 %86)
br label %88
88: ; preds = %81, %80
br label %89
89: ; preds = %88
%90 = load i32, i32* %2
%91 = add nsw i32 %90, 1
store i32 %91, i32* %2
br label %67
92: ; preds = %67
%93 = call i32 @gettimeofday(%struct.timeval* %4, i32* null)
%94 = getelementptr inbounds %struct.timeval, %struct.timeval* %4, i32 0, i32 0
%95 = load i32, i32* %94
%96 = getelementptr inbounds %struct.timeval, %struct.timeval* %3, i32 0, i32 0
%97 = load i32, i32* %96
%98 = sub nsw i32 %95, %97
%99 = mul nsw i32 %98, 1000
%100 = getelementptr inbounds %struct.timeval, %struct.timeval* %4, i32 0, i32 1
%101 = load i32, i32* %100
%102 = getelementptr inbounds %struct.timeval, %struct.timeval* %3, i32 0, i32 1
%103 = load i32, i32* %102
%104 = sub nsw i32 %101, %103
%105 = sdiv i32 %104, 1000
%106 = add nsw i32 %99, %105
%107 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i32 %106)
%108 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.5, i64 0, i64 0))
%109 = call i32 @gettimeofday(%struct.timeval* %3, i32* null)
store i32 0, i32* %2
br label %110
110: ; preds = %126, %92
%111 = load i32, i32* %2
%112 = icmp slt i32 %111, 2097152
br i1 %112, label %113, label %129
113: ; preds = %110
%114 = load %struct.skiplist*, %struct.skiplist** %6
%115 = load i32, i32* %2
%116 = add nsw i32 %115, 1
%117 = call %struct.skipnode* @skiplist_search_by_rank(%struct.skiplist* %114, i32 %116)
store %struct.skipnode* %117, %struct.skipnode** %9
%118 = load %struct.skipnode*, %struct.skipnode** %9
%119 = icmp ne %struct.skipnode* %118, null
br i1 %119, label %120, label %121
120: ; preds = %113
br label %125
121: ; preds = %113
%122 = load i32, i32* %2
%123 = add nsw i32 %122, 1
%124 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.6, i64 0, i64 0), i32 %123)
br label %125
125: ; preds = %121, %120
br label %126
126: ; preds = %125
%127 = load i32, i32* %2
%128 = add nsw i32 %127, 1
store i32 %128, i32* %2
br label %110
129: ; preds = %110
%130 = call i32 @gettimeofday(%struct.timeval* %4, i32* null)
%131 = getelementptr inbounds %struct.timeval, %struct.timeval* %4, i32 0, i32 0
%132 = load i32, i32* %131
%133 = getelementptr inbounds %struct.timeval, %struct.timeval* %3, i32 0, i32 0
%134 = load i32, i32* %133
%135 = sub nsw i32 %132, %134
%136 = mul nsw i32 %135, 1000
%137 = getelementptr inbounds %struct.timeval, %struct.timeval* %4, i32 0, i32 1
%138 = load i32, i32* %137
%139 = getelementptr inbounds %struct.timeval, %struct.timeval* %3, i32 0, i32 1
%140 = load i32, i32* %139
%141 = sub nsw i32 %138, %140
%142 = sdiv i32 %141, 1000
%143 = add nsw i32 %136, %142
%144 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i32 %143)
%145 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.7, i64 0, i64 0))
%146 = call i32 @gettimeofday(%struct.timeval* %3, i32* null)
store i32 0, i32* %2
br label %147
147: ; preds = %158, %129
%148 = load i32, i32* %2
%149 = icmp slt i32 %148, 2097152
br i1 %149, label %150, label %161
150: ; preds = %147
%151 = load %struct.skiplist*, %struct.skiplist** %6
%152 = load i32*, i32** %5
%153 = load i32, i32* %2
%154 = sext i32 %153 to i64
%155 = getelementptr inbounds i32, i32* %152, i64 %154
%156 = load i32, i32* %155
%157 = call i32 @skiplist_remove(%struct.skiplist* %151, i32 %156)
br label %158
158: ; preds = %150
%159 = load i32, i32* %2
%160 = add nsw i32 %159, 1
store i32 %160, i32* %2
br label %147
161: ; preds = %147
%162 = call i32 @gettimeofday(%struct.timeval* %4, i32* null)
%163 = getelementptr inbounds %struct.timeval, %struct.timeval* %4, i32 0, i32 0
%164 = load i32, i32* %163
%165 = getelementptr inbounds %struct.timeval, %struct.timeval* %3, i32 0, i32 0
%166 = load i32, i32* %165
%167 = sub nsw i32 %164, %166
%168 = mul nsw i32 %167, 1000
%169 = getelementptr inbounds %struct.timeval, %struct.timeval* %4, i32 0, i32 1
%170 = load i32, i32* %169
%171 = getelementptr inbounds %struct.timeval, %struct.timeval* %3, i32 0, i32 1
%172 = load i32, i32* %171
%173 = sub nsw i32 %170, %172
%174 = sdiv i32 %173, 1000
%175 = add nsw i32 %168, %174
%176 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i32 %175)
%177 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.8, i64 0, i64 0))
%178 = load %struct.skiplist*, %struct.skiplist** %6
%179 = call i32 @skiplist_delete(%struct.skiplist* %178)
ret i32 0
}

LLVM IR (-O2):
%struct.timeval = type { i32, i32 }
%struct.skiplist = type { i32 }
%struct.skipnode = type { i32 }
@.str.1 = [17 x i8] c"Add %d nodes...\0A\00"
@.str.2 = [18 x i8] c"time span: %ldms\0A\00"
@.str.4 = [18 x i8] c"Not found:0x%08x\0A\00"
@.str.6 = [14 x i8] c"Not found:%d\0A\00"
@str = [12 x i8] c"Test start!\00"
@str.9 = [31 x i8] c"Now search each node by key...\00"
@str.10 = [32 x i8] c"Now search each node by rank...\00"
@str.11 = [24 x i8] c"Now remove all nodes...\00"
@str.12 = [13 x i8] c"End of Test.\00"
define i32 @main() {
%1 = alloca %struct.timeval
%2 = alloca %struct.timeval
%3 = bitcast %struct.timeval* %1 to i8*
%4 = bitcast %struct.timeval* %2 to i8*
%5 = tail call i64 @malloc(i32 8388608)
%6 = inttoptr i64 %5 to i32*
%7 = icmp eq i64 %5, 0
br i1 %7, label %8, label %10
8: ; preds = %0
%9 = tail call i32 @exit(i32 -1)
unreachable
10: ; preds = %0
%11 = tail call %struct.skiplist* (...) @skiplist_new()
%12 = icmp eq %struct.skiplist* %11, null
br i1 %12, label %13, label %15
13: ; preds = %10
%14 = tail call i32 @exit(i32 -1)
unreachable
15: ; preds = %10
%16 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str, i64 0, i64 0))
%17 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i32 2097152)
%18 = tail call i32 @time(i32* null)
%19 = tail call i32 @srandom(i32 %18)
%20 = call i32 @gettimeofday(%struct.timeval* %1, i32* null)
br label %21
21: ; preds = %15, %21
%22 = phi i64 [ 0, %15 ], [ %27, %21 ]
%23 = tail call i64 (...) @random()
%24 = trunc i64 %23 to i32
%25 = getelementptr inbounds i32, i32* %6, i64 %22
store i32 %24, i32* %25
%26 = tail call i32 @skiplist_insert(%struct.skiplist* %11, i32 %24, i32 %24)
%27 = add nuw nsw i64 %22, 1
%28 = icmp eq i64 %27, 2097152
br i1 %28, label %29, label %21
29: ; preds = %21
%30 = call i32 @gettimeofday(%struct.timeval* %2, i32* null)
%31 = getelementptr inbounds %struct.timeval, %struct.timeval* %2, i64 0, i32 0
%32 = load i32, i32* %31
%33 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i64 0, i32 0
%34 = load i32, i32* %33
%35 = sub nsw i32 %32, %34
%36 = mul nsw i32 %35, 1000
%37 = getelementptr inbounds %struct.timeval, %struct.timeval* %2, i64 0, i32 1
%38 = load i32, i32* %37
%39 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i64 0, i32 1
%40 = load i32, i32* %39
%41 = sub nsw i32 %38, %40
%42 = sdiv i32 %41, 1000
%43 = add nsw i32 %42, %36
%44 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i32 %43)
%45 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str.9, i64 0, i64 0))
%46 = call i32 @gettimeofday(%struct.timeval* %1, i32* null)
br label %47
47: ; preds = %29, %56
%48 = phi i64 [ 0, %29 ], [ %57, %56 ]
%49 = getelementptr inbounds i32, i32* %6, i64 %48
%50 = load i32, i32* %49
%51 = tail call %struct.skipnode* @skiplist_search_by_key(%struct.skiplist* %11, i32 %50)
%52 = icmp eq %struct.skipnode* %51, null
br i1 %52, label %53, label %56
53: ; preds = %47
%54 = load i32, i32* %49
%55 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0), i32 %54)
br label %56
56: ; preds = %47, %53
%57 = add nuw nsw i64 %48, 1
%58 = icmp eq i64 %57, 2097152
br i1 %58, label %59, label %47
59: ; preds = %56
%60 = call i32 @gettimeofday(%struct.timeval* %2, i32* null)
%61 = load i32, i32* %31
%62 = load i32, i32* %33
%63 = sub nsw i32 %61, %62
%64 = mul nsw i32 %63, 1000
%65 = load i32, i32* %37
%66 = load i32, i32* %39
%67 = sub nsw i32 %65, %66
%68 = sdiv i32 %67, 1000
%69 = add nsw i32 %68, %64
%70 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i32 %69)
%71 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str.10, i64 0, i64 0))
%72 = call i32 @gettimeofday(%struct.timeval* %1, i32* null)
br label %73
73: ; preds = %59, %80
%74 = phi i32 [ 0, %59 ], [ %75, %80 ]
%75 = add nuw nsw i32 %74, 1
%76 = tail call %struct.skipnode* @skiplist_search_by_rank(%struct.skiplist* %11, i32 %75)
%77 = icmp eq %struct.skipnode* %76, null
br i1 %77, label %78, label %80
78: ; preds = %73
%79 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.6, i64 0, i64 0), i32 %75)
br label %80
80: ; preds = %73, %78
%81 = icmp eq i32 %75, 2097152
br i1 %81, label %82, label %73
82: ; preds = %80
%83 = call i32 @gettimeofday(%struct.timeval* %2, i32* null)
%84 = load i32, i32* %31
%85 = load i32, i32* %33
%86 = sub nsw i32 %84, %85
%87 = mul nsw i32 %86, 1000
%88 = load i32, i32* %37
%89 = load i32, i32* %39
%90 = sub nsw i32 %88, %89
%91 = sdiv i32 %90, 1000
%92 = add nsw i32 %91, %87
%93 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i32 %92)
%94 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str.11, i64 0, i64 0))
%95 = call i32 @gettimeofday(%struct.timeval* %1, i32* null)
br label %96
96: ; preds = %82, %96
%97 = phi i64 [ 0, %82 ], [ %101, %96 ]
%98 = getelementptr inbounds i32, i32* %6, i64 %97
%99 = load i32, i32* %98
%100 = tail call i32 @skiplist_remove(%struct.skiplist* %11, i32 %99)
%101 = add nuw nsw i64 %97, 1
%102 = icmp eq i64 %101, 2097152
br i1 %102, label %103, label %96
103: ; preds = %96
%104 = call i32 @gettimeofday(%struct.timeval* %2, i32* null)
%105 = load i32, i32* %31
%106 = load i32, i32* %33
%107 = sub nsw i32 %105, %106
%108 = mul nsw i32 %107, 1000
%109 = load i32, i32* %37
%110 = load i32, i32* %39
%111 = sub nsw i32 %109, %110
%112 = sdiv i32 %111, 1000
%113 = add nsw i32 %112, %108
%114 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i32 %113)
%115 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str.12, i64 0, i64 0))
%116 = tail call i32 @skiplist_delete(%struct.skiplist* %11)
ret i32 0
}