#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__ isdigit(unsigned char);
int /*<<< orphan*/ strncasecmp(char const *, char *, int);
int mont2mont(const char *m) {
  static char *monNames[] = {"jan", "feb", "mar", "apr", "may", "jun",
                             "jul", "aug", "sep", "oct", "nov", "dec"};
  int i;
  if (isdigit((unsigned char)m[0]))
    return atoi(m);
  else {
    for (i = 0; i < 12; i++) {
      if (!strncasecmp(m, monNames[i], 3))
        return i + 1;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<mont2mont>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movzbl (%rax),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%rax
je     1163 <mont2mont+0x33>
mov    -0x10(%rbp),%rdi
call   1050 <atoi@plt>
mov    %eax,-0x4(%rbp)
jmp    11c7 <mont2mont+0x97>
movl   $0x0,-0x14(%rbp)
cmpl   $0xc,-0x14(%rbp)
jge    11bb <mont2mont+0x8b>
mov    -0x10(%rbp),%rdi
movslq -0x14(%rbp),%rcx
lea    0x2ebd(%rip),%rax
mov    (%rax,%rcx,8),%rsi
mov    $0x3,%edx
call   1040 <strncasecmp@plt>
cmp    $0x0,%eax
jne    11a8 <mont2mont+0x78>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    11c7 <mont2mont+0x97>
jmp    11ad <mont2mont+0x7d>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    116a <mont2mont+0x3a>
jmp    11c0 <mont2mont+0x90>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mont2mont>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbx
movzbl (%rdi),%edi
call   1030 <isdigit@plt>
test   %rax,%rax
je     1151 <mont2mont+0x21>
mov    %rbx,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1050 <atoi@plt>
lea    0xea8(%rip),%rsi
mov    %rbx,%rdi
mov    $0x3,%edx
call   1040 <strncasecmp@plt>
test   %eax,%eax
je     12a4 <mont2mont+0x174>
lea    0xe90(%rip),%rsi
mov    $0x3,%ebp
mov    %rbx,%rdi
mov    $0x3,%edx
call   1040 <strncasecmp@plt>
test   %eax,%eax
je     12ab <mont2mont+0x17b>
lea    0xe73(%rip),%rsi
mov    %rbx,%rdi
mov    $0x3,%edx
call   1040 <strncasecmp@plt>
test   %eax,%eax
je     12e8 <mont2mont+0x1b8>
lea    0xe5b(%rip),%rsi
mov    %rbx,%rdi
mov    $0x3,%edx
call   1040 <strncasecmp@plt>
test   %eax,%eax
je     12b2 <mont2mont+0x182>
lea    0xe43(%rip),%rsi
mov    %rbx,%rdi
mov    $0x3,%edx
call   1040 <strncasecmp@plt>
test   %eax,%eax
je     12b9 <mont2mont+0x189>
lea    0xe2b(%rip),%rsi
mov    %rbx,%rdi
mov    $0x3,%edx
call   1040 <strncasecmp@plt>
test   %eax,%eax
je     12c0 <mont2mont+0x190>
lea    0xe13(%rip),%rsi
mov    %rbx,%rdi
mov    $0x3,%edx
call   1040 <strncasecmp@plt>
test   %eax,%eax
je     12c7 <mont2mont+0x197>
lea    0xdfb(%rip),%rsi
mov    %rbx,%rdi
mov    $0x3,%edx
call   1040 <strncasecmp@plt>
test   %eax,%eax
je     12ce <mont2mont+0x19e>
lea    0xde3(%rip),%rsi
mov    %rbx,%rdi
mov    $0x3,%edx
call   1040 <strncasecmp@plt>
test   %eax,%eax
je     12d5 <mont2mont+0x1a5>
lea    0xdcb(%rip),%rsi
mov    %rbx,%rdi
mov    $0x3,%edx
call   1040 <strncasecmp@plt>
test   %eax,%eax
je     12dc <mont2mont+0x1ac>
lea    0xdb7(%rip),%rsi
mov    %rbx,%rdi
mov    $0x3,%edx
call   1040 <strncasecmp@plt>
test   %eax,%eax
je     12e3 <mont2mont+0x1b3>
lea    0xda3(%rip),%rsi
mov    %rbx,%rdi
mov    $0x3,%edx
call   1040 <strncasecmp@plt>
xor    %ecx,%ecx
test   %eax,%eax
mov    $0xc,%ebp
cmovne %ecx,%ebp
jmp    12e8 <mont2mont+0x1b8>
mov    $0x1,%ebp
jmp    12e8 <mont2mont+0x1b8>
mov    $0x2,%ebp
jmp    12e8 <mont2mont+0x1b8>
mov    $0x4,%ebp
jmp    12e8 <mont2mont+0x1b8>
mov    $0x5,%ebp
jmp    12e8 <mont2mont+0x1b8>
mov    $0x6,%ebp
jmp    12e8 <mont2mont+0x1b8>
mov    $0x7,%ebp
jmp    12e8 <mont2mont+0x1b8>
mov    $0x8,%ebp
jmp    12e8 <mont2mont+0x1b8>
mov    $0x9,%ebp
jmp    12e8 <mont2mont+0x1b8>
mov    $0xa,%ebp
jmp    12e8 <mont2mont+0x1b8>
mov    $0xb,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@mont2mont.monNames = internal global [12 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)]
@.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 @mont2mont(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
store i8* %0, i8** %3
%5 = load i8*, i8** %3
%6 = getelementptr inbounds i8, i8* %5, i64 0
%7 = load i8, i8* %6
%8 = call i64 @isdigit(i8 zeroext %7)
%9 = icmp ne i64 %8, 0
br i1 %9, label %10, label %13
10: ; preds = %1
%11 = load i8*, i8** %3
%12 = call i32 @atoi(i8* %11)
store i32 %12, i32* %2
br label %34
13: ; preds = %1
store i32 0, i32* %4
br label %14
14: ; preds = %29, %13
%15 = load i32, i32* %4
%16 = icmp slt i32 %15, 12
br i1 %16, label %17, label %32
17: ; preds = %14
%18 = load i8*, i8** %3
%19 = load i32, i32* %4
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds [12 x i8*], [12 x i8*]* @mont2mont.monNames, i64 0, i64 %20
%22 = load i8*, i8** %21
%23 = call i32 @strncasecmp(i8* %18, i8* %22, i32 3)
%24 = icmp ne i32 %23, 0
br i1 %24, label %28, label %25
25: ; preds = %17
%26 = load i32, i32* %4
%27 = add nsw i32 %26, 1
store i32 %27, i32* %2
br label %34
28: ; preds = %17
br label %29
29: ; preds = %28
%30 = load i32, i32* %4
%31 = add nsw i32 %30, 1
store i32 %31, i32* %4
br label %14
32: ; preds = %14
br label %33
33: ; preds = %32
store i32 0, i32* %2
br label %34
34: ; preds = %33, %25, %10
%35 = load i32, i32* %2
ret i32 %35
}

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"
define i32 @mont2mont(i8* nocapture %0) {
%2 = load i8, i8* %0
%3 = tail call i64 @isdigit(i8 zeroext %2)
%4 = icmp eq i64 %3, 0
br i1 %4, label %5, label %8
5: ; preds = %1
%6 = tail call i32 @strncasecmp(i8* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 3)
%7 = icmp eq i32 %6, 0
br i1 %7, label %44, label %10
8: ; preds = %1
%9 = tail call i32 @atoi(i8* %0)
br label %44
10: ; preds = %5
%11 = tail call i32 @strncasecmp(i8* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 3)
%12 = icmp eq i32 %11, 0
br i1 %12, label %44, label %13
13: ; preds = %10
%14 = tail call i32 @strncasecmp(i8* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 3)
%15 = icmp eq i32 %14, 0
br i1 %15, label %44, label %16
16: ; preds = %13
%17 = tail call i32 @strncasecmp(i8* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 3)
%18 = icmp eq i32 %17, 0
br i1 %18, label %44, label %19
19: ; preds = %16
%20 = tail call i32 @strncasecmp(i8* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 3)
%21 = icmp eq i32 %20, 0
br i1 %21, label %44, label %22
22: ; preds = %19
%23 = tail call i32 @strncasecmp(i8* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i32 3)
%24 = icmp eq i32 %23, 0
br i1 %24, label %44, label %25
25: ; preds = %22
%26 = tail call i32 @strncasecmp(i8* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i32 3)
%27 = icmp eq i32 %26, 0
br i1 %27, label %44, label %28
28: ; preds = %25
%29 = tail call i32 @strncasecmp(i8* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), i32 3)
%30 = icmp eq i32 %29, 0
br i1 %30, label %44, label %31
31: ; preds = %28
%32 = tail call i32 @strncasecmp(i8* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0), i32 3)
%33 = icmp eq i32 %32, 0
br i1 %33, label %44, label %34
34: ; preds = %31
%35 = tail call i32 @strncasecmp(i8* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0), i32 3)
%36 = icmp eq i32 %35, 0
br i1 %36, label %44, label %37
37: ; preds = %34
%38 = tail call i32 @strncasecmp(i8* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.10, i64 0, i64 0), i32 3)
%39 = icmp eq i32 %38, 0
br i1 %39, label %44, label %40
40: ; preds = %37
%41 = tail call i32 @strncasecmp(i8* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.11, i64 0, i64 0), i32 3)
%42 = icmp eq i32 %41, 0
%43 = select i1 %42, i32 12, i32 0
br label %44
44: ; preds = %40, %5, %10, %13, %16, %19, %22, %25, %28, %31, %34, %37, %8
%45 = phi i32 [ %9, %8 ], [ 1, %5 ], [ 2, %10 ], [ 3, %13 ], [ 4, %16 ], [ 5, %19 ], [ 6, %22 ], [ 7, %25 ], [ 8, %28 ], [ 9, %31 ], [ 10, %34 ], [ 11, %37 ], [ %43, %40 ]
ret i32 %45
}