#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ SEEK_CUR;
int /*<<< orphan*/ fscanf(int /*<<< orphan*/ *, char *, char *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int, int /*<<< orphan*/);
unsigned month(char c, FILE *fp) {
  unsigned m = 0;
  switch (c) {
  case 'J':
    fscanf(fp, "%c", &c);
    if (c == 'a') {
      m = 1;
      fseek(fp, 2, SEEK_CUR);
    } else {
      fscanf(fp, "%c", &c);
      m = c == 'n' ? 6 : 7;
      fseek(fp, 1, SEEK_CUR);
    }
    break;
  case 'F':
    m = 2;
    fseek(fp, 3, SEEK_CUR);
    break;
  case 'M':
    fseek(fp, 1, SEEK_CUR);
    fscanf(fp, "%c", &c);
    m = c == 'r' ? 3 : 5;
    fseek(fp, 1, SEEK_CUR);
    break;
  case 'A':
    fscanf(fp, "%c", &c);
    m = c == 'p' ? 4 : 8;
    fseek(fp, 2, SEEK_CUR);
    break;
  case 'S':
    m = 9;
    fseek(fp, 3, SEEK_CUR);
    break;
  case 'O':
    m = 10;
    fseek(fp, 3, SEEK_CUR);
    break;
  case 'N':
    m = 11;
    fseek(fp, 3, SEEK_CUR);
    break;
  case 'D':
    m = 12;
    fseek(fp, 3, SEEK_CUR);
  }
  return m;
}


x86 assembly (clang, -O0):
<month>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %dil,%al
mov    %al,-0x1(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movsbl -0x1(%rbp),%eax
add    $0xffffffbf,%eax
mov    %eax,%ecx
mov    %rcx,-0x20(%rbp)
sub    $0x12,%eax
ja     133d <month+0x21d>
mov    -0x20(%rbp),%rax
lea    0xea6(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x10(%rbp),%rdi
lea    0xede(%rip),%rsi
lea    -0x1(%rbp),%rdx
call   1030 <fscanf@plt>
movsbl -0x1(%rbp),%eax
cmp    $0x61,%eax
jne    11a7 <month+0x87>
movl   $0x1,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
mov    0x2e52(%rip),%rax
mov    (%rax),%edx
mov    $0x2,%esi
call   1040 <fseek@plt>
jmp    11e9 <month+0xc9>
mov    -0x10(%rbp),%rdi
lea    0xe9a(%rip),%rsi
lea    -0x1(%rbp),%rdx
call   1030 <fscanf@plt>
movsbl -0x1(%rbp),%edx
mov    $0x7,%eax
mov    $0x6,%ecx
cmp    $0x6e,%edx
cmove  %ecx,%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
mov    0x2e0b(%rip),%rax
mov    (%rax),%edx
mov    $0x1,%esi
call   1040 <fseek@plt>
jmp    133d <month+0x21d>
movl   $0x2,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
mov    0x2de8(%rip),%rax
mov    (%rax),%edx
mov    $0x3,%esi
call   1040 <fseek@plt>
jmp    133d <month+0x21d>
mov    -0x10(%rbp),%rdi
mov    0x2dcc(%rip),%rax
mov    (%rax),%edx
mov    $0x1,%esi
call   1040 <fseek@plt>
mov    -0x10(%rbp),%rdi
lea    0xe19(%rip),%rsi
lea    -0x1(%rbp),%rdx
call   1030 <fscanf@plt>
movsbl -0x1(%rbp),%edx
mov    $0x5,%eax
mov    $0x3,%ecx
cmp    $0x72,%edx
cmove  %ecx,%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
mov    0x2d8a(%rip),%rax
mov    (%rax),%edx
mov    $0x1,%esi
call   1040 <fseek@plt>
jmp    133d <month+0x21d>
mov    -0x10(%rbp),%rdi
lea    0xdd2(%rip),%rsi
lea    -0x1(%rbp),%rdx
call   1030 <fscanf@plt>
movsbl -0x1(%rbp),%edx
mov    $0x8,%eax
mov    $0x4,%ecx
cmp    $0x70,%edx
cmove  %ecx,%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
mov    0x2d43(%rip),%rax
mov    (%rax),%edx
mov    $0x2,%esi
call   1040 <fseek@plt>
jmp    133d <month+0x21d>
movl   $0x9,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
mov    0x2d20(%rip),%rax
mov    (%rax),%edx
mov    $0x3,%esi
call   1040 <fseek@plt>
jmp    133d <month+0x21d>
movl   $0xa,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
mov    0x2cfd(%rip),%rax
mov    (%rax),%edx
mov    $0x3,%esi
call   1040 <fseek@plt>
jmp    133d <month+0x21d>
movl   $0xb,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
mov    0x2cda(%rip),%rax
mov    (%rax),%edx
mov    $0x3,%esi
call   1040 <fseek@plt>
jmp    133d <month+0x21d>
movl   $0xc,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
mov    0x2cb7(%rip),%rax
mov    (%rax),%edx
mov    $0x3,%esi
call   1040 <fseek@plt>
mov    -0x14(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<month>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %dil,0xf(%rsp)
xor    %ebp,%ebp
add    $0xffffffbf,%edi
cmp    $0x12,%edi
ja     12d9 <month+0x1b9>
mov    %rsi,%rbx
lea    0xebb(%rip),%rax
movslq (%rax,%rdi,4),%rcx
add    %rax,%rcx
jmp    *%rcx
lea    0xef7(%rip),%rsi
lea    0xf(%rsp),%rdx
mov    %rbx,%rdi
call   1030 <fscanf@plt>
xor    %eax,%eax
cmpb   $0x70,0xf(%rsp)
setne  %al
lea    0x4(,%rax,4),%ebp
mov    0x2e6e(%rip),%rax
mov    (%rax),%edx
mov    %rbx,%rdi
mov    $0x2,%esi
jmp    12d4 <month+0x1b4>
mov    0x2e58(%rip),%rax
mov    (%rax),%edx
mov    %rbx,%rdi
mov    $0x3,%esi
call   1040 <fseek@plt>
mov    $0xc,%ebp
jmp    12d9 <month+0x1b9>
mov    0x2e38(%rip),%rax
mov    (%rax),%edx
mov    %rbx,%rdi
mov    $0x3,%esi
call   1040 <fseek@plt>
mov    $0x2,%ebp
jmp    12d9 <month+0x1b9>
mov    0x2e18(%rip),%rax
mov    (%rax),%edx
mov    %rbx,%rdi
mov    $0x3,%esi
call   1040 <fseek@plt>
mov    $0xb,%ebp
jmp    12d9 <month+0x1b9>
mov    0x2df8(%rip),%rax
mov    (%rax),%edx
mov    %rbx,%rdi
mov    $0x3,%esi
call   1040 <fseek@plt>
mov    $0xa,%ebp
jmp    12d9 <month+0x1b9>
mov    0x2dd8(%rip),%rax
mov    (%rax),%edx
mov    %rbx,%rdi
mov    $0x3,%esi
call   1040 <fseek@plt>
mov    $0x9,%ebp
jmp    12d9 <month+0x1b9>
lea    0xe1c(%rip),%rsi
lea    0xf(%rsp),%rdx
mov    %rbx,%rdi
call   1030 <fscanf@plt>
cmpb   $0x61,0xf(%rsp)
jne    12a1 <month+0x181>
mov    0x2d9d(%rip),%rax
mov    (%rax),%edx
mov    %rbx,%rdi
mov    $0x2,%esi
call   1040 <fseek@plt>
mov    $0x1,%ebp
jmp    12d9 <month+0x1b9>
mov    0x2d80(%rip),%r14
mov    (%r14),%edx
mov    %rbx,%rdi
mov    $0x1,%esi
call   1040 <fseek@plt>
lea    0xdcd(%rip),%rsi
lea    0xf(%rsp),%rdx
mov    %rbx,%rdi
call   1030 <fscanf@plt>
xor    %eax,%eax
cmpb   $0x72,0xf(%rsp)
setne  %al
lea    (%rax,%rax,1),%ebp
add    $0x3,%ebp
mov    (%r14),%edx
jmp    12cc <month+0x1ac>
lea    0xda4(%rip),%rsi
lea    0xf(%rsp),%rdx
mov    %rbx,%rdi
call   1030 <fscanf@plt>
xor    %ebp,%ebp
cmpb   $0x6e,0xf(%rsp)
sete   %bpl
xor    $0x7,%ebp
mov    0x2d1e(%rip),%rax
mov    (%rax),%edx
mov    %rbx,%rdi
mov    $0x1,%esi
call   1040 <fseek@plt>
mov    %ebp,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%c\00"
@SEEK_CUR = global i32 0
define i32 @month(i8 signext %0, i32* %1) {
%3 = alloca i8
%4 = alloca i32*
%5 = alloca i32
store i8 %0, i8* %3
store i32* %1, i32** %4
store i32 0, i32* %5
%6 = load i8, i8* %3
%7 = sext i8 %6 to i32
switch i32 %7, label %75 [
i32 74, label %8
i32 70, label %30
i32 77, label %34
i32 65, label %48
i32 83, label %59
i32 79, label %63
i32 78, label %67
i32 68, label %71
]
8: ; preds = %2
%9 = load i32*, i32** %4
%10 = call i32 @fscanf(i32* %9, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %3)
%11 = load i8, i8* %3
%12 = sext i8 %11 to i32
%13 = icmp eq i32 %12, 97
br i1 %13, label %14, label %18
14: ; preds = %8
store i32 1, i32* %5
%15 = load i32*, i32** %4
%16 = load i32, i32* @SEEK_CUR
%17 = call i32 @fseek(i32* %15, i32 2, i32 %16)
br label %29
18: ; preds = %8
%19 = load i32*, i32** %4
%20 = call i32 @fscanf(i32* %19, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %3)
%21 = load i8, i8* %3
%22 = sext i8 %21 to i32
%23 = icmp eq i32 %22, 110
%24 = zext i1 %23 to i64
%25 = select i1 %23, i32 6, i32 7
store i32 %25, i32* %5
%26 = load i32*, i32** %4
%27 = load i32, i32* @SEEK_CUR
%28 = call i32 @fseek(i32* %26, i32 1, i32 %27)
br label %29
29: ; preds = %18, %14
br label %75
30: ; preds = %2
store i32 2, i32* %5
%31 = load i32*, i32** %4
%32 = load i32, i32* @SEEK_CUR
%33 = call i32 @fseek(i32* %31, i32 3, i32 %32)
br label %75
34: ; preds = %2
%35 = load i32*, i32** %4
%36 = load i32, i32* @SEEK_CUR
%37 = call i32 @fseek(i32* %35, i32 1, i32 %36)
%38 = load i32*, i32** %4
%39 = call i32 @fscanf(i32* %38, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %3)
%40 = load i8, i8* %3
%41 = sext i8 %40 to i32
%42 = icmp eq i32 %41, 114
%43 = zext i1 %42 to i64
%44 = select i1 %42, i32 3, i32 5
store i32 %44, i32* %5
%45 = load i32*, i32** %4
%46 = load i32, i32* @SEEK_CUR
%47 = call i32 @fseek(i32* %45, i32 1, i32 %46)
br label %75
48: ; preds = %2
%49 = load i32*, i32** %4
%50 = call i32 @fscanf(i32* %49, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %3)
%51 = load i8, i8* %3
%52 = sext i8 %51 to i32
%53 = icmp eq i32 %52, 112
%54 = zext i1 %53 to i64
%55 = select i1 %53, i32 4, i32 8
store i32 %55, i32* %5
%56 = load i32*, i32** %4
%57 = load i32, i32* @SEEK_CUR
%58 = call i32 @fseek(i32* %56, i32 2, i32 %57)
br label %75
59: ; preds = %2
store i32 9, i32* %5
%60 = load i32*, i32** %4
%61 = load i32, i32* @SEEK_CUR
%62 = call i32 @fseek(i32* %60, i32 3, i32 %61)
br label %75
63: ; preds = %2
store i32 10, i32* %5
%64 = load i32*, i32** %4
%65 = load i32, i32* @SEEK_CUR
%66 = call i32 @fseek(i32* %64, i32 3, i32 %65)
br label %75
67: ; preds = %2
store i32 11, i32* %5
%68 = load i32*, i32** %4
%69 = load i32, i32* @SEEK_CUR
%70 = call i32 @fseek(i32* %68, i32 3, i32 %69)
br label %75
71: ; preds = %2
store i32 12, i32* %5
%72 = load i32*, i32** %4
%73 = load i32, i32* @SEEK_CUR
%74 = call i32 @fseek(i32* %72, i32 3, i32 %73)
br label %75
75: ; preds = %71, %2, %67, %63, %59, %48, %34, %30, %29
%76 = load i32, i32* %5
ret i32 %76
}

LLVM IR (-O2):
@.str = [3 x i8] c"%c\00"
@SEEK_CUR = global i32 0
define i32 @month(i8 signext %0, i32* nocapture %1) {
%3 = alloca i8
store i8 %0, i8* %3
%4 = sext i8 %0 to i32
switch i32 %4, label %50 [
i32 74, label %5
i32 70, label %19
i32 77, label %22
i32 65, label %31
i32 83, label %38
i32 79, label %41
i32 78, label %44
i32 68, label %47
]
5: ; preds = %2
%6 = call i32 @fscanf(i32* %1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %3)
%7 = load i8, i8* %3
%8 = icmp eq i8 %7, 97
br i1 %8, label %9, label %12
9: ; preds = %5
%10 = load i32, i32* @SEEK_CUR
%11 = call i32 @fseek(i32* %1, i32 2, i32 %10)
br label %50
12: ; preds = %5
%13 = call i32 @fscanf(i32* %1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %3)
%14 = load i8, i8* %3
%15 = icmp eq i8 %14, 110
%16 = select i1 %15, i32 6, i32 7
%17 = load i32, i32* @SEEK_CUR
%18 = call i32 @fseek(i32* %1, i32 1, i32 %17)
br label %50
19: ; preds = %2
%20 = load i32, i32* @SEEK_CUR
%21 = tail call i32 @fseek(i32* %1, i32 3, i32 %20)
br label %50
22: ; preds = %2
%23 = load i32, i32* @SEEK_CUR
%24 = tail call i32 @fseek(i32* %1, i32 1, i32 %23)
%25 = call i32 @fscanf(i32* %1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %3)
%26 = load i8, i8* %3
%27 = icmp eq i8 %26, 114
%28 = select i1 %27, i32 3, i32 5
%29 = load i32, i32* @SEEK_CUR
%30 = call i32 @fseek(i32* %1, i32 1, i32 %29)
br label %50
31: ; preds = %2
%32 = call i32 @fscanf(i32* %1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %3)
%33 = load i8, i8* %3
%34 = icmp eq i8 %33, 112
%35 = select i1 %34, i32 4, i32 8
%36 = load i32, i32* @SEEK_CUR
%37 = call i32 @fseek(i32* %1, i32 2, i32 %36)
br label %50
38: ; preds = %2
%39 = load i32, i32* @SEEK_CUR
%40 = tail call i32 @fseek(i32* %1, i32 3, i32 %39)
br label %50
41: ; preds = %2
%42 = load i32, i32* @SEEK_CUR
%43 = tail call i32 @fseek(i32* %1, i32 3, i32 %42)
br label %50
44: ; preds = %2
%45 = load i32, i32* @SEEK_CUR
%46 = tail call i32 @fseek(i32* %1, i32 3, i32 %45)
br label %50
47: ; preds = %2
%48 = load i32, i32* @SEEK_CUR
%49 = tail call i32 @fseek(i32* %1, i32 3, i32 %48)
br label %50
50: ; preds = %9, %12, %47, %2, %44, %41, %38, %31, %22, %19
%51 = phi i32 [ 0, %2 ], [ 12, %47 ], [ 11, %44 ], [ 10, %41 ], [ 9, %38 ], [ %35, %31 ], [ %28, %22 ], [ 2, %19 ], [ 1, %9 ], [ %16, %12 ]
ret i32 %51
}