#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 /*<<< orphan*/ scanf(char *, int *);
int main(void) {
  int number, revNumber, digit;
  revNumber = 0;
  printf("Enter a number: ");
  scanf("%d", &number);
  if (number == 0) {
    printf("zero\n");
    return 0;
  }
  do {
    revNumber *= 10;
    revNumber += number % 10;
    number /= 10;
  } while (number > 0);
  do {
    switch (revNumber % 10) {
    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;
    }
    revNumber /= 10;
  } while (revNumber > 0);
  printf("\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xc(%rbp)
lea    0xeeb(%rip),%rdi
call   1030 <printf@plt>
lea    0xef0(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
cmpl   $0x0,-0x8(%rbp)
jne    1174 <main+0x54>
lea    0xed9(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    12c4 <main+0x1a4>
jmp    1179 <main+0x59>
imul   $0xa,-0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
add    -0xc(%rbp),%edx
mov    %edx,-0xc(%rbp)
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jg     1179 <main+0x59>
jmp    11ae <main+0x8e>
movslq -0xc(%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,%ecx
mov    %rcx,-0x18(%rbp)
sub    $0x9,%eax
ja     1299 <main+0x179>
mov    -0x18(%rbp),%rax
lea    0xe15(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xe47(%rip),%rdi
call   1030 <printf@plt>
jmp    1299 <main+0x179>
lea    0xe3c(%rip),%rdi
call   1030 <printf@plt>
jmp    1299 <main+0x179>
lea    0xe30(%rip),%rdi
call   1030 <printf@plt>
jmp    1299 <main+0x179>
lea    0xe24(%rip),%rdi
call   1030 <printf@plt>
jmp    1299 <main+0x179>
lea    0xe1a(%rip),%rdi
call   1030 <printf@plt>
jmp    1299 <main+0x179>
lea    0xe0f(%rip),%rdi
call   1030 <printf@plt>
jmp    1299 <main+0x179>
lea    0xe04(%rip),%rdi
call   1030 <printf@plt>
jmp    1299 <main+0x179>
lea    0xdf8(%rip),%rdi
call   1030 <printf@plt>
jmp    1299 <main+0x179>
lea    0xdee(%rip),%rdi
call   1030 <printf@plt>
jmp    1299 <main+0x179>
lea    0xde4(%rip),%rdi
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jg     11ae <main+0x8e>
lea    0xd88(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
lea    0xeb0(%rip),%rdi
call   1050 <printf@plt>
lea    0xeb5(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1060 <scanf@plt>
mov    0xc(%rsp),%eax
test   %eax,%eax
je     1209 <main+0xc9>
xor    %r15d,%r15d
cs nopw 0x0(%rax,%rax,1)
nop
lea    (%r15,%r15,4),%ecx
movslq %eax,%rdx
imul   $0x66666667,%rdx,%rax
mov    %rax,%rsi
shr    $0x3f,%rsi
sar    $0x22,%rax
add    %esi,%eax
lea    (%rax,%rax,1),%esi
lea    (%rsi,%rsi,4),%esi
mov    %edx,%edi
sub    %esi,%edi
lea    (%rdi,%rcx,2),%r15d
cmp    $0x9,%edx
jg     1180 <main+0x40>
mov    %eax,0xc(%rsp)
lea    0xe9f(%rip),%r14
jmp    11c9 <main+0x89>
nopl   0x0(%rax,%rax,1)
cmp    $0x9,%r15d
mov    %ebx,%r15d
jle    11fd <main+0xbd>
movslq %r15d,%rax
imul   $0x66666667,%rax,%rbx
mov    %rbx,%rcx
shr    $0x3f,%rcx
sar    $0x22,%rbx
add    %ecx,%ebx
lea    (%rbx,%rbx,1),%ecx
lea    (%rcx,%rcx,4),%ecx
sub    %ecx,%eax
cmp    $0x9,%eax
ja     11c0 <main+0x80>
cltq
movslq (%r14,%rax,4),%rdi
add    %r14,%rdi
call   1050 <printf@plt>
jmp    11c0 <main+0x80>
mov    $0xa,%edi
call   1030 <putchar@plt>
jmp    1215 <main+0xd5>
lea    0xe40(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@.str = [17 x i8] c"Enter a number: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.3 = [6 x i8] c"zero \00"
@.str.4 = [5 x i8] c"one \00"
@.str.5 = [5 x i8] c"two \00"
@.str.6 = [7 x i8] c"three \00"
@.str.7 = [6 x i8] c"four \00"
@.str.8 = [6 x i8] c"five \00"
@.str.9 = [5 x i8] c"six \00"
@.str.10 = [7 x i8] c"seven \00"
@.str.11 = [7 x i8] c"eight \00"
@.str.12 = [6 x i8] c"nine \00"
@str = [5 x i8] c"zero\00"
@reltable.main = [10 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([6 x i8]* @.str.3 to i64), i64 ptrtoint ([10 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([5 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 ([7 x i8]* @.str.6 to i64), i64 ptrtoint ([10 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([6 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 ([5 x i8]* @.str.9 to i64), i64 ptrtoint ([10 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([7 x i8]* @.str.10 to i64), i64 ptrtoint ([10 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([7 x i8]* @.str.11 to i64), i64 ptrtoint ([10 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([6 x i8]* @.str.12 to i64), i64 ptrtoint ([10 x i32]* @reltable.main to i64)) to i32)]
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%5 = load i32, i32* %1
%6 = icmp eq i32 %5, 0
br i1 %6, label %7, label %9
7: ; preds = %0
%8 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @str, i64 0, i64 0))
br label %32
9: ; preds = %0, %9
%10 = phi i32 [ %15, %9 ], [ %5, %0 ]
%11 = phi i32 [ %14, %9 ], [ 0, %0 ]
%12 = mul nsw i32 %11, 10
%13 = srem i32 %10, 10
%14 = add nsw i32 %12, %13
%15 = sdiv i32 %10, 10
%16 = icmp sgt i32 %10, 9
br i1 %16, label %9, label %17
17: ; preds = %9
store i32 %15, i32* %1
br label %18
18: ; preds = %17, %28
%19 = phi i32 [ %21, %28 ], [ %14, %17 ]
%20 = srem i32 %19, 10
%21 = sdiv i32 %19, 10
%22 = icmp ult i32 %20, 10
br i1 %22, label %23, label %28
23: ; preds = %18
%24 = sext i32 %20 to i64
%25 = shl i64 %24, 2
%26 = call i8* @llvm.load.relative.i64(i8* bitcast ([10 x i32]* @reltable.main to i8*), i64 %25)
%27 = call i32 @printf(i8* dereferenceable(1) %26)
br label %28
28: ; preds = %18, %23
%29 = icmp sgt i32 %19, 9
br i1 %29, label %18, label %30
30: ; preds = %28
%31 = call i32 @putchar(i32 10)
br label %32
32: ; preds = %30, %7
ret i32 0
}