#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 atoi(char const *);
scalar_t__ ignoreCaseComp(char const *, char const *, int);
int strlen(char const *);
int findAction(const char **actions, const char *action) {
  int actionLength = strlen(action);
  int k;
  for (k = 0; actions[k]; k += 2)
    if (actionLength == strlen(actions[k]) &&
        ignoreCaseComp(actions[k], action, actionLength) == 0)
      break;
  if (actions[k] == NULL)
    return -1;
  return atoi(actions[k + 1]);
}


x86 assembly (clang, -O0):
<findAction>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
cmpq   $0x0,(%rax,%rcx,8)
je     11c4 <findAction+0x94>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x24(%rbp),%eax
cmp    %ecx,%eax
jne    11b1 <findAction+0x81>
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x1c(%rbp),%edx
call   1050 <ignoreCaseComp@plt>
cmp    $0x0,%rax
jne    11b1 <findAction+0x81>
jmp    11c4 <findAction+0x94>
jmp    11b6 <findAction+0x86>
mov    -0x20(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x20(%rbp)
jmp    1153 <findAction+0x23>
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
cmpq   $0x0,(%rax,%rcx,8)
jne    11e3 <findAction+0xb3>
movl   $0xffffffff,-0x4(%rbp)
jmp    11fc <findAction+0xcc>
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rdi
call   1040 <atoi@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<findAction>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%r15
mov    %rsi,%rdi
call   1030 <strlen@plt>
mov    (%r15),%rdi
test   %rdi,%rdi
je     11ae <findAction+0x7e>
mov    %eax,%ebp
xor    %ebx,%ebx
jmp    116e <findAction+0x3e>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    0x10(%r15,%rbx,8),%rdi
add    $0x2,%rbx
test   %rdi,%rdi
je     11ae <findAction+0x7e>
call   1030 <strlen@plt>
cmp    %eax,%ebp
jne    1160 <findAction+0x30>
mov    (%r15,%rbx,8),%rdi
mov    %r14,%rsi
mov    %ebp,%edx
call   1050 <ignoreCaseComp@plt>
test   %rax,%rax
jne    1160 <findAction+0x30>
cmpq   $0x0,(%r15,%rbx,8)
je     11ae <findAction+0x7e>
mov    %ebx,%eax
shl    $0x3,%rax
or     $0x8,%rax
mov    (%r15,%rax,1),%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <atoi@plt>
mov    $0xffffffff,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define i32 @findAction(i8** nocapture %0, i8* %1) {
%3 = tail call i32 @strlen(i8* %1)
%4 = load i8*, i8** %0
%5 = icmp eq i8* %4, null
br i1 %5, label %30, label %6
6: ; preds = %2, %16
%7 = phi i64 [ %17, %16 ], [ 0, %2 ]
%8 = phi i8* [ %19, %16 ], [ %4, %2 ]
%9 = phi i8** [ %18, %16 ], [ %0, %2 ]
%10 = tail call i32 @strlen(i8* %8)
%11 = icmp eq i32 %3, %10
br i1 %11, label %12, label %16
12: ; preds = %6
%13 = load i8*, i8** %9
%14 = tail call i64 @ignoreCaseComp(i8* %13, i8* %1, i32 %3)
%15 = icmp eq i64 %14, 0
br i1 %15, label %21, label %16
16: ; preds = %6, %12
%17 = add nuw i64 %7, 2
%18 = getelementptr inbounds i8*, i8** %0, i64 %17
%19 = load i8*, i8** %18
%20 = icmp eq i8* %19, null
br i1 %20, label %30, label %6
21: ; preds = %12
%22 = load i8*, i8** %9
%23 = icmp eq i8* %22, null
br i1 %23, label %30, label %24
24: ; preds = %21
%25 = and i64 %7, 4294967294
%26 = or i64 %25, 1
%27 = getelementptr inbounds i8*, i8** %0, i64 %26
%28 = load i8*, i8** %27
%29 = tail call i32 @atoi(i8* %28)
br label %30
30: ; preds = %16, %2, %21, %24
%31 = phi i32 [ %29, %24 ], [ -1, %21 ], [ -1, %2 ], [ -1, %16 ]
ret i32 %31
}