#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*/ puterr2(char *, char *);
scalar_t__ strcmp(char *, char *);
scalar_t__ strlen(char *);
char toupper(char);
int Month2Int(char *cmonth) {
  int i;
  for (i = 0; i < (int)strlen(cmonth); i++)
    cmonth[i] = toupper(cmonth[i]);
  if (strcmp(cmonth, "JAN") == 0)
    return (1);
  if (strcmp(cmonth, "FEB") == 0)
    return (2);
  if (strcmp(cmonth, "MAR") == 0)
    return (3);
  if (strcmp(cmonth, "APR") == 0)
    return (4);
  if (strcmp(cmonth, "MAY") == 0)
    return (5);
  if (strcmp(cmonth, "JUN") == 0)
    return (6);
  if (strcmp(cmonth, "JUL") == 0)
    return (7);
  if (strcmp(cmonth, "AUG") == 0)
    return (8);
  if (strcmp(cmonth, "SEP") == 0)
    return (9);
  if (strcmp(cmonth, "OCT") == 0)
    return (10);
  if (strcmp(cmonth, "NOV") == 0)
    return (11);
  if (strcmp(cmonth, "DEC") == 0)
    return (12);
  puterr2("ERROR: unrecognized charcter month", cmonth);
  return (0);
}


x86 assembly (clang, -O0):
<Month2Int>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,%rcx
mov    -0x18(%rbp),%eax
cmp    %ecx,%eax
jge    119c <Month2Int+0x5c>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1030 <toupper@plt>
mov    %al,%dl
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1153 <Month2Int+0x13>
mov    -0x10(%rbp),%rdi
lea    0xe59(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    11c2 <Month2Int+0x82>
movl   $0x1,-0x4(%rbp)
jmp    137b <Month2Int+0x23b>
mov    -0x10(%rbp),%rdi
lea    0xe37(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    11e8 <Month2Int+0xa8>
movl   $0x2,-0x4(%rbp)
jmp    137b <Month2Int+0x23b>
mov    -0x10(%rbp),%rdi
lea    0xe15(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    120e <Month2Int+0xce>
movl   $0x3,-0x4(%rbp)
jmp    137b <Month2Int+0x23b>
mov    -0x10(%rbp),%rdi
lea    0xdf3(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    1234 <Month2Int+0xf4>
movl   $0x4,-0x4(%rbp)
jmp    137b <Month2Int+0x23b>
mov    -0x10(%rbp),%rdi
lea    0xdd1(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    125a <Month2Int+0x11a>
movl   $0x5,-0x4(%rbp)
jmp    137b <Month2Int+0x23b>
mov    -0x10(%rbp),%rdi
lea    0xdaf(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    1280 <Month2Int+0x140>
movl   $0x6,-0x4(%rbp)
jmp    137b <Month2Int+0x23b>
mov    -0x10(%rbp),%rdi
lea    0xd8d(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    12a6 <Month2Int+0x166>
movl   $0x7,-0x4(%rbp)
jmp    137b <Month2Int+0x23b>
mov    -0x10(%rbp),%rdi
lea    0xd6b(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    12cc <Month2Int+0x18c>
movl   $0x8,-0x4(%rbp)
jmp    137b <Month2Int+0x23b>
mov    -0x10(%rbp),%rdi
lea    0xd49(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    12f2 <Month2Int+0x1b2>
movl   $0x9,-0x4(%rbp)
jmp    137b <Month2Int+0x23b>
mov    -0x10(%rbp),%rdi
lea    0xd27(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    1318 <Month2Int+0x1d8>
movl   $0xa,-0x4(%rbp)
jmp    137b <Month2Int+0x23b>
mov    -0x10(%rbp),%rdi
lea    0xd05(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    133e <Month2Int+0x1fe>
movl   $0xb,-0x4(%rbp)
jmp    137b <Month2Int+0x23b>
mov    -0x10(%rbp),%rdi
lea    0xce3(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    1364 <Month2Int+0x224>
movl   $0xc,-0x4(%rbp)
jmp    137b <Month2Int+0x23b>
mov    -0x10(%rbp),%rsi
lea    0xcc1(%rip),%rdi
call   1060 <puterr2@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Month2Int>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
call   1040 <strlen@plt>
test   %eax,%eax
jle    1181 <Month2Int+0x41>
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movsbl (%r14,%rbx,1),%edi
call   1030 <toupper@plt>
mov    %al,(%r14,%rbx,1)
add    $0x1,%rbx
mov    %r14,%rdi
call   1040 <strlen@plt>
cltq
cmp    %rax,%rbx
jl     1160 <Month2Int+0x20>
lea    0xe78(%rip),%rsi
mov    %r14,%rdi
call   1050 <strcmp@plt>
test   %rax,%rax
je     12a8 <Month2Int+0x168>
lea    0xe64(%rip),%rsi
mov    %r14,%rdi
call   1050 <strcmp@plt>
test   %rax,%rax
je     12af <Month2Int+0x16f>
lea    0xe50(%rip),%rsi
mov    %r14,%rdi
call   1050 <strcmp@plt>
test   %rax,%rax
je     12b6 <Month2Int+0x176>
lea    0xe3c(%rip),%rsi
mov    %r14,%rdi
call   1050 <strcmp@plt>
test   %rax,%rax
je     12bd <Month2Int+0x17d>
lea    0xe28(%rip),%rsi
mov    %r14,%rdi
call   1050 <strcmp@plt>
test   %rax,%rax
je     12c4 <Month2Int+0x184>
lea    0xe14(%rip),%rsi
mov    %r14,%rdi
call   1050 <strcmp@plt>
test   %rax,%rax
je     12cb <Month2Int+0x18b>
lea    0xe00(%rip),%rsi
mov    %r14,%rdi
call   1050 <strcmp@plt>
test   %rax,%rax
je     12d2 <Month2Int+0x192>
lea    0xdec(%rip),%rsi
mov    %r14,%rdi
call   1050 <strcmp@plt>
test   %rax,%rax
je     12d9 <Month2Int+0x199>
lea    0xdd8(%rip),%rsi
mov    %r14,%rdi
call   1050 <strcmp@plt>
test   %rax,%rax
je     12e0 <Month2Int+0x1a0>
lea    0xdc4(%rip),%rsi
mov    %r14,%rdi
call   1050 <strcmp@plt>
test   %rax,%rax
je     12e7 <Month2Int+0x1a7>
lea    0xdb4(%rip),%rsi
mov    %r14,%rdi
call   1050 <strcmp@plt>
test   %rax,%rax
je     12ee <Month2Int+0x1ae>
lea    0xda4(%rip),%rsi
mov    %r14,%rdi
call   1050 <strcmp@plt>
test   %rax,%rax
je     12f5 <Month2Int+0x1b5>
lea    0xd94(%rip),%rdi
mov    %r14,%rsi
call   1060 <puterr2@plt>
xor    %eax,%eax
jmp    12fa <Month2Int+0x1ba>
mov    $0x1,%eax
jmp    12fa <Month2Int+0x1ba>
mov    $0x2,%eax
jmp    12fa <Month2Int+0x1ba>
mov    $0x3,%eax
jmp    12fa <Month2Int+0x1ba>
mov    $0x4,%eax
jmp    12fa <Month2Int+0x1ba>
mov    $0x5,%eax
jmp    12fa <Month2Int+0x1ba>
mov    $0x6,%eax
jmp    12fa <Month2Int+0x1ba>
mov    $0x7,%eax
jmp    12fa <Month2Int+0x1ba>
mov    $0x8,%eax
jmp    12fa <Month2Int+0x1ba>
mov    $0x9,%eax
jmp    12fa <Month2Int+0x1ba>
mov    $0xa,%eax
jmp    12fa <Month2Int+0x1ba>
mov    $0xb,%eax
jmp    12fa <Month2Int+0x1ba>
mov    $0xc,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.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"
@.str.12 = [35 x i8] c"ERROR: unrecognized charcter month\00"
define i32 @Month2Int(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
store i8* %0, i8** %3
store i32 0, i32* %4
br label %5
5: ; preds = %22, %1
%6 = load i32, i32* %4
%7 = load i8*, i8** %3
%8 = call i64 @strlen(i8* %7)
%9 = trunc i64 %8 to i32
%10 = icmp slt i32 %6, %9
br i1 %10, label %11, label %25
11: ; preds = %5
%12 = load i8*, i8** %3
%13 = load i32, i32* %4
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds i8, i8* %12, i64 %14
%16 = load i8, i8* %15
%17 = call signext i8 @toupper(i8 signext %16)
%18 = load i8*, i8** %3
%19 = load i32, i32* %4
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds i8, i8* %18, i64 %20
store i8 %17, i8* %21
br label %22
22: ; preds = %11
%23 = load i32, i32* %4
%24 = add nsw i32 %23, 1
store i32 %24, i32* %4
br label %5
25: ; preds = %5
%26 = load i8*, i8** %3
%27 = call i64 @strcmp(i8* %26, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%28 = icmp eq i64 %27, 0
br i1 %28, label %29, label %30
29: ; preds = %25
store i32 1, i32* %2
br label %88
30: ; preds = %25
%31 = load i8*, i8** %3
%32 = call i64 @strcmp(i8* %31, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%33 = icmp eq i64 %32, 0
br i1 %33, label %34, label %35
34: ; preds = %30
store i32 2, i32* %2
br label %88
35: ; preds = %30
%36 = load i8*, i8** %3
%37 = call i64 @strcmp(i8* %36, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%38 = icmp eq i64 %37, 0
br i1 %38, label %39, label %40
39: ; preds = %35
store i32 3, i32* %2
br label %88
40: ; preds = %35
%41 = load i8*, i8** %3
%42 = call i64 @strcmp(i8* %41, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%43 = icmp eq i64 %42, 0
br i1 %43, label %44, label %45
44: ; preds = %40
store i32 4, i32* %2
br label %88
45: ; preds = %40
%46 = load i8*, i8** %3
%47 = call i64 @strcmp(i8* %46, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
%48 = icmp eq i64 %47, 0
br i1 %48, label %49, label %50
49: ; preds = %45
store i32 5, i32* %2
br label %88
50: ; preds = %45
%51 = load i8*, i8** %3
%52 = call i64 @strcmp(i8* %51, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0))
%53 = icmp eq i64 %52, 0
br i1 %53, label %54, label %55
54: ; preds = %50
store i32 6, i32* %2
br label %88
55: ; preds = %50
%56 = load i8*, i8** %3
%57 = call i64 @strcmp(i8* %56, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0))
%58 = icmp eq i64 %57, 0
br i1 %58, label %59, label %60
59: ; preds = %55
store i32 7, i32* %2
br label %88
60: ; preds = %55
%61 = load i8*, i8** %3
%62 = call i64 @strcmp(i8* %61, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0))
%63 = icmp eq i64 %62, 0
br i1 %63, label %64, label %65
64: ; preds = %60
store i32 8, i32* %2
br label %88
65: ; preds = %60
%66 = load i8*, i8** %3
%67 = call i64 @strcmp(i8* %66, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0))
%68 = icmp eq i64 %67, 0
br i1 %68, label %69, label %70
69: ; preds = %65
store i32 9, i32* %2
br label %88
70: ; preds = %65
%71 = load i8*, i8** %3
%72 = call i64 @strcmp(i8* %71, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0))
%73 = icmp eq i64 %72, 0
br i1 %73, label %74, label %75
74: ; preds = %70
store i32 10, i32* %2
br label %88
75: ; preds = %70
%76 = load i8*, i8** %3
%77 = call i64 @strcmp(i8* %76, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.10, i64 0, i64 0))
%78 = icmp eq i64 %77, 0
br i1 %78, label %79, label %80
79: ; preds = %75
store i32 11, i32* %2
br label %88
80: ; preds = %75
%81 = load i8*, i8** %3
%82 = call i64 @strcmp(i8* %81, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.11, i64 0, i64 0))
%83 = icmp eq i64 %82, 0
br i1 %83, label %84, label %85
84: ; preds = %80
store i32 12, i32* %2
br label %88
85: ; preds = %80
%86 = load i8*, i8** %3
%87 = call i32 @puterr2(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.12, i64 0, i64 0), i8* %86)
store i32 0, i32* %2
br label %88
88: ; preds = %85, %84, %79, %74, %69, %64, %59, %54, %49, %44, %39, %34, %29
%89 = load i32, i32* %2
ret i32 %89
}

LLVM IR (-O2):
@.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"
@.str.12 = [35 x i8] c"ERROR: unrecognized charcter month\00"
define i32 @Month2Int(i8* %0) {
%2 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%3 = trunc i64 %2 to i32
%4 = icmp sgt i32 %3, 0
br i1 %4, label %5, label %15
5: ; preds = %1, %5
%6 = phi i64 [ %10, %5 ], [ 0, %1 ]
%7 = getelementptr inbounds i8, i8* %0, i64 %6
%8 = load i8, i8* %7
%9 = tail call signext i8 @toupper(i8 signext %8)
store i8 %9, i8* %7
%10 = add nuw nsw i64 %6, 1
%11 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%12 = shl i64 %11, 32
%13 = ashr exact i64 %12, 32
%14 = icmp slt i64 %10, %13
br i1 %14, label %5, label %15
15: ; preds = %5, %1
%16 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%17 = icmp eq i64 %16, 0
br i1 %17, label %53, label %18
18: ; preds = %15
%19 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%20 = icmp eq i64 %19, 0
br i1 %20, label %53, label %21
21: ; preds = %18
%22 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%23 = icmp eq i64 %22, 0
br i1 %23, label %53, label %24
24: ; preds = %21
%25 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%26 = icmp eq i64 %25, 0
br i1 %26, label %53, label %27
27: ; preds = %24
%28 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
%29 = icmp eq i64 %28, 0
br i1 %29, label %53, label %30
30: ; preds = %27
%31 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0))
%32 = icmp eq i64 %31, 0
br i1 %32, label %53, label %33
33: ; preds = %30
%34 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0))
%35 = icmp eq i64 %34, 0
br i1 %35, label %53, label %36
36: ; preds = %33
%37 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0))
%38 = icmp eq i64 %37, 0
br i1 %38, label %53, label %39
39: ; preds = %36
%40 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0))
%41 = icmp eq i64 %40, 0
br i1 %41, label %53, label %42
42: ; preds = %39
%43 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0))
%44 = icmp eq i64 %43, 0
br i1 %44, label %53, label %45
45: ; preds = %42
%46 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.10, i64 0, i64 0))
%47 = icmp eq i64 %46, 0
br i1 %47, label %53, label %48
48: ; preds = %45
%49 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.11, i64 0, i64 0))
%50 = icmp eq i64 %49, 0
br i1 %50, label %53, label %51
51: ; preds = %48
%52 = tail call i32 @puterr2(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.12, i64 0, i64 0), i8* %0)
br label %53
53: ; preds = %48, %45, %42, %39, %36, %33, %30, %27, %24, %21, %18, %15, %51
%54 = phi i32 [ 0, %51 ], [ 1, %15 ], [ 2, %18 ], [ 3, %21 ], [ 4, %24 ], [ 5, %27 ], [ 6, %30 ], [ 7, %33 ], [ 8, %36 ], [ 9, %39 ], [ 10, %42 ], [ 11, %45 ], [ 12, %48 ]
ret i32 %54
}