#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 const *, char const *);
signed int GetKeyIndex(const char **ppKeys, const char *szKey,
                       const unsigned int len) {
  signed int i = 0;
  do {
    if (!strcmp(ppKeys[i], szKey))
      return i;
  } while (++i < len);
  return -1;
}


x86 assembly (clang, -O0):
<GetKeyIndex>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
jne    1153 <GetKeyIndex+0x43>
mov    -0x20(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1171 <GetKeyIndex+0x61>
jmp    1158 <GetKeyIndex+0x48>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
cmp    -0x1c(%rbp),%eax
jb     112a <GetKeyIndex+0x1a>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<GetKeyIndex>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%r15
cmp    $0x2,%edx
mov    $0x1,%r12d
cmovae %edx,%r12d
xor    %ebx,%ebx
nopl   (%rax)
mov    (%r15,%rbx,8),%rdi
mov    %r14,%rsi
call   1030 <strcmp@plt>
test   %eax,%eax
je     114e <GetKeyIndex+0x3e>
add    $0x1,%rbx
cmp    %rbx,%r12
jne    1130 <GetKeyIndex+0x20>
mov    $0xffffffff,%ebx
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i32 @GetKeyIndex(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 = %21, %3
%10 = load i8**, i8*** %5
%11 = load i32, i32* %8
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds i8*, i8** %10, i64 %12
%14 = load i8*, i8** %13
%15 = load i8*, i8** %6
%16 = call i32 @strcmp(i8* %14, i8* %15)
%17 = icmp ne i32 %16, 0
br i1 %17, label %20, label %18
18: ; preds = %9
%19 = load i32, i32* %8
store i32 %19, i32* %4
br label %27
20: ; preds = %9
br label %21
21: ; preds = %20
%22 = load i32, i32* %8
%23 = add nsw i32 %22, 1
store i32 %23, i32* %8
%24 = load i32, i32* %7
%25 = icmp ult i32 %23, %24
br i1 %25, label %9, label %26
26: ; preds = %21
store i32 -1, i32* %4
br label %27
27: ; preds = %26, %18
%28 = load i32, i32* %4
ret i32 %28
}

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