void test_int() {
  printf("%s start.\n", __func__);
  int arr[4] = {1, 2, 3, 4};
  create();
  insert(0, &arr[0]);
  insert_first(&arr[1]);
  insert_last(&arr[2]);
  insert(1, &arr[3]);
  printf("int is_empty=%d\n", is_empty());
  printf("int size=%d\n", size());
  int i;
  int *p;
  int len = size();
  for (i = 0; i < len; i++) {
    p = (int *)get(i);
    printf("int get(%d)=%d\n", i, *p);
  }
  destory();
  printf("%s finish.\n", __func__);
}


x86 assembly (clang, -O0):
<test_int>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
lea    0xe61(%rip),%rdi
lea    0xe65(%rip),%rsi
mov    $0x0,%al
call   1050 <printf@plt>
mov    0xe9c(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    0xe99(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    $0x0,%al
call   1070 <create@plt>
lea    -0x10(%rbp),%rsi
xor    %edi,%edi
mov    $0x0,%al
call   1090 <insert@plt>
lea    -0x10(%rbp),%rdi
add    $0x4,%rdi
mov    $0x0,%al
call   10b0 <insert_first@plt>
lea    -0x10(%rbp),%rdi
add    $0x8,%rdi
mov    $0x0,%al
call   1040 <insert_last@plt>
lea    -0x10(%rbp),%rsi
add    $0xc,%rsi
mov    $0x1,%edi
mov    $0x0,%al
call   1090 <insert@plt>
mov    $0x0,%al
call   1060 <is_empty@plt>
mov    %eax,%esi
lea    0xdfb(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x0,%al
call   1030 <size@plt>
mov    %eax,%esi
lea    0xdf5(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x0,%al
call   1030 <size@plt>
mov    %eax,-0x24(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x24(%rbp),%eax
jge    1289 <test_int+0xf9>
mov    -0x14(%rbp),%edi
mov    $0x0,%al
call   1080 <get@plt>
cltq
mov    %rax,-0x20(%rbp)
mov    -0x14(%rbp),%esi
mov    -0x20(%rbp),%rax
mov    (%rax),%edx
lea    0xdbe(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1248 <test_int+0xb8>
mov    $0x0,%al
call   10a0 <destory@plt>
lea    0xdab(%rip),%rdi
lea    0xd6d(%rip),%rsi
mov    $0x0,%al
call   1050 <printf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_int>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
lea    0xe61(%rip),%rdi
lea    0xe65(%rip),%rsi
xor    %eax,%eax
call   1050 <printf@plt>
movaps 0xe9c(%rip),%xmm0
movaps %xmm0,(%rsp)
xor    %eax,%eax
call   1070 <create@plt>
mov    %rsp,%rsi
xor    %edi,%edi
xor    %eax,%eax
call   1090 <insert@plt>
lea    0x4(%rsp),%rdi
xor    %eax,%eax
call   10b0 <insert_first@plt>
lea    0x8(%rsp),%rdi
xor    %eax,%eax
call   1040 <insert_last@plt>
lea    0xc(%rsp),%rsi
mov    $0x1,%edi
xor    %eax,%eax
call   1090 <insert@plt>
xor    %eax,%eax
call   1060 <is_empty@plt>
lea    0xe12(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
call   1030 <size@plt>
lea    0xe0c(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
call   1030 <size@plt>
test   %eax,%eax
jle    1260 <test_int+0xd0>
mov    %eax,%ebx
lea    0xdfc(%rip),%r14
xor    %ebp,%ebp
nopl   0x0(%rax,%rax,1)
mov    %ebp,%edi
xor    %eax,%eax
call   1080 <get@plt>
cltq
mov    (%rax),%edx
mov    %r14,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%ebp
cmp    %ebp,%ebx
jne    1240 <test_int+0xb0>
xor    %eax,%eax
call   10a0 <destory@plt>
lea    0xdd4(%rip),%rdi
lea    0xd96(%rip),%rsi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [11 x i8] c"%s start.\0A\00"
@__func__.test_int = [9 x i8] c"test_int\00"
@__const.test_int.arr = [4 x i32] [i32 1, i32 2, i32 3, i32 4]
@.str.1 = [17 x i8] c"int is_empty=%d\0A\00"
@.str.2 = [13 x i8] c"int size=%d\0A\00"
@.str.3 = [16 x i8] c"int get(%d)=%d\0A\00"
@.str.4 = [12 x i8] c"%s finish.\0A\00"
define void @test_int() {
%1 = alloca [4 x i32]
%2 = alloca i32
%3 = alloca i32*
%4 = alloca i32
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @__func__.test_int, i64 0, i64 0))
%6 = bitcast [4 x i32]* %1 to i8*
%7 = call i32 (...) @create()
%8 = getelementptr inbounds [4 x i32], [4 x i32]* %1, i64 0, i64 0
%9 = call i32 (i32, i32*, ...) bitcast (i32 (...)* @insert to i32 (i32, i32*, ...)*)(i32 0, i32* %8)
%10 = getelementptr inbounds [4 x i32], [4 x i32]* %1, i64 0, i64 1
%11 = call i32 (i32*, ...) bitcast (i32 (...)* @insert_first to i32 (i32*, ...)*)(i32* %10)
%12 = getelementptr inbounds [4 x i32], [4 x i32]* %1, i64 0, i64 2
%13 = call i32 (i32*, ...) bitcast (i32 (...)* @insert_last to i32 (i32*, ...)*)(i32* %12)
%14 = getelementptr inbounds [4 x i32], [4 x i32]* %1, i64 0, i64 3
%15 = call i32 (i32, i32*, ...) bitcast (i32 (...)* @insert to i32 (i32, i32*, ...)*)(i32 1, i32* %14)
%16 = call i32 (...) @is_empty()
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i32 %16)
%18 = call i32 (...) @size()
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i32 %18)
%20 = call i32 (...) @size()
store i32 %20, i32* %4
store i32 0, i32* %2
br label %21
21: ; preds = %34, %0
%22 = load i32, i32* %2
%23 = load i32, i32* %4
%24 = icmp slt i32 %22, %23
br i1 %24, label %25, label %37
25: ; preds = %21
%26 = load i32, i32* %2
%27 = call i32 (i32, ...) bitcast (i32 (...)* @get to i32 (i32, ...)*)(i32 %26)
%28 = sext i32 %27 to i64
%29 = inttoptr i64 %28 to i32*
store i32* %29, i32** %3
%30 = load i32, i32* %2
%31 = load i32*, i32** %3
%32 = load i32, i32* %31
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i32 %30, i32 %32)
br label %34
34: ; preds = %25
%35 = load i32, i32* %2
%36 = add nsw i32 %35, 1
store i32 %36, i32* %2
br label %21
37: ; preds = %21
%38 = call i32 (...) @destory()
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @__func__.test_int, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [11 x i8] c"%s start.\0A\00"
@__func__.test_int = [9 x i8] c"test_int\00"
@__const.test_int.arr = [4 x i32] [i32 1, i32 2, i32 3, i32 4]
@.str.1 = [17 x i8] c"int is_empty=%d\0A\00"
@.str.2 = [13 x i8] c"int size=%d\0A\00"
@.str.3 = [16 x i8] c"int get(%d)=%d\0A\00"
@.str.4 = [12 x i8] c"%s finish.\0A\00"
define void @test_int() {
%1 = alloca [4 x i32]
%2 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @__func__.test_int, i64 0, i64 0))
%3 = bitcast [4 x i32]* %1 to i8*
%4 = tail call i32 (...) @create()
%5 = getelementptr inbounds [4 x i32], [4 x i32]* %1, i64 0, i64 0
%6 = call i32 (i32, i32*, ...) bitcast (i32 (...)* @insert to i32 (i32, i32*, ...)*)(i32 0, i32* %5)
%7 = getelementptr inbounds [4 x i32], [4 x i32]* %1, i64 0, i64 1
%8 = call i32 (i32*, ...) bitcast (i32 (...)* @insert_first to i32 (i32*, ...)*)(i32* %7)
%9 = getelementptr inbounds [4 x i32], [4 x i32]* %1, i64 0, i64 2
%10 = call i32 (i32*, ...) bitcast (i32 (...)* @insert_last to i32 (i32*, ...)*)(i32* %9)
%11 = getelementptr inbounds [4 x i32], [4 x i32]* %1, i64 0, i64 3
%12 = call i32 (i32, i32*, ...) bitcast (i32 (...)* @insert to i32 (i32, i32*, ...)*)(i32 1, i32* %11)
%13 = call i32 (...) @is_empty()
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i32 %13)
%15 = call i32 (...) @size()
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i32 %15)
%17 = call i32 (...) @size()
%18 = icmp sgt i32 %17, 0
br i1 %18, label %19, label %28
19: ; preds = %0, %19
%20 = phi i32 [ %26, %19 ], [ 0, %0 ]
%21 = call i32 (i32, ...) bitcast (i32 (...)* @get to i32 (i32, ...)*)(i32 %20)
%22 = sext i32 %21 to i64
%23 = inttoptr i64 %22 to i32*
%24 = load i32, i32* %23
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i32 %20, i32 %24)
%26 = add nuw nsw i32 %20, 1
%27 = icmp eq i32 %26, %17
br i1 %27, label %28, label %19
28: ; preds = %19, %0
%29 = call i32 (...) @destory()
%30 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @__func__.test_int, i64 0, i64 0))
ret void
}