#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*/ printTens(int);
int /*<<< orphan*/ printf(char *);
void printHundreds(int num) {
  int hundredth = num / 100;
  switch (hundredth) {
  case 1:
    printf("C");
    break;
  case 2:
    printf("CC");
    break;
  case 3:
    printf("CCC");
    break;
  case 4:
    printf("CD");
    break;
  case 5:
    printf("D");
    break;
  case 6:
    printf("DC");
    break;
  case 7:
    printf("DCC");
    break;
  case 8:
    printf("DCCC");
    break;
  case 9:
    printf("CM");
    break;
  }
  printTens(num % 100);
  return;
}


x86 assembly (clang, -O0):
<printHundreds>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
movslq -0x4(%rbp),%rax
imul   $0x51eb851f,%rax,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x25,%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 <printHundreds+0xe3>
mov    -0x10(%rbp),%rax
lea    0xe9a(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xebb(%rip),%rdi
call   1040 <printf@plt>
jmp    1203 <printHundreds+0xe3>
lea    0xea9(%rip),%rdi
call   1040 <printf@plt>
jmp    1203 <printHundreds+0xe3>
lea    0xe97(%rip),%rdi
call   1040 <printf@plt>
jmp    1203 <printHundreds+0xe3>
lea    0xe7b(%rip),%rdi
call   1040 <printf@plt>
jmp    1203 <printHundreds+0xe3>
lea    0xe6b(%rip),%rdi
call   1040 <printf@plt>
jmp    1203 <printHundreds+0xe3>
lea    0xe5c(%rip),%rdi
call   1040 <printf@plt>
jmp    1203 <printHundreds+0xe3>
lea    0xe4e(%rip),%rdi
call   1040 <printf@plt>
jmp    1203 <printHundreds+0xe3>
lea    0xe41(%rip),%rdi
call   1040 <printf@plt>
jmp    1203 <printHundreds+0xe3>
lea    0xe35(%rip),%rdi
call   1040 <printf@plt>
mov    -0x4(%rbp),%eax
mov    $0x64,%ecx
cltd
idiv   %ecx
mov    %edx,%edi
call   1030 <printTens@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printHundreds>:
push   %rbx
movslq %edi,%rbx
imul   $0x51eb851f,%rbx,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x25,%rax
lea    (%rax,%rcx,1),%edx
imul   $0x64,%edx,%edx
sub    %edx,%ebx
add    %ecx,%eax
add    $0xffffffff,%eax
cmp    $0x8,%eax
ja     11c2 <printHundreds+0x92>
lea    0xea1(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    $0x43,%edi
call   1030 <putchar@plt>
jmp    11c2 <printHundreds+0x92>
lea    0xeb5(%rip),%rdi
jmp    11bd <printHundreds+0x8d>
lea    0xeab(%rip),%rdi
jmp    11bd <printHundreds+0x8d>
lea    0xe97(%rip),%rdi
jmp    11bd <printHundreds+0x8d>
mov    $0x44,%edi
call   1030 <putchar@plt>
jmp    11c2 <printHundreds+0x92>
lea    0xe85(%rip),%rdi
jmp    11bd <printHundreds+0x8d>
lea    0xe7f(%rip),%rdi
jmp    11bd <printHundreds+0x8d>
lea    0xe7a(%rip),%rdi
jmp    11bd <printHundreds+0x8d>
lea    0xe76(%rip),%rdi
call   1050 <printf@plt>
mov    %ebx,%edi
pop    %rbx
jmp    1040 <printTens@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"C\00"
@.str.1 = [3 x i8] c"CC\00"
@.str.2 = [4 x i8] c"CCC\00"
@.str.3 = [3 x i8] c"CD\00"
@.str.4 = [2 x i8] c"D\00"
@.str.5 = [3 x i8] c"DC\00"
@.str.6 = [4 x i8] c"DCC\00"
@.str.7 = [5 x i8] c"DCCC\00"
@.str.8 = [3 x i8] c"CM\00"
define void @printHundreds(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %2
%4 = load i32, i32* %2
%5 = sdiv i32 %4, 100
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, 100
%28 = call i32 @printTens(i32 %27)
ret void
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"CC\00"
@.str.2 = [4 x i8] c"CCC\00"
@.str.3 = [3 x i8] c"CD\00"
@.str.5 = [3 x i8] c"DC\00"
@.str.6 = [4 x i8] c"DCC\00"
@.str.7 = [5 x i8] c"DCCC\00"
@.str.8 = [3 x i8] c"CM\00"
define void @printHundreds(i32 %0) {
%2 = sdiv i32 %0, 100
%3 = srem i32 %0, 100
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 67)
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 68)
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 @printTens(i32 %3)
ret void
}