#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 const *, char const *const);
int /*<<< orphan*/ usage(char *, char const *, char const *);
int getenum(const char *v, const char *const *l, const char *w) {
  int i = 0;
  while (*l && strcmp(v, *l)) {
    l++;
    i++;
  }
  if (!*l)
    usage("%s value `%s' unknown", w, v);
  return i;
}


x86 assembly (clang, -O0):
<getenum>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x10(%rbp),%rcx
xor    %eax,%eax
cmpq   $0x0,(%rcx)
mov    %al,-0x1d(%rbp)
je     1168 <getenum+0x48>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
setne  %al
mov    %al,-0x1d(%rbp)
mov    -0x1d(%rbp),%al
test   $0x1,%al
jne    1178 <getenum+0x58>
jmp    1192 <getenum+0x72>
mov    -0x10(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x10(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    113b <getenum+0x1b>
mov    -0x10(%rbp),%rax
cmpq   $0x0,(%rax)
jne    11b4 <getenum+0x94>
mov    -0x18(%rbp),%rsi
mov    -0x8(%rbp),%rdx
lea    0xe51(%rip),%rdi
call   1040 <usage@plt>
mov    -0x1c(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getenum>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %rsi,%r12
mov    %rdi,%r15
mov    (%rsi),%rsi
xor    %ebx,%ebx
test   %rsi,%rsi
je     115b <getenum+0x3b>
nopl   0x0(%rax,%rax,1)
mov    %r15,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     116f <getenum+0x4f>
mov    0x8(%r12,%rbx,8),%rsi
add    $0x1,%rbx
test   %rsi,%rsi
jne    1140 <getenum+0x20>
lea    0xe9e(%rip),%rdi
mov    %r14,%rsi
mov    %r15,%rdx
call   1040 <usage@plt>
jmp    1176 <getenum+0x56>
cmpq   $0x0,(%r12,%rbx,8)
je     115b <getenum+0x3b>
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [22 x i8] c"%s value `%s' unknown\00"
define i32 @getenum(i8* %0, i8** %1, i8* %2) {
%4 = alloca i8*
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i32
store i8* %0, i8** %4
store i8** %1, i8*** %5
store i8* %2, i8** %6
store i32 0, i32* %7
br label %8
8: ; preds = %20, %3
%9 = load i8**, i8*** %5
%10 = load i8*, i8** %9
%11 = icmp ne i8* %10, null
br i1 %11, label %12, label %18
12: ; preds = %8
%13 = load i8*, i8** %4
%14 = load i8**, i8*** %5
%15 = load i8*, i8** %14
%16 = call i64 @strcmp(i8* %13, i8* %15)
%17 = icmp ne i64 %16, 0
br label %18
18: ; preds = %12, %8
%19 = phi i1 [ false, %8 ], [ %17, %12 ]
br i1 %19, label %20, label %25
20: ; preds = %18
%21 = load i8**, i8*** %5
%22 = getelementptr inbounds i8*, i8** %21, i32 1
store i8** %22, i8*** %5
%23 = load i32, i32* %7
%24 = add nsw i32 %23, 1
store i32 %24, i32* %7
br label %8
25: ; preds = %18
%26 = load i8**, i8*** %5
%27 = load i8*, i8** %26
%28 = icmp ne i8* %27, null
br i1 %28, label %33, label %29
29: ; preds = %25
%30 = load i8*, i8** %6
%31 = load i8*, i8** %4
%32 = call i32 @usage(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* %30, i8* %31)
br label %33
33: ; preds = %29, %25
%34 = load i32, i32* %7
ret i32 %34
}

LLVM IR (-O2):
@.str = [22 x i8] c"%s value `%s' unknown\00"
define i32 @getenum(i8* %0, i8** nocapture %1, i8* %2) {
%4 = load i8*, i8** %1
%5 = icmp eq i8* %4, null
br i1 %5, label %20, label %6
6: ; preds = %3, %12
%7 = phi i8* [ %15, %12 ], [ %4, %3 ]
%8 = phi i32 [ %14, %12 ], [ 0, %3 ]
%9 = phi i8** [ %13, %12 ], [ %1, %3 ]
%10 = tail call i64 @strcmp(i8* %0, i8* %7)
%11 = icmp eq i64 %10, 0
br i1 %11, label %17, label %12
12: ; preds = %6
%13 = getelementptr inbounds i8*, i8** %9, i64 1
%14 = add nuw nsw i32 %8, 1
%15 = load i8*, i8** %13
%16 = icmp eq i8* %15, null
br i1 %16, label %20, label %6
17: ; preds = %6
%18 = load i8*, i8** %9
%19 = icmp eq i8* %18, null
br i1 %19, label %20, label %23
20: ; preds = %12, %3, %17
%21 = phi i32 [ %8, %17 ], [ 0, %3 ], [ %14, %12 ]
%22 = tail call i32 @usage(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* %2, i8* %0)
br label %23
23: ; preds = %20, %17
%24 = phi i32 [ %21, %20 ], [ %8, %17 ]
ret i32 %24
}