#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*/ free(char *);
scalar_t__ memcmp(char *, char *, int);
int /*<<< orphan*/ str_lower(char *);
char *strdup(char *);
int txt2mon(char *m) {
  int month = 0;
  char *m1;
  m1 = strdup(m);
  str_lower(m1);
  if (memcmp(m1, "jan", 3) == 0)
    month = 0;
  else if (memcmp(m1, "feb", 3) == 0)
    month = 1;
  else if (memcmp(m1, "mar", 3) == 0)
    month = 2;
  else if (memcmp(m1, "apr", 3) == 0)
    month = 3;
  else if (memcmp(m1, "may", 3) == 0)
    month = 4;
  else if (memcmp(m1, "jun", 3) == 0)
    month = 5;
  else if (memcmp(m1, "jul", 3) == 0)
    month = 6;
  else if (memcmp(m1, "aug", 3) == 0)
    month = 7;
  else if (memcmp(m1, "sep", 3) == 0)
    month = 8;
  else if (memcmp(m1, "oct", 3) == 0)
    month = 9;
  else if (memcmp(m1, "nov", 3) == 0)
    month = 10;
  else if (memcmp(m1, "dec", 3) == 0)
    month = 11;
  free(m1);
  return month;
}


x86 assembly (clang, -O0):
<txt2mon>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
call   1060 <strdup@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <str_lower@plt>
mov    -0x18(%rbp),%rdi
lea    0xe8c(%rip),%rsi
mov    $0x3,%edx
call   1050 <memcmp@plt>
cmp    $0x0,%rax
jne    1194 <txt2mon+0x54>
movl   $0x0,-0xc(%rbp)
jmp    139f <txt2mon+0x25f>
mov    -0x18(%rbp),%rdi
lea    0xe65(%rip),%rsi
mov    $0x3,%edx
call   1050 <memcmp@plt>
cmp    $0x0,%rax
jne    11bf <txt2mon+0x7f>
movl   $0x1,-0xc(%rbp)
jmp    139a <txt2mon+0x25a>
mov    -0x18(%rbp),%rdi
lea    0xe3e(%rip),%rsi
mov    $0x3,%edx
call   1050 <memcmp@plt>
cmp    $0x0,%rax
jne    11ea <txt2mon+0xaa>
movl   $0x2,-0xc(%rbp)
jmp    1395 <txt2mon+0x255>
mov    -0x18(%rbp),%rdi
lea    0xe17(%rip),%rsi
mov    $0x3,%edx
call   1050 <memcmp@plt>
cmp    $0x0,%rax
jne    1215 <txt2mon+0xd5>
movl   $0x3,-0xc(%rbp)
jmp    1390 <txt2mon+0x250>
mov    -0x18(%rbp),%rdi
lea    0xdf0(%rip),%rsi
mov    $0x3,%edx
call   1050 <memcmp@plt>
cmp    $0x0,%rax
jne    1240 <txt2mon+0x100>
movl   $0x4,-0xc(%rbp)
jmp    138b <txt2mon+0x24b>
mov    -0x18(%rbp),%rdi
lea    0xdc9(%rip),%rsi
mov    $0x3,%edx
call   1050 <memcmp@plt>
cmp    $0x0,%rax
jne    126b <txt2mon+0x12b>
movl   $0x5,-0xc(%rbp)
jmp    1386 <txt2mon+0x246>
mov    -0x18(%rbp),%rdi
lea    0xda2(%rip),%rsi
mov    $0x3,%edx
call   1050 <memcmp@plt>
cmp    $0x0,%rax
jne    1296 <txt2mon+0x156>
movl   $0x6,-0xc(%rbp)
jmp    1381 <txt2mon+0x241>
mov    -0x18(%rbp),%rdi
lea    0xd7b(%rip),%rsi
mov    $0x3,%edx
call   1050 <memcmp@plt>
cmp    $0x0,%rax
jne    12c1 <txt2mon+0x181>
movl   $0x7,-0xc(%rbp)
jmp    137c <txt2mon+0x23c>
mov    -0x18(%rbp),%rdi
lea    0xd54(%rip),%rsi
mov    $0x3,%edx
call   1050 <memcmp@plt>
cmp    $0x0,%rax
jne    12ec <txt2mon+0x1ac>
movl   $0x8,-0xc(%rbp)
jmp    1377 <txt2mon+0x237>
mov    -0x18(%rbp),%rdi
lea    0xd2d(%rip),%rsi
mov    $0x3,%edx
call   1050 <memcmp@plt>
cmp    $0x0,%rax
jne    1317 <txt2mon+0x1d7>
movl   $0x9,-0xc(%rbp)
jmp    1372 <txt2mon+0x232>
mov    -0x18(%rbp),%rdi
lea    0xd06(%rip),%rsi
mov    $0x3,%edx
call   1050 <memcmp@plt>
cmp    $0x0,%rax
jne    1342 <txt2mon+0x202>
movl   $0xa,-0xc(%rbp)
jmp    136d <txt2mon+0x22d>
mov    -0x18(%rbp),%rdi
lea    0xcdf(%rip),%rsi
mov    $0x3,%edx
call   1050 <memcmp@plt>
cmp    $0x0,%rax
jne    1368 <txt2mon+0x228>
movl   $0xb,-0xc(%rbp)
jmp    136d <txt2mon+0x22d>
jmp    1372 <txt2mon+0x232>
jmp    1377 <txt2mon+0x237>
jmp    137c <txt2mon+0x23c>
jmp    1381 <txt2mon+0x241>
jmp    1386 <txt2mon+0x246>
jmp    138b <txt2mon+0x24b>
jmp    1390 <txt2mon+0x250>
jmp    1395 <txt2mon+0x255>
jmp    139a <txt2mon+0x25a>
jmp    139f <txt2mon+0x25f>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
mov    -0xc(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<txt2mon>:
push   %rbp
push   %rbx
push   %rax
call   1060 <strdup@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1040 <str_lower@plt>
lea    0xea6(%rip),%rsi
mov    %rbx,%rdi
mov    $0x3,%edx
call   1050 <memcmp@plt>
test   %rax,%rax
je     12b2 <txt2mon+0x172>
lea    0xe8d(%rip),%rsi
mov    %rbx,%rdi
mov    $0x3,%edx
call   1050 <memcmp@plt>
test   %rax,%rax
je     12b6 <txt2mon+0x176>
lea    0xe74(%rip),%rsi
mov    $0x3,%ebp
mov    %rbx,%rdi
mov    $0x3,%edx
call   1050 <memcmp@plt>
test   %rax,%rax
je     12bd <txt2mon+0x17d>
lea    0xe56(%rip),%rsi
mov    %rbx,%rdi
mov    $0x3,%edx
call   1050 <memcmp@plt>
test   %rax,%rax
je     12f3 <txt2mon+0x1b3>
lea    0xe3d(%rip),%rsi
mov    %rbx,%rdi
mov    $0x3,%edx
call   1050 <memcmp@plt>
test   %rax,%rax
je     12c4 <txt2mon+0x184>
lea    0xe24(%rip),%rsi
mov    %rbx,%rdi
mov    $0x3,%edx
call   1050 <memcmp@plt>
test   %rax,%rax
je     12cb <txt2mon+0x18b>
lea    0xe0b(%rip),%rsi
mov    %rbx,%rdi
mov    $0x3,%edx
call   1050 <memcmp@plt>
test   %rax,%rax
je     12d2 <txt2mon+0x192>
lea    0xdf2(%rip),%rsi
mov    %rbx,%rdi
mov    $0x3,%edx
call   1050 <memcmp@plt>
test   %rax,%rax
je     12d9 <txt2mon+0x199>
lea    0xdd9(%rip),%rsi
mov    %rbx,%rdi
mov    $0x3,%edx
call   1050 <memcmp@plt>
test   %rax,%rax
je     12e0 <txt2mon+0x1a0>
lea    0xdc0(%rip),%rsi
mov    %rbx,%rdi
mov    $0x3,%edx
call   1050 <memcmp@plt>
test   %rax,%rax
je     12e7 <txt2mon+0x1a7>
lea    0xdab(%rip),%rsi
mov    %rbx,%rdi
mov    $0x3,%edx
call   1050 <memcmp@plt>
test   %rax,%rax
je     12ee <txt2mon+0x1ae>
lea    0xd96(%rip),%rsi
mov    %rbx,%rdi
mov    $0x3,%edx
call   1050 <memcmp@plt>
xor    %ecx,%ecx
test   %rax,%rax
mov    $0xb,%ebp
cmovne %ecx,%ebp
jmp    12f3 <txt2mon+0x1b3>
xor    %ebp,%ebp
jmp    12f3 <txt2mon+0x1b3>
mov    $0x1,%ebp
jmp    12f3 <txt2mon+0x1b3>
mov    $0x2,%ebp
jmp    12f3 <txt2mon+0x1b3>
mov    $0x4,%ebp
jmp    12f3 <txt2mon+0x1b3>
mov    $0x5,%ebp
jmp    12f3 <txt2mon+0x1b3>
mov    $0x6,%ebp
jmp    12f3 <txt2mon+0x1b3>
mov    $0x7,%ebp
jmp    12f3 <txt2mon+0x1b3>
mov    $0x8,%ebp
jmp    12f3 <txt2mon+0x1b3>
mov    $0x9,%ebp
jmp    12f3 <txt2mon+0x1b3>
mov    $0xa,%ebp
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
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"
define i32 @txt2mon(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i8*
store i8* %0, i8** %2
store i32 0, i32* %3
%5 = load i8*, i8** %2
%6 = call i8* @strdup(i8* %5)
store i8* %6, i8** %4
%7 = load i8*, i8** %4
%8 = call i32 @str_lower(i8* %7)
%9 = load i8*, i8** %4
%10 = call i64 @memcmp(i8* %9, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 3)
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %13
12: ; preds = %1
store i32 0, i32* %3
br label %79
13: ; preds = %1
%14 = load i8*, i8** %4
%15 = call i64 @memcmp(i8* %14, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 3)
%16 = icmp eq i64 %15, 0
br i1 %16, label %17, label %18
17: ; preds = %13
store i32 1, i32* %3
br label %78
18: ; preds = %13
%19 = load i8*, i8** %4
%20 = call i64 @memcmp(i8* %19, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 3)
%21 = icmp eq i64 %20, 0
br i1 %21, label %22, label %23
22: ; preds = %18
store i32 2, i32* %3
br label %77
23: ; preds = %18
%24 = load i8*, i8** %4
%25 = call i64 @memcmp(i8* %24, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 3)
%26 = icmp eq i64 %25, 0
br i1 %26, label %27, label %28
27: ; preds = %23
store i32 3, i32* %3
br label %76
28: ; preds = %23
%29 = load i8*, i8** %4
%30 = call i64 @memcmp(i8* %29, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 3)
%31 = icmp eq i64 %30, 0
br i1 %31, label %32, label %33
32: ; preds = %28
store i32 4, i32* %3
br label %75
33: ; preds = %28
%34 = load i8*, i8** %4
%35 = call i64 @memcmp(i8* %34, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i32 3)
%36 = icmp eq i64 %35, 0
br i1 %36, label %37, label %38
37: ; preds = %33
store i32 5, i32* %3
br label %74
38: ; preds = %33
%39 = load i8*, i8** %4
%40 = call i64 @memcmp(i8* %39, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i32 3)
%41 = icmp eq i64 %40, 0
br i1 %41, label %42, label %43
42: ; preds = %38
store i32 6, i32* %3
br label %73
43: ; preds = %38
%44 = load i8*, i8** %4
%45 = call i64 @memcmp(i8* %44, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), i32 3)
%46 = icmp eq i64 %45, 0
br i1 %46, label %47, label %48
47: ; preds = %43
store i32 7, i32* %3
br label %72
48: ; preds = %43
%49 = load i8*, i8** %4
%50 = call i64 @memcmp(i8* %49, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0), i32 3)
%51 = icmp eq i64 %50, 0
br i1 %51, label %52, label %53
52: ; preds = %48
store i32 8, i32* %3
br label %71
53: ; preds = %48
%54 = load i8*, i8** %4
%55 = call i64 @memcmp(i8* %54, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0), i32 3)
%56 = icmp eq i64 %55, 0
br i1 %56, label %57, label %58
57: ; preds = %53
store i32 9, i32* %3
br label %70
58: ; preds = %53
%59 = load i8*, i8** %4
%60 = call i64 @memcmp(i8* %59, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.10, i64 0, i64 0), i32 3)
%61 = icmp eq i64 %60, 0
br i1 %61, label %62, label %63
62: ; preds = %58
store i32 10, i32* %3
br label %69
63: ; preds = %58
%64 = load i8*, i8** %4
%65 = call i64 @memcmp(i8* %64, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.11, i64 0, i64 0), i32 3)
%66 = icmp eq i64 %65, 0
br i1 %66, label %67, label %68
67: ; preds = %63
store i32 11, i32* %3
br label %68
68: ; preds = %67, %63
br label %69
69: ; preds = %68, %62
br label %70
70: ; preds = %69, %57
br label %71
71: ; preds = %70, %52
br label %72
72: ; preds = %71, %47
br label %73
73: ; preds = %72, %42
br label %74
74: ; preds = %73, %37
br label %75
75: ; preds = %74, %32
br label %76
76: ; preds = %75, %27
br label %77
77: ; preds = %76, %22
br label %78
78: ; preds = %77, %17
br label %79
79: ; preds = %78, %12
%80 = load i8*, i8** %4
%81 = call i32 @free(i8* %80)
%82 = load i32, i32* %3
ret i32 %82
}

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