#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 *, size_t);
size_t strlen(char const *);
int findAction(const char **actions, const char *action) {
  size_t 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    %rax,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
cmpq   $0x0,(%rax,%rcx,8)
je     11cb <findAction+0x9b>
mov    -0x20(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1030 <strlen@plt>
mov    %rax,%rcx
mov    -0x30(%rbp),%rax
cmp    %rcx,%rax
jne    11b8 <findAction+0x88>
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1050 <ignoreCaseComp@plt>
cmp    $0x0,%rax
jne    11b8 <findAction+0x88>
jmp    11cb <findAction+0x9b>
jmp    11bd <findAction+0x8d>
mov    -0x24(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x24(%rbp)
jmp    1154 <findAction+0x24>
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
cmpq   $0x0,(%rax,%rcx,8)
jne    11ea <findAction+0xba>
movl   $0xffffffff,-0x4(%rbp)
jmp    1203 <findAction+0xd3>
mov    -0x10(%rbp),%rax
mov    -0x24(%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   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rsi,%r14
mov    %rdi,%r15
mov    %rsi,%rdi
call   1030 <strlen@plt>
mov    (%r15),%rbx
test   %rbx,%rbx
je     11b8 <findAction+0x88>
mov    %rax,%r12
xor    %r13d,%r13d
jmp    116e <findAction+0x3e>
nopw   0x0(%rax,%rax,1)
mov    0x10(%r15,%r13,8),%rbx
add    $0x2,%r13
test   %rbx,%rbx
je     11b8 <findAction+0x88>
mov    %rbx,%rdi
call   1030 <strlen@plt>
cmp    %rax,%r12
jne    1160 <findAction+0x30>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %r12,%rdx
call   1050 <ignoreCaseComp@plt>
test   %rax,%rax
jne    1160 <findAction+0x30>
mov    %r13d,%eax
and    $0xfffffffe,%eax
cmpq   $0x0,(%r15,%rax,8)
je     11b8 <findAction+0x88>
mov    %r13d,%eax
shl    $0x3,%rax
or     $0x8,%rax
mov    (%r15,%rax,1),%rdi
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
jmp    1040 <atoi@plt>
mov    $0xffffffff,%eax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i32 @findAction(i8** %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca i8*
%6 = alloca i64
%7 = alloca i32
store i8** %0, i8*** %4
store i8* %1, i8** %5
%8 = load i8*, i8** %5
%9 = call i64 @strlen(i8* %8)
store i64 %9, i64* %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 i64, i64* %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 i64 @strlen(i8* %23)
%25 = icmp eq i64 %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 i64, i64* %6
%34 = call i64 @ignoreCaseComp(i8* %31, i8* %32, i64 %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 i64 @strlen(i8* dereferenceable(1) %1)
%4 = load i8*, i8** %0
%5 = icmp eq i8* %4, null
br i1 %5, label %30, label %6
6: ; preds = %2, %14
%7 = phi i64 [ %15, %14 ], [ 0, %2 ]
%8 = phi i8* [ %17, %14 ], [ %4, %2 ]
%9 = tail call i64 @strlen(i8* %8)
%10 = icmp eq i64 %3, %9
br i1 %10, label %11, label %14
11: ; preds = %6
%12 = tail call i64 @ignoreCaseComp(i8* %8, i8* %1, i64 %3)
%13 = icmp eq i64 %12, 0
br i1 %13, label %19, label %14
14: ; preds = %6, %11
%15 = add nuw i64 %7, 2
%16 = getelementptr inbounds i8*, i8** %0, i64 %15
%17 = load i8*, i8** %16
%18 = icmp eq i8* %17, null
br i1 %18, label %30, label %6
19: ; preds = %11
%20 = and i64 %7, 4294967294
%21 = getelementptr inbounds i8*, i8** %0, i64 %20
%22 = load i8*, i8** %21
%23 = icmp eq i8* %22, null
br i1 %23, label %30, label %24
24: ; preds = %19
%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 = %14, %2, %19, %24
%31 = phi i32 [ %29, %24 ], [ -1, %19 ], [ -1, %2 ], [ -1, %14 ]
ret i32 %31
}