#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__ strcasecmp(char const *, char const *);
int _parse_enum(char const **strings, char const *string) {
  size_t i;
  for (i = 0; strings[i] != NULL; i++)
    if (strcasecmp(strings[i], string) == 0)
      return i;
  return -1;
}


x86 assembly (clang, -O0):
<_parse_enum>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%rcx
cmpq   $0x0,(%rax,%rcx,8)
je     117c <_parse_enum+0x6c>
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%rax
jne    1166 <_parse_enum+0x56>
mov    -0x20(%rbp),%rax
mov    %eax,-0x4(%rbp)
jmp    1183 <_parse_enum+0x73>
jmp    116b <_parse_enum+0x5b>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    1128 <_parse_enum+0x18>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_parse_enum>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbp
mov    (%rdi),%rdi
mov    $0xffffffff,%r14d
test   %rdi,%rdi
je     1150 <_parse_enum+0x40>
mov    %rsi,%r15
xor    %ebx,%ebx
nopl   (%rax)
mov    %r15,%rsi
call   1030 <strcasecmp@plt>
test   %rax,%rax
je     114d <_parse_enum+0x3d>
mov    0x8(%rbp,%rbx,8),%rdi
add    $0x1,%rbx
test   %rdi,%rdi
jne    1130 <_parse_enum+0x20>
jmp    1150 <_parse_enum+0x40>
mov    %ebx,%r14d
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

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