#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 *);
int asx_attrib_to_enum(const char *val, char **valid_vals) {
  char **ptr;
  int r = 0;
  if (valid_vals == NULL || val == NULL)
    return -2;
  for (ptr = valid_vals; ptr[0] != NULL; ptr++) {
    if (strcasecmp(val, ptr[0]) == 0)
      return r;
    r++;
  }
  return -1;
}


x86 assembly (clang, -O0):
<asx_attrib_to_enum>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movl   $0x0,-0x24(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     113d <asx_attrib_to_enum+0x2d>
cmpq   $0x0,-0x10(%rbp)
jne    1149 <asx_attrib_to_enum+0x39>
movl   $0xfffffffe,-0x4(%rbp)
jmp    11a5 <asx_attrib_to_enum+0x95>
mov    -0x18(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmpq   $0x0,(%rax)
je     119e <asx_attrib_to_enum+0x8e>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rax
mov    (%rax),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%rax
jne    1184 <asx_attrib_to_enum+0x74>
mov    -0x24(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11a5 <asx_attrib_to_enum+0x95>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
mov    -0x20(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x20(%rbp)
jmp    1151 <asx_attrib_to_enum+0x41>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<asx_attrib_to_enum>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    $0xfffffffe,%r14d
test   %rdi,%rdi
je     1160 <asx_attrib_to_enum+0x50>
mov    %rsi,%r15
test   %rsi,%rsi
je     1160 <asx_attrib_to_enum+0x50>
mov    (%r15),%rsi
mov    $0xffffffff,%r14d
test   %rsi,%rsi
je     1160 <asx_attrib_to_enum+0x50>
mov    %rdi,%rbp
xor    %ebx,%ebx
nopl   (%rax)
mov    %rbp,%rdi
call   1030 <strcasecmp@plt>
test   %rax,%rax
je     115d <asx_attrib_to_enum+0x4d>
mov    0x8(%r15,%rbx,8),%rsi
add    $0x1,%rbx
test   %rsi,%rsi
jne    1140 <asx_attrib_to_enum+0x30>
jmp    1160 <asx_attrib_to_enum+0x50>
mov    %ebx,%r14d
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

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