#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 *);
int searchArray(char **dictionary, int wordCount, char *word) {
  int found = -1;
  for (int i = 0; i < wordCount; i++) {
    if (strcmp(dictionary[i], word) == 0) {
      found = i;
    }
  }
  return found;
}


x86 assembly (clang, -O0):
<searchArray>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0xffffffff,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1175 <searchArray+0x65>
mov    -0x8(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    1162 <searchArray+0x52>
mov    -0x20(%rbp),%eax
mov    %eax,-0x1c(%rbp)
jmp    1167 <searchArray+0x57>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1131 <searchArray+0x21>
mov    -0x1c(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<searchArray>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
test   %esi,%esi
jle    114d <searchArray+0x3d>
mov    %rdx,%r14
mov    %rdi,%r15
mov    %esi,%r12d
mov    $0xffffffff,%ebp
xor    %ebx,%ebx
nopl   0x0(%rax)
mov    (%r15,%rbx,8),%rdi
mov    %r14,%rsi
call   1030 <strcmp@plt>
test   %rax,%rax
cmove  %ebx,%ebp
add    $0x1,%rbx
cmp    %rbx,%r12
jne    1130 <searchArray+0x20>
jmp    1152 <searchArray+0x42>
mov    $0xffffffff,%ebp
mov    %ebp,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

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