#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*/ convert_hundreds(char);
int /*<<< orphan*/ convert_tens(char);
int /*<<< orphan*/ convert_units(char);
int /*<<< orphan*/ gets(char *);
int /*<<< orphan*/ printf(char *);
int strlen(int /*<<< orphan*/);
int main() {
  char x[5];
  int lnth;
  lnth = strlen(gets(x));
  if (lnth == 3) {
    convert_hundreds(x[0]);
    convert_tens(x[1]);
    convert_units(x[2]);
  } else if (lnth == 2) {
    convert_tens(x[0]);
    convert_units(x[1]);
  } else if (lnth == 1) {
    convert_units(x[0]);
  }
  printf("\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x9(%rbp),%rdi
call   1060 <gets@plt>
mov    %eax,%edi
call   1040 <strlen@plt>
mov    %eax,-0x10(%rbp)
cmpl   $0x3,-0x10(%rbp)
jne    11ac <main+0x4c>
movsbl -0x9(%rbp),%edi
call   1030 <convert_hundreds@plt>
movsbl -0x8(%rbp),%edi
call   1080 <convert_tens@plt>
movsbl -0x7(%rbp),%edi
call   1070 <convert_units@plt>
jmp    11ea <main+0x8a>
cmpl   $0x2,-0x10(%rbp)
jne    11cd <main+0x6d>
movsbl -0x9(%rbp),%edi
call   1080 <convert_tens@plt>
movsbl -0x8(%rbp),%edi
call   1070 <convert_units@plt>
jmp    11e5 <main+0x85>
cmpl   $0x1,-0x10(%rbp)
jne    11e0 <main+0x80>
movsbl -0x9(%rbp),%edi
call   1070 <convert_units@plt>
jmp    11e5 <main+0x85>
jmp    11ea <main+0x8a>
lea    0xe0f(%rip),%rdi
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0x3(%rsp),%rdi
call   1060 <gets@plt>
mov    %eax,%edi
call   1050 <strlen@plt>
cmp    $0x1,%eax
je     119b <main+0x3b>
cmp    $0x2,%eax
je     11a1 <main+0x41>
cmp    $0x3,%eax
jne    11b7 <main+0x57>
movsbl 0x3(%rsp),%edi
call   1030 <convert_hundreds@plt>
movsbl 0x4(%rsp),%edi
call   1080 <convert_tens@plt>
mov    0x5(%rsp),%al
jmp    11af <main+0x4f>
mov    0x3(%rsp),%al
jmp    11af <main+0x4f>
movsbl 0x3(%rsp),%edi
call   1080 <convert_tens@plt>
mov    0x4(%rsp),%al
movsbl %al,%edi
call   1070 <convert_units@plt>
mov    $0xa,%edi
call   1040 <putchar@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [5 x i8]
%3 = alloca i32
store i32 0, i32* %1
%4 = getelementptr inbounds [5 x i8], [5 x i8]* %2, i64 0, i64 0
%5 = call i32 @gets(i8* %4)
%6 = call i32 @strlen(i32 %5)
store i32 %6, i32* %3
%7 = load i32, i32* %3
%8 = icmp eq i32 %7, 3
br i1 %8, label %9, label %19
9: ; preds = %0
%10 = getelementptr inbounds [5 x i8], [5 x i8]* %2, i64 0, i64 0
%11 = load i8, i8* %10
%12 = call i32 @convert_hundreds(i8 signext %11)
%13 = getelementptr inbounds [5 x i8], [5 x i8]* %2, i64 0, i64 1
%14 = load i8, i8* %13
%15 = call i32 @convert_tens(i8 signext %14)
%16 = getelementptr inbounds [5 x i8], [5 x i8]* %2, i64 0, i64 2
%17 = load i8, i8* %16
%18 = call i32 @convert_units(i8 signext %17)
br label %38
19: ; preds = %0
%20 = load i32, i32* %3
%21 = icmp eq i32 %20, 2
br i1 %21, label %22, label %29
22: ; preds = %19
%23 = getelementptr inbounds [5 x i8], [5 x i8]* %2, i64 0, i64 0
%24 = load i8, i8* %23
%25 = call i32 @convert_tens(i8 signext %24)
%26 = getelementptr inbounds [5 x i8], [5 x i8]* %2, i64 0, i64 1
%27 = load i8, i8* %26
%28 = call i32 @convert_units(i8 signext %27)
br label %37
29: ; preds = %19
%30 = load i32, i32* %3
%31 = icmp eq i32 %30, 1
br i1 %31, label %32, label %36
32: ; preds = %29
%33 = getelementptr inbounds [5 x i8], [5 x i8]* %2, i64 0, i64 0
%34 = load i8, i8* %33
%35 = call i32 @convert_units(i8 signext %34)
br label %36
36: ; preds = %32, %29
br label %37
37: ; preds = %36, %22
br label %38
38: ; preds = %37, %9
%39 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
define i32 @main() {
%1 = alloca [5 x i8]
%2 = getelementptr inbounds [5 x i8], [5 x i8]* %1, i64 0, i64 0
%3 = call i32 @gets(i8* %2)
%4 = call i32 @strlen(i32 %3)
switch i32 %4, label %23 [
i32 3, label %5
i32 2, label %13
i32 1, label %18
]
5: ; preds = %0
%6 = load i8, i8* %2
%7 = call i32 @convert_hundreds(i8 signext %6)
%8 = getelementptr inbounds [5 x i8], [5 x i8]* %1, i64 0, i64 1
%9 = load i8, i8* %8
%10 = call i32 @convert_tens(i8 signext %9)
%11 = getelementptr inbounds [5 x i8], [5 x i8]* %1, i64 0, i64 2
%12 = load i8, i8* %11
br label %20
13: ; preds = %0
%14 = load i8, i8* %2
%15 = call i32 @convert_tens(i8 signext %14)
%16 = getelementptr inbounds [5 x i8], [5 x i8]* %1, i64 0, i64 1
%17 = load i8, i8* %16
br label %20
18: ; preds = %0
%19 = load i8, i8* %2
br label %20
20: ; preds = %5, %18, %13
%21 = phi i8 [ %17, %13 ], [ %19, %18 ], [ %12, %5 ]
%22 = call i32 @convert_units(i8 signext %21)
br label %23
23: ; preds = %20, %0
%24 = call i32 @putchar(i32 10)
ret i32 0
}