void seven() {
  int date, day, month, year,
      days[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
  char months[13][10] = {
      "",     "January", "February",  "March",   "April",    "May",     "June",
      "July", "August",  "September", "October", "November", "December"};
  printf("enter date (int) in ddmmyy format: ");
  scanf("%d", &date);
  day = date / 10000;
  month = (date / 100) % 100;
  year = date % 100;
  days[2] += (year % 4 == 0) ? 1 : 0;
  if ((month < 1) || (month > 12) || (day < 1) || (day > days[month]))
    printf("\ninvalid date\n");
  else {
    printf("\nformatted date: %d", day);
    if ((day / 10) == 1)
      printf("th ");
    else
      switch (day % 10) {
      case 1:
        printf("st ");
        break;
      case 2:
        printf("nd ");
        break;
      case 3:
        printf("rd ");
        break;
      default:
        printf("th ");
        break;
      }
    printf("%s '%d\n", months[month], year);
  }
  getchar();
  printf("\nreturning to menu. press Enter...");
  getchar();
}


x86 assembly (clang, -O0):
<seven>:
push   %rbp
mov    %rsp,%rbp
sub    $0xf0,%rsp
lea    -0x50(%rbp),%rdi
lea    0xeaa(%rip),%rsi
mov    $0x34,%edx
call   1050 <memcpy@plt>
lea    -0xe0(%rbp),%rdi
lea    0xed2(%rip),%rsi
mov    $0x82,%edx
call   1050 <memcpy@plt>
lea    0xf43(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf79(%rip),%rdi
lea    -0x4(%rbp),%rsi
mov    $0x0,%al
call   1060 <scanf@plt>
mov    -0x4(%rbp),%eax
mov    $0x2710,%ecx
cltd
idiv   %ecx
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%eax
mov    $0x64,%ecx
cltd
idiv   %ecx
mov    $0x64,%ecx
cltd
idiv   %ecx
mov    %edx,-0xc(%rbp)
mov    -0x4(%rbp),%eax
mov    $0x64,%ecx
cltd
idiv   %ecx
mov    %edx,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
xor    %eax,%eax
mov    $0x1,%ecx
cmp    $0x0,%edx
cmove  %ecx,%eax
add    -0x48(%rbp),%eax
mov    %eax,-0x48(%rbp)
cmpl   $0x1,-0xc(%rbp)
jl     1217 <seven+0xd7>
cmpl   $0xc,-0xc(%rbp)
jg     1217 <seven+0xd7>
cmpl   $0x1,-0x8(%rbp)
jl     1217 <seven+0xd7>
mov    -0x8(%rbp),%eax
movslq -0xc(%rbp),%rcx
cmp    -0x50(%rbp,%rcx,4),%eax
jle    122a <seven+0xea>
lea    0xec8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1330 <seven+0x1f0>
mov    -0x8(%rbp),%esi
lea    0xec1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
cmp    $0x1,%eax
jne    1262 <seven+0x122>
lea    0xeb3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    130d <seven+0x1cd>
movslq -0x8(%rbp),%rcx
mov    %ecx,%eax
imul   $0x66666667,%rcx,%rdx
mov    %rdx,%rcx
shr    $0x3f,%rcx
sar    $0x22,%rdx
add    %ecx,%edx
add    %edx,%edx
mov    %edx,%ecx
lea    (%rcx,%rcx,4),%ecx
sub    %ecx,%eax
mov    %eax,-0xe4(%rbp)
sub    $0x1,%eax
je     12c1 <seven+0x181>
jmp    1299 <seven+0x159>
mov    -0xe4(%rbp),%eax
sub    $0x2,%eax
je     12d4 <seven+0x194>
jmp    12ad <seven+0x16d>
mov    -0xe4(%rbp),%eax
sub    $0x3,%eax
je     12e7 <seven+0x1a7>
jmp    12fa <seven+0x1ba>
lea    0xe45(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1308 <seven+0x1c8>
lea    0xe36(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1308 <seven+0x1c8>
lea    0xe27(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1308 <seven+0x1c8>
lea    0xe08(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    130d <seven+0x1cd>
movslq -0xc(%rbp),%rax
lea    -0xe0(%rbp),%rsi
imul   $0xa,%rax,%rax
add    %rax,%rsi
mov    -0x10(%rbp),%edx
lea    0xdf0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x0,%al
call   1040 <getchar@plt>
lea    0xde3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x0,%al
call   1040 <getchar@plt>
add    $0xf0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<seven>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0xd8,%rsp
mov    0xecd(%rip),%eax
mov    %eax,0x40(%rsp)
movaps 0xeb2(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
movaps 0xe96(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0xe7a(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
lea    0xeae(%rip),%rsi
lea    0x50(%rsp),%rdi
mov    $0x82,%edx
call   1060 <memcpy@plt>
lea    0xf28(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xf4f(%rip),%rdi
lea    0xc(%rsp),%rsi
xor    %eax,%eax
call   1070 <scanf@plt>
movslq 0xc(%rsp),%rbp
imul   $0x51eb851f,%rbp,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
shr    $0x20,%rax
sar    $0x5,%eax
add    %ecx,%eax
cltq
imul   $0x51eb851f,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
shr    $0x20,%rcx
sar    $0x5,%ecx
add    %edx,%ecx
imul   $0x64,%ecx,%ecx
imul   $0x64,%eax,%edx
sub    %ecx,%eax
mov    %ebp,%r14d
sub    %edx,%r14d
xor    %ecx,%ecx
test   $0x3,%r14b
sete   %cl
or     $0x1c,%ecx
mov    %ecx,0x18(%rsp)
lea    -0xd(%rax),%ecx
cmp    $0xfffffff4,%ecx
jb     1246 <seven+0xf6>
cmp    $0x2710,%ebp
jl     1246 <seven+0xf6>
imul   $0x68db8bad,%rbp,%rbx
mov    %rbx,%rcx
shr    $0x3f,%rcx
shr    $0x20,%rbx
sar    $0xc,%ebx
add    %ecx,%ebx
mov    %eax,%r15d
cmp    0x10(%rsp,%r15,4),%ebx
jle    1254 <seven+0x104>
lea    0xef6(%rip),%rdi
call   1030 <puts@plt>
jmp    12d1 <seven+0x181>
lea    0xe99(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    -0x186a0(%rbp),%eax
lea    0xe97(%rip),%rdi
cmp    $0x186a0,%eax
jb     12ad <seven+0x15d>
movslq %ebx,%rax
imul   $0x66666667,%rax,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x22,%rax
add    %ecx,%eax
add    %eax,%eax
lea    (%rax,%rax,4),%eax
not    %eax
add    %ebx,%eax
cmp    $0x2,%eax
ja     12ad <seven+0x15d>
cltq
lea    0xe1e(%rip),%rcx
movslq (%rcx,%rax,4),%rdi
add    %rcx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    (%r15,%r15,4),%rax
lea    (%rsp,%rax,2),%rsi
add    $0x50,%rsi
lea    0xe51(%rip),%rdi
mov    %r14d,%edx
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
call   1050 <getchar@plt>
lea    0xe41(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
call   1050 <getchar@plt>
add    $0xd8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@__const.seven.days = [13 x i32] [i32 0, i32 31, i32 28, i32 31, i32 30, i32 31, i32 30, i32 31, i32 31, i32 30, i32 31, i32 30, i32 31]
@__const.seven.months = [13 x [10 x i8]] [[10 x i8] zeroinitializer, [10 x i8] c"January\00\00\00", [10 x i8] c"February\00\00", [10 x i8] c"March\00\00\00\00\00", [10 x i8] c"April\00\00\00\00\00", [10 x i8] c"May\00\00\00\00\00\00\00", [10 x i8] c"June\00\00\00\00\00\00", [10 x i8] c"July\00\00\00\00\00\00", [10 x i8] c"August\00\00\00\00", [10 x i8] c"September\00", [10 x i8] c"October\00\00\00", [10 x i8] c"November\00\00", [10 x i8] c"December\00\00"]
@.str = [36 x i8] c"enter date (int) in ddmmyy format: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [15 x i8] c"\0Ainvalid date\0A\00"
@.str.3 = [20 x i8] c"\0Aformatted date: %d\00"
@.str.4 = [4 x i8] c"th \00"
@.str.5 = [4 x i8] c"st \00"
@.str.6 = [4 x i8] c"nd \00"
@.str.7 = [4 x i8] c"rd \00"
@.str.8 = [8 x i8] c"%s '%d\0A\00"
@.str.9 = [35 x i8] c"\0Areturning to menu. press Enter...\00"
define void @seven() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca [13 x i32]
%6 = alloca [13 x [10 x i8]]
%7 = bitcast [13 x i32]* %5 to i8*
%8 = bitcast [13 x [10 x i8]]* %6 to i8*
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0))
%10 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%11 = load i32, i32* %1
%12 = sdiv i32 %11, 10000
store i32 %12, i32* %2
%13 = load i32, i32* %1
%14 = sdiv i32 %13, 100
%15 = srem i32 %14, 100
store i32 %15, i32* %3
%16 = load i32, i32* %1
%17 = srem i32 %16, 100
store i32 %17, i32* %4
%18 = load i32, i32* %4
%19 = srem i32 %18, 4
%20 = icmp eq i32 %19, 0
%21 = zext i1 %20 to i64
%22 = select i1 %20, i32 1, i32 0
%23 = getelementptr inbounds [13 x i32], [13 x i32]* %5, i64 0, i64 2
%24 = load i32, i32* %23
%25 = add nsw i32 %24, %22
store i32 %25, i32* %23
%26 = load i32, i32* %3
%27 = icmp slt i32 %26, 1
br i1 %27, label %41, label %28
28: ; preds = %0
%29 = load i32, i32* %3
%30 = icmp sgt i32 %29, 12
br i1 %30, label %41, label %31
31: ; preds = %28
%32 = load i32, i32* %2
%33 = icmp slt i32 %32, 1
br i1 %33, label %41, label %34
34: ; preds = %31
%35 = load i32, i32* %2
%36 = load i32, i32* %3
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds [13 x i32], [13 x i32]* %5, i64 0, i64 %37
%39 = load i32, i32* %38
%40 = icmp sgt i32 %35, %39
br i1 %40, label %41, label %43
41: ; preds = %34, %31, %28, %0
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
br label %70
43: ; preds = %34
%44 = load i32, i32* %2
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0), i32 %44)
%46 = load i32, i32* %2
%47 = sdiv i32 %46, 10
%48 = icmp eq i32 %47, 1
br i1 %48, label %49, label %51
49: ; preds = %43
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
br label %63
51: ; preds = %43
%52 = load i32, i32* %2
%53 = srem i32 %52, 10
switch i32 %53, label %60 [
i32 1, label %54
i32 2, label %56
i32 3, label %58
]
54: ; preds = %51
%55 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0))
br label %62
56: ; preds = %51
%57 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0))
br label %62
58: ; preds = %51
%59 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0))
br label %62
60: ; preds = %51
%61 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
br label %62
62: ; preds = %60, %58, %56, %54
br label %63
63: ; preds = %62, %49
%64 = load i32, i32* %3
%65 = sext i32 %64 to i64
%66 = getelementptr inbounds [13 x [10 x i8]], [13 x [10 x i8]]* %6, i64 0, i64 %65
%67 = getelementptr inbounds [10 x i8], [10 x i8]* %66, i64 0, i64 0
%68 = load i32, i32* %4
%69 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i64 0, i64 0), i8* %67, i32 %68)
br label %70
70: ; preds = %63, %41
%71 = call i32 (...) @getchar()
%72 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.9, i64 0, i64 0))
%73 = call i32 (...) @getchar()
ret void
}

LLVM IR (-O2):
@__const.seven.days = [13 x i32] [i32 0, i32 31, i32 28, i32 31, i32 30, i32 31, i32 30, i32 31, i32 31, i32 30, i32 31, i32 30, i32 31]
@__const.seven.months = [13 x [10 x i8]] [[10 x i8] zeroinitializer, [10 x i8] c"January\00\00\00", [10 x i8] c"February\00\00", [10 x i8] c"March\00\00\00\00\00", [10 x i8] c"April\00\00\00\00\00", [10 x i8] c"May\00\00\00\00\00\00\00", [10 x i8] c"June\00\00\00\00\00\00", [10 x i8] c"July\00\00\00\00\00\00", [10 x i8] c"August\00\00\00\00", [10 x i8] c"September\00", [10 x i8] c"October\00\00\00", [10 x i8] c"November\00\00", [10 x i8] c"December\00\00"]
@.str = [36 x i8] c"enter date (int) in ddmmyy format: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.3 = [20 x i8] c"\0Aformatted date: %d\00"
@.str.4 = [4 x i8] c"th \00"
@.str.5 = [4 x i8] c"st \00"
@.str.6 = [4 x i8] c"nd \00"
@.str.7 = [4 x i8] c"rd \00"
@.str.8 = [8 x i8] c"%s '%d\0A\00"
@.str.9 = [35 x i8] c"\0Areturning to menu. press Enter...\00"
@str = [14 x i8] c"\0Ainvalid date\00"
@reltable.seven = [3 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.5 to i64), i64 ptrtoint ([3 x i32]* @reltable.seven to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.6 to i64), i64 ptrtoint ([3 x i32]* @reltable.seven to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.7 to i64), i64 ptrtoint ([3 x i32]* @reltable.seven to i64)) to i32)]
define void @seven() {
%1 = alloca i32
%2 = alloca [13 x i32]
%3 = alloca [13 x [10 x i8]]
%4 = bitcast i32* %1 to i8*
%5 = bitcast [13 x i32]* %2 to i8*
%6 = getelementptr inbounds [13 x [10 x i8]], [13 x [10 x i8]]* %3, i64 0, i64 0, i64 0
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0))
%8 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%9 = load i32, i32* %1
%10 = sdiv i32 %9, 10000
%11 = sdiv i32 %9, 100
%12 = srem i32 %11, 100
%13 = srem i32 %9, 100
%14 = and i32 %13, 3
%15 = icmp eq i32 %14, 0
%16 = getelementptr inbounds [13 x i32], [13 x i32]* %2, i64 0, i64 2
%17 = select i1 %15, i32 29, i32 28
store i32 %17, i32* %16
%18 = add nsw i32 %12, -13
%19 = icmp ult i32 %18, -12
%20 = icmp slt i32 %9, 10000
%21 = select i1 %19, i1 true, i1 %20
br i1 %21, label %27, label %22
22: ; preds = %0
%23 = zext i32 %12 to i64
%24 = getelementptr inbounds [13 x i32], [13 x i32]* %2, i64 0, i64 %23
%25 = load i32, i32* %24
%26 = icmp sgt i32 %10, %25
br i1 %26, label %27, label %29
27: ; preds = %22, %0
%28 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str, i64 0, i64 0))
br label %46
29: ; preds = %22
%30 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0), i32 %10)
%31 = add nsw i32 %9, -100000
%32 = icmp ult i32 %31, 100000
br i1 %32, label %41, label %33
33: ; preds = %29
%34 = srem i32 %10, 10
%35 = add nsw i32 %34, -1
%36 = icmp ult i32 %35, 3
br i1 %36, label %37, label %41
37: ; preds = %33
%38 = sext i32 %35 to i64
%39 = shl i64 %38, 2
%40 = call i8* @llvm.load.relative.i64(i8* bitcast ([3 x i32]* @reltable.seven to i8*), i64 %39)
br label %41
41: ; preds = %33, %37, %29
%42 = phi i8* [ getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), %29 ], [ %40, %37 ], [ getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), %33 ]
%43 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) %42)
%44 = getelementptr inbounds [13 x [10 x i8]], [13 x [10 x i8]]* %3, i64 0, i64 %23, i64 0
%45 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i64 0, i64 0), i8* %44, i32 %13)
br label %46
46: ; preds = %41, %27
%47 = call i32 (...) @getchar()
%48 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.9, i64 0, i64 0))
%49 = call i32 (...) @getchar()
ret void
}