#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 *const);
int snoopy_genericregistry_getIdFromName(char *regArray[],
                                         char const *const itemName) {
  for (int i = 0; 0 != strcmp(regArray[i], ""); i++) {
    if (strcmp(regArray[i], itemName) == 0) {
      return i;
    }
  }
  return -1;
}


x86 assembly (clang, -O0):
<snoopy_genericregistry_getIdFromName>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xec6(%rip),%rsi
call   1030 <strcmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
je     118a <snoopy_genericregistry_getIdFromName+0x7a>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    1177 <snoopy_genericregistry_getIdFromName+0x67>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1191 <snoopy_genericregistry_getIdFromName+0x81>
jmp    117c <snoopy_genericregistry_getIdFromName+0x6c>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1127 <snoopy_genericregistry_getIdFromName+0x17>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<snoopy_genericregistry_getIdFromName>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rsi,%r14
mov    %rdi,%rbx
mov    (%rdi),%rdi
lea    0xed8(%rip),%rsi
call   1030 <strcmp@plt>
mov    $0xffffffff,%r15d
test   %rax,%rax
je     117c <snoopy_genericregistry_getIdFromName+0x6c>
xor    %ebp,%ebp
lea    0xebf(%rip),%r12
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    (%rbx,%rbp,8),%rdi
mov    %r14,%rsi
call   1030 <strcmp@plt>
test   %rax,%rax
je     1179 <snoopy_genericregistry_getIdFromName+0x69>
mov    0x8(%rbx,%rbp,8),%rdi
add    $0x1,%rbp
mov    %r12,%rsi
call   1030 <strcmp@plt>
test   %rax,%rax
jne    1150 <snoopy_genericregistry_getIdFromName+0x40>
jmp    117c <snoopy_genericregistry_getIdFromName+0x6c>
mov    %ebp,%r15d
mov    %r15d,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

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