#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*/ printOnes(int);
int /*<<< orphan*/ printf(char *);
void printTens(int num) {
  int tenth = num / 10;
  switch (tenth) {
  case 1:
    printf("X");
    break;
  case 2:
    printf("XX");
    break;
  case 3:
    printf("XXX");
    break;
  case 4:
    printf("XL");
    break;
  case 5:
    printf("L");
    break;
  case 6:
    printf("LX");
    break;
  case 7:
    printf("LXX");
    break;
  case 8:
    printf("LXXX");
    break;
  case 9:
    printf("XC");
    break;
  }
  printOnes(num % 10);
  return;
}


x86 assembly (clang, -O0):
<printTens>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
movslq -0x4(%rbp),%rax
imul   $0x66666667,%rax,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x22,%rax
add    %ecx,%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x10(%rbp)
sub    $0x8,%eax
ja     1203 <printTens+0xe3>
mov    -0x10(%rbp),%rax
lea    0xe9a(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xeb2(%rip),%rdi
call   1030 <printf@plt>
jmp    1203 <printTens+0xe3>
lea    0xea4(%rip),%rdi
call   1030 <printf@plt>
jmp    1203 <printTens+0xe3>
lea    0xe97(%rip),%rdi
call   1030 <printf@plt>
jmp    1203 <printTens+0xe3>
lea    0xe7b(%rip),%rdi
call   1030 <printf@plt>
jmp    1203 <printTens+0xe3>
lea    0xe6b(%rip),%rdi
call   1030 <printf@plt>
jmp    1203 <printTens+0xe3>
lea    0xe5c(%rip),%rdi
call   1030 <printf@plt>
jmp    1203 <printTens+0xe3>
lea    0xe4e(%rip),%rdi
call   1030 <printf@plt>
jmp    1203 <printTens+0xe3>
lea    0xe41(%rip),%rdi
call   1030 <printf@plt>
jmp    1203 <printTens+0xe3>
lea    0xe35(%rip),%rdi
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,%edi
call   1040 <printOnes@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printTens>:
push   %rbx
movslq %edi,%rbx
imul   $0x66666667,%rbx,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x22,%rax
lea    (%rax,%rcx,1),%edx
add    %edx,%edx
lea    (%rdx,%rdx,4),%edx
sub    %edx,%ebx
add    %ecx,%eax
add    $0xffffffff,%eax
cmp    $0x8,%eax
ja     11c4 <printTens+0x94>
lea    0xe9f(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    $0x58,%edi
call   1030 <putchar@plt>
jmp    11c4 <printTens+0x94>
lea    0xeae(%rip),%rdi
jmp    11bf <printTens+0x8f>
lea    0xea9(%rip),%rdi
jmp    11bf <printTens+0x8f>
lea    0xe95(%rip),%rdi
jmp    11bf <printTens+0x8f>
mov    $0x4c,%edi
call   1030 <putchar@plt>
jmp    11c4 <printTens+0x94>
lea    0xe83(%rip),%rdi
jmp    11bf <printTens+0x8f>
lea    0xe7d(%rip),%rdi
jmp    11bf <printTens+0x8f>
lea    0xe78(%rip),%rdi
jmp    11bf <printTens+0x8f>
lea    0xe74(%rip),%rdi
call   1040 <printf@plt>
mov    %ebx,%edi
pop    %rbx
jmp    1050 <printOnes@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"X\00"
@.str.1 = [3 x i8] c"XX\00"
@.str.2 = [4 x i8] c"XXX\00"
@.str.3 = [3 x i8] c"XL\00"
@.str.4 = [2 x i8] c"L\00"
@.str.5 = [3 x i8] c"LX\00"
@.str.6 = [4 x i8] c"LXX\00"
@.str.7 = [5 x i8] c"LXXX\00"
@.str.8 = [3 x i8] c"XC\00"
define void @printTens(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %2
%4 = load i32, i32* %2
%5 = sdiv i32 %4, 10
store i32 %5, i32* %3
%6 = load i32, i32* %3
switch i32 %6, label %25 [
i32 1, label %7
i32 2, label %9
i32 3, label %11
i32 4, label %13
i32 5, label %15
i32 6, label %17
i32 7, label %19
i32 8, label %21
i32 9, label %23
]
7: ; preds = %1
%8 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %25
9: ; preds = %1
%10 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
br label %25
11: ; preds = %1
%12 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
br label %25
13: ; preds = %1
%14 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
br label %25
15: ; preds = %1
%16 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %25
17: ; preds = %1
%18 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
br label %25
19: ; preds = %1
%20 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0))
br label %25
21: ; preds = %1
%22 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0))
br label %25
23: ; preds = %1
%24 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0))
br label %25
25: ; preds = %1, %23, %21, %19, %17, %15, %13, %11, %9, %7
%26 = load i32, i32* %2
%27 = srem i32 %26, 10
%28 = call i32 @printOnes(i32 %27)
ret void
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"XX\00"
@.str.2 = [4 x i8] c"XXX\00"
@.str.3 = [3 x i8] c"XL\00"
@.str.5 = [3 x i8] c"LX\00"
@.str.6 = [4 x i8] c"LXX\00"
@.str.7 = [5 x i8] c"LXXX\00"
@.str.8 = [3 x i8] c"XC\00"
define void @printTens(i32 %0) {
%2 = sdiv i32 %0, 10
%3 = srem i32 %0, 10
switch i32 %2, label %22 [
i32 1, label %4
i32 2, label %6
i32 3, label %8
i32 4, label %10
i32 5, label %12
i32 6, label %14
i32 7, label %16
i32 8, label %18
i32 9, label %20
]
4: ; preds = %1
%5 = tail call i32 @putchar(i32 88)
br label %22
6: ; preds = %1
%7 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
br label %22
8: ; preds = %1
%9 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
br label %22
10: ; preds = %1
%11 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
br label %22
12: ; preds = %1
%13 = tail call i32 @putchar(i32 76)
br label %22
14: ; preds = %1
%15 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
br label %22
16: ; preds = %1
%17 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0))
br label %22
18: ; preds = %1
%19 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0))
br label %22
20: ; preds = %1
%21 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0))
br label %22
22: ; preds = %1, %20, %18, %16, %14, %12, %10, %8, %6, %4
%23 = tail call i32 @printOnes(i32 %3)
ret void
}