#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*/ EXIT_FAILURE;
int EXIT_SUCCESS;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ stdin;
int main() {
  char digit[5];
  fgets(digit, 5, stdin);
  if (digit[0] == '-' || digit[1] != '\n') {
    printf("not a digit");
    exit(EXIT_FAILURE);
  }
  if (digit[0] >= '0' || digit[0] <= '9') {
    switch (digit[0]) {
    case '0':
      printf("zero");
      break;
    case '1':
      printf("one");
      break;
    case '2':
      printf("two");
      break;
    case '3':
      printf("three");
      break;
    case '4':
      printf("four");
      break;
    case '5':
      printf("five");
      break;
    case '6':
      printf("six");
      break;
    case '7':
      printf("seven");
      break;
    case '8':
      printf("eight");
      break;
    case '9':
      printf("nine");
      break;
    default:
      printf("not a digit");
    }
  }
  return (EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x9(%rbp),%rdi
mov    0x2e9e(%rip),%rax
mov    (%rax),%edx
mov    $0x5,%esi
call   1040 <fgets@plt>
movsbl -0x9(%rbp),%eax
cmp    $0x2d,%eax
je     1170 <main+0x40>
movsbl -0x8(%rbp),%eax
cmp    $0xa,%eax
je     118a <main+0x5a>
lea    0xeb1(%rip),%rdi
call   1030 <printf@plt>
mov    0x2e55(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>
movsbl -0x9(%rbp),%eax
cmp    $0x30,%eax
jge    11a4 <main+0x74>
movsbl -0x9(%rbp),%eax
cmp    $0x39,%eax
jg     1289 <main+0x159>
movsbl -0x9(%rbp),%eax
add    $0xffffffd0,%eax
mov    %eax,%ecx
mov    %rcx,-0x18(%rbp)
sub    $0x9,%eax
ja     1278 <main+0x148>
mov    -0x18(%rbp),%rax
lea    0xe3b(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xe5f(%rip),%rdi
call   1030 <printf@plt>
jmp    1284 <main+0x154>
lea    0xe53(%rip),%rdi
call   1030 <printf@plt>
jmp    1284 <main+0x154>
lea    0xe46(%rip),%rdi
call   1030 <printf@plt>
jmp    1284 <main+0x154>
lea    0xe39(%rip),%rdi
call   1030 <printf@plt>
jmp    1284 <main+0x154>
lea    0xe2e(%rip),%rdi
call   1030 <printf@plt>
jmp    1284 <main+0x154>
lea    0xe22(%rip),%rdi
call   1030 <printf@plt>
jmp    1284 <main+0x154>
lea    0xe16(%rip),%rdi
call   1030 <printf@plt>
jmp    1284 <main+0x154>
lea    0xe09(%rip),%rdi
call   1030 <printf@plt>
jmp    1284 <main+0x154>
lea    0xdfe(%rip),%rdi
call   1030 <printf@plt>
jmp    1284 <main+0x154>
lea    0xdf3(%rip),%rdi
call   1030 <printf@plt>
jmp    1284 <main+0x154>
lea    0xda9(%rip),%rdi
call   1030 <printf@plt>
jmp    1289 <main+0x159>
mov    0x2d40(%rip),%rax
mov    (%rax),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
mov    0x2eb0(%rip),%rax
mov    (%rax),%edx
lea    0x3(%rsp),%rdi
mov    $0x5,%esi
call   1040 <fgets@plt>
movsbq 0x3(%rsp),%rax
cmp    $0x2d,%rax
je     118c <main+0x5c>
cmpb   $0xa,0x4(%rsp)
jne    118c <main+0x5c>
add    $0xffffffffffffffd0,%rax
cmp    $0x9,%eax
ja     1175 <main+0x45>
lea    0xed4(%rip),%rcx
movslq (%rcx,%rax,4),%rdi
add    %rcx,%rdi
jmp    117c <main+0x4c>
lea    0xe84(%rip),%rdi
call   1030 <printf@plt>
mov    0x2e48(%rip),%rax
mov    (%rax),%eax
pop    %rcx
ret
lea    0xe6d(%rip),%rdi
call   1030 <printf@plt>
mov    0x2e39(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@stdin = global i32 0
@.str = [12 x i8] c"not a digit\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [5 x i8] c"zero\00"
@.str.2 = [4 x i8] c"one\00"
@.str.3 = [4 x i8] c"two\00"
@.str.4 = [6 x i8] c"three\00"
@.str.5 = [5 x i8] c"four\00"
@.str.6 = [5 x i8] c"five\00"
@.str.7 = [4 x i8] c"six\00"
@.str.8 = [6 x i8] c"seven\00"
@.str.9 = [6 x i8] c"eight\00"
@.str.10 = [5 x i8] c"nine\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca [5 x i8]
store i32 0, i32* %1
%3 = getelementptr inbounds [5 x i8], [5 x i8]* %2, i64 0, i64 0
%4 = load i32, i32* @stdin
%5 = call i32 @fgets(i8* %3, i32 5, i32 %4)
%6 = getelementptr inbounds [5 x i8], [5 x i8]* %2, i64 0, i64 0
%7 = load i8, i8* %6
%8 = sext i8 %7 to i32
%9 = icmp eq i32 %8, 45
br i1 %9, label %15, label %10
10: ; preds = %0
%11 = getelementptr inbounds [5 x i8], [5 x i8]* %2, i64 0, i64 1
%12 = load i8, i8* %11
%13 = sext i8 %12 to i32
%14 = icmp ne i32 %13, 10
br i1 %14, label %15, label %19
15: ; preds = %10, %0
%16 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%17 = load i32, i32* @EXIT_FAILURE
%18 = call i32 @exit(i32 %17)
unreachable
19: ; preds = %10
%20 = getelementptr inbounds [5 x i8], [5 x i8]* %2, i64 0, i64 0
%21 = load i8, i8* %20
%22 = sext i8 %21 to i32
%23 = icmp sge i32 %22, 48
br i1 %23, label %29, label %24
24: ; preds = %19
%25 = getelementptr inbounds [5 x i8], [5 x i8]* %2, i64 0, i64 0
%26 = load i8, i8* %25
%27 = sext i8 %26 to i32
%28 = icmp sle i32 %27, 57
br i1 %28, label %29, label %56
29: ; preds = %24, %19
%30 = getelementptr inbounds [5 x i8], [5 x i8]* %2, i64 0, i64 0
%31 = load i8, i8* %30
%32 = sext i8 %31 to i32
switch i32 %32, label %53 [
i32 48, label %33
i32 49, label %35
i32 50, label %37
i32 51, label %39
i32 52, label %41
i32 53, label %43
i32 54, label %45
i32 55, label %47
i32 56, label %49
i32 57, label %51
]
33: ; preds = %29
%34 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
br label %55
35: ; preds = %29
%36 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
br label %55
37: ; preds = %29
%38 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
br label %55
39: ; preds = %29
%40 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
br label %55
41: ; preds = %29
%42 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
br label %55
43: ; preds = %29
%44 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
br label %55
45: ; preds = %29
%46 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0))
br label %55
47: ; preds = %29
%48 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.8, i64 0, i64 0))
br label %55
49: ; preds = %29
%50 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.9, i64 0, i64 0))
br label %55
51: ; preds = %29
%52 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.10, i64 0, i64 0))
br label %55
53: ; preds = %29
%54 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
br label %55
55: ; preds = %53, %51, %49, %47, %45, %43, %41, %39, %37, %35, %33
br label %56
56: ; preds = %55, %24
%57 = load i32, i32* @EXIT_SUCCESS
ret i32 %57
}

LLVM IR (-O2):
@stdin = global i32 0
@.str = [12 x i8] c"not a digit\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [5 x i8] c"zero\00"
@.str.2 = [4 x i8] c"one\00"
@.str.3 = [4 x i8] c"two\00"
@.str.4 = [6 x i8] c"three\00"
@.str.5 = [5 x i8] c"four\00"
@.str.6 = [5 x i8] c"five\00"
@.str.7 = [4 x i8] c"six\00"
@.str.8 = [6 x i8] c"seven\00"
@.str.9 = [6 x i8] c"eight\00"
@.str.10 = [5 x i8] c"nine\00"
@EXIT_SUCCESS = global i32 0
@reltable.main = [10 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str.1 to i64), i64 ptrtoint ([10 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.2 to i64), i64 ptrtoint ([10 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.3 to i64), i64 ptrtoint ([10 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([6 x i8]* @.str.4 to i64), i64 ptrtoint ([10 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str.5 to i64), i64 ptrtoint ([10 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str.6 to i64), i64 ptrtoint ([10 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.7 to i64), i64 ptrtoint ([10 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([6 x i8]* @.str.8 to i64), i64 ptrtoint ([10 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([6 x i8]* @.str.9 to i64), i64 ptrtoint ([10 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str.10 to i64), i64 ptrtoint ([10 x i32]* @reltable.main to i64)) to i32)]
define i32 @main() {
%1 = alloca [5 x i8]
%2 = getelementptr inbounds [5 x i8], [5 x i8]* %1, i64 0, i64 0
%3 = load i32, i32* @stdin
%4 = call i32 @fgets(i8* %2, i32 5, i32 %3)
%5 = load i8, i8* %2
%6 = icmp eq i8 %5, 45
%7 = getelementptr inbounds [5 x i8], [5 x i8]* %1, i64 0, i64 1
%8 = load i8, i8* %7
%9 = icmp ne i8 %8, 10
%10 = select i1 %6, i1 true, i1 %9
br i1 %10, label %11, label %15
11: ; preds = %0
%12 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%13 = load i32, i32* @EXIT_FAILURE
%14 = call i32 @exit(i32 %13)
unreachable
15: ; preds = %0
%16 = sext i8 %5 to i32
%17 = add nsw i32 %16, -48
%18 = icmp ult i32 %17, 10
br i1 %18, label %19, label %23
19: ; preds = %15
%20 = sext i32 %17 to i64
%21 = shl i64 %20, 2
%22 = call i8* @llvm.load.relative.i64(i8* bitcast ([10 x i32]* @reltable.main to i8*), i64 %21)
br label %23
23: ; preds = %15, %19
%24 = phi i8* [ %22, %19 ], [ getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), %15 ]
%25 = call i32 @printf(i8* dereferenceable(1) %24)
%26 = load i32, i32* @EXIT_SUCCESS
ret i32 %26
}