#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 *);
void day_string(int day) {
  if (day > 32 || day < 0) {
    printf("Invalid day");
    return;
  }
  if ((day - 9) <= 0) {
    switch (day) {
    case 0:
      break;
    case 1:
      printf("First");
      break;
    case 2:
      printf("Second");
      break;
    case 3:
      printf("Third");
      break;
    case 4:
      printf("Fourth");
      break;
    case 5:
      printf("Fifth");
      break;
    case 6:
      printf("Fifth");
      break;
    case 7:
      printf("Seventh");
      break;
    case 8:
      printf("Eigth");
      break;
    case 9:
      printf("Ninth");
      break;
    default:
      printf("\nDate Cannot be negative");
      break;
    }
  } else if ((day - 19) <= 0) {
    switch (day) {
    case 10:
      printf("Tenth");
      break;
    case 11:
      printf("Eleventh");
      break;
    case 12:
      printf("Twelfth");
      break;
    case 13:
      printf("Thirteenth");
      break;
    case 14:
      printf("Fourteenth");
      break;
    case 15:
      printf("Fifteenth");
      break;
    case 16:
      printf("Sixteenth");
      break;
    case 17:
      printf("Seventeenth");
      break;
    case 18:
      printf("Eighteenth");
      break;
    case 19:
      printf("Ninteenth");
      break;
    }
  }
  int r = day % 10;
  int x = day - r;
  switch (x) {
  case 20:
    printf("Twenty");
    day_string(r);
    break;
  case 30:
    printf("Thirty");
    day_string(r);
    break;
  }
}


x86 assembly (clang, -O0):
<day_string>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
cmpl   $0x20,-0x4(%rbp)
jg     113f <day_string+0x1f>
cmpl   $0x0,-0x4(%rbp)
jge    1150 <day_string+0x30>
lea    0xf0a(%rip),%rdi
call   1030 <printf@plt>
jmp    139d <day_string+0x27d>
mov    -0x4(%rbp),%eax
sub    $0x9,%eax
cmp    $0x0,%eax
jg     1233 <day_string+0x113>
mov    -0x4(%rbp),%eax
mov    %rax,-0x18(%rbp)
sub    $0x9,%rax
ja     1222 <day_string+0x102>
mov    -0x18(%rbp),%rax
lea    0xead(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
jmp    122e <day_string+0x10e>
lea    0xecc(%rip),%rdi
call   1030 <printf@plt>
jmp    122e <day_string+0x10e>
lea    0xec1(%rip),%rdi
call   1030 <printf@plt>
jmp    122e <day_string+0x10e>
lea    0xeb7(%rip),%rdi
call   1030 <printf@plt>
jmp    122e <day_string+0x10e>
lea    0xeac(%rip),%rdi
call   1030 <printf@plt>
jmp    122e <day_string+0x10e>
lea    0xea2(%rip),%rdi
call   1030 <printf@plt>
jmp    122e <day_string+0x10e>
lea    0xe91(%rip),%rdi
call   1030 <printf@plt>
jmp    122e <day_string+0x10e>
lea    0xe86(%rip),%rdi
call   1030 <printf@plt>
jmp    122e <day_string+0x10e>
lea    0xe7d(%rip),%rdi
call   1030 <printf@plt>
jmp    122e <day_string+0x10e>
lea    0xe72(%rip),%rdi
call   1030 <printf@plt>
jmp    122e <day_string+0x10e>
lea    0xe67(%rip),%rdi
call   1030 <printf@plt>
jmp    131a <day_string+0x1fa>
mov    -0x4(%rbp),%eax
sub    $0x13,%eax
cmp    $0x0,%eax
jg     1315 <day_string+0x1f5>
mov    -0x4(%rbp),%eax
add    $0xfffffff6,%eax
mov    %eax,%ecx
mov    %rcx,-0x20(%rbp)
sub    $0x9,%eax
ja     1310 <day_string+0x1f0>
mov    -0x20(%rbp),%rax
lea    0xd9e(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xe37(%rip),%rdi
call   1030 <printf@plt>
jmp    1310 <day_string+0x1f0>
lea    0xe2c(%rip),%rdi
call   1030 <printf@plt>
jmp    1310 <day_string+0x1f0>
lea    0xe24(%rip),%rdi
call   1030 <printf@plt>
jmp    1310 <day_string+0x1f0>
lea    0xe1b(%rip),%rdi
call   1030 <printf@plt>
jmp    1310 <day_string+0x1f0>
lea    0xe15(%rip),%rdi
call   1030 <printf@plt>
jmp    1310 <day_string+0x1f0>
lea    0xe0f(%rip),%rdi
call   1030 <printf@plt>
jmp    1310 <day_string+0x1f0>
lea    0xe08(%rip),%rdi
call   1030 <printf@plt>
jmp    1310 <day_string+0x1f0>
lea    0xe01(%rip),%rdi
call   1030 <printf@plt>
jmp    1310 <day_string+0x1f0>
lea    0xdfc(%rip),%rdi
call   1030 <printf@plt>
jmp    1310 <day_string+0x1f0>
lea    0xdf6(%rip),%rdi
call   1030 <printf@plt>
jmp    1315 <day_string+0x1f5>
jmp    131a <day_string+0x1fa>
movslq -0x4(%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,-0x8(%rbp)
mov    -0x4(%rbp),%eax
mov    -0x8(%rbp),%ecx
sub    %ecx,%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x24(%rbp)
sub    $0x14,%eax
je     1370 <day_string+0x250>
jmp    135f <day_string+0x23f>
mov    -0x24(%rbp),%eax
sub    $0x1e,%eax
je     1389 <day_string+0x269>
jmp    139d <day_string+0x27d>
lea    0xd94(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%edi
call   1040 <day_string@plt>
jmp    139d <day_string+0x27d>
lea    0xd82(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%edi
call   1040 <day_string@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<day_string>:
cmp    $0x20,%edi
jbe    1121 <day_string+0x11>
lea    0xf34(%rip),%rdi
jmp    1030 <printf@plt>
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edi,%ebx
lea    0xf27(%rip),%r14
lea    0xec4(%rip),%r12
lea    0xfcf(%rip),%r15
lea    0xfc1(%rip),%rbp
jmp    1158 <day_string+0x48>
nopl   0x0(%rax)
call   1030 <printf@plt>
mov    %r13d,%ebx
cmp    $0x9,%ebx
ja     1180 <day_string+0x70>
ja     119f <day_string+0x8f>
mov    %ebx,%eax
movslq (%r12,%rax,4),%rax
add    %r12,%rax
mov    %r14,%rdi
jmp    *%rax
lea    0xf02(%rip),%rdi
jmp    11e0 <day_string+0xd0>
cs nopw 0x0(%rax,%rax,1)
cmp    $0x13,%ebx
ja     11e5 <day_string+0xd5>
lea    -0xa(%rbx),%eax
cmp    $0x9,%eax
ja     11e5 <day_string+0xd5>
cltq
lea    0xe92(%rip),%rcx
movslq (%rcx,%rax,4),%rdi
add    %rcx,%rdi
jmp    11e0 <day_string+0xd0>
lea    0xeea(%rip),%rdi
jmp    11e0 <day_string+0xd0>
lea    0xeb3(%rip),%rdi
jmp    11e0 <day_string+0xd0>
lea    0xeb1(%rip),%rdi
jmp    11e0 <day_string+0xd0>
lea    0xeae(%rip),%rdi
jmp    11e0 <day_string+0xd0>
lea    0xeb2(%rip),%rdi
jmp    11e0 <day_string+0xd0>
lea    0xeb1(%rip),%rdi
jmp    11e0 <day_string+0xd0>
lea    0xeae(%rip),%rdi
nopl   0x0(%rax)
call   1030 <printf@plt>
movzbl %bl,%eax
imul   $0xcd,%eax,%ecx
shr    $0xa,%ecx
and    $0xfffffffe,%ecx
lea    (%rcx,%rcx,4),%ecx
sub    %cl,%al
movzbl %al,%r13d
sub    %r13d,%ebx
mov    %r15,%rdi
cmp    $0x1e,%ebx
je     1150 <day_string+0x40>
cmp    $0x14,%ebx
jne    1219 <day_string+0x109>
mov    %rbp,%rdi
jmp    1150 <day_string+0x40>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [12 x i8] c"Invalid day\00"
@.str.1 = [6 x i8] c"First\00"
@.str.2 = [7 x i8] c"Second\00"
@.str.3 = [6 x i8] c"Third\00"
@.str.4 = [7 x i8] c"Fourth\00"
@.str.5 = [6 x i8] c"Fifth\00"
@.str.6 = [8 x i8] c"Seventh\00"
@.str.7 = [6 x i8] c"Eigth\00"
@.str.8 = [6 x i8] c"Ninth\00"
@.str.9 = [25 x i8] c"\0ADate Cannot be negative\00"
@.str.10 = [6 x i8] c"Tenth\00"
@.str.11 = [9 x i8] c"Eleventh\00"
@.str.12 = [8 x i8] c"Twelfth\00"
@.str.13 = [11 x i8] c"Thirteenth\00"
@.str.14 = [11 x i8] c"Fourteenth\00"
@.str.15 = [10 x i8] c"Fifteenth\00"
@.str.16 = [10 x i8] c"Sixteenth\00"
@.str.17 = [12 x i8] c"Seventeenth\00"
@.str.18 = [11 x i8] c"Eighteenth\00"
@.str.19 = [10 x i8] c"Ninteenth\00"
@.str.20 = [7 x i8] c"Twenty\00"
@.str.21 = [7 x i8] c"Thirty\00"
define void @day_string(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %2
%5 = load i32, i32* %2
%6 = icmp sgt i32 %5, 32
br i1 %6, label %10, label %7
7: ; preds = %1
%8 = load i32, i32* %2
%9 = icmp slt i32 %8, 0
br i1 %9, label %10, label %12
10: ; preds = %7, %1
%11 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
br label %81
12: ; preds = %7
%13 = load i32, i32* %2
%14 = sub nsw i32 %13, 9
%15 = icmp sle i32 %14, 0
br i1 %15, label %16, label %40
16: ; preds = %12
%17 = load i32, i32* %2
switch i32 %17, label %37 [
i32 0, label %18
i32 1, label %19
i32 2, label %21
i32 3, label %23
i32 4, label %25
i32 5, label %27
i32 6, label %29
i32 7, label %31
i32 8, label %33
i32 9, label %35
]
18: ; preds = %16
br label %39
19: ; preds = %16
%20 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
br label %39
21: ; preds = %16
%22 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
br label %39
23: ; preds = %16
%24 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
br label %39
25: ; preds = %16
%26 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
br label %39
27: ; preds = %16
%28 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0))
br label %39
29: ; preds = %16
%30 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0))
br label %39
31: ; preds = %16
%32 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i64 0, i64 0))
br label %39
33: ; preds = %16
%34 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0))
br label %39
35: ; preds = %16
%36 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.8, i64 0, i64 0))
br label %39
37: ; preds = %16
%38 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.9, i64 0, i64 0))
br label %39
39: ; preds = %37, %35, %33, %31, %29, %27, %25, %23, %21, %19, %18
br label %68
40: ; preds = %12
%41 = load i32, i32* %2
%42 = sub nsw i32 %41, 19
%43 = icmp sle i32 %42, 0
br i1 %43, label %44, label %67
44: ; preds = %40
%45 = load i32, i32* %2
switch i32 %45, label %66 [
i32 10, label %46
i32 11, label %48
i32 12, label %50
i32 13, label %52
i32 14, label %54
i32 15, label %56
i32 16, label %58
i32 17, label %60
i32 18, label %62
i32 19, label %64
]
46: ; preds = %44
%47 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.10, i64 0, i64 0))
br label %66
48: ; preds = %44
%49 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.11, i64 0, i64 0))
br label %66
50: ; preds = %44
%51 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.12, i64 0, i64 0))
br label %66
52: ; preds = %44
%53 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.13, i64 0, i64 0))
br label %66
54: ; preds = %44
%55 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.14, i64 0, i64 0))
br label %66
56: ; preds = %44
%57 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.15, i64 0, i64 0))
br label %66
58: ; preds = %44
%59 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.16, i64 0, i64 0))
br label %66
60: ; preds = %44
%61 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.17, i64 0, i64 0))
br label %66
62: ; preds = %44
%63 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.18, i64 0, i64 0))
br label %66
64: ; preds = %44
%65 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.19, i64 0, i64 0))
br label %66
66: ; preds = %44, %64, %62, %60, %58, %56, %54, %52, %50, %48, %46
br label %67
67: ; preds = %66, %40
br label %68
68: ; preds = %67, %39
%69 = load i32, i32* %2
%70 = srem i32 %69, 10
store i32 %70, i32* %3
%71 = load i32, i32* %2
%72 = load i32, i32* %3
%73 = sub nsw i32 %71, %72
store i32 %73, i32* %4
%74 = load i32, i32* %4
switch i32 %74, label %81 [
i32 20, label %75
i32 30, label %78
]
75: ; preds = %68
%76 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.20, i64 0, i64 0))
%77 = load i32, i32* %3
br label %81
78: ; preds = %68
%79 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.21, i64 0, i64 0))
%80 = load i32, i32* %3
br label %81
81: ; preds = %10, %68, %78, %75
ret void
}

LLVM IR (-O2):
@.str = [12 x i8] c"Invalid day\00"
@.str.1 = [6 x i8] c"First\00"
@.str.2 = [7 x i8] c"Second\00"
@.str.3 = [6 x i8] c"Third\00"
@.str.4 = [7 x i8] c"Fourth\00"
@.str.5 = [6 x i8] c"Fifth\00"
@.str.6 = [8 x i8] c"Seventh\00"
@.str.7 = [6 x i8] c"Eigth\00"
@.str.8 = [6 x i8] c"Ninth\00"
@.str.9 = [25 x i8] c"\0ADate Cannot be negative\00"
@.str.10 = [6 x i8] c"Tenth\00"
@.str.11 = [9 x i8] c"Eleventh\00"
@.str.12 = [8 x i8] c"Twelfth\00"
@.str.13 = [11 x i8] c"Thirteenth\00"
@.str.14 = [11 x i8] c"Fourteenth\00"
@.str.15 = [10 x i8] c"Fifteenth\00"
@.str.16 = [10 x i8] c"Sixteenth\00"
@.str.17 = [12 x i8] c"Seventeenth\00"
@.str.18 = [11 x i8] c"Eighteenth\00"
@.str.19 = [10 x i8] c"Ninteenth\00"
@.str.20 = [7 x i8] c"Twenty\00"
@.str.21 = [7 x i8] c"Thirty\00"
@reltable.day_string = [10 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([6 x i8]* @.str.10 to i64), i64 ptrtoint ([10 x i32]* @reltable.day_string to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([9 x i8]* @.str.11 to i64), i64 ptrtoint ([10 x i32]* @reltable.day_string to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([8 x i8]* @.str.12 to i64), i64 ptrtoint ([10 x i32]* @reltable.day_string to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([11 x i8]* @.str.13 to i64), i64 ptrtoint ([10 x i32]* @reltable.day_string to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([11 x i8]* @.str.14 to i64), i64 ptrtoint ([10 x i32]* @reltable.day_string to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([10 x i8]* @.str.15 to i64), i64 ptrtoint ([10 x i32]* @reltable.day_string to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([10 x i8]* @.str.16 to i64), i64 ptrtoint ([10 x i32]* @reltable.day_string to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([12 x i8]* @.str.17 to i64), i64 ptrtoint ([10 x i32]* @reltable.day_string to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([11 x i8]* @.str.18 to i64), i64 ptrtoint ([10 x i32]* @reltable.day_string to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([10 x i8]* @.str.19 to i64), i64 ptrtoint ([10 x i32]* @reltable.day_string to i64)) to i32)]
define void @day_string(i32 %0) {
%2 = icmp ugt i32 %0, 32
br i1 %2, label %3, label %5
3: ; preds = %1
%4 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
br label %39
5: ; preds = %1, %36
%6 = phi i32 [ %33, %36 ], [ %0, %1 ]
%7 = icmp ult i32 %6, 10
br i1 %7, label %8, label %18
8: ; preds = %5
switch i32 %6, label %17 [
i32 0, label %30
i32 1, label %27
i32 2, label %9
i32 3, label %10
i32 4, label %11
i32 5, label %12
i32 6, label %13
i32 7, label %14
i32 8, label %15
i32 9, label %16
]
9: ; preds = %8
br label %27
10: ; preds = %8
br label %27
11: ; preds = %8
br label %27
12: ; preds = %8
br label %27
13: ; preds = %8
br label %27
14: ; preds = %8
br label %27
15: ; preds = %8
br label %27
16: ; preds = %8
br label %27
17: ; preds = %8
br label %27
18: ; preds = %5
%19 = icmp ult i32 %6, 20
br i1 %19, label %20, label %30
20: ; preds = %18
%21 = add i32 %6, -10
%22 = icmp ult i32 %21, 10
br i1 %22, label %23, label %30
23: ; preds = %20
%24 = sext i32 %21 to i64
%25 = shl i64 %24, 2
%26 = call i8* @llvm.load.relative.i64(i8* bitcast ([10 x i32]* @reltable.day_string to i8*), i64 %25)
br label %27
27: ; preds = %23, %8, %17, %16, %15, %14, %13, %12, %11, %10, %9
%28 = phi i8* [ getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), %9 ], [ getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), %10 ], [ getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), %11 ], [ getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0), %12 ], [ getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0), %13 ], [ getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i64 0, i64 0), %14 ], [ getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0), %15 ], [ getelementptr inbounds ([6 x i8], [6 x i8]* @.str.8, i64 0, i64 0), %16 ], [ getelementptr inbounds ([25 x i8], [25 x i8]* @.str.9, i64 0, i64 0), %17 ], [ getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), %8 ], [ %26, %23 ]
%29 = tail call i32 @printf(i8* dereferenceable(1) %28)
br label %30
30: ; preds = %20, %27, %18, %8
%31 = trunc i32 %6 to i8
%32 = urem i8 %31, 10
%33 = zext i8 %32 to i32
%34 = sub nsw i32 %6, %33
switch i32 %34, label %39 [
i32 20, label %35
i32 30, label %36
]
35: ; preds = %30
br label %36
36: ; preds = %30, %35
%37 = phi i8* [ getelementptr inbounds ([7 x i8], [7 x i8]* @.str.20, i64 0, i64 0), %35 ], [ getelementptr inbounds ([7 x i8], [7 x i8]* @.str.21, i64 0, i64 0), %30 ]
%38 = tail call i32 @printf(i8* dereferenceable(1) %37)
br label %5
39: ; preds = %30, %3
ret void
}