#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__ case_ignore_strcmp(char const *, char const *);
signed int month_lookup(const char *m) {
  static const char *months[] = {"JAN", "FEB", "MAR", "APR", "MAY",
                                 "JUN", "JUL", "AUG", "SEP", "OCT",
                                 "NOV", "DEC", NULL};
  const char **mp;
  for (mp = months; *mp; mp++) {
    if (0 == case_ignore_strcmp(*mp, m))
      return mp - months;
  }
  return -1;
}


x86 assembly (clang, -O0):
<month_lookup>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
lea    0x2f0d(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
cmpq   $0x0,(%rax)
je     1183 <month_lookup+0x73>
mov    -0x18(%rbp),%rax
mov    (%rax),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <case_ignore_strcmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
jne    116d <month_lookup+0x5d>
mov    -0x18(%rbp),%rax
lea    0x2ed2(%rip),%rcx
sub    %rcx,%rax
sar    $0x3,%rax
mov    %eax,-0x4(%rbp)
jmp    118a <month_lookup+0x7a>
jmp    1172 <month_lookup+0x62>
mov    -0x18(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x18(%rbp)
jmp    1127 <month_lookup+0x17>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<month_lookup>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
mov    0x2f0f(%rip),%rdi
mov    $0xffffffff,%r14d
test   %rdi,%rdi
je     1160 <month_lookup+0x50>
xor    %ebp,%ebp
lea    0x2efb(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
nop
mov    %rbx,%rsi
call   1030 <case_ignore_strcmp@plt>
test   %rax,%rax
je     115d <month_lookup+0x4d>
mov    0x8(%r15,%rbp,8),%rdi
add    $0x1,%rbp
test   %rdi,%rdi
jne    1140 <month_lookup+0x30>
jmp    1160 <month_lookup+0x50>
mov    %ebp,%r14d
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@month_lookup.months = internal global [13 x i8*] [i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.10, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.11, i32 0, i32 0), i8* null]
@.str = [4 x i8] c"JAN\00"
@.str.1 = [4 x i8] c"FEB\00"
@.str.2 = [4 x i8] c"MAR\00"
@.str.3 = [4 x i8] c"APR\00"
@.str.4 = [4 x i8] c"MAY\00"
@.str.5 = [4 x i8] c"JUN\00"
@.str.6 = [4 x i8] c"JUL\00"
@.str.7 = [4 x i8] c"AUG\00"
@.str.8 = [4 x i8] c"SEP\00"
@.str.9 = [4 x i8] c"OCT\00"
@.str.10 = [4 x i8] c"NOV\00"
@.str.11 = [4 x i8] c"DEC\00"
define i32 @month_lookup(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i8**
store i8* %0, i8** %3
store i8** getelementptr inbounds ([13 x i8*], [13 x i8*]* @month_lookup.months, i64 0, i64 0), i8*** %4
br label %5
5: ; preds = %22, %1
%6 = load i8**, i8*** %4
%7 = load i8*, i8** %6
%8 = icmp ne i8* %7, null
br i1 %8, label %9, label %25
9: ; preds = %5
%10 = load i8**, i8*** %4
%11 = load i8*, i8** %10
%12 = load i8*, i8** %3
%13 = call i64 @case_ignore_strcmp(i8* %11, i8* %12)
%14 = icmp eq i64 0, %13
br i1 %14, label %15, label %21
15: ; preds = %9
%16 = load i8**, i8*** %4
%17 = ptrtoint i8** %16 to i64
%18 = sub i64 %17, ptrtoint ([13 x i8*]* @month_lookup.months to i64)
%19 = sdiv exact i64 %18, 8
%20 = trunc i64 %19 to i32
store i32 %20, i32* %2
br label %26
21: ; preds = %9
br label %22
22: ; preds = %21
%23 = load i8**, i8*** %4
%24 = getelementptr inbounds i8*, i8** %23, i32 1
store i8** %24, i8*** %4
br label %5
25: ; preds = %5
store i32 -1, i32* %2
br label %26
26: ; preds = %25, %15
%27 = load i32, i32* %2
ret i32 %27
}

LLVM IR (-O2):
@month_lookup.months = internal global [13 x i8*] [i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.10, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.11, i32 0, i32 0), i8* null]
@.str = [4 x i8] c"JAN\00"
@.str.1 = [4 x i8] c"FEB\00"
@.str.2 = [4 x i8] c"MAR\00"
@.str.3 = [4 x i8] c"APR\00"
@.str.4 = [4 x i8] c"MAY\00"
@.str.5 = [4 x i8] c"JUN\00"
@.str.6 = [4 x i8] c"JUL\00"
@.str.7 = [4 x i8] c"AUG\00"
@.str.8 = [4 x i8] c"SEP\00"
@.str.9 = [4 x i8] c"OCT\00"
@.str.10 = [4 x i8] c"NOV\00"
@.str.11 = [4 x i8] c"DEC\00"
define i32 @month_lookup(i8* %0) {
%2 = load i8*, i8** getelementptr inbounds ([13 x i8*], [13 x i8*]* @month_lookup.months, i64 0, i64 0)
%3 = icmp eq i8* %2, null
br i1 %3, label %18, label %4
4: ; preds = %1, %14
%5 = phi i8* [ %16, %14 ], [ %2, %1 ]
%6 = phi i8** [ %15, %14 ], [ getelementptr inbounds ([13 x i8*], [13 x i8*]* @month_lookup.months, i64 0, i64 0), %1 ]
%7 = tail call i64 @case_ignore_strcmp(i8* %5, i8* %0)
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %14
9: ; preds = %4
%10 = ptrtoint i8** %6 to i64
%11 = sub i64 %10, ptrtoint ([13 x i8*]* @month_lookup.months to i64)
%12 = lshr exact i64 %11, 3
%13 = trunc i64 %12 to i32
br label %18
14: ; preds = %4
%15 = getelementptr inbounds i8*, i8** %6, i64 1
%16 = load i8*, i8** %15
%17 = icmp eq i8* %16, null
br i1 %17, label %18, label %4
18: ; preds = %14, %1, %9
%19 = phi i32 [ %13, %9 ], [ -1, %1 ], [ -1, %14 ]
ret i32 %19
}