#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*/ error(char *, char *);
scalar_t__ strcmp(char *, char *);
char toupper(char);
int month2int(char *month) {
  int i;
  char *months[12] = {"March",    "April",    "May",       "June",
                      "July",     "August",   "September", "October",
                      "November", "December", "January",   "February"};
  month[0] = toupper(month[0]);
  for (i = 0; i < 12; i++) {
    if (strcmp(months[i], month) == 0) {
      return i + 3;
    }
  }
  error("%s is not a valid month\n", month);
}


x86 assembly (clang, -O0):
<month2int>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    %rdi,-0x10(%rbp)
lea    -0x80(%rbp),%rdi
lea    0x2c66(%rip),%rsi
mov    $0x60,%edx
call   1050 <memcpy@plt>
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1030 <toupper@plt>
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %cl,(%rax)
movl   $0x0,-0x14(%rbp)
cmpl   $0xc,-0x14(%rbp)
jge    11c6 <month2int+0x86>
movslq -0x14(%rbp),%rax
mov    -0x80(%rbp,%rax,8),%rdi
mov    -0x10(%rbp),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    11b3 <month2int+0x73>
mov    -0x14(%rbp),%eax
add    $0x3,%eax
mov    %eax,-0x4(%rbp)
jmp    11d6 <month2int+0x96>
jmp    11b8 <month2int+0x78>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    117f <month2int+0x3f>
mov    -0x10(%rbp),%rsi
lea    0xe85(%rip),%rdi
call   1060 <error@plt>
mov    -0x4(%rbp),%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<month2int>:
push   %rbx
mov    %rdi,%rbx
movsbl (%rdi),%edi
call   1030 <toupper@plt>
mov    %al,(%rbx)
lea    0xebb(%rip),%rdi
mov    %rbx,%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
je     1263 <month2int+0x133>
lea    0xea9(%rip),%rdi
mov    %rbx,%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
je     126a <month2int+0x13a>
lea    0xe97(%rip),%rdi
mov    %rbx,%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
je     1271 <month2int+0x141>
lea    0xe83(%rip),%rdi
mov    %rbx,%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
je     1278 <month2int+0x148>
lea    0xe70(%rip),%rdi
mov    %rbx,%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
je     127f <month2int+0x14f>
lea    0xe5d(%rip),%rdi
mov    %rbx,%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
je     1286 <month2int+0x156>
lea    0xe4c(%rip),%rdi
mov    %rbx,%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
je     128d <month2int+0x15d>
lea    0xe3e(%rip),%rdi
mov    %rbx,%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
je     1294 <month2int+0x164>
lea    0xe2e(%rip),%rdi
mov    %rbx,%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
je     129b <month2int+0x16b>
lea    0xe1f(%rip),%rdi
mov    %rbx,%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
je     12a2 <month2int+0x172>
lea    0xe14(%rip),%rdi
mov    %rbx,%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
je     12a9 <month2int+0x179>
lea    0xe08(%rip),%rdi
mov    %rbx,%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
je     12b0 <month2int+0x180>
lea    0xdfd(%rip),%rdi
mov    %rbx,%rsi
call   1050 <error@plt>
pop    %rbx
ret
mov    $0x3,%eax
pop    %rbx
ret
mov    $0x4,%eax
pop    %rbx
ret
mov    $0x5,%eax
pop    %rbx
ret
mov    $0x6,%eax
pop    %rbx
ret
mov    $0x7,%eax
pop    %rbx
ret
mov    $0x8,%eax
pop    %rbx
ret
mov    $0x9,%eax
pop    %rbx
ret
mov    $0xa,%eax
pop    %rbx
ret
mov    $0xb,%eax
pop    %rbx
ret
mov    $0xc,%eax
pop    %rbx
ret
mov    $0xd,%eax
pop    %rbx
ret
mov    $0xe,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [6 x i8] c"March\00"
@.str.1 = [6 x i8] c"April\00"
@.str.2 = [4 x i8] c"May\00"
@.str.3 = [5 x i8] c"June\00"
@.str.4 = [5 x i8] c"July\00"
@.str.5 = [7 x i8] c"August\00"
@.str.6 = [10 x i8] c"September\00"
@.str.7 = [8 x i8] c"October\00"
@.str.8 = [9 x i8] c"November\00"
@.str.9 = [9 x i8] c"December\00"
@.str.10 = [8 x i8] c"January\00"
@.str.11 = [9 x i8] c"February\00"
@__const.month2int.months = [12 x i8*] [i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 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 ([5 x i8], [5 x i8]* @.str.3, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i32 0, i32 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i32 0, i32 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i32 0, i32 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.7, i32 0, i32 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.8, i32 0, i32 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.9, i32 0, i32 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.10, i32 0, i32 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.11, i32 0, i32 0)]
@.str.12 = [25 x i8] c"%s is not a valid month\0A\00"
define i32 @month2int(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
%5 = alloca [12 x i8*]
store i8* %0, i8** %3
%6 = bitcast [12 x i8*]* %5 to i8*
%7 = load i8*, i8** %3
%8 = getelementptr inbounds i8, i8* %7, i64 0
%9 = load i8, i8* %8
%10 = call signext i8 @toupper(i8 signext %9)
%11 = load i8*, i8** %3
%12 = getelementptr inbounds i8, i8* %11, i64 0
store i8 %10, i8* %12
store i32 0, i32* %4
br label %13
13: ; preds = %28, %1
%14 = load i32, i32* %4
%15 = icmp slt i32 %14, 12
br i1 %15, label %16, label %31
16: ; preds = %13
%17 = load i32, i32* %4
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds [12 x i8*], [12 x i8*]* %5, i64 0, i64 %18
%20 = load i8*, i8** %19
%21 = load i8*, i8** %3
%22 = call i64 @strcmp(i8* %20, i8* %21)
%23 = icmp eq i64 %22, 0
br i1 %23, label %24, label %27
24: ; preds = %16
%25 = load i32, i32* %4
%26 = add nsw i32 %25, 3
store i32 %26, i32* %2
br label %34
27: ; preds = %16
br label %28
28: ; preds = %27
%29 = load i32, i32* %4
%30 = add nsw i32 %29, 1
store i32 %30, i32* %4
br label %13
31: ; preds = %13
%32 = load i8*, i8** %3
%33 = call i32 @error(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.12, i64 0, i64 0), i8* %32)
br label %34
34: ; preds = %31, %24
%35 = load i32, i32* %2
ret i32 %35
}

LLVM IR (-O2):
@.str = [6 x i8] c"March\00"
@.str.1 = [6 x i8] c"April\00"
@.str.2 = [4 x i8] c"May\00"
@.str.3 = [5 x i8] c"June\00"
@.str.4 = [5 x i8] c"July\00"
@.str.5 = [7 x i8] c"August\00"
@.str.6 = [10 x i8] c"September\00"
@.str.7 = [8 x i8] c"October\00"
@.str.8 = [9 x i8] c"November\00"
@.str.9 = [9 x i8] c"December\00"
@.str.10 = [8 x i8] c"January\00"
@.str.11 = [9 x i8] c"February\00"
@.str.12 = [25 x i8] c"%s is not a valid month\0A\00"
define i32 @month2int(i8* %0) {
%2 = load i8, i8* %0
%3 = tail call signext i8 @toupper(i8 signext %2)
store i8 %3, i8* %0
%4 = tail call i64 @strcmp(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %0)
%5 = icmp eq i64 %4, 0
br i1 %5, label %41, label %6
6: ; preds = %1
%7 = tail call i64 @strcmp(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %0)
%8 = icmp eq i64 %7, 0
br i1 %8, label %41, label %9
9: ; preds = %6
%10 = tail call i64 @strcmp(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %0)
%11 = icmp eq i64 %10, 0
br i1 %11, label %41, label %12
12: ; preds = %9
%13 = tail call i64 @strcmp(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i8* %0)
%14 = icmp eq i64 %13, 0
br i1 %14, label %41, label %15
15: ; preds = %12
%16 = tail call i64 @strcmp(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i8* %0)
%17 = icmp eq i64 %16, 0
br i1 %17, label %41, label %18
18: ; preds = %15
%19 = tail call i64 @strcmp(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0), i8* %0)
%20 = icmp eq i64 %19, 0
br i1 %20, label %41, label %21
21: ; preds = %18
%22 = tail call i64 @strcmp(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0), i8* %0)
%23 = icmp eq i64 %22, 0
br i1 %23, label %41, label %24
24: ; preds = %21
%25 = tail call i64 @strcmp(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.7, i64 0, i64 0), i8* %0)
%26 = icmp eq i64 %25, 0
br i1 %26, label %41, label %27
27: ; preds = %24
%28 = tail call i64 @strcmp(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.8, i64 0, i64 0), i8* %0)
%29 = icmp eq i64 %28, 0
br i1 %29, label %41, label %30
30: ; preds = %27
%31 = tail call i64 @strcmp(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.9, i64 0, i64 0), i8* %0)
%32 = icmp eq i64 %31, 0
br i1 %32, label %41, label %33
33: ; preds = %30
%34 = tail call i64 @strcmp(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.10, i64 0, i64 0), i8* %0)
%35 = icmp eq i64 %34, 0
br i1 %35, label %41, label %36
36: ; preds = %33
%37 = tail call i64 @strcmp(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.11, i64 0, i64 0), i8* %0)
%38 = icmp eq i64 %37, 0
br i1 %38, label %41, label %39
39: ; preds = %36
%40 = tail call i32 @error(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.12, i64 0, i64 0), i8* %0)
br label %41
41: ; preds = %1, %6, %9, %12, %15, %18, %21, %24, %27, %30, %33, %36, %39
%42 = phi i32 [ undef, %39 ], [ 3, %1 ], [ 4, %6 ], [ 5, %9 ], [ 6, %12 ], [ 7, %15 ], [ 8, %18 ], [ 9, %21 ], [ 10, %24 ], [ 11, %27 ], [ 12, %30 ], [ 13, %33 ], [ 14, %36 ]
ret i32 %42
}