#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*/ free(char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int main(void) {
  char *nums[] = {"zero", "one", "two",   "three", "four",
                  "five", "six", "seven", "eight", "nine"};
  int entry;
  char final[] = "";
  char new[] = "";
  printf("Enter a number ");
  scanf("%i", &entry);
  while (entry) {
    int result = entry % 10;
    entry /= 10;
    strcpy(new, nums[result]);
    strcat(new, final);
    strcpy(final, new);
    free(new);
  }
  printf("%s\n", final);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x60(%rbp),%rdi
lea    0x2c46(%rip),%rsi
mov    $0x50,%edx
call   1070 <memcpy@plt>
lea    -0x65(%rbp),%rdi
xor    %esi,%esi
mov    $0x1,%edx
call   1060 <memset@plt>
lea    -0x66(%rbp),%rdi
xor    %esi,%esi
mov    $0x1,%edx
call   1060 <memset@plt>
lea    0xe77(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xe79(%rip),%rdi
lea    -0x64(%rbp),%rsi
call   1080 <scanf@plt>
cmpl   $0x0,-0x64(%rbp)
je     1232 <main+0xc2>
mov    -0x64(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,-0x6c(%rbp)
mov    -0x64(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0x64(%rbp)
lea    -0x66(%rbp),%rdi
movslq -0x6c(%rbp),%rax
mov    -0x60(%rbp,%rax,8),%rsi
call   1040 <strcpy@plt>
lea    -0x66(%rbp),%rdi
lea    -0x65(%rbp),%rsi
call   1090 <strcat@plt>
lea    -0x65(%rbp),%rdi
lea    -0x66(%rbp),%rsi
call   1040 <strcpy@plt>
lea    -0x66(%rbp),%rdi
call   1030 <free@plt>
jmp    11d2 <main+0x62>
lea    -0x65(%rbp),%rsi
lea    0xe08(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
movb   $0x0,0xa(%rsp)
movb   $0x0,0xb(%rsp)
lea    0xeb8(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xeba(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1070 <scanf@plt>
mov    0xc(%rsp),%eax
test   %eax,%eax
je     1209 <main+0xa9>
lea    0xea7(%rip),%r15
lea    0xb(%rsp),%rbx
lea    0xa(%rsp),%r14
nopl   0x0(%rax,%rax,1)
cltq
imul   $0x66666667,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x22,%rcx
add    %edx,%ecx
lea    (%rcx,%rcx,1),%edx
lea    (%rdx,%rdx,4),%edx
sub    %edx,%eax
mov    %ecx,0xc(%rsp)
cltq
movslq (%r15,%rax,4),%rsi
add    %r15,%rsi
mov    %rbx,%rdi
call   1040 <strcpy@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1080 <strcat@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <strcpy@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    0xc(%rsp),%eax
test   %eax,%eax
jne    11b0 <main+0x50>
lea    0xa(%rsp),%rdi
call   1050 <puts@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [5 x i8] c"zero\00"
@.str.1 = [4 x i8] c"one\00"
@.str.2 = [4 x i8] c"two\00"
@.str.3 = [6 x i8] c"three\00"
@.str.4 = [5 x i8] c"four\00"
@.str.5 = [5 x i8] c"five\00"
@.str.6 = [4 x i8] c"six\00"
@.str.7 = [6 x i8] c"seven\00"
@.str.8 = [6 x i8] c"eight\00"
@.str.9 = [5 x i8] c"nine\00"
@__const.main.nums = [10 x i8*] [i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.8, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i32 0, i32 0)]
@.str.10 = [16 x i8] c"Enter a number \00"
@.str.11 = [3 x i8] c"%i\00"
@.str.12 = [4 x i8] c"%s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [10 x i8*]
%3 = alloca i32
%4 = alloca [1 x i8]
%5 = alloca [1 x i8]
%6 = alloca i32
store i32 0, i32* %1
%7 = bitcast [10 x i8*]* %2 to i8*
%8 = bitcast [1 x i8]* %4 to i8*
%9 = bitcast [1 x i8]* %5 to i8*
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.10, i64 0, i64 0))
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.11, i64 0, i64 0), i32* %3)
br label %12
12: ; preds = %15, %0
%13 = load i32, i32* %3
%14 = icmp ne i32 %13, 0
br i1 %14, label %15, label %34
15: ; preds = %12
%16 = load i32, i32* %3
%17 = srem i32 %16, 10
store i32 %17, i32* %6
%18 = load i32, i32* %3
%19 = sdiv i32 %18, 10
store i32 %19, i32* %3
%20 = getelementptr inbounds [1 x i8], [1 x i8]* %5, i64 0, i64 0
%21 = load i32, i32* %6
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds [10 x i8*], [10 x i8*]* %2, i64 0, i64 %22
%24 = load i8*, i8** %23
%25 = call i32 @strcpy(i8* %20, i8* %24)
%26 = getelementptr inbounds [1 x i8], [1 x i8]* %5, i64 0, i64 0
%27 = getelementptr inbounds [1 x i8], [1 x i8]* %4, i64 0, i64 0
%28 = call i32 @strcat(i8* %26, i8* %27)
%29 = getelementptr inbounds [1 x i8], [1 x i8]* %4, i64 0, i64 0
%30 = getelementptr inbounds [1 x i8], [1 x i8]* %5, i64 0, i64 0
%31 = call i32 @strcpy(i8* %29, i8* %30)
%32 = getelementptr inbounds [1 x i8], [1 x i8]* %5, i64 0, i64 0
%33 = call i32 @free(i8* %32)
br label %12
34: ; preds = %12
%35 = getelementptr inbounds [1 x i8], [1 x i8]* %4, i64 0, i64 0
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.12, i64 0, i64 0), i8* %35)
%37 = load i32, i32* %1
ret i32 %37
}

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