#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*/ getchar();
int /*<<< orphan*/ printf(char *);
void aRomanos(int p1) {
  int rem;
  int redondo;
  int pTimes;
  if (p1 != 0 && p1 < 4000) {
    if (p1 / 1000 >= 1) {
      rem = p1 % 1000;
      redondo = p1 - rem;
      pTimes = redondo / 1000;
      for (int i = 1; i <= pTimes; i++) {
        printf("M");
      }
    }
    if ((rem >= 900 && rem <= 999) || (p1 >= 900 && p1 <= 999)) {
      printf("CM");
      ;
    }
    if (p1 < 1000) {
      rem = p1;
    }
    if ((rem >= 500 && rem < 900) || (p1 >= 500 && p1 < 900)) {
      printf("D");
      redondo = rem - (rem % 100);
      pTimes = (redondo / 100) - 5;
      for (int i = 1; i <= pTimes; i++) {
        printf("C");
      }
    }
    if ((rem >= 400 && rem < 500) || (p1 >= 400 && p1 < 500)) {
      printf("CD");
    } else if (rem < 500 && rem >= 100 || p1 < 500 && p1 >= 100) {
      redondo = rem - (rem % 100);
      pTimes = redondo / 100;
      for (int i = 1; i <= pTimes; i++) {
        printf("C");
      }
    }
    rem = rem % 100;
    if ((rem >= 50 && rem < 90) || (p1 >= 50 && p1 < 90)) {
      printf("L");
      redondo = rem - (rem % 10);
      pTimes = (redondo / 10) - 5;
      for (int i = 1; i <= pTimes; i++) {
        printf("X");
      }
    }
    if (rem >= 90) {
      printf("XC");
    }
    if ((rem >= 40 && rem < 50) || (p1 >= 40 && p1 < 50)) {
      printf("XL");
    } else if (rem < 50 && rem >= 10 || p1 < 50 && p1 >= 10) {
      redondo = rem - (rem % 10);
      pTimes = redondo / 10;
      for (int i = 1; i <= pTimes; i++) {
        printf("X");
      }
    }
    rem = rem % 10;
    if ((rem >= 5 && rem < 9) || (p1 >= 5 && p1 < 9)) {
      printf("V");
      redondo = rem;
      pTimes = redondo - 5;
      for (int i = 1; i <= pTimes; i++) {
        printf("I");
      }
    }
    if (rem >= 9) {
      printf("IX");
    }
    if (rem == 4 || p1 == 4) {
      printf("IV");
    }
    redondo = rem;
    pTimes = redondo;
    if (rem < 4 || p1 < 4) {
      for (int i = 1; i <= pTimes; i++) {
        printf("I");
      }
    }
  } else {
    printf("ERROR: Numero Invalido\n");
  }
  getchar();
}


x86 assembly (clang, -O0):
<aRomanos>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
cmpl   $0x0,-0x4(%rbp)
je     15f0 <aRomanos+0x4d0>
cmpl   $0xfa0,-0x4(%rbp)
jge    15f0 <aRomanos+0x4d0>
mov    -0x4(%rbp),%eax
mov    $0x3e8,%ecx
cltd
idiv   %ecx
cmp    $0x1,%eax
jl     11ad <aRomanos+0x8d>
mov    -0x4(%rbp),%eax
mov    $0x3e8,%ecx
cltd
idiv   %ecx
mov    %edx,-0x8(%rbp)
mov    -0x4(%rbp),%eax
sub    -0x8(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    $0x3e8,%ecx
cltd
idiv   %ecx
mov    %eax,-0x10(%rbp)
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x10(%rbp),%eax
jg     11a8 <aRomanos+0x88>
lea    0xe6c(%rip),%rdi
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1182 <aRomanos+0x62>
jmp    11ad <aRomanos+0x8d>
cmpl   $0x384,-0x8(%rbp)
jl     11c7 <aRomanos+0xa7>
cmpl   $0x3e7,-0x8(%rbp)
jle    11e1 <aRomanos+0xc1>
cmpl   $0x384,-0x4(%rbp)
jl     11ed <aRomanos+0xcd>
cmpl   $0x3e7,-0x4(%rbp)
jg     11ed <aRomanos+0xcd>
lea    0xe18(%rip),%rdi
call   1030 <printf@plt>
cmpl   $0x3e8,-0x4(%rbp)
jge    1200 <aRomanos+0xe0>
mov    -0x4(%rbp),%eax
mov    %eax,-0x8(%rbp)
cmpl   $0x1f4,-0x8(%rbp)
jl     121a <aRomanos+0xfa>
cmpl   $0x384,-0x8(%rbp)
jl     1234 <aRomanos+0x114>
cmpl   $0x1f4,-0x4(%rbp)
jl     129c <aRomanos+0x17c>
cmpl   $0x384,-0x4(%rbp)
jge    129c <aRomanos+0x17c>
lea    0xdc9(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
mov    %eax,-0x30(%rbp)
mov    -0x8(%rbp),%eax
mov    $0x64,%ecx
cltd
idiv   %ecx
mov    -0x30(%rbp),%eax
sub    %edx,%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    $0x64,%ecx
cltd
idiv   %ecx
sub    $0x5,%eax
mov    %eax,-0x10(%rbp)
movl   $0x1,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x10(%rbp),%eax
jg     1297 <aRomanos+0x177>
lea    0xd83(%rip),%rdi
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1271 <aRomanos+0x151>
jmp    129c <aRomanos+0x17c>
cmpl   $0x190,-0x8(%rbp)
jl     12b6 <aRomanos+0x196>
cmpl   $0x1f4,-0x8(%rbp)
jl     12d0 <aRomanos+0x1b0>
cmpl   $0x190,-0x4(%rbp)
jl     12e1 <aRomanos+0x1c1>
cmpl   $0x1f4,-0x4(%rbp)
jge    12e1 <aRomanos+0x1c1>
lea    0xd2c(%rip),%rdi
call   1030 <printf@plt>
jmp    136d <aRomanos+0x24d>
cmpl   $0x1f4,-0x8(%rbp)
jge    12f8 <aRomanos+0x1d8>
cmpl   $0x64,-0x8(%rbp)
jge    130f <aRomanos+0x1ef>
cmpl   $0x1f4,-0x4(%rbp)
jge    1368 <aRomanos+0x248>
cmpl   $0x64,-0x4(%rbp)
jl     1368 <aRomanos+0x248>
mov    -0x8(%rbp),%eax
mov    %eax,-0x34(%rbp)
mov    -0x8(%rbp),%eax
mov    $0x64,%ecx
cltd
idiv   %ecx
mov    -0x34(%rbp),%eax
sub    %edx,%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    $0x64,%ecx
cltd
idiv   %ecx
mov    %eax,-0x10(%rbp)
movl   $0x1,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x10(%rbp),%eax
jg     1363 <aRomanos+0x243>
lea    0xcb7(%rip),%rdi
call   1030 <printf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    133d <aRomanos+0x21d>
jmp    1368 <aRomanos+0x248>
jmp    136d <aRomanos+0x24d>
mov    -0x8(%rbp),%eax
mov    $0x64,%ecx
cltd
idiv   %ecx
mov    %edx,-0x8(%rbp)
cmpl   $0x32,-0x8(%rbp)
jl     138f <aRomanos+0x26f>
cmpl   $0x5a,-0x8(%rbp)
jl     13a3 <aRomanos+0x283>
cmpl   $0x32,-0x4(%rbp)
jl     140b <aRomanos+0x2eb>
cmpl   $0x5a,-0x4(%rbp)
jge    140b <aRomanos+0x2eb>
lea    0xc60(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
mov    %eax,-0x38(%rbp)
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    -0x38(%rbp),%eax
sub    %edx,%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
sub    $0x5,%eax
mov    %eax,-0x10(%rbp)
movl   $0x1,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x10(%rbp),%eax
jg     1406 <aRomanos+0x2e6>
lea    0xc1c(%rip),%rdi
call   1030 <printf@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    13e0 <aRomanos+0x2c0>
jmp    140b <aRomanos+0x2eb>
cmpl   $0x5a,-0x8(%rbp)
jl     1421 <aRomanos+0x301>
lea    0xbea(%rip),%rdi
call   1030 <printf@plt>
cmpl   $0x28,-0x8(%rbp)
jl     1435 <aRomanos+0x315>
cmpl   $0x32,-0x8(%rbp)
jl     1449 <aRomanos+0x329>
cmpl   $0x28,-0x4(%rbp)
jl     145a <aRomanos+0x33a>
cmpl   $0x32,-0x4(%rbp)
jge    145a <aRomanos+0x33a>
lea    0xbb9(%rip),%rdi
call   1030 <printf@plt>
jmp    14e0 <aRomanos+0x3c0>
cmpl   $0x32,-0x8(%rbp)
jge    146e <aRomanos+0x34e>
cmpl   $0xa,-0x8(%rbp)
jge    1482 <aRomanos+0x362>
cmpl   $0x32,-0x4(%rbp)
jge    14db <aRomanos+0x3bb>
cmpl   $0xa,-0x4(%rbp)
jl     14db <aRomanos+0x3bb>
mov    -0x8(%rbp),%eax
mov    %eax,-0x3c(%rbp)
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    -0x3c(%rbp),%eax
sub    %edx,%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0x10(%rbp)
movl   $0x1,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x10(%rbp),%eax
jg     14d6 <aRomanos+0x3b6>
lea    0xb4c(%rip),%rdi
call   1030 <printf@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    14b0 <aRomanos+0x390>
jmp    14db <aRomanos+0x3bb>
jmp    14e0 <aRomanos+0x3c0>
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,-0x8(%rbp)
cmpl   $0x5,-0x8(%rbp)
jl     1502 <aRomanos+0x3e2>
cmpl   $0x9,-0x8(%rbp)
jl     1516 <aRomanos+0x3f6>
cmpl   $0x5,-0x4(%rbp)
jl     1563 <aRomanos+0x443>
cmpl   $0x9,-0x4(%rbp)
jge    1563 <aRomanos+0x443>
lea    0xaf5(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
sub    $0x5,%eax
mov    %eax,-0x10(%rbp)
movl   $0x1,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x10(%rbp),%eax
jg     155e <aRomanos+0x43e>
lea    0xac1(%rip),%rdi
call   1030 <printf@plt>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1538 <aRomanos+0x418>
jmp    1563 <aRomanos+0x443>
cmpl   $0x9,-0x8(%rbp)
jl     1579 <aRomanos+0x459>
lea    0xa9a(%rip),%rdi
call   1030 <printf@plt>
cmpl   $0x4,-0x8(%rbp)
je     158d <aRomanos+0x46d>
cmpl   $0x4,-0x4(%rbp)
jne    1599 <aRomanos+0x479>
lea    0xa7d(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
cmpl   $0x4,-0x8(%rbp)
jl     15b9 <aRomanos+0x499>
cmpl   $0x4,-0x4(%rbp)
jge    15eb <aRomanos+0x4cb>
movl   $0x1,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x10(%rbp),%eax
jg     15e6 <aRomanos+0x4c6>
lea    0xa39(%rip),%rdi
call   1030 <printf@plt>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    15c0 <aRomanos+0x4a0>
jmp    15eb <aRomanos+0x4cb>
jmp    15fc <aRomanos+0x4dc>
lea    0xa1d(%rip),%rdi
call   1030 <printf@plt>
mov    $0x0,%al
call   1040 <getchar@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<aRomanos>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
test   %edi,%edi
je     1281 <aRomanos+0x141>
mov    %edi,%r14d
cmp    $0xf9f,%edi
jg     1281 <aRomanos+0x141>
cmp    $0x3e8,%r14d
jl     119f <aRomanos+0x5f>
movzwl %r14w,%eax
shr    $0x3,%eax
imul   $0x20c5,%eax,%ebx
shr    $0x14,%ebx
imul   $0x3e8,%ebx,%eax
mov    %r14d,%ecx
sub    %eax,%ecx
movzwl %cx,%r15d
nopw   0x0(%rax,%rax,1)
mov    $0x4d,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%ebx
jne    1190 <aRomanos+0x50>
lea    -0x384(%r14),%eax
cmp    $0x64,%eax
jb     11b4 <aRomanos+0x74>
cmp    $0x384,%r15d
jl     11c0 <aRomanos+0x80>
lea    0xe45(%rip),%rdi
call   1050 <printf@plt>
cmp    $0x3e8,%r14d
cmovl  %r14d,%r15d
lea    -0x1f4(%r15),%r12d
lea    -0x1f4(%r14),%ebp
cmp    $0x190,%ebp
jb     11ea <aRomanos+0xaa>
cmp    $0x18f,%r12d
ja     121f <aRomanos+0xdf>
mov    $0x44,%edi
call   1030 <putchar@plt>
cmp    $0x258,%r15d
jl     121f <aRomanos+0xdf>
mov    %r15d,%eax
imul   $0x51eb851f,%rax,%rbx
shr    $0x25,%rbx
add    $0xfffffffb,%ebx
xchg   %ax,%ax
mov    $0x43,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%ebx
jne    1210 <aRomanos+0xd0>
lea    -0x190(%r14),%eax
cmp    $0x64,%eax
jb     1292 <aRomanos+0x152>
lea    -0x190(%r15),%eax
cmp    $0x63,%eax
jbe    1292 <aRomanos+0x152>
cmp    $0xfffffe70,%r12d
setb   %al
cmp    $0xfffffe70,%ebp
setb   %cl
test   %al,%cl
jne    129e <aRomanos+0x15e>
cmp    $0x64,%r15d
jl     129e <aRomanos+0x15e>
mov    %r15d,%eax
imul   $0x51eb851f,%rax,%rbx
shr    $0x25,%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    $0x43,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%ebx
jne    1270 <aRomanos+0x130>
jmp    129e <aRomanos+0x15e>
lea    0xd8a(%rip),%rdi
call   1040 <puts@plt>
jmp    142f <aRomanos+0x2ef>
lea    0xd6a(%rip),%rdi
call   1050 <printf@plt>
movslq %r15d,%rax
imul   $0x51eb851f,%rax,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x25,%rax
add    %ecx,%eax
imul   $0x64,%eax,%eax
mov    %r15d,%r12d
sub    %eax,%r12d
lea    -0x32(%r14),%ebx
cmp    $0x28,%ebx
jb     12d4 <aRomanos+0x194>
neg    %eax
add    %r15d,%eax
add    $0xffffffce,%eax
cmp    $0x27,%eax
ja     130f <aRomanos+0x1cf>
mov    $0x4c,%edi
call   1030 <putchar@plt>
cmp    $0x3c,%r12b
jl     130f <aRomanos+0x1cf>
movzbl %r12b,%eax
imul   $0xcd,%eax,%ebp
shr    $0xb,%ebp
add    $0xfffffffb,%ebp
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    $0x58,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%ebp
jne    1300 <aRomanos+0x1c0>
cmp    $0x5a,%r12d
jl     1321 <aRomanos+0x1e1>
lea    0xcea(%rip),%rdi
call   1050 <printf@plt>
lea    -0x28(%r14),%eax
cmp    $0xa,%eax
jb     1371 <aRomanos+0x231>
lea    -0x28(%r12),%eax
cmp    $0x9,%eax
jbe    1371 <aRomanos+0x231>
lea    -0x32(%r12),%eax
cmp    $0xffffffd8,%eax
setb   %al
cmp    $0xffffffd8,%ebx
setb   %cl
test   %al,%cl
jne    137d <aRomanos+0x23d>
cmp    $0xa,%r12d
jl     137d <aRomanos+0x23d>
mov    %r12d,%eax
mov    $0xcccccccd,%ebx
imul   %rax,%rbx
shr    $0x23,%rbx
nop
mov    $0x58,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%ebx
jne    1360 <aRomanos+0x220>
jmp    137d <aRomanos+0x23d>
lea    0xc91(%rip),%rdi
call   1050 <printf@plt>
movslq %r12d,%rax
imul   $0x66666667,%rax,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x22,%rax
add    %ecx,%eax
add    %eax,%eax
lea    (%rax,%rax,4),%eax
mov    %r12d,%ebx
sub    %eax,%ebx
lea    -0x5(%r14),%ecx
cmp    $0x4,%ecx
jb     13b4 <aRomanos+0x274>
neg    %eax
add    %r12d,%eax
add    $0xfffffffb,%eax
cmp    $0x3,%eax
ja     13df <aRomanos+0x29f>
mov    $0x56,%edi
call   1030 <putchar@plt>
cmp    $0x6,%ebx
jl     13f0 <aRomanos+0x2b0>
lea    -0x5(%rbx),%ebp
cs nopw 0x0(%rax,%rax,1)
mov    $0x49,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%ebp
jne    13d0 <aRomanos+0x290>
cmp    $0x9,%ebx
jl     13f0 <aRomanos+0x2b0>
lea    0xc21(%rip),%rdi
call   1050 <printf@plt>
cmp    $0x4,%r14d
je     13fb <aRomanos+0x2bb>
cmp    $0x4,%ebx
jne    1407 <aRomanos+0x2c7>
lea    0xc0d(%rip),%rdi
call   1050 <printf@plt>
cmp    $0x4,%ebx
setge  %al
cmp    $0x4,%r14d
setge  %cl
test   %al,%cl
jne    142f <aRomanos+0x2ef>
test   %ebx,%ebx
jle    142f <aRomanos+0x2ef>
nopl   0x0(%rax)
mov    $0x49,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%ebx
jne    1420 <aRomanos+0x2e0>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1060 <getchar@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"M\00"
@.str.1 = [3 x i8] c"CM\00"
@.str.2 = [2 x i8] c"D\00"
@.str.3 = [2 x i8] c"C\00"
@.str.4 = [3 x i8] c"CD\00"
@.str.5 = [2 x i8] c"L\00"
@.str.6 = [2 x i8] c"X\00"
@.str.7 = [3 x i8] c"XC\00"
@.str.8 = [3 x i8] c"XL\00"
@.str.9 = [2 x i8] c"V\00"
@.str.10 = [2 x i8] c"I\00"
@.str.11 = [3 x i8] c"IX\00"
@.str.12 = [3 x i8] c"IV\00"
@.str.13 = [24 x i8] c"ERROR: Numero Invalido\0A\00"
define void @aRomanos(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
store i32 %0, i32* %2
%13 = load i32, i32* %2
%14 = icmp ne i32 %13, 0
br i1 %14, label %15, label %278
15: ; preds = %1
%16 = load i32, i32* %2
%17 = icmp slt i32 %16, 4000
br i1 %17, label %18, label %278
18: ; preds = %15
%19 = load i32, i32* %2
%20 = sdiv i32 %19, 1000
%21 = icmp sge i32 %20, 1
br i1 %21, label %22, label %40
22: ; preds = %18
%23 = load i32, i32* %2
%24 = srem i32 %23, 1000
store i32 %24, i32* %3
%25 = load i32, i32* %2
%26 = load i32, i32* %3
%27 = sub nsw i32 %25, %26
store i32 %27, i32* %4
%28 = load i32, i32* %4
%29 = sdiv i32 %28, 1000
store i32 %29, i32* %5
store i32 1, i32* %6
br label %30
30: ; preds = %36, %22
%31 = load i32, i32* %6
%32 = load i32, i32* %5
%33 = icmp sle i32 %31, %32
br i1 %33, label %34, label %39
34: ; preds = %30
%35 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %36
36: ; preds = %34
%37 = load i32, i32* %6
%38 = add nsw i32 %37, 1
store i32 %38, i32* %6
br label %30
39: ; preds = %30
br label %40
40: ; preds = %39, %18
%41 = load i32, i32* %3
%42 = icmp sge i32 %41, 900
br i1 %42, label %43, label %46
43: ; preds = %40
%44 = load i32, i32* %3
%45 = icmp sle i32 %44, 999
br i1 %45, label %52, label %46
46: ; preds = %43, %40
%47 = load i32, i32* %2
%48 = icmp sge i32 %47, 900
br i1 %48, label %49, label %54
49: ; preds = %46
%50 = load i32, i32* %2
%51 = icmp sle i32 %50, 999
br i1 %51, label %52, label %54
52: ; preds = %49, %43
%53 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
br label %54
54: ; preds = %52, %49, %46
%55 = load i32, i32* %2
%56 = icmp slt i32 %55, 1000
br i1 %56, label %57, label %59
57: ; preds = %54
%58 = load i32, i32* %2
store i32 %58, i32* %3
br label %59
59: ; preds = %57, %54
%60 = load i32, i32* %3
%61 = icmp sge i32 %60, 500
br i1 %61, label %62, label %65
62: ; preds = %59
%63 = load i32, i32* %3
%64 = icmp slt i32 %63, 900
br i1 %64, label %71, label %65
65: ; preds = %62, %59
%66 = load i32, i32* %2
%67 = icmp sge i32 %66, 500
br i1 %67, label %68, label %90
68: ; preds = %65
%69 = load i32, i32* %2
%70 = icmp slt i32 %69, 900
br i1 %70, label %71, label %90
71: ; preds = %68, %62
%72 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%73 = load i32, i32* %3
%74 = load i32, i32* %3
%75 = srem i32 %74, 100
%76 = sub nsw i32 %73, %75
store i32 %76, i32* %4
%77 = load i32, i32* %4
%78 = sdiv i32 %77, 100
%79 = sub nsw i32 %78, 5
store i32 %79, i32* %5
store i32 1, i32* %7
br label %80
80: ; preds = %86, %71
%81 = load i32, i32* %7
%82 = load i32, i32* %5
%83 = icmp sle i32 %81, %82
br i1 %83, label %84, label %89
84: ; preds = %80
%85 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %86
86: ; preds = %84
%87 = load i32, i32* %7
%88 = add nsw i32 %87, 1
store i32 %88, i32* %7
br label %80
89: ; preds = %80
br label %90
90: ; preds = %89, %68, %65
%91 = load i32, i32* %3
%92 = icmp sge i32 %91, 400
br i1 %92, label %93, label %96
93: ; preds = %90
%94 = load i32, i32* %3
%95 = icmp slt i32 %94, 500
br i1 %95, label %102, label %96
96: ; preds = %93, %90
%97 = load i32, i32* %2
%98 = icmp sge i32 %97, 400
br i1 %98, label %99, label %104
99: ; preds = %96
%100 = load i32, i32* %2
%101 = icmp slt i32 %100, 500
br i1 %101, label %102, label %104
102: ; preds = %99, %93
%103 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
br label %134
104: ; preds = %99, %96
%105 = load i32, i32* %3
%106 = icmp slt i32 %105, 500
br i1 %106, label %107, label %110
107: ; preds = %104
%108 = load i32, i32* %3
%109 = icmp sge i32 %108, 100
br i1 %109, label %116, label %110
110: ; preds = %107, %104
%111 = load i32, i32* %2
%112 = icmp slt i32 %111, 500
br i1 %112, label %113, label %133
113: ; preds = %110
%114 = load i32, i32* %2
%115 = icmp sge i32 %114, 100
br i1 %115, label %116, label %133
116: ; preds = %113, %107
%117 = load i32, i32* %3
%118 = load i32, i32* %3
%119 = srem i32 %118, 100
%120 = sub nsw i32 %117, %119
store i32 %120, i32* %4
%121 = load i32, i32* %4
%122 = sdiv i32 %121, 100
store i32 %122, i32* %5
store i32 1, i32* %8
br label %123
123: ; preds = %129, %116
%124 = load i32, i32* %8
%125 = load i32, i32* %5
%126 = icmp sle i32 %124, %125
br i1 %126, label %127, label %132
127: ; preds = %123
%128 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %129
129: ; preds = %127
%130 = load i32, i32* %8
%131 = add nsw i32 %130, 1
store i32 %131, i32* %8
br label %123
132: ; preds = %123
br label %133
133: ; preds = %132, %113, %110
br label %134
134: ; preds = %133, %102
%135 = load i32, i32* %3
%136 = srem i32 %135, 100
store i32 %136, i32* %3
%137 = load i32, i32* %3
%138 = icmp sge i32 %137, 50
br i1 %138, label %139, label %142
139: ; preds = %134
%140 = load i32, i32* %3
%141 = icmp slt i32 %140, 90
br i1 %141, label %148, label %142
142: ; preds = %139, %134
%143 = load i32, i32* %2
%144 = icmp sge i32 %143, 50
br i1 %144, label %145, label %167
145: ; preds = %142
%146 = load i32, i32* %2
%147 = icmp slt i32 %146, 90
br i1 %147, label %148, label %167
148: ; preds = %145, %139
%149 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%150 = load i32, i32* %3
%151 = load i32, i32* %3
%152 = srem i32 %151, 10
%153 = sub nsw i32 %150, %152
store i32 %153, i32* %4
%154 = load i32, i32* %4
%155 = sdiv i32 %154, 10
%156 = sub nsw i32 %155, 5
store i32 %156, i32* %5
store i32 1, i32* %9
br label %157
157: ; preds = %163, %148
%158 = load i32, i32* %9
%159 = load i32, i32* %5
%160 = icmp sle i32 %158, %159
br i1 %160, label %161, label %166
161: ; preds = %157
%162 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
br label %163
163: ; preds = %161
%164 = load i32, i32* %9
%165 = add nsw i32 %164, 1
store i32 %165, i32* %9
br label %157
166: ; preds = %157
br label %167
167: ; preds = %166, %145, %142
%168 = load i32, i32* %3
%169 = icmp sge i32 %168, 90
br i1 %169, label %170, label %172
170: ; preds = %167
%171 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0))
br label %172
172: ; preds = %170, %167
%173 = load i32, i32* %3
%174 = icmp sge i32 %173, 40
br i1 %174, label %175, label %178
175: ; preds = %172
%176 = load i32, i32* %3
%177 = icmp slt i32 %176, 50
br i1 %177, label %184, label %178
178: ; preds = %175, %172
%179 = load i32, i32* %2
%180 = icmp sge i32 %179, 40
br i1 %180, label %181, label %186
181: ; preds = %178
%182 = load i32, i32* %2
%183 = icmp slt i32 %182, 50
br i1 %183, label %184, label %186
184: ; preds = %181, %175
%185 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0))
br label %216
186: ; preds = %181, %178
%187 = load i32, i32* %3
%188 = icmp slt i32 %187, 50
br i1 %188, label %189, label %192
189: ; preds = %186
%190 = load i32, i32* %3
%191 = icmp sge i32 %190, 10
br i1 %191, label %198, label %192
192: ; preds = %189, %186
%193 = load i32, i32* %2
%194 = icmp slt i32 %193, 50
br i1 %194, label %195, label %215
195: ; preds = %192
%196 = load i32, i32* %2
%197 = icmp sge i32 %196, 10
br i1 %197, label %198, label %215
198: ; preds = %195, %189
%199 = load i32, i32* %3
%200 = load i32, i32* %3
%201 = srem i32 %200, 10
%202 = sub nsw i32 %199, %201
store i32 %202, i32* %4
%203 = load i32, i32* %4
%204 = sdiv i32 %203, 10
store i32 %204, i32* %5
store i32 1, i32* %10
br label %205
205: ; preds = %211, %198
%206 = load i32, i32* %10
%207 = load i32, i32* %5
%208 = icmp sle i32 %206, %207
br i1 %208, label %209, label %214
209: ; preds = %205
%210 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
br label %211
211: ; preds = %209
%212 = load i32, i32* %10
%213 = add nsw i32 %212, 1
store i32 %213, i32* %10
br label %205
214: ; preds = %205
br label %215
215: ; preds = %214, %195, %192
br label %216
216: ; preds = %215, %184
%217 = load i32, i32* %3
%218 = srem i32 %217, 10
store i32 %218, i32* %3
%219 = load i32, i32* %3
%220 = icmp sge i32 %219, 5
br i1 %220, label %221, label %224
221: ; preds = %216
%222 = load i32, i32* %3
%223 = icmp slt i32 %222, 9
br i1 %223, label %230, label %224
224: ; preds = %221, %216
%225 = load i32, i32* %2
%226 = icmp sge i32 %225, 5
br i1 %226, label %227, label %245
227: ; preds = %224
%228 = load i32, i32* %2
%229 = icmp slt i32 %228, 9
br i1 %229, label %230, label %245
230: ; preds = %227, %221
%231 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0))
%232 = load i32, i32* %3
store i32 %232, i32* %4
%233 = load i32, i32* %4
%234 = sub nsw i32 %233, 5
store i32 %234, i32* %5
store i32 1, i32* %11
br label %235
235: ; preds = %241, %230
%236 = load i32, i32* %11
%237 = load i32, i32* %5
%238 = icmp sle i32 %236, %237
br i1 %238, label %239, label %244
239: ; preds = %235
%240 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.10, i64 0, i64 0))
br label %241
241: ; preds = %239
%242 = load i32, i32* %11
%243 = add nsw i32 %242, 1
store i32 %243, i32* %11
br label %235
244: ; preds = %235
br label %245
245: ; preds = %244, %227, %224
%246 = load i32, i32* %3
%247 = icmp sge i32 %246, 9
br i1 %247, label %248, label %250
248: ; preds = %245
%249 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.11, i64 0, i64 0))
br label %250
250: ; preds = %248, %245
%251 = load i32, i32* %3
%252 = icmp eq i32 %251, 4
br i1 %252, label %256, label %253
253: ; preds = %250
%254 = load i32, i32* %2
%255 = icmp eq i32 %254, 4
br i1 %255, label %256, label %258
256: ; preds = %253, %250
%257 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.12, i64 0, i64 0))
br label %258
258: ; preds = %256, %253
%259 = load i32, i32* %3
store i32 %259, i32* %4
%260 = load i32, i32* %4
store i32 %260, i32* %5
%261 = load i32, i32* %3
%262 = icmp slt i32 %261, 4
br i1 %262, label %266, label %263
263: ; preds = %258
%264 = load i32, i32* %2
%265 = icmp slt i32 %264, 4
br i1 %265, label %266, label %277
266: ; preds = %263, %258
store i32 1, i32* %12
br label %267
267: ; preds = %273, %266
%268 = load i32, i32* %12
%269 = load i32, i32* %5
%270 = icmp sle i32 %268, %269
br i1 %270, label %271, label %276
271: ; preds = %267
%272 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.10, i64 0, i64 0))
br label %273
273: ; preds = %271
%274 = load i32, i32* %12
%275 = add nsw i32 %274, 1
store i32 %275, i32* %12
br label %267
276: ; preds = %267
br label %277
277: ; preds = %276, %263
br label %280
278: ; preds = %15, %1
%279 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.13, i64 0, i64 0))
br label %280
280: ; preds = %278, %277
%281 = call i32 (...) @getchar()
ret void
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"CM\00"
@.str.4 = [3 x i8] c"CD\00"
@.str.7 = [3 x i8] c"XC\00"
@.str.8 = [3 x i8] c"XL\00"
@.str.11 = [3 x i8] c"IX\00"
@.str.12 = [3 x i8] c"IV\00"
@str = [23 x i8] c"ERROR: Numero Invalido\00"
define void @aRomanos(i32 %0) {
%2 = icmp ne i32 %0, 0
%3 = icmp slt i32 %0, 4000
%4 = and i1 %2, %3
br i1 %4, label %5, label %154
5: ; preds = %1
%6 = icmp sgt i32 %0, 999
br i1 %6, label %7, label %19
7: ; preds = %5
%8 = trunc i32 %0 to i16
%9 = urem i16 %8, 1000
%10 = zext i16 %9 to i32
%11 = udiv i16 %8, 1000
%12 = add nuw nsw i16 %11, 1
%13 = zext i16 %12 to i32
br label %14
14: ; preds = %7, %14
%15 = phi i32 [ %17, %14 ], [ 1, %7 ]
%16 = tail call i32 @putchar(i32 77)
%17 = add nuw nsw i32 %15, 1
%18 = icmp eq i32 %17, %13
br i1 %18, label %19, label %14
19: ; preds = %14, %5
%20 = phi i32 [ undef, %5 ], [ %10, %14 ]
%21 = icmp sgt i32 %20, 899
%22 = add i32 %0, -900
%23 = icmp ult i32 %22, 100
%24 = or i1 %23, %21
br i1 %24, label %25, label %27
25: ; preds = %19
%26 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
br label %27
27: ; preds = %19, %25
%28 = icmp slt i32 %0, 1000
%29 = select i1 %28, i32 %0, i32 %20
%30 = add i32 %29, -500
%31 = icmp ult i32 %30, 400
%32 = add i32 %0, -500
%33 = icmp ult i32 %32, 400
%34 = or i1 %33, %31
br i1 %34, label %35, label %46
35: ; preds = %27
%36 = tail call i32 @putchar(i32 68)
%37 = icmp slt i32 %29, 600
br i1 %37, label %46, label %38
38: ; preds = %35
%39 = udiv i32 %29, 100
%40 = add nsw i32 %39, -4
br label %41
41: ; preds = %38, %41
%42 = phi i32 [ %44, %41 ], [ 1, %38 ]
%43 = tail call i32 @putchar(i32 67)
%44 = add nuw nsw i32 %42, 1
%45 = icmp eq i32 %44, %40
br i1 %45, label %46, label %41
46: ; preds = %41, %35, %27
%47 = add i32 %29, -400
%48 = icmp ult i32 %47, 100
%49 = add i32 %0, -400
%50 = icmp ult i32 %49, 100
%51 = or i1 %50, %48
br i1 %51, label %52, label %54
52: ; preds = %46
%53 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
br label %69
54: ; preds = %46
%55 = add i32 %29, -500
%56 = icmp ult i32 %55, -400
%57 = add i32 %0, -500
%58 = icmp ult i32 %57, -400
%59 = and i1 %58, %56
%60 = icmp slt i32 %29, 100
%61 = select i1 %59, i1 true, i1 %60
br i1 %61, label %69, label %62
62: ; preds = %54
%63 = udiv i32 %29, 100
br label %64
64: ; preds = %62, %64
%65 = phi i32 [ %67, %64 ], [ 1, %62 ]
%66 = tail call i32 @putchar(i32 67)
%67 = add nuw nsw i32 %65, 1
%68 = icmp eq i32 %65, %63
br i1 %68, label %69, label %64
69: ; preds = %64, %54, %52
%70 = srem i32 %29, 100
%71 = add nsw i32 %70, -50
%72 = icmp ult i32 %71, 40
%73 = add i32 %0, -50
%74 = icmp ult i32 %73, 40
%75 = or i1 %74, %72
br i1 %75, label %76, label %89
76: ; preds = %69
%77 = tail call i32 @putchar(i32 76)
%78 = trunc i32 %70 to i8
%79 = icmp slt i8 %78, 60
br i1 %79, label %89, label %80
80: ; preds = %76
%81 = udiv i8 %78, 10
%82 = zext i8 %81 to i32
%83 = add nsw i32 %82, -4
br label %84
84: ; preds = %80, %84
%85 = phi i32 [ %87, %84 ], [ 1, %80 ]
%86 = tail call i32 @putchar(i32 88)
%87 = add nuw nsw i32 %85, 1
%88 = icmp eq i32 %87, %83
br i1 %88, label %89, label %84
89: ; preds = %84, %76, %69
%90 = icmp sgt i32 %70, 89
br i1 %90, label %91, label %93
91: ; preds = %89
%92 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0))
br label %93
93: ; preds = %91, %89
%94 = add nsw i32 %70, -40
%95 = icmp ult i32 %94, 10
%96 = add i32 %0, -40
%97 = icmp ult i32 %96, 10
%98 = or i1 %97, %95
br i1 %98, label %99, label %101
99: ; preds = %93
%100 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0))
br label %116
101: ; preds = %93
%102 = add nsw i32 %70, -50
%103 = icmp ult i32 %102, -40
%104 = add i32 %0, -50
%105 = icmp ult i32 %104, -40
%106 = and i1 %105, %103
%107 = icmp slt i32 %70, 10
%108 = select i1 %106, i1 true, i1 %107
br i1 %108, label %116, label %109
109: ; preds = %101
%110 = udiv i32 %70, 10
br label %111
111: ; preds = %109, %111
%112 = phi i32 [ %114, %111 ], [ 1, %109 ]
%113 = tail call i32 @putchar(i32 88)
%114 = add nuw nsw i32 %112, 1
%115 = icmp eq i32 %112, %110
br i1 %115, label %116, label %111
116: ; preds = %111, %101, %99
%117 = srem i32 %70, 10
%118 = add nsw i32 %117, -5
%119 = icmp ult i32 %118, 4
%120 = add i32 %0, -5
%121 = icmp ult i32 %120, 4
%122 = or i1 %121, %119
br i1 %122, label %123, label %133
123: ; preds = %116
%124 = tail call i32 @putchar(i32 86)
%125 = icmp slt i32 %117, 6
br i1 %125, label %137, label %126
126: ; preds = %123
%127 = add nsw i32 %117, -4
br label %128
128: ; preds = %126, %128
%129 = phi i32 [ %131, %128 ], [ 1, %126 ]
%130 = tail call i32 @putchar(i32 73)
%131 = add nuw nsw i32 %129, 1
%132 = icmp eq i32 %131, %127
br i1 %132, label %133, label %128
133: ; preds = %128, %116
%134 = icmp sgt i32 %117, 8
br i1 %134, label %135, label %137
135: ; preds = %133
%136 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.11, i64 0, i64 0))
br label %137
137: ; preds = %123, %135, %133
%138 = icmp eq i32 %117, 4
%139 = icmp eq i32 %0, 4
%140 = or i1 %139, %138
br i1 %140, label %141, label %143
141: ; preds = %137
%142 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.12, i64 0, i64 0))
br label %143
143: ; preds = %137, %141
%144 = icmp sgt i32 %117, 3
%145 = icmp sgt i32 %0, 3
%146 = and i1 %145, %144
%147 = icmp slt i32 %117, 1
%148 = or i1 %146, %147
br i1 %148, label %156, label %149
149: ; preds = %143, %149
%150 = phi i32 [ %152, %149 ], [ 1, %143 ]
%151 = tail call i32 @putchar(i32 73)
%152 = add nuw nsw i32 %150, 1
%153 = icmp eq i32 %150, %117
br i1 %153, label %156, label %149
154: ; preds = %1
%155 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str, i64 0, i64 0))
br label %156
156: ; preds = %149, %143, %154
%157 = tail call i32 (...) @getchar()
ret void
}