#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 */
scalar_t__ strcmp(char *, char const *);
bool findKey(char **keys, const char *seek, unsigned int *index) {
  for (unsigned int i = 0; keys[i] != NULL; i++) {
    if (strcmp(keys[i], seek) == 0) {
      return true;
    }
    (*index)++;
  }
  return false;
}


x86 assembly (clang, -O0):
<findKey>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x24(%rbp),%ecx
cmpq   $0x0,(%rax,%rcx,8)
je     1180 <findKey+0x70>
mov    -0x10(%rbp),%rax
mov    -0x24(%rbp),%ecx
mov    (%rax,%rcx,8),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    1167 <findKey+0x57>
movl   $0x1,-0x4(%rbp)
jmp    1187 <findKey+0x77>
mov    -0x20(%rbp),%rax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    %ecx,(%rax)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    112b <findKey+0x1b>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<findKey>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
mov    (%rdi),%rdi
test   %rdi,%rdi
je     1159 <findKey+0x49>
mov    %rdx,%r14
mov    %rsi,%r15
mov    $0x1,%ebp
nopl   (%rax)
mov    %r15,%rsi
call   1030 <strcmp@plt>
test   %rax,%rax
je     114f <findKey+0x3f>
addl   $0x1,(%r14)
mov    %ebp,%ecx
mov    (%rbx,%rcx,8),%rdi
add    $0x1,%ebp
test   %rdi,%rdi
jne    1130 <findKey+0x20>
xor    %ecx,%ecx
test   %rax,%rax
sete   %cl
jmp    115b <findKey+0x4b>
xor    %ecx,%ecx
mov    %ecx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

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