#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 */
typedef size_t int8_t;

/* Variables and functions */
int /*<<< orphan*/ strcmp(char const *, char const *const);
int parse_enum(const char *arg, const char *const *names, int8_t *dst) {
  int8_t i;
  for (i = 0; names[i]; i++) {
    if (!strcmp(arg, names[i])) {
      *dst = i;
      return 1;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<parse_enum>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
mov    -0x18(%rbp),%rax
mov    -0x28(%rbp),%rcx
cmpq   $0x0,(%rax,%rcx,8)
je     118a <parse_enum+0x7a>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rax
mov    -0x28(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
jne    1174 <parse_enum+0x64>
mov    -0x28(%rbp),%rcx
mov    -0x20(%rbp),%rax
mov    %rcx,(%rax)
movl   $0x1,-0x4(%rbp)
jmp    1191 <parse_enum+0x81>
jmp    1179 <parse_enum+0x69>
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    112c <parse_enum+0x1c>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_enum>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r12
mov    (%rsi),%rsi
test   %rsi,%rsi
je     114a <parse_enum+0x3a>
mov    %rdx,%r14
mov    %rdi,%r15
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
mov    %r15,%rdi
call   1030 <strcmp@plt>
test   %eax,%eax
je     114e <parse_enum+0x3e>
mov    0x8(%r12,%rbx,8),%rsi
add    $0x1,%rbx
test   %rsi,%rsi
jne    1130 <parse_enum+0x20>
xor    %eax,%eax
jmp    1156 <parse_enum+0x46>
mov    %rbx,(%r14)
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

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