#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 */

/* Variables and functions */
int /*<<< orphan*/ strcmp(char *, char *);
int findString(char *name, char **namelist) {
  int i;
  for (i = 0; *namelist; ++namelist, ++i)
    if (!strcmp(name, *namelist))
      return i;
  return -1;
}


x86 assembly (clang, -O0):
<findString>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x18(%rbp),%rax
cmpq   $0x0,(%rax)
je     1178 <findString+0x68>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rax
mov    (%rax),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
jne    1159 <findString+0x49>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    117f <findString+0x6f>
jmp    115e <findString+0x4e>
mov    -0x18(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x18(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1127 <findString+0x17>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<findString>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    (%rsi),%rsi
mov    $0xffffffff,%r14d
test   %rsi,%rsi
je     114f <findString+0x3f>
mov    %rdi,%r15
xor    %ebp,%ebp
nopl   (%rax)
mov    %r15,%rdi
call   1030 <strcmp@plt>
test   %eax,%eax
je     114c <findString+0x3c>
mov    0x8(%rbx,%rbp,8),%rsi
add    $0x1,%rbp
test   %rsi,%rsi
jne    1130 <findString+0x20>
jmp    114f <findString+0x3f>
mov    %ebp,%r14d
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

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