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

/* Variables and functions */
int /*<<< orphan*/ assert(int);
int /*<<< orphan*/ str_list_clear_fn(struct str_list *, int /*<<< orphan*/ *);
struct str_list *str_list_create();
int /*<<< orphan*/ str_list_destroy(struct str_list *);
int str_list_indexof(struct str_list *, char *);
int /*<<< orphan*/ str_list_insert(struct str_list *, char *);
void test_indexof() {
  struct str_list *l = str_list_create();
  str_list_insert(l, "a");
  str_list_insert(l, "b");
  str_list_insert(l, "c");
  assert(str_list_indexof(l, "a") == 0);
  assert(str_list_indexof(l, "b") == 1);
  assert(str_list_indexof(l, "c") == 2);
  str_list_clear_fn(l, NULL);
  str_list_destroy(l);
}


x86 assembly (clang, -O0):
<test_indexof>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x0,%al
call   1040 <str_list_create@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe82(%rip),%rsi
call   1050 <str_list_insert@plt>
mov    -0x8(%rbp),%rdi
lea    0xe74(%rip),%rsi
call   1050 <str_list_insert@plt>
mov    -0x8(%rbp),%rdi
lea    0xe66(%rip),%rsi
call   1050 <str_list_insert@plt>
mov    -0x8(%rbp),%rdi
lea    0xe52(%rip),%rsi
call   1030 <str_list_indexof@plt>
cmp    $0x0,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
mov    -0x8(%rbp),%rdi
lea    0xe34(%rip),%rsi
call   1030 <str_list_indexof@plt>
cmp    $0x1,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
mov    -0x8(%rbp),%rdi
lea    0xe16(%rip),%rsi
call   1030 <str_list_indexof@plt>
cmp    $0x2,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
mov    -0x8(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1070 <str_list_clear_fn@plt>
mov    -0x8(%rbp),%rdi
call   1080 <str_list_destroy@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_indexof>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
xor    %eax,%eax
call   1040 <str_list_create@plt>
mov    %rax,%rbx
lea    0xe87(%rip),%r15
mov    %rax,%rdi
mov    %r15,%rsi
call   1050 <str_list_insert@plt>
lea    0xe77(%rip),%r12
mov    %rbx,%rdi
mov    %r12,%rsi
call   1050 <str_list_insert@plt>
lea    0xe67(%rip),%r14
mov    %rbx,%rdi
mov    %r14,%rsi
call   1050 <str_list_insert@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1030 <str_list_indexof@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
call   1060 <assert@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
call   1030 <str_list_indexof@plt>
xor    %edi,%edi
cmp    $0x1,%eax
sete   %dil
call   1060 <assert@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1030 <str_list_indexof@plt>
xor    %edi,%edi
cmp    $0x2,%eax
sete   %dil
call   1060 <assert@plt>
mov    %rbx,%rdi
xor    %esi,%esi
call   1070 <str_list_clear_fn@plt>
mov    %rbx,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1080 <str_list_destroy@plt>

LLVM IR (-O0):
%struct.str_list = type { i32 }
@.str = [2 x i8] c"a\00"
@.str.1 = [2 x i8] c"b\00"
@.str.2 = [2 x i8] c"c\00"
define void @test_indexof() {
%1 = alloca %struct.str_list*
%2 = call %struct.str_list* (...) @str_list_create()
store %struct.str_list* %2, %struct.str_list** %1
%3 = load %struct.str_list*, %struct.str_list** %1
%4 = call i32 @str_list_insert(%struct.str_list* %3, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%5 = load %struct.str_list*, %struct.str_list** %1
%6 = call i32 @str_list_insert(%struct.str_list* %5, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%7 = load %struct.str_list*, %struct.str_list** %1
%8 = call i32 @str_list_insert(%struct.str_list* %7, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%9 = load %struct.str_list*, %struct.str_list** %1
%10 = call i32 @str_list_indexof(%struct.str_list* %9, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%11 = icmp eq i32 %10, 0
%12 = zext i1 %11 to i32
%13 = call i32 @assert(i32 %12)
%14 = load %struct.str_list*, %struct.str_list** %1
%15 = call i32 @str_list_indexof(%struct.str_list* %14, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%16 = icmp eq i32 %15, 1
%17 = zext i1 %16 to i32
%18 = call i32 @assert(i32 %17)
%19 = load %struct.str_list*, %struct.str_list** %1
%20 = call i32 @str_list_indexof(%struct.str_list* %19, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%21 = icmp eq i32 %20, 2
%22 = zext i1 %21 to i32
%23 = call i32 @assert(i32 %22)
%24 = load %struct.str_list*, %struct.str_list** %1
%25 = call i32 @str_list_clear_fn(%struct.str_list* %24, i32* null)
%26 = load %struct.str_list*, %struct.str_list** %1
%27 = call i32 @str_list_destroy(%struct.str_list* %26)
ret void
}

LLVM IR (-O2):
%struct.str_list = type { i32 }
@.str = [2 x i8] c"a\00"
@.str.1 = [2 x i8] c"b\00"
@.str.2 = [2 x i8] c"c\00"
define void @test_indexof() {
%1 = tail call %struct.str_list* (...) @str_list_create()
%2 = tail call i32 @str_list_insert(%struct.str_list* %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%3 = tail call i32 @str_list_insert(%struct.str_list* %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%4 = tail call i32 @str_list_insert(%struct.str_list* %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%5 = tail call i32 @str_list_indexof(%struct.str_list* %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%6 = icmp eq i32 %5, 0
%7 = zext i1 %6 to i32
%8 = tail call i32 @assert(i32 %7)
%9 = tail call i32 @str_list_indexof(%struct.str_list* %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%10 = icmp eq i32 %9, 1
%11 = zext i1 %10 to i32
%12 = tail call i32 @assert(i32 %11)
%13 = tail call i32 @str_list_indexof(%struct.str_list* %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%14 = icmp eq i32 %13, 2
%15 = zext i1 %14 to i32
%16 = tail call i32 @assert(i32 %15)
%17 = tail call i32 @str_list_clear_fn(%struct.str_list* %1, i32* null)
%18 = tail call i32 @str_list_destroy(%struct.str_list* %1)
ret void
}