#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*/ strncmp(char *, char *, int);
int num_to_roman_2(char *s) {
  if (!strncmp("CM", s, 2))
    return (900);
  if (!strncmp("CD", s, 2))
    return (400);
  if (!strncmp("XC", s, 2))
    return (90);
  if (!strncmp("XL", s, 2))
    return (40);
  if (!strncmp("IX", s, 2))
    return (9);
  if (!strncmp("IV", s, 2))
    return (4);
  return (0);
}


x86 assembly (clang, -O0):
<num_to_roman_2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rsi
lea    0xed9(%rip),%rdi
mov    $0x2,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
jne    1146 <num_to_roman_2+0x36>
movl   $0x384,-0x4(%rbp)
jmp    121f <num_to_roman_2+0x10f>
mov    -0x10(%rbp),%rsi
lea    0xeb2(%rip),%rdi
mov    $0x2,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
jne    1170 <num_to_roman_2+0x60>
movl   $0x190,-0x4(%rbp)
jmp    121f <num_to_roman_2+0x10f>
mov    -0x10(%rbp),%rsi
lea    0xe8b(%rip),%rdi
mov    $0x2,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
jne    119a <num_to_roman_2+0x8a>
movl   $0x5a,-0x4(%rbp)
jmp    121f <num_to_roman_2+0x10f>
mov    -0x10(%rbp),%rsi
lea    0xe64(%rip),%rdi
mov    $0x2,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
jne    11c4 <num_to_roman_2+0xb4>
movl   $0x28,-0x4(%rbp)
jmp    121f <num_to_roman_2+0x10f>
mov    -0x10(%rbp),%rsi
lea    0xe3d(%rip),%rdi
mov    $0x2,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
jne    11ee <num_to_roman_2+0xde>
movl   $0x9,-0x4(%rbp)
jmp    121f <num_to_roman_2+0x10f>
mov    -0x10(%rbp),%rsi
lea    0xe16(%rip),%rdi
mov    $0x2,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
jne    1218 <num_to_roman_2+0x108>
movl   $0x4,-0x4(%rbp)
jmp    121f <num_to_roman_2+0x10f>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<num_to_roman_2>:
push   %rbx
mov    %rdi,%rbx
lea    0xee5(%rip),%rdi
mov    %rbx,%rsi
mov    $0x2,%edx
call   1030 <strncmp@plt>
test   %eax,%eax
je     11b2 <num_to_roman_2+0xa2>
lea    0xecc(%rip),%rdi
mov    %rbx,%rsi
mov    $0x2,%edx
call   1030 <strncmp@plt>
test   %eax,%eax
je     11b9 <num_to_roman_2+0xa9>
lea    0xeb7(%rip),%rdi
mov    %rbx,%rsi
mov    $0x2,%edx
call   1030 <strncmp@plt>
test   %eax,%eax
je     11c0 <num_to_roman_2+0xb0>
lea    0xea2(%rip),%rdi
mov    %rbx,%rsi
mov    $0x2,%edx
call   1030 <strncmp@plt>
test   %eax,%eax
je     11c7 <num_to_roman_2+0xb7>
lea    0xe8d(%rip),%rdi
mov    %rbx,%rsi
mov    $0x2,%edx
call   1030 <strncmp@plt>
test   %eax,%eax
je     11ce <num_to_roman_2+0xbe>
lea    0xe78(%rip),%rdi
mov    %rbx,%rsi
mov    $0x2,%edx
call   1030 <strncmp@plt>
mov    %eax,%ecx
xor    %eax,%eax
test   %ecx,%ecx
sete   %al
shl    $0x2,%eax
pop    %rbx
ret
mov    $0x384,%eax
pop    %rbx
ret
mov    $0x190,%eax
pop    %rbx
ret
mov    $0x5a,%eax
pop    %rbx
ret
mov    $0x28,%eax
pop    %rbx
ret
mov    $0x9,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [3 x i8] c"CM\00"
@.str.1 = [3 x i8] c"CD\00"
@.str.2 = [3 x i8] c"XC\00"
@.str.3 = [3 x i8] c"XL\00"
@.str.4 = [3 x i8] c"IX\00"
@.str.5 = [3 x i8] c"IV\00"
define i32 @num_to_roman_2(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
store i8* %0, i8** %3
%4 = load i8*, i8** %3
%5 = call i32 @strncmp(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %4, i32 2)
%6 = icmp ne i32 %5, 0
br i1 %6, label %8, label %7
7: ; preds = %1
store i32 900, i32* %2
br label %34
8: ; preds = %1
%9 = load i8*, i8** %3
%10 = call i32 @strncmp(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %9, i32 2)
%11 = icmp ne i32 %10, 0
br i1 %11, label %13, label %12
12: ; preds = %8
store i32 400, i32* %2
br label %34
13: ; preds = %8
%14 = load i8*, i8** %3
%15 = call i32 @strncmp(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %14, i32 2)
%16 = icmp ne i32 %15, 0
br i1 %16, label %18, label %17
17: ; preds = %13
store i32 90, i32* %2
br label %34
18: ; preds = %13
%19 = load i8*, i8** %3
%20 = call i32 @strncmp(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %19, i32 2)
%21 = icmp ne i32 %20, 0
br i1 %21, label %23, label %22
22: ; preds = %18
store i32 40, i32* %2
br label %34
23: ; preds = %18
%24 = load i8*, i8** %3
%25 = call i32 @strncmp(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %24, i32 2)
%26 = icmp ne i32 %25, 0
br i1 %26, label %28, label %27
27: ; preds = %23
store i32 9, i32* %2
br label %34
28: ; preds = %23
%29 = load i8*, i8** %3
%30 = call i32 @strncmp(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i8* %29, i32 2)
%31 = icmp ne i32 %30, 0
br i1 %31, label %33, label %32
32: ; preds = %28
store i32 4, i32* %2
br label %34
33: ; preds = %28
store i32 0, i32* %2
br label %34
34: ; preds = %33, %32, %27, %22, %17, %12, %7
%35 = load i32, i32* %2
ret i32 %35
}

LLVM IR (-O2):
@.str = [3 x i8] c"CM\00"
@.str.1 = [3 x i8] c"CD\00"
@.str.2 = [3 x i8] c"XC\00"
@.str.3 = [3 x i8] c"XL\00"
@.str.4 = [3 x i8] c"IX\00"
@.str.5 = [3 x i8] c"IV\00"
define i32 @num_to_roman_2(i8* %0) {
%2 = tail call i32 @strncmp(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %0, i32 2)
%3 = icmp eq i32 %2, 0
br i1 %3, label %20, label %4
4: ; preds = %1
%5 = tail call i32 @strncmp(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %0, i32 2)
%6 = icmp eq i32 %5, 0
br i1 %6, label %20, label %7
7: ; preds = %4
%8 = tail call i32 @strncmp(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %0, i32 2)
%9 = icmp eq i32 %8, 0
br i1 %9, label %20, label %10
10: ; preds = %7
%11 = tail call i32 @strncmp(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %0, i32 2)
%12 = icmp eq i32 %11, 0
br i1 %12, label %20, label %13
13: ; preds = %10
%14 = tail call i32 @strncmp(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %0, i32 2)
%15 = icmp eq i32 %14, 0
br i1 %15, label %20, label %16
16: ; preds = %13
%17 = tail call i32 @strncmp(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i8* %0, i32 2)
%18 = icmp eq i32 %17, 0
%19 = select i1 %18, i32 4, i32 0
br label %20
20: ; preds = %16, %13, %10, %7, %4, %1
%21 = phi i32 [ 900, %1 ], [ 400, %4 ], [ 90, %7 ], [ 40, %10 ], [ 9, %13 ], [ %19, %16 ]
ret i32 %21
}