int main(void) {
  char num[10][5] = {"ling", "yi",  "er", "san", "si",
                     "wu",   "liu", "qi", "ba",  "jiu"};
  char input[100];
  char output[5];
  int sum = 0;
  int i = 0;
  int j = 0;
  memset(input, 0, sizeof(input) / sizeof(char));
  memset(output, 0, sizeof(output) / sizeof(char));
  scanf("%s", input);
  while (input[i] != '\0') {
    sum += input[i] - '0';
    i++;
  }
  while (sum != 0) {
    output[j] = sum % 10 + '0';
    sum /= 10;
    j++;
  }
  for (int j = 4; j >= 0; j--) {
    if (output[j] != '\0') {
      printf("%s", num[output[j] - '0']);
      if (j != 0) {
        printf(" ");
      }
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xd0,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x40(%rbp),%rdi
lea    0xea3(%rip),%rsi
mov    $0x32,%edx
call   1050 <memcpy@plt>
movl   $0x0,-0xbc(%rbp)
movl   $0x0,-0xc0(%rbp)
movl   $0x0,-0xc4(%rbp)
lea    -0xb0(%rbp),%rdi
xor    %esi,%esi
mov    $0x64,%edx
call   1040 <memset@plt>
lea    -0xb5(%rbp),%rdi
xor    %esi,%esi
mov    $0x5,%edx
call   1040 <memset@plt>
lea    -0xb0(%rbp),%rsi
lea    0xe79(%rip),%rdi
mov    $0x0,%al
call   1060 <scanf@plt>
movslq -0xc0(%rbp),%rax
movsbl -0xb0(%rbp,%rax,1),%eax
ff
cmp    $0x0,%eax
je     120a <main+0xca>
movslq -0xc0(%rbp),%rax
movsbl -0xb0(%rbp,%rax,1),%eax
ff
sub    $0x30,%eax
add    -0xbc(%rbp),%eax
mov    %eax,-0xbc(%rbp)
mov    -0xc0(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc0(%rbp)
jmp    11c0 <main+0x80>
jmp    120f <main+0xcf>
cmpl   $0x0,-0xbc(%rbp)
je     1265 <main+0x125>
mov    -0xbc(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
add    $0x30,%edx
mov    %dl,%cl
movslq -0xc4(%rbp),%rax
mov    %cl,-0xb5(%rbp,%rax,1)
mov    -0xbc(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0xbc(%rbp)
mov    -0xc4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc4(%rbp)
jmp    120f <main+0xcf>
movl   $0x4,-0xc8(%rbp)
cmpl   $0x0,-0xc8(%rbp)
jl     12fa <main+0x1ba>
movslq -0xc8(%rbp),%rax
movsbl -0xb5(%rbp,%rax,1),%eax
ff
cmp    $0x0,%eax
je     12e1 <main+0x1a1>
movslq -0xc8(%rbp),%rax
movsbl -0xb5(%rbp,%rax,1),%eax
ff
sub    $0x30,%eax
cltq
lea    -0x40(%rbp),%rsi
imul   $0x5,%rax,%rax
add    %rax,%rsi
lea    0xd78(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x0,-0xc8(%rbp)
je     12dc <main+0x19c>
lea    0xd60(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12e1 <main+0x1a1>
jmp    12e6 <main+0x1a6>
mov    -0xc8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xc8(%rbp)
jmp    126f <main+0x12f>
xor    %eax,%eax
add    $0xd0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0xc0,%rsp
movzwl 0xef1(%rip),%eax
mov    %ax,0x40(%rsp)
movaps 0xed5(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
movaps 0xeb9(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0xe9d(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
xorps  %xmm0,%xmm0
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x60(%rsp)
movaps %xmm0,0x70(%rsp)
movaps %xmm0,0x80(%rsp)
movaps %xmm0,0x90(%rsp)
movaps %xmm0,0xa0(%rsp)
movl   $0x0,0xb0(%rsp)
movl   $0x0,0x8(%rsp)
movb   $0x0,0xc(%rsp)
lea    0xe81(%rip),%rdi
xor    %ebx,%ebx
lea    0x50(%rsp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
mov    0x50(%rsp),%al
test   %al,%al
je     1256 <main+0x126>
lea    0x51(%rsp),%rcx
movsbl %al,%eax
add    %eax,%ebx
add    $0xffffffd0,%ebx
movzbl (%rcx),%eax
add    $0x1,%rcx
test   %al,%al
jne    11d0 <main+0xa0>
test   %ebx,%ebx
je     1256 <main+0x126>
lea    0x8(%rsp),%rax
nopl   0x0(%rax)
movslq %ebx,%rcx
imul   $0x66666667,%rcx,%rbx
mov    %rbx,%rdx
shr    $0x3f,%rdx
sar    $0x22,%rbx
add    %edx,%ebx
lea    (%rbx,%rbx,1),%edx
lea    (%rdx,%rdx,4),%edx
mov    %ecx,%esi
sub    %edx,%esi
add    $0x30,%sil
mov    %sil,(%rax)
add    $0x9,%ecx
add    $0x1,%rax
cmp    $0x13,%ecx
jae    11f0 <main+0xc0>
movsbq 0xc(%rsp),%rax
test   %rax,%rax
je     1256 <main+0x126>
lea    (%rax,%rax,4),%rax
lea    (%rsp,%rax,1),%rsi
add    $0xffffffffffffff20,%rsi
lea    0xded(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x20,%edi
call   1030 <putchar@plt>
movsbq 0xb(%rsp),%rax
test   %rax,%rax
je     1288 <main+0x158>
lea    (%rax,%rax,4),%rax
lea    (%rsp,%rax,1),%rsi
add    $0xffffffffffffff20,%rsi
lea    0xdbb(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x20,%edi
call   1030 <putchar@plt>
movsbq 0xa(%rsp),%rax
test   %rax,%rax
je     12ba <main+0x18a>
lea    (%rax,%rax,4),%rax
lea    (%rsp,%rax,1),%rsi
add    $0xffffffffffffff20,%rsi
lea    0xd89(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x20,%edi
call   1030 <putchar@plt>
movsbq 0x9(%rsp),%rax
test   %rax,%rax
je     12ec <main+0x1bc>
lea    (%rax,%rax,4),%rax
lea    (%rsp,%rax,1),%rsi
add    $0xffffffffffffff20,%rsi
lea    0xd57(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x20,%edi
call   1030 <putchar@plt>
movsbq 0x8(%rsp),%rax
test   %rax,%rax
je     1314 <main+0x1e4>
lea    (%rax,%rax,4),%rax
lea    (%rsp,%rax,1),%rsi
add    $0xffffffffffffff20,%rsi
lea    0xd25(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0xc0,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@__const.main.num = [10 x [5 x i8]] [[5 x i8] c"ling\00", [5 x i8] c"yi\00\00\00", [5 x i8] c"er\00\00\00", [5 x i8] c"san\00\00", [5 x i8] c"si\00\00\00", [5 x i8] c"wu\00\00\00", [5 x i8] c"liu\00\00", [5 x i8] c"qi\00\00\00", [5 x i8] c"ba\00\00\00", [5 x i8] c"jiu\00\00"]
@.str = [3 x i8] c"%s\00"
@.str.1 = [2 x i8] c" \00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [10 x [5 x i8]]
%3 = alloca [100 x i8]
%4 = alloca [5 x i8]
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %1
%9 = bitcast [10 x [5 x i8]]* %2 to i8*
store i32 0, i32* %5
store i32 0, i32* %6
store i32 0, i32* %7
%10 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%11 = getelementptr inbounds [5 x i8], [5 x i8]* %4, i64 0, i64 0
%12 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%13 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %12)
br label %14
14: ; preds = %21, %0
%15 = load i32, i32* %6
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 %16
%18 = load i8, i8* %17
%19 = sext i8 %18 to i32
%20 = icmp ne i32 %19, 0
br i1 %20, label %21, label %32
21: ; preds = %14
%22 = load i32, i32* %6
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 %23
%25 = load i8, i8* %24
%26 = sext i8 %25 to i32
%27 = sub nsw i32 %26, 48
%28 = load i32, i32* %5
%29 = add nsw i32 %28, %27
store i32 %29, i32* %5
%30 = load i32, i32* %6
%31 = add nsw i32 %30, 1
store i32 %31, i32* %6
br label %14
32: ; preds = %14
br label %33
33: ; preds = %36, %32
%34 = load i32, i32* %5
%35 = icmp ne i32 %34, 0
br i1 %35, label %36, label %48
36: ; preds = %33
%37 = load i32, i32* %5
%38 = srem i32 %37, 10
%39 = add nsw i32 %38, 48
%40 = trunc i32 %39 to i8
%41 = load i32, i32* %7
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds [5 x i8], [5 x i8]* %4, i64 0, i64 %42
store i8 %40, i8* %43
%44 = load i32, i32* %5
%45 = sdiv i32 %44, 10
store i32 %45, i32* %5
%46 = load i32, i32* %7
%47 = add nsw i32 %46, 1
store i32 %47, i32* %7
br label %33
48: ; preds = %33
store i32 4, i32* %8
br label %49
49: ; preds = %76, %48
%50 = load i32, i32* %8
%51 = icmp sge i32 %50, 0
br i1 %51, label %52, label %79
52: ; preds = %49
%53 = load i32, i32* %8
%54 = sext i32 %53 to i64
%55 = getelementptr inbounds [5 x i8], [5 x i8]* %4, i64 0, i64 %54
%56 = load i8, i8* %55
%57 = sext i8 %56 to i32
%58 = icmp ne i32 %57, 0
br i1 %58, label %59, label %75
59: ; preds = %52
%60 = load i32, i32* %8
%61 = sext i32 %60 to i64
%62 = getelementptr inbounds [5 x i8], [5 x i8]* %4, i64 0, i64 %61
%63 = load i8, i8* %62
%64 = sext i8 %63 to i32
%65 = sub nsw i32 %64, 48
%66 = sext i32 %65 to i64
%67 = getelementptr inbounds [10 x [5 x i8]], [10 x [5 x i8]]* %2, i64 0, i64 %66
%68 = getelementptr inbounds [5 x i8], [5 x i8]* %67, i64 0, i64 0
%69 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %68)
%70 = load i32, i32* %8
%71 = icmp ne i32 %70, 0
br i1 %71, label %72, label %74
72: ; preds = %59
%73 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %74
74: ; preds = %72, %59
br label %75
75: ; preds = %74, %52
br label %76
76: ; preds = %75
%77 = load i32, i32* %8
%78 = add nsw i32 %77, -1
store i32 %78, i32* %8
br label %49
79: ; preds = %49
ret i32 0
}

LLVM IR (-O2):
@__const.main.num = [10 x [5 x i8]] [[5 x i8] c"ling\00", [5 x i8] c"yi\00\00\00", [5 x i8] c"er\00\00\00", [5 x i8] c"san\00\00", [5 x i8] c"si\00\00\00", [5 x i8] c"wu\00\00\00", [5 x i8] c"liu\00\00", [5 x i8] c"qi\00\00\00", [5 x i8] c"ba\00\00\00", [5 x i8] c"jiu\00\00"]
@.str = [3 x i8] c"%s\00"
define i32 @main() {
%1 = alloca [10 x [5 x i8]]
%2 = alloca [100 x i8]
%3 = alloca [5 x i8]
%4 = getelementptr inbounds [10 x [5 x i8]], [10 x [5 x i8]]* %1, i64 0, i64 0, i64 0
%5 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%6 = getelementptr inbounds [5 x i8], [5 x i8]* %3, i64 0, i64 0
%7 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %5)
%8 = load i8, i8* %5
%9 = icmp eq i8 %8, 0
br i1 %9, label %44, label %12
10: ; preds = %12
%11 = icmp eq i32 %18, 0
br i1 %11, label %44, label %27
12: ; preds = %0, %12
%13 = phi i64 [ %19, %12 ], [ 0, %0 ]
%14 = phi i8 [ %21, %12 ], [ %8, %0 ]
%15 = phi i32 [ %18, %12 ], [ 0, %0 ]
%16 = sext i8 %14 to i32
%17 = add i32 %15, -48
%18 = add i32 %17, %16
%19 = add nuw nsw i64 %13, 1
%20 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 %19
%21 = load i8, i8* %20
%22 = icmp eq i8 %21, 0
br i1 %22, label %10, label %12
23: ; preds = %27
%24 = getelementptr inbounds [5 x i8], [5 x i8]* %3, i64 0, i64 4
%25 = load i8, i8* %24
%26 = icmp eq i8 %25, 0
br i1 %26, label %44, label %38
27: ; preds = %10, %27
%28 = phi i64 [ %35, %27 ], [ 0, %10 ]
%29 = phi i32 [ %34, %27 ], [ %18, %10 ]
%30 = srem i32 %29, 10
%31 = trunc i32 %30 to i8
%32 = add nsw i8 %31, 48
%33 = getelementptr inbounds [5 x i8], [5 x i8]* %3, i64 0, i64 %28
store i8 %32, i8* %33
%34 = sdiv i32 %29, 10
%35 = add nuw i64 %28, 1
%36 = add i32 %29, 9
%37 = icmp ult i32 %36, 19
br i1 %37, label %23, label %27
38: ; preds = %23
%39 = sext i8 %25 to i64
%40 = add nsw i64 %39, -48
%41 = getelementptr inbounds [10 x [5 x i8]], [10 x [5 x i8]]* %1, i64 0, i64 %40, i64 0
%42 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %41)
%43 = call i32 @putchar(i32 32)
br label %44
44: ; preds = %0, %10, %23, %38
%45 = getelementptr inbounds [5 x i8], [5 x i8]* %3, i64 0, i64 3
%46 = load i8, i8* %45
%47 = icmp eq i8 %46, 0
br i1 %47, label %54, label %48
48: ; preds = %44
%49 = sext i8 %46 to i64
%50 = add nsw i64 %49, -48
%51 = getelementptr inbounds [10 x [5 x i8]], [10 x [5 x i8]]* %1, i64 0, i64 %50, i64 0
%52 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %51)
%53 = call i32 @putchar(i32 32)
br label %54
54: ; preds = %48, %44
%55 = getelementptr inbounds [5 x i8], [5 x i8]* %3, i64 0, i64 2
%56 = load i8, i8* %55
%57 = icmp eq i8 %56, 0
br i1 %57, label %64, label %58
58: ; preds = %54
%59 = sext i8 %56 to i64
%60 = add nsw i64 %59, -48
%61 = getelementptr inbounds [10 x [5 x i8]], [10 x [5 x i8]]* %1, i64 0, i64 %60, i64 0
%62 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %61)
%63 = call i32 @putchar(i32 32)
br label %64
64: ; preds = %58, %54
%65 = getelementptr inbounds [5 x i8], [5 x i8]* %3, i64 0, i64 1
%66 = load i8, i8* %65
%67 = icmp eq i8 %66, 0
br i1 %67, label %74, label %68
68: ; preds = %64
%69 = sext i8 %66 to i64
%70 = add nsw i64 %69, -48
%71 = getelementptr inbounds [10 x [5 x i8]], [10 x [5 x i8]]* %1, i64 0, i64 %70, i64 0
%72 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %71)
%73 = call i32 @putchar(i32 32)
br label %74
74: ; preds = %68, %64
%75 = load i8, i8* %6
%76 = icmp eq i8 %75, 0
br i1 %76, label %82, label %77
77: ; preds = %74
%78 = sext i8 %75 to i64
%79 = add nsw i64 %78, -48
%80 = getelementptr inbounds [10 x [5 x i8]], [10 x [5 x i8]]* %1, i64 0, i64 %79, i64 0
%81 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %80)
br label %82
82: ; preds = %77, %74
ret i32 0
}