#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*/ ci_strcmp(char const *, char const *);
int helpmod_select(const char *str, const char **strs, int *enums, int count) {
  int i;
  if (count == 0)
    return -1;
  for (i = 0; i < count; i++)
    if (!ci_strcmp(strs[i], str))
      return enums[i];
  return -1;
}


x86 assembly (clang, -O0):
<helpmod_select>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %ecx,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
jne    113d <helpmod_select+0x2d>
movl   $0xffffffff,-0x4(%rbp)
jmp    119b <helpmod_select+0x8b>
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x24(%rbp),%eax
jge    1194 <helpmod_select+0x84>
mov    -0x18(%rbp),%rax
movslq -0x28(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <ci_strcmp@plt>
cmp    $0x0,%eax
jne    1181 <helpmod_select+0x71>
mov    -0x20(%rbp),%rax
movslq -0x28(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x4(%rbp)
jmp    119b <helpmod_select+0x8b>
jmp    1186 <helpmod_select+0x76>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1144 <helpmod_select+0x34>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<helpmod_select>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    $0xffffffff,%r15d
test   %ecx,%ecx
jle    115f <helpmod_select+0x4f>
mov    %rdx,%r14
mov    %rsi,%r12
mov    %rdi,%r13
mov    %ecx,%ebx
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    (%r12,%rbp,8),%rdi
mov    %r13,%rsi
call   1030 <ci_strcmp@plt>
test   %eax,%eax
je     115b <helpmod_select+0x4b>
add    $0x1,%rbp
cmp    %rbp,%rbx
jne    1140 <helpmod_select+0x30>
jmp    115f <helpmod_select+0x4f>
mov    (%r14,%rbp,4),%r15d
mov    %r15d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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