#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 */
int /*<<< orphan*/ strcmp(char *, char *);
int bind_to_enum(char *str, char **emap, int *eval, int emap_sz, int *res) {
  int i;
  for (i = 0; i < emap_sz; i++) {
    if (!strcmp(str, emap[i])) {
      if (eval) {
        *res = eval[i];
      } else {
        *res = i;
      }
      return 1;
    }
  }
  *res = -1;
  return 0;
}


x86 assembly (clang, -O0):
<bind_to_enum>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %ecx,-0x24(%rbp)
mov    %r8,-0x30(%rbp)
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x24(%rbp),%eax
jge    11a5 <bind_to_enum+0x95>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
jne    1192 <bind_to_enum+0x82>
cmpq   $0x0,-0x20(%rbp)
je     117d <bind_to_enum+0x6d>
mov    -0x20(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    (%rax,%rcx,4),%ecx
mov    -0x30(%rbp),%rax
mov    %ecx,(%rax)
jmp    1186 <bind_to_enum+0x76>
mov    -0x34(%rbp),%ecx
mov    -0x30(%rbp),%rax
mov    %ecx,(%rax)
movl   $0x1,-0x4(%rbp)
jmp    11b6 <bind_to_enum+0xa6>
jmp    1197 <bind_to_enum+0x87>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1132 <bind_to_enum+0x22>
mov    -0x30(%rbp),%rax
movl   $0xffffffff,(%rax)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<bind_to_enum>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    $0xffffffff,%r13d
test   %ecx,%ecx
jle    115d <bind_to_enum+0x4d>
mov    %rdx,%r15
mov    %rsi,%r12
mov    %rdi,%rbx
mov    %r8,(%rsp)
mov    %ecx,%r14d
xor    %ebp,%ebp
nopw   0x0(%rax,%rax,1)
mov    (%r12,%rbp,8),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %eax,%eax
je     1161 <bind_to_enum+0x51>
add    $0x1,%rbp
cmp    %rbp,%r14
jne    1140 <bind_to_enum+0x30>
xor    %eax,%eax
jmp    1179 <bind_to_enum+0x69>
xor    %eax,%eax
jmp    117d <bind_to_enum+0x6d>
test   %r15,%r15
je     1171 <bind_to_enum+0x61>
mov    (%r15,%rbp,4),%r13d
mov    $0x1,%eax
jmp    1179 <bind_to_enum+0x69>
mov    $0x1,%eax
mov    %ebp,%r13d
mov    (%rsp),%r8
mov    %r13d,(%r8)
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define i32 @bind_to_enum(i8* nocapture %0, i8** nocapture %1, i32* %2, i32 %3, i32* nocapture writeonly %4) {
%6 = icmp sgt i32 %3, 0
br i1 %6, label %7, label %25
7: ; preds = %5
%8 = zext i32 %3 to i64
br label %9
9: ; preds = %7, %22
%10 = phi i64 [ 0, %7 ], [ %23, %22 ]
%11 = getelementptr inbounds i8*, i8** %1, i64 %10
%12 = load i8*, i8** %11
%13 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* dereferenceable(1) %12)
%14 = icmp eq i32 %13, 0
br i1 %14, label %15, label %22
15: ; preds = %9
%16 = trunc i64 %10 to i32
%17 = icmp eq i32* %2, null
br i1 %17, label %25, label %18
18: ; preds = %15
%19 = and i64 %10, 4294967295
%20 = getelementptr inbounds i32, i32* %2, i64 %19
%21 = load i32, i32* %20
br label %25
22: ; preds = %9
%23 = add nuw nsw i64 %10, 1
%24 = icmp eq i64 %23, %8
br i1 %24, label %25, label %9
25: ; preds = %22, %5, %18, %15
%26 = phi i32 [ %21, %18 ], [ %16, %15 ], [ -1, %5 ], [ -1, %22 ]
%27 = phi i32 [ 1, %18 ], [ 1, %15 ], [ 0, %5 ], [ 0, %22 ]
store i32 %26, i32* %4
ret i32 %27
}