#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, popped;
  int reversed = 0;
  printf("Enter a positive integer: ");
  scanf("%i", &input);
  do {
    popped = input % 10;
    reversed = (reversed * 10) + popped;
    input /= 10;
  } while (input != 0);
  do {
    popped = reversed % 10;
    switch (popped) {
    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("?");
    }
    printf(" ");
    reversed /= 10;
  } while (reversed != 0);
  printf("\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x10(%rbp)
lea    0xeeb(%rip),%rdi
call   1030 <printf@plt>
lea    0xefa(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,-0xc(%rbp)
imul   $0xa,-0x10(%rbp),%eax
add    -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jne    1152 <main+0x32>
jmp    1187 <main+0x67>
movslq -0x10(%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,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %rax,-0x18(%rbp)
sub    $0x9,%rax
ja     127c <main+0x15c>
mov    -0x18(%rbp),%rax
lea    0xe37(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xe6d(%rip),%rdi
call   1030 <printf@plt>
jmp    1288 <main+0x168>
lea    0xe61(%rip),%rdi
call   1030 <printf@plt>
jmp    1288 <main+0x168>
lea    0xe54(%rip),%rdi
call   1030 <printf@plt>
jmp    1288 <main+0x168>
lea    0xe47(%rip),%rdi
call   1030 <printf@plt>
jmp    1288 <main+0x168>
lea    0xe3c(%rip),%rdi
call   1030 <printf@plt>
jmp    1288 <main+0x168>
lea    0xe30(%rip),%rdi
call   1030 <printf@plt>
jmp    1288 <main+0x168>
lea    0xe24(%rip),%rdi
call   1030 <printf@plt>
jmp    1288 <main+0x168>
lea    0xe17(%rip),%rdi
call   1030 <printf@plt>
jmp    1288 <main+0x168>
lea    0xe0c(%rip),%rdi
call   1030 <printf@plt>
jmp    1288 <main+0x168>
lea    0xe01(%rip),%rdi
call   1030 <printf@plt>
jmp    1288 <main+0x168>
lea    0xdf5(%rip),%rdi
call   1030 <printf@plt>
lea    0xdb2(%rip),%rdi
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
jne    1187 <main+0x67>
lea    0xdc7(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xee6(%rip),%rdi
call   1040 <printf@plt>
lea    0xef5(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1050 <scanf@plt>
xor    %ebx,%ebx
mov    0x4(%rsp),%eax
xchg   %ax,%ax
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
cmp    $0x12,%edx
ja     1160 <main+0x30>
mov    %eax,0x4(%rsp)
lea    0xe66(%rip),%rbp
lea    0xec6(%rip),%r15
lea    0xec5(%rip),%r12
lea    0xec4(%rip),%r13
jmp    11d8 <main+0xa8>
mov    $0x3f,%edi
call   1030 <putchar@plt>
nopl   0x0(%rax,%rax,1)
mov    $0x20,%edi
call   1030 <putchar@plt>
add    $0x9,%r14d
cmp    $0x12,%r14d
jbe    129e <main+0x16e>
mov    %ebx,%r14d
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     11b1 <main+0x81>
movslq 0x0(%rbp,%rax,4),%rax
add    %rbp,%rax
jmp    *%rax
lea    0xe36(%rip),%rdi
call   1040 <printf@plt>
jmp    11c0 <main+0x90>
lea    0xe2d(%rip),%rdi
call   1040 <printf@plt>
jmp    11c0 <main+0x90>
lea    0xe23(%rip),%rdi
call   1040 <printf@plt>
jmp    11c0 <main+0x90>
lea    0xe19(%rip),%rdi
call   1040 <printf@plt>
jmp    11c0 <main+0x90>
lea    0xe0e(%rip),%rdi
call   1040 <printf@plt>
jmp    11c0 <main+0x90>
lea    0xe02(%rip),%rdi
call   1040 <printf@plt>
jmp    11c0 <main+0x90>
lea    0xdf6(%rip),%rdi
call   1040 <printf@plt>
jmp    11c0 <main+0x90>
mov    %r15,%rdi
call   1040 <printf@plt>
jmp    11c0 <main+0x90>
mov    %r12,%rdi
call   1040 <printf@plt>
jmp    11c0 <main+0x90>
mov    %r13,%rdi
call   1040 <printf@plt>
jmp    11c0 <main+0x90>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [27 x i8] c"Enter a positive integer: \00"
@.str.1 = [3 x i8] c"%i\00"
@.str.2 = [5 x i8] c"zero\00"
@.str.3 = [4 x i8] c"one\00"
@.str.4 = [4 x i8] c"two\00"
@.str.5 = [6 x i8] c"three\00"
@.str.6 = [5 x i8] c"four\00"
@.str.7 = [5 x i8] c"five\00"
@.str.8 = [4 x i8] c"six\00"
@.str.9 = [6 x i8] c"seven\00"
@.str.10 = [6 x i8] c"eight\00"
@.str.11 = [5 x i8] c"nine\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 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
br label %6
6: ; preds = %6, %0
%7 = phi i32 [ %5, %0 ], [ %12, %6 ]
%8 = phi i32 [ 0, %0 ], [ %11, %6 ]
%9 = srem i32 %7, 10
%10 = mul nsw i32 %8, 10
%11 = add nsw i32 %9, %10
%12 = sdiv i32 %7, 10
%13 = add i32 %7, 9
%14 = icmp ult i32 %13, 19
br i1 %14, label %15, label %6
15: ; preds = %6
store i32 %12, i32* %1
br label %16
16: ; preds = %15, %42
%17 = phi i32 [ %19, %42 ], [ %11, %15 ]
%18 = srem i32 %17, 10
%19 = sdiv i32 %17, 10
switch i32 %18, label %40 [
i32 0, label %20
i32 1, label %22
i32 2, label %24
i32 3, label %26
i32 4, label %28
i32 5, label %30
i32 6, label %32
i32 7, label %34
i32 8, label %36
i32 9, label %38
]
20: ; preds = %16
%21 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
br label %42
22: ; preds = %16
%23 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
br label %42
24: ; preds = %16
%25 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
br label %42
26: ; preds = %16
%27 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0))
br label %42
28: ; preds = %16
%29 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
br label %42
30: ; preds = %16
%31 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0))
br label %42
32: ; preds = %16
%33 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0))
br label %42
34: ; preds = %16
%35 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.9, i64 0, i64 0))
br label %42
36: ; preds = %16
%37 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.10, i64 0, i64 0))
br label %42
38: ; preds = %16
%39 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.11, i64 0, i64 0))
br label %42
40: ; preds = %16
%41 = call i32 @putchar(i32 63)
br label %42
42: ; preds = %40, %38, %36, %34, %32, %30, %28, %26, %24, %22, %20
%43 = call i32 @putchar(i32 32)
%44 = add i32 %17, 9
%45 = icmp ult i32 %44, 19
br i1 %45, label %46, label %16
46: ; preds = %42
%47 = call i32 @putchar(i32 10)
ret i32 0
}