int Decode_date_month(char *text, int flag) {
  int i;
  static char months[][4] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul",
                             "Aug", "Sep", "Oct", "Nov", "Dec", ""};
  for (i = 0; months[i][0] != 0; i++)
    if (strncmp(text, months[i], 3) == 0)
      return (i);
  return (-1);
}


x86 assembly (clang, -O0):
<Decode_date_month>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
movslq -0x18(%rbp),%rcx
lea    0x2eff(%rip),%rax
movsbl (%rax,%rcx,4),%eax
cmp    $0x0,%eax
je     1185 <Decode_date_month+0x75>
mov    -0x10(%rbp),%rdi
movslq -0x18(%rbp),%rax
lea    0x2ee3(%rip),%rsi
shl    $0x2,%rax
add    %rax,%rsi
mov    $0x3,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
jne    1172 <Decode_date_month+0x62>
mov    -0x18(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    118c <Decode_date_month+0x7c>
jmp    1177 <Decode_date_month+0x67>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1126 <Decode_date_month+0x16>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Decode_date_month>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    $0xffffffff,%r14d
cmpb   $0x0,0x2f0c(%rip)
je     1166 <Decode_date_month+0x56>
mov    %rdi,%r15
xor    %ebx,%ebx
lea    0x2efe(%rip),%rbp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    $0x3,%edx
mov    %r15,%rdi
mov    %rbp,%rsi
call   1030 <strncmp@plt>
test   %eax,%eax
je     1163 <Decode_date_month+0x53>
add    $0x1,%ebx
cmpb   $0x0,0x4(%rbp)
lea    0x4(%rbp),%rbp
jne    1140 <Decode_date_month+0x30>
jmp    1166 <Decode_date_month+0x56>
mov    %ebx,%r14d
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@Decode_date_month.months = internal global [13 x [4 x i8]] [[4 x i8] c"Jan\00", [4 x i8] c"Feb\00", [4 x i8] c"Mar\00", [4 x i8] c"Apr\00", [4 x i8] c"May\00", [4 x i8] c"Jun\00", [4 x i8] c"Jul\00", [4 x i8] c"Aug\00", [4 x i8] c"Sep\00", [4 x i8] c"Oct\00", [4 x i8] c"Nov\00", [4 x i8] c"Dec\00", [4 x i8] zeroinitializer]
define i32 @Decode_date_month(i8* %0, i32 %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
store i8* %0, i8** %4
store i32 %1, i32* %5
store i32 0, i32* %6
br label %7
7: ; preds = %26, %2
%8 = load i32, i32* %6
%9 = sext i32 %8 to i64
%10 = getelementptr inbounds [13 x [4 x i8]], [13 x [4 x i8]]* @Decode_date_month.months, i64 0, i64 %9
%11 = getelementptr inbounds [4 x i8], [4 x i8]* %10, i64 0, i64 0
%12 = load i8, i8* %11
%13 = sext i8 %12 to i32
%14 = icmp ne i32 %13, 0
br i1 %14, label %15, label %29
15: ; preds = %7
%16 = load i8*, i8** %4
%17 = load i32, i32* %6
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds [13 x [4 x i8]], [13 x [4 x i8]]* @Decode_date_month.months, i64 0, i64 %18
%20 = getelementptr inbounds [4 x i8], [4 x i8]* %19, i64 0, i64 0
%21 = call i32 @strncmp(i8* %16, i8* %20, i64 3)
%22 = icmp eq i32 %21, 0
br i1 %22, label %23, label %25
23: ; preds = %15
%24 = load i32, i32* %6
store i32 %24, i32* %3
br label %30
25: ; preds = %15
br label %26
26: ; preds = %25
%27 = load i32, i32* %6
%28 = add nsw i32 %27, 1
store i32 %28, i32* %6
br label %7
29: ; preds = %7
store i32 -1, i32* %3
br label %30
30: ; preds = %29, %23
%31 = load i32, i32* %3
ret i32 %31
}

LLVM IR (-O2):
@Decode_date_month.months = internal global [13 x [4 x i8]] [[4 x i8] c"Jan\00", [4 x i8] c"Feb\00", [4 x i8] c"Mar\00", [4 x i8] c"Apr\00", [4 x i8] c"May\00", [4 x i8] c"Jun\00", [4 x i8] c"Jul\00", [4 x i8] c"Aug\00", [4 x i8] c"Sep\00", [4 x i8] c"Oct\00", [4 x i8] c"Nov\00", [4 x i8] c"Dec\00", [4 x i8] zeroinitializer]
define i32 @Decode_date_month(i8* nocapture %0, i32 %1) {
%3 = load i8, i8* getelementptr inbounds ([13 x [4 x i8]], [13 x [4 x i8]]* @Decode_date_month.months, i64 0, i64 0, i64 0)
%4 = icmp eq i8 %3, 0
br i1 %4, label %17, label %5
5: ; preds = %2, %10
%6 = phi i64 [ %11, %10 ], [ 0, %2 ]
%7 = phi i8* [ %12, %10 ], [ getelementptr inbounds ([13 x [4 x i8]], [13 x [4 x i8]]* @Decode_date_month.months, i64 0, i64 0, i64 0), %2 ]
%8 = tail call i32 @strncmp(i8* dereferenceable(1) %0, i8* %7, i64 3)
%9 = icmp eq i32 %8, 0
br i1 %9, label %15, label %10
10: ; preds = %5
%11 = add nuw i64 %6, 1
%12 = getelementptr inbounds [13 x [4 x i8]], [13 x [4 x i8]]* @Decode_date_month.months, i64 0, i64 %11, i64 0
%13 = load i8, i8* %12
%14 = icmp eq i8 %13, 0
br i1 %14, label %17, label %5
15: ; preds = %5
%16 = trunc i64 %6 to i32
br label %17
17: ; preds = %10, %15, %2
%18 = phi i32 [ -1, %2 ], [ %16, %15 ], [ -1, %10 ]
ret i32 %18
}