#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 */
typedef size_t ssize_t;

/* Variables and functions */
scalar_t__ string_equal(char const *, char const *);
ssize_t string_list_find(const char **list, const char *string) {
  if (list) {
    ssize_t i = 0;
    while (list[i]) {
      if (string_equal(list[i], string))
        return i;
      else
        ++i;
    }
  }
  return -1;
}


x86 assembly (clang, -O0):
<string_list_find>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1188 <string_list_find+0x78>
movq   $0x0,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%rcx
cmpq   $0x0,(%rax,%rcx,8)
je     1183 <string_list_find+0x73>
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <string_equal@plt>
cmp    $0x0,%rax
je     1172 <string_list_find+0x62>
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    1190 <string_list_find+0x80>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    1133 <string_list_find+0x23>
jmp    1188 <string_list_find+0x78>
movq   $0xffffffffffffffff,-0x8(%rbp)
ff
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<string_list_find>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    $0xffffffffffffffff,%r14
test   %rdi,%rdi
je     1160 <string_list_find+0x50>
mov    %rdi,%r12
mov    (%rdi),%rdi
test   %rdi,%rdi
je     1160 <string_list_find+0x50>
mov    %rsi,%r15
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r15,%rsi
call   1030 <string_equal@plt>
test   %rax,%rax
jne    115d <string_list_find+0x4d>
mov    0x8(%r12,%rbx,8),%rdi
add    $0x1,%rbx
test   %rdi,%rdi
jne    1140 <string_list_find+0x30>
jmp    1160 <string_list_find+0x50>
mov    %rbx,%r14
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i64 @string_list_find(i8** %0, i8* %1) {
%3 = alloca i64
%4 = alloca i8**
%5 = alloca i8*
%6 = alloca i64
store i8** %0, i8*** %4
store i8* %1, i8** %5
%7 = load i8**, i8*** %4
%8 = icmp ne i8** %7, null
br i1 %8, label %9, label %31
9: ; preds = %2
store i64 0, i64* %6
br label %10
10: ; preds = %29, %9
%11 = load i8**, i8*** %4
%12 = load i64, i64* %6
%13 = getelementptr inbounds i8*, i8** %11, i64 %12
%14 = load i8*, i8** %13
%15 = icmp ne i8* %14, null
br i1 %15, label %16, label %30
16: ; preds = %10
%17 = load i8**, i8*** %4
%18 = load i64, i64* %6
%19 = getelementptr inbounds i8*, i8** %17, i64 %18
%20 = load i8*, i8** %19
%21 = load i8*, i8** %5
%22 = call i64 @string_equal(i8* %20, i8* %21)
%23 = icmp ne i64 %22, 0
br i1 %23, label %24, label %26
24: ; preds = %16
%25 = load i64, i64* %6
store i64 %25, i64* %3
br label %32
26: ; preds = %16
%27 = load i64, i64* %6
%28 = add i64 %27, 1
store i64 %28, i64* %6
br label %29
29: ; preds = %26
br label %10
30: ; preds = %10
br label %31
31: ; preds = %30, %2
store i64 -1, i64* %3
br label %32
32: ; preds = %31, %24
%33 = load i64, i64* %3
ret i64 %33
}

LLVM IR (-O2):
define i64 @string_list_find(i8** %0, i8* %1) {
%3 = icmp eq i8** %0, null
br i1 %3, label %17, label %4
4: ; preds = %2
%5 = load i8*, i8** %0
%6 = icmp eq i8* %5, null
br i1 %6, label %17, label %7
7: ; preds = %4, %12
%8 = phi i8* [ %15, %12 ], [ %5, %4 ]
%9 = phi i64 [ %13, %12 ], [ 0, %4 ]
%10 = tail call i64 @string_equal(i8* %8, i8* %1)
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %17
12: ; preds = %7
%13 = add i64 %9, 1
%14 = getelementptr inbounds i8*, i8** %0, i64 %13
%15 = load i8*, i8** %14
%16 = icmp eq i8* %15, null
br i1 %16, label %17, label %7
17: ; preds = %12, %7, %4, %2
%18 = phi i64 [ -1, %2 ], [ -1, %4 ], [ -1, %12 ], [ %9, %7 ]
ret i64 %18
}