#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 input = 0, reversedInput = 0, digit;
  int numberOfDigits = 0;
  scanf("%d", &input);
  do {
    reversedInput *= 10;
    reversedInput = reversedInput + input % 10;
    input /= 10;
    numberOfDigits++;
  } while (input != 0);
  do {
    digit = reversedInput % 10;
    reversedInput /= 10;
    numberOfDigits--;
    switch (digit) {
    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;
    }
  } while (numberOfDigits != 0);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x14(%rbp)
lea    0xedd(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
imul   $0xa,-0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    -0x18(%rbp),%eax
add    %edx,%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0x8(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x8(%rbp)
jne    1154 <main+0x34>
jmp    119a <main+0x7a>
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,-0x10(%rbp)
movslq -0xc(%rbp),%rax
imul   $0x66666667,%rax,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x22,%rax
add    %ecx,%eax
mov    %eax,-0xc(%rbp)
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%eax
mov    %rax,-0x20(%rbp)
sub    $0x9,%rax
ja     12ae <main+0x18e>
mov    -0x20(%rbp),%rax
lea    0xe00(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xe1b(%rip),%rdi
call   1030 <printf@plt>
jmp    12ae <main+0x18e>
lea    0xe10(%rip),%rdi
call   1030 <printf@plt>
jmp    12ae <main+0x18e>
lea    0xe04(%rip),%rdi
call   1030 <printf@plt>
jmp    12ae <main+0x18e>
lea    0xdf8(%rip),%rdi
call   1030 <printf@plt>
jmp    12ae <main+0x18e>
lea    0xdee(%rip),%rdi
call   1030 <printf@plt>
jmp    12ae <main+0x18e>
lea    0xde3(%rip),%rdi
call   1030 <printf@plt>
jmp    12ae <main+0x18e>
lea    0xdd8(%rip),%rdi
call   1030 <printf@plt>
jmp    12ae <main+0x18e>
lea    0xdcc(%rip),%rdi
call   1030 <printf@plt>
jmp    12ae <main+0x18e>
lea    0xdc2(%rip),%rdi
call   1030 <printf@plt>
jmp    12ae <main+0x18e>
lea    0xdb8(%rip),%rdi
call   1030 <printf@plt>
jmp    12b3 <main+0x193>
cmpl   $0x0,-0x14(%rbp)
jne    119a <main+0x7a>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
movl   $0x0,0xc(%rsp)
lea    0xec9(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1040 <scanf@plt>
xor    %ebp,%ebp
mov    0xc(%rsp),%eax
xor    %ebx,%ebx
nopl   0x0(%rax)
lea    (%rbx,%rbx,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),%ebx
add    $0x9,%edx
add    $0xffffffff,%ebp
cmp    $0x12,%edx
ja     1150 <main+0x30>
mov    %eax,0xc(%rsp)
lea    0xeb3(%rip),%r14
jmp    1194 <main+0x74>
nop
inc    %ebp
je     11c8 <main+0xa8>
movslq %ebx,%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     1190 <main+0x70>
cltq
movslq (%r14,%rax,4),%rdi
add    %r14,%rdi
call   1030 <printf@plt>
jmp    1190 <main+0x70>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

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

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