#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*/ printf(char *, int, char *, int);
void dateString(int day, int month, int year) {
  char *m;
  switch (month) {
  case 1:
    m = "Jan";
    break;
  case 2:
    m = "Feb";
    break;
  case 3:
    m = "Mar";
    break;
  case 4:
    m = "Apr";
    break;
  case 5:
    m = "May";
    break;
  case 6:
    m = "Jun";
    break;
  case 7:
    m = "July";
    break;
  case 8:
    m = "Aug";
    break;
  case 9:
    m = "Sep";
    break;
  case 10:
    m = "Oct";
    break;
  case 11:
    m = "Nov";
    break;
  case 12:
    m = "Dec";
    break;
  default:
    m = "Illegal month";
    break;
  }
  printf("%d-%s-%d\n", day, m, year);
}


x86 assembly (clang, -O0):
<dateString>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x20(%rbp)
sub    $0xb,%eax
ja     120a <dateString+0xfa>
mov    -0x20(%rbp),%rax
lea    0xebf(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xedf(%rip),%rax
mov    %rax,-0x18(%rbp)
jmp    1215 <dateString+0x105>
lea    0xed3(%rip),%rax
mov    %rax,-0x18(%rbp)
jmp    1215 <dateString+0x105>
lea    0xec7(%rip),%rax
mov    %rax,-0x18(%rbp)
jmp    1215 <dateString+0x105>
lea    0xebb(%rip),%rax
mov    %rax,-0x18(%rbp)
jmp    1215 <dateString+0x105>
lea    0xeaf(%rip),%rax
mov    %rax,-0x18(%rbp)
jmp    1215 <dateString+0x105>
lea    0xea3(%rip),%rax
mov    %rax,-0x18(%rbp)
jmp    1215 <dateString+0x105>
lea    0xe97(%rip),%rax
mov    %rax,-0x18(%rbp)
jmp    1215 <dateString+0x105>
lea    0xe8c(%rip),%rax
mov    %rax,-0x18(%rbp)
jmp    1215 <dateString+0x105>
lea    0xe80(%rip),%rax
mov    %rax,-0x18(%rbp)
jmp    1215 <dateString+0x105>
lea    0xe74(%rip),%rax
mov    %rax,-0x18(%rbp)
jmp    1215 <dateString+0x105>
lea    0xe68(%rip),%rax
mov    %rax,-0x18(%rbp)
jmp    1215 <dateString+0x105>
lea    0xe5c(%rip),%rax
mov    %rax,-0x18(%rbp)
jmp    1215 <dateString+0x105>
lea    0xe50(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    -0x4(%rbp),%esi
mov    -0x18(%rbp),%rdx
mov    -0xc(%rbp),%ecx
lea    0xe49(%rip),%rdi
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dateString>:
mov    %edx,%ecx
mov    %edi,%eax
add    $0xffffffff,%esi
cmp    $0xb,%esi
ja     112f <dateString+0x1f>
movslq %esi,%rdx
lea    0xf26(%rip),%rsi
movslq (%rsi,%rdx,4),%rdx
add    %rsi,%rdx
jmp    1136 <dateString+0x26>
lea    0xefb(%rip),%rdx
lea    0xf02(%rip),%rdi
mov    %eax,%esi
jmp    1030 <printf@plt>

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 = [5 x i8] c"July\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 = [14 x i8] c"Illegal month\00"
@.str.13 = [10 x i8] c"%d-%s-%d\0A\00"
define void @dateString(i32 %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i8*
store i32 %0, i32* %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%8 = load i32, i32* %5
switch i32 %8, label %21 [
i32 1, label %9
i32 2, label %10
i32 3, label %11
i32 4, label %12
i32 5, label %13
i32 6, label %14
i32 7, label %15
i32 8, label %16
i32 9, label %17
i32 10, label %18
i32 11, label %19
i32 12, label %20
]
9: ; preds = %3
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8** %7
br label %22
10: ; preds = %3
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8** %7
br label %22
11: ; preds = %3
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8** %7
br label %22
12: ; preds = %3
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8** %7
br label %22
13: ; preds = %3
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i8** %7
br label %22
14: ; preds = %3
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i8** %7
br label %22
15: ; preds = %3
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), i8** %7
br label %22
16: ; preds = %3
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), i8** %7
br label %22
17: ; preds = %3
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0), i8** %7
br label %22
18: ; preds = %3
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0), i8** %7
br label %22
19: ; preds = %3
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.10, i64 0, i64 0), i8** %7
br label %22
20: ; preds = %3
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.11, i64 0, i64 0), i8** %7
br label %22
21: ; preds = %3
store i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.12, i64 0, i64 0), i8** %7
br label %22
22: ; preds = %21, %20, %19, %18, %17, %16, %15, %14, %13, %12, %11, %10, %9
%23 = load i32, i32* %4
%24 = load i8*, i8** %7
%25 = load i32, i32* %6
%26 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.13, i64 0, i64 0), i32 %23, i8* %24, i32 %25)
ret void
}

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 = [5 x i8] c"July\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 = [14 x i8] c"Illegal month\00"
@.str.13 = [10 x i8] c"%d-%s-%d\0A\00"
@reltable.dateString = [12 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str to i64), i64 ptrtoint ([12 x i32]* @reltable.dateString to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.1 to i64), i64 ptrtoint ([12 x i32]* @reltable.dateString to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.2 to i64), i64 ptrtoint ([12 x i32]* @reltable.dateString to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.3 to i64), i64 ptrtoint ([12 x i32]* @reltable.dateString to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.4 to i64), i64 ptrtoint ([12 x i32]* @reltable.dateString to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.5 to i64), i64 ptrtoint ([12 x i32]* @reltable.dateString to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str.6 to i64), i64 ptrtoint ([12 x i32]* @reltable.dateString to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.7 to i64), i64 ptrtoint ([12 x i32]* @reltable.dateString to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.8 to i64), i64 ptrtoint ([12 x i32]* @reltable.dateString to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.9 to i64), i64 ptrtoint ([12 x i32]* @reltable.dateString to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.10 to i64), i64 ptrtoint ([12 x i32]* @reltable.dateString to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.11 to i64), i64 ptrtoint ([12 x i32]* @reltable.dateString to i64)) to i32)]
define void @dateString(i32 %0, i32 %1, i32 %2) {
%4 = add i32 %1, -1
%5 = icmp ult i32 %4, 12
br i1 %5, label %6, label %10
6: ; preds = %3
%7 = sext i32 %4 to i64
%8 = shl i64 %7, 2
%9 = call i8* @llvm.load.relative.i64(i8* bitcast ([12 x i32]* @reltable.dateString to i8*), i64 %8)
br label %10
10: ; preds = %3, %6
%11 = phi i8* [ %9, %6 ], [ getelementptr inbounds ([14 x i8], [14 x i8]* @.str.12, i64 0, i64 0), %3 ]
%12 = tail call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.13, i64 0, i64 0), i32 %0, i8* %11, i32 %2)
ret void
}