#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 OlLrcItem {
  int dummy;
};
struct OlLrc {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ ol_lrc_free(struct OlLrc *);
struct OlLrcItem *ol_lrc_get_item(struct OlLrc *, int);
int ol_lrc_item_count(struct OlLrc *);
int ol_lrc_item_get_id(struct OlLrcItem const *);
int ol_lrc_item_get_time(struct OlLrcItem const *);
struct OlLrc *ol_lrc_new(char *);
int /*<<< orphan*/ printf(char *, int, char *);
void basic_test() {
  struct OlLrc *lrc = ol_lrc_new("lrc_basic.lrc");
  int i;
  int lasttime;
  for (i = 0; i < ol_lrc_item_count(lrc); i++) {
    const struct OlLrcItem *item = ol_lrc_get_item(lrc, i);
    if (!(item != NULL)) {
      printf("ERROR[%d]: EXPECT %s failed\n", 43, "item != NULL");
    };
    if (!(ol_lrc_item_get_id(item) == i)) {
      printf("ERROR[%d]: EXPECT %s failed\n", 44,
             "ol_lrc_item_get_id (item) == i");
    };
    if (i > 0)
      if (!(ol_lrc_item_get_time(item) >= lasttime)) {
        printf("ERROR[%d]: EXPECT %s failed\n", 46,
               "ol_lrc_item_get_time (item) >= lasttime");
      };
    lasttime = ol_lrc_item_get_time(item);
  }
  ol_lrc_free(lrc);
}


x86 assembly (clang, -O0):
<basic_test>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
lea    0xe81(%rip),%rdi
call   1040 <ol_lrc_new@plt>
mov    %rax,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%rdi
call   1070 <ol_lrc_item_count@plt>
mov    %eax,%ecx
mov    -0x1c(%rbp),%eax
cmp    %ecx,%eax
jge    125b <basic_test+0xeb>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1060 <ol_lrc_get_item@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11de <basic_test+0x6e>
lea    0xe41(%rip),%rdi
mov    $0x2b,%esi
lea    0xe52(%rip),%rdx
call   1030 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1050 <ol_lrc_item_get_id@plt>
cmp    -0xc(%rbp),%eax
je     1208 <basic_test+0x98>
lea    0xe17(%rip),%rdi
mov    $0x2c,%esi
lea    0xe35(%rip),%rdx
call   1030 <printf@plt>
cmpl   $0x0,-0xc(%rbp)
jle    1241 <basic_test+0xd1>
mov    -0x18(%rbp),%rdi
call   1090 <ol_lrc_item_get_time@plt>
cmp    -0x10(%rbp),%eax
jge    123c <basic_test+0xcc>
lea    0xde3(%rip),%rdi
mov    $0x2e,%esi
lea    0xe20(%rip),%rdx
call   1030 <printf@plt>
jmp    1241 <basic_test+0xd1>
mov    -0x18(%rbp),%rdi
call   1090 <ol_lrc_item_get_time@plt>
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    118f <basic_test+0x1f>
mov    -0x8(%rbp),%rdi
call   1080 <ol_lrc_free@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<basic_test>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xe7e(%rip),%rdi
call   1040 <ol_lrc_new@plt>
mov    %rax,%r13
mov    %rax,%rdi
call   1070 <ol_lrc_item_count@plt>
test   %eax,%eax
jle    129d <basic_test+0x12d>
mov    %r13,%rdi
xor    %esi,%esi
call   1060 <ol_lrc_get_item@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    11c4 <basic_test+0x54>
lea    0xe5b(%rip),%rdi
lea    0xe71(%rip),%rdx
mov    $0x2b,%esi
call   1030 <printf@plt>
mov    %rbx,%rdi
call   1050 <ol_lrc_item_get_id@plt>
test   %eax,%eax
je     11e8 <basic_test+0x78>
lea    0xe37(%rip),%rdi
lea    0xe5a(%rip),%rdx
mov    $0x2c,%esi
call   1030 <printf@plt>
mov    %rbx,%rdi
call   1090 <ol_lrc_item_get_time@plt>
mov    %eax,%ebx
mov    %r13,%rdi
call   1070 <ol_lrc_item_count@plt>
cmp    $0x2,%eax
jl     129d <basic_test+0x12d>
mov    $0x1,%ebp
lea    0xdff(%rip),%r14
lea    0xe22(%rip),%r15
jmp    1239 <basic_test+0xc9>
nopl   0x0(%rax,%rax,1)
mov    %r12,%rdi
call   1090 <ol_lrc_item_get_time@plt>
mov    %eax,%ebx
add    $0x1,%ebp
mov    %r13,%rdi
call   1070 <ol_lrc_item_count@plt>
cmp    %eax,%ebp
jge    129d <basic_test+0x12d>
mov    %r13,%rdi
mov    %ebp,%esi
call   1060 <ol_lrc_get_item@plt>
mov    %rax,%r12
test   %rax,%rax
jne    125f <basic_test+0xef>
mov    %r14,%rdi
mov    $0x2b,%esi
lea    0xdd1(%rip),%rdx
call   1030 <printf@plt>
mov    %r12,%rdi
call   1050 <ol_lrc_item_get_id@plt>
cmp    %eax,%ebp
je     127b <basic_test+0x10b>
mov    %r14,%rdi
mov    $0x2c,%esi
mov    %r15,%rdx
call   1030 <printf@plt>
mov    %r12,%rdi
call   1090 <ol_lrc_item_get_time@plt>
cmp    %ebx,%eax
jge    1220 <basic_test+0xb0>
mov    %r14,%rdi
mov    $0x2e,%esi
lea    0xdc1(%rip),%rdx
call   1030 <printf@plt>
jmp    1220 <basic_test+0xb0>
mov    %r13,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1080 <ol_lrc_free@plt>

LLVM IR (-O0):
%struct.OlLrc = type { i32 }
%struct.OlLrcItem = type { i32 }
@.str = [14 x i8] c"lrc_basic.lrc\00"
@.str.1 = [29 x i8] c"ERROR[%d]: EXPECT %s failed\0A\00"
@.str.2 = [13 x i8] c"item != NULL\00"
@.str.3 = [31 x i8] c"ol_lrc_item_get_id (item) == i\00"
@.str.4 = [40 x i8] c"ol_lrc_item_get_time (item) >= lasttime\00"
define void @basic_test() {
%1 = alloca %struct.OlLrc*
%2 = alloca i32
%3 = alloca i32
%4 = alloca %struct.OlLrcItem*
%5 = call %struct.OlLrc* @ol_lrc_new(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
store %struct.OlLrc* %5, %struct.OlLrc** %1
store i32 0, i32* %2
br label %6
6: ; preds = %40, %0
%7 = load i32, i32* %2
%8 = load %struct.OlLrc*, %struct.OlLrc** %1
%9 = call i32 @ol_lrc_item_count(%struct.OlLrc* %8)
%10 = icmp slt i32 %7, %9
br i1 %10, label %11, label %43
11: ; preds = %6
%12 = load %struct.OlLrc*, %struct.OlLrc** %1
%13 = load i32, i32* %2
%14 = call %struct.OlLrcItem* @ol_lrc_get_item(%struct.OlLrc* %12, i32 %13)
store %struct.OlLrcItem* %14, %struct.OlLrcItem** %4
%15 = load %struct.OlLrcItem*, %struct.OlLrcItem** %4
%16 = icmp ne %struct.OlLrcItem* %15, null
br i1 %16, label %19, label %17
17: ; preds = %11
%18 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), i32 43, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
br label %19
19: ; preds = %17, %11
%20 = load %struct.OlLrcItem*, %struct.OlLrcItem** %4
%21 = call i32 @ol_lrc_item_get_id(%struct.OlLrcItem* %20)
%22 = load i32, i32* %2
%23 = icmp eq i32 %21, %22
br i1 %23, label %26, label %24
24: ; preds = %19
%25 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), i32 44, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0))
br label %26
26: ; preds = %24, %19
%27 = load i32, i32* %2
%28 = icmp sgt i32 %27, 0
br i1 %28, label %29, label %37
29: ; preds = %26
%30 = load %struct.OlLrcItem*, %struct.OlLrcItem** %4
%31 = call i32 @ol_lrc_item_get_time(%struct.OlLrcItem* %30)
%32 = load i32, i32* %3
%33 = icmp sge i32 %31, %32
br i1 %33, label %36, label %34
34: ; preds = %29
%35 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), i32 46, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.4, i64 0, i64 0))
br label %36
36: ; preds = %34, %29
br label %37
37: ; preds = %36, %26
%38 = load %struct.OlLrcItem*, %struct.OlLrcItem** %4
%39 = call i32 @ol_lrc_item_get_time(%struct.OlLrcItem* %38)
store i32 %39, i32* %3
br label %40
40: ; preds = %37
%41 = load i32, i32* %2
%42 = add nsw i32 %41, 1
store i32 %42, i32* %2
br label %6
43: ; preds = %6
%44 = load %struct.OlLrc*, %struct.OlLrc** %1
%45 = call i32 @ol_lrc_free(%struct.OlLrc* %44)
ret void
}

LLVM IR (-O2):
%struct.OlLrc = type { i32 }
%struct.OlLrcItem = type { i32 }
@.str = [14 x i8] c"lrc_basic.lrc\00"
@.str.1 = [29 x i8] c"ERROR[%d]: EXPECT %s failed\0A\00"
@.str.2 = [13 x i8] c"item != NULL\00"
@.str.3 = [31 x i8] c"ol_lrc_item_get_id (item) == i\00"
@.str.4 = [40 x i8] c"ol_lrc_item_get_time (item) >= lasttime\00"
define void @basic_test() {
%1 = tail call %struct.OlLrc* @ol_lrc_new(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
%2 = tail call i32 @ol_lrc_item_count(%struct.OlLrc* %1)
%3 = icmp sgt i32 %2, 0
br i1 %3, label %4, label %40
4: ; preds = %0
%5 = tail call %struct.OlLrcItem* @ol_lrc_get_item(%struct.OlLrc* %1, i32 0)
%6 = icmp eq %struct.OlLrcItem* %5, null
br i1 %6, label %7, label %9
7: ; preds = %4
%8 = tail call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), i32 43, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
br label %9
9: ; preds = %7, %4
%10 = tail call i32 @ol_lrc_item_get_id(%struct.OlLrcItem* %5)
%11 = icmp eq i32 %10, 0
br i1 %11, label %14, label %12
12: ; preds = %9
%13 = tail call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), i32 44, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0))
br label %14
14: ; preds = %9, %12
%15 = tail call i32 @ol_lrc_item_get_time(%struct.OlLrcItem* %5)
%16 = tail call i32 @ol_lrc_item_count(%struct.OlLrc* %1)
%17 = icmp sgt i32 %16, 1
br i1 %17, label %18, label %40
18: ; preds = %14, %35
%19 = phi i32 [ %37, %35 ], [ 1, %14 ]
%20 = phi i32 [ %36, %35 ], [ %15, %14 ]
%21 = tail call %struct.OlLrcItem* @ol_lrc_get_item(%struct.OlLrc* %1, i32 %19)
%22 = icmp eq %struct.OlLrcItem* %21, null
br i1 %22, label %23, label %25
23: ; preds = %18
%24 = tail call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), i32 43, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
br label %25
25: ; preds = %23, %18
%26 = tail call i32 @ol_lrc_item_get_id(%struct.OlLrcItem* %21)
%27 = icmp eq i32 %26, %19
br i1 %27, label %30, label %28
28: ; preds = %25
%29 = tail call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), i32 44, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0))
br label %30
30: ; preds = %25, %28
%31 = tail call i32 @ol_lrc_item_get_time(%struct.OlLrcItem* %21)
%32 = icmp slt i32 %31, %20
br i1 %32, label %33, label %35
33: ; preds = %30
%34 = tail call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), i32 46, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.4, i64 0, i64 0))
br label %35
35: ; preds = %30, %33
%36 = tail call i32 @ol_lrc_item_get_time(%struct.OlLrcItem* %21)
%37 = add nuw nsw i32 %19, 1
%38 = tail call i32 @ol_lrc_item_count(%struct.OlLrc* %1)
%39 = icmp slt i32 %37, %38
br i1 %39, label %18, label %40
40: ; preds = %35, %14, %0
%41 = tail call i32 @ol_lrc_free(%struct.OlLrc* %1)
ret void
}