#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 */
char *calloc(unsigned int, int);
int /*<<< orphan*/ insert_abbreviation(char *, char *, unsigned int *);
scalar_t__ is_substitutable_sequence(char *, unsigned int *, char *);
unsigned int strlen(char *);
char *abbreviate(char original[]) {
  unsigned int original_length = strlen(original);
  char *abbreviated = calloc(original_length + 1, sizeof(char));
  unsigned int j = 0;
  unsigned int i;
  for (i = 0; i < original_length; i++) {
    if (is_substitutable_sequence(original, &i, "DCCCC")) {
      insert_abbreviation(abbreviated, "CM", &j);
    } else if (is_substitutable_sequence(original, &i, "CCCC")) {
      insert_abbreviation(abbreviated, "CD", &j);
    } else if (is_substitutable_sequence(original, &i, "LXXXX")) {
      insert_abbreviation(abbreviated, "XC", &j);
    } else if (is_substitutable_sequence(original, &i, "XXXX")) {
      insert_abbreviation(abbreviated, "XL", &j);
    } else if (is_substitutable_sequence(original, &i, "VIIII")) {
      insert_abbreviation(abbreviated, "IX", &j);
    } else if (is_substitutable_sequence(original, &i, "IIII")) {
      insert_abbreviation(abbreviated, "IV", &j);
    } else {
      abbreviated[j] = original[i];
      j += 1;
    }
  }
  return abbreviated;
}


x86 assembly (clang, -O0):
<abbreviate>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%edi
add    $0x1,%edi
mov    $0x1,%esi
call   1040 <calloc@plt>
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0xc(%rbp),%eax
jae    1319 <abbreviate+0x1d9>
mov    -0x8(%rbp),%rdi
lea    -0x20(%rbp),%rsi
lea    0xe6b(%rip),%rdx
call   1050 <is_substitutable_sequence@plt>
cmp    $0x0,%rax
je     11bd <abbreviate+0x7d>
mov    -0x18(%rbp),%rdi
lea    0xe57(%rip),%rsi
lea    -0x1c(%rbp),%rdx
call   1060 <insert_abbreviation@plt>
jmp    1306 <abbreviate+0x1c6>
mov    -0x8(%rbp),%rdi
lea    -0x20(%rbp),%rsi
lea    0xe35(%rip),%rdx
call   1050 <is_substitutable_sequence@plt>
cmp    $0x0,%rax
je     11f4 <abbreviate+0xb4>
mov    -0x18(%rbp),%rdi
lea    0xe23(%rip),%rsi
lea    -0x1c(%rbp),%rdx
call   1060 <insert_abbreviation@plt>
jmp    1301 <abbreviate+0x1c1>
mov    -0x8(%rbp),%rdi
lea    -0x20(%rbp),%rsi
lea    0xe09(%rip),%rdx
call   1050 <is_substitutable_sequence@plt>
cmp    $0x0,%rax
je     122b <abbreviate+0xeb>
mov    -0x18(%rbp),%rdi
lea    0xdf5(%rip),%rsi
lea    -0x1c(%rbp),%rdx
call   1060 <insert_abbreviation@plt>
jmp    12fc <abbreviate+0x1bc>
mov    -0x8(%rbp),%rdi
lea    -0x20(%rbp),%rsi
lea    0xdd3(%rip),%rdx
call   1050 <is_substitutable_sequence@plt>
cmp    $0x0,%rax
je     1262 <abbreviate+0x122>
mov    -0x18(%rbp),%rdi
lea    0xdc1(%rip),%rsi
lea    -0x1c(%rbp),%rdx
call   1060 <insert_abbreviation@plt>
jmp    12f7 <abbreviate+0x1b7>
mov    -0x8(%rbp),%rdi
lea    -0x20(%rbp),%rsi
lea    0xda7(%rip),%rdx
call   1050 <is_substitutable_sequence@plt>
cmp    $0x0,%rax
je     1299 <abbreviate+0x159>
mov    -0x18(%rbp),%rdi
lea    0xd93(%rip),%rsi
lea    -0x1c(%rbp),%rdx
call   1060 <insert_abbreviation@plt>
jmp    12f2 <abbreviate+0x1b2>
mov    -0x8(%rbp),%rdi
lea    -0x20(%rbp),%rsi
lea    0xd71(%rip),%rdx
call   1050 <is_substitutable_sequence@plt>
cmp    $0x0,%rax
je     12d0 <abbreviate+0x190>
mov    -0x18(%rbp),%rdi
lea    0xd5f(%rip),%rsi
lea    -0x1c(%rbp),%rdx
call   1060 <insert_abbreviation@plt>
jmp    12ed <abbreviate+0x1ad>
mov    -0x8(%rbp),%rax
mov    -0x20(%rbp),%ecx
mov    (%rax,%rcx,1),%dl
mov    -0x18(%rbp),%rax
mov    -0x1c(%rbp),%ecx
mov    %dl,(%rax,%rcx,1)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    12f2 <abbreviate+0x1b2>
jmp    12f7 <abbreviate+0x1b7>
jmp    12fc <abbreviate+0x1bc>
jmp    1301 <abbreviate+0x1c1>
jmp    1306 <abbreviate+0x1c6>
jmp    130b <abbreviate+0x1cb>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    117a <abbreviate+0x3a>
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<abbreviate>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdi,%rbx
call   1030 <strlen@plt>
mov    %eax,%r14d
lea    0x1(%r14),%edi
mov    $0x1,%esi
call   1040 <calloc@plt>
mov    %rax,%r15
movl   $0x0,0x4(%rsp)
movl   $0x0,(%rsp)
test   %r14d,%r14d
je     12a4 <abbreviate+0x164>
lea    0xe7a(%rip),%r12
mov    %rsp,%r13
lea    0x4(%rsp),%rbp
xchg   %ax,%ax
mov    %rbx,%rdi
mov    %r13,%rsi
mov    %r12,%rdx
call   1050 <is_substitutable_sequence@plt>
test   %rax,%rax
je     11c0 <abbreviate+0x80>
mov    %r15,%rdi
lea    0xe59(%rip),%rsi
jmp    1270 <abbreviate+0x130>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %rbx,%rdi
mov    %r13,%rsi
lea    0xe34(%rip),%rdx
call   1050 <is_substitutable_sequence@plt>
test   %rax,%rax
je     11e6 <abbreviate+0xa6>
mov    %r15,%rdi
lea    0xe28(%rip),%rsi
jmp    1270 <abbreviate+0x130>
mov    %rbx,%rdi
mov    %r13,%rsi
lea    0xe19(%rip),%rdx
call   1050 <is_substitutable_sequence@plt>
test   %rax,%rax
je     1209 <abbreviate+0xc9>
mov    %r15,%rdi
lea    0xe0b(%rip),%rsi
jmp    1270 <abbreviate+0x130>
mov    %rbx,%rdi
mov    %r13,%rsi
lea    0xdf7(%rip),%rdx
call   1050 <is_substitutable_sequence@plt>
test   %rax,%rax
je     122c <abbreviate+0xec>
mov    %r15,%rdi
lea    0xdeb(%rip),%rsi
jmp    1270 <abbreviate+0x130>
mov    %rbx,%rdi
mov    %r13,%rsi
lea    0xddf(%rip),%rdx
call   1050 <is_substitutable_sequence@plt>
test   %rax,%rax
je     124f <abbreviate+0x10f>
mov    %r15,%rdi
lea    0xdd1(%rip),%rsi
jmp    1270 <abbreviate+0x130>
mov    %rbx,%rdi
mov    %r13,%rsi
lea    0xdbd(%rip),%rdx
call   1050 <is_substitutable_sequence@plt>
test   %rax,%rax
je     128c <abbreviate+0x14c>
mov    %r15,%rdi
lea    0xdb1(%rip),%rsi
mov    %rbp,%rdx
call   1060 <insert_abbreviation@plt>
mov    (%rsp),%eax
add    $0x1,%eax
mov    %eax,(%rsp)
cmp    %r14d,%eax
jb     1190 <abbreviate+0x50>
jmp    12a4 <abbreviate+0x164>
mov    (%rsp),%eax
movzbl (%rbx,%rax,1),%eax
mov    0x4(%rsp),%ecx
mov    %al,(%r15,%rcx,1)
lea    0x1(%rcx),%eax
mov    %eax,0x4(%rsp)
jmp    1278 <abbreviate+0x138>
mov    %r15,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [6 x i8] c"DCCCC\00"
@.str.1 = [3 x i8] c"CM\00"
@.str.2 = [5 x i8] c"CCCC\00"
@.str.3 = [3 x i8] c"CD\00"
@.str.4 = [6 x i8] c"LXXXX\00"
@.str.5 = [3 x i8] c"XC\00"
@.str.6 = [5 x i8] c"XXXX\00"
@.str.7 = [3 x i8] c"XL\00"
@.str.8 = [6 x i8] c"VIIII\00"
@.str.9 = [3 x i8] c"IX\00"
@.str.10 = [5 x i8] c"IIII\00"
@.str.11 = [3 x i8] c"IV\00"
define i8* @abbreviate(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
store i8* %0, i8** %2
%7 = load i8*, i8** %2
%8 = call i32 @strlen(i8* %7)
store i32 %8, i32* %3
%9 = load i32, i32* %3
%10 = add i32 %9, 1
%11 = call i8* @calloc(i32 %10, i32 1)
store i8* %11, i8** %4
store i32 0, i32* %5
store i32 0, i32* %6
br label %12
12: ; preds = %76, %1
%13 = load i32, i32* %6
%14 = load i32, i32* %3
%15 = icmp ult i32 %13, %14
br i1 %15, label %16, label %79
16: ; preds = %12
%17 = load i8*, i8** %2
%18 = call i64 @is_substitutable_sequence(i8* %17, i32* %6, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%19 = icmp ne i64 %18, 0
br i1 %19, label %20, label %23
20: ; preds = %16
%21 = load i8*, i8** %4
%22 = call i32 @insert_abbreviation(i8* %21, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %5)
br label %75
23: ; preds = %16
%24 = load i8*, i8** %2
%25 = call i64 @is_substitutable_sequence(i8* %24, i32* %6, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%26 = icmp ne i64 %25, 0
br i1 %26, label %27, label %30
27: ; preds = %23
%28 = load i8*, i8** %4
%29 = call i32 @insert_abbreviation(i8* %28, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %5)
br label %74
30: ; preds = %23
%31 = load i8*, i8** %2
%32 = call i64 @is_substitutable_sequence(i8* %31, i32* %6, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
%33 = icmp ne i64 %32, 0
br i1 %33, label %34, label %37
34: ; preds = %30
%35 = load i8*, i8** %4
%36 = call i32 @insert_abbreviation(i8* %35, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32* %5)
br label %73
37: ; preds = %30
%38 = load i8*, i8** %2
%39 = call i64 @is_substitutable_sequence(i8* %38, i32* %6, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
%40 = icmp ne i64 %39, 0
br i1 %40, label %41, label %44
41: ; preds = %37
%42 = load i8*, i8** %4
%43 = call i32 @insert_abbreviation(i8* %42, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i32* %5)
br label %72
44: ; preds = %37
%45 = load i8*, i8** %2
%46 = call i64 @is_substitutable_sequence(i8* %45, i32* %6, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.8, i64 0, i64 0))
%47 = icmp ne i64 %46, 0
br i1 %47, label %48, label %51
48: ; preds = %44
%49 = load i8*, i8** %4
%50 = call i32 @insert_abbreviation(i8* %49, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0), i32* %5)
br label %71
51: ; preds = %44
%52 = load i8*, i8** %2
%53 = call i64 @is_substitutable_sequence(i8* %52, i32* %6, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.10, i64 0, i64 0))
%54 = icmp ne i64 %53, 0
br i1 %54, label %55, label %58
55: ; preds = %51
%56 = load i8*, i8** %4
%57 = call i32 @insert_abbreviation(i8* %56, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.11, i64 0, i64 0), i32* %5)
br label %70
58: ; preds = %51
%59 = load i8*, i8** %2
%60 = load i32, i32* %6
%61 = zext i32 %60 to i64
%62 = getelementptr inbounds i8, i8* %59, i64 %61
%63 = load i8, i8* %62
%64 = load i8*, i8** %4
%65 = load i32, i32* %5
%66 = zext i32 %65 to i64
%67 = getelementptr inbounds i8, i8* %64, i64 %66
store i8 %63, i8* %67
%68 = load i32, i32* %5
%69 = add i32 %68, 1
store i32 %69, i32* %5
br label %70
70: ; preds = %58, %55
br label %71
71: ; preds = %70, %48
br label %72
72: ; preds = %71, %41
br label %73
73: ; preds = %72, %34
br label %74
74: ; preds = %73, %27
br label %75
75: ; preds = %74, %20
br label %76
76: ; preds = %75
%77 = load i32, i32* %6
%78 = add i32 %77, 1
store i32 %78, i32* %6
br label %12
79: ; preds = %12
%80 = load i8*, i8** %4
ret i8* %80
}

LLVM IR (-O2):
@.str = [6 x i8] c"DCCCC\00"
@.str.1 = [3 x i8] c"CM\00"
@.str.2 = [5 x i8] c"CCCC\00"
@.str.3 = [3 x i8] c"CD\00"
@.str.4 = [6 x i8] c"LXXXX\00"
@.str.5 = [3 x i8] c"XC\00"
@.str.6 = [5 x i8] c"XXXX\00"
@.str.7 = [3 x i8] c"XL\00"
@.str.8 = [6 x i8] c"VIIII\00"
@.str.9 = [3 x i8] c"IX\00"
@.str.10 = [5 x i8] c"IIII\00"
@.str.11 = [3 x i8] c"IV\00"
define i8* @abbreviate(i8* %0) {
%2 = alloca i32
%3 = alloca i32
%4 = tail call i32 @strlen(i8* %0)
%5 = add i32 %4, 1
%6 = tail call i8* @calloc(i32 %5, i32 1)
%7 = bitcast i32* %2 to i8*
store i32 0, i32* %2
%8 = bitcast i32* %3 to i8*
store i32 0, i32* %3
%9 = icmp eq i32 %4, 0
br i1 %9, label %53, label %10
10: ; preds = %1, %49
%11 = call i64 @is_substitutable_sequence(i8* %0, i32* %3, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%12 = icmp eq i64 %11, 0
br i1 %12, label %15, label %13
13: ; preds = %10
%14 = call i32 @insert_abbreviation(i8* %6, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
br label %49
15: ; preds = %10
%16 = call i64 @is_substitutable_sequence(i8* %0, i32* %3, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%17 = icmp eq i64 %16, 0
br i1 %17, label %20, label %18
18: ; preds = %15
%19 = call i32 @insert_abbreviation(i8* %6, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %2)
br label %49
20: ; preds = %15
%21 = call i64 @is_substitutable_sequence(i8* %0, i32* %3, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
%22 = icmp eq i64 %21, 0
br i1 %22, label %25, label %23
23: ; preds = %20
%24 = call i32 @insert_abbreviation(i8* %6, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32* %2)
br label %49
25: ; preds = %20
%26 = call i64 @is_substitutable_sequence(i8* %0, i32* %3, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
%27 = icmp eq i64 %26, 0
br i1 %27, label %30, label %28
28: ; preds = %25
%29 = call i32 @insert_abbreviation(i8* %6, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i32* %2)
br label %49
30: ; preds = %25
%31 = call i64 @is_substitutable_sequence(i8* %0, i32* %3, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.8, i64 0, i64 0))
%32 = icmp eq i64 %31, 0
br i1 %32, label %35, label %33
33: ; preds = %30
%34 = call i32 @insert_abbreviation(i8* %6, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0), i32* %2)
br label %49
35: ; preds = %30
%36 = call i64 @is_substitutable_sequence(i8* %0, i32* %3, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.10, i64 0, i64 0))
%37 = icmp eq i64 %36, 0
br i1 %37, label %40, label %38
38: ; preds = %35
%39 = call i32 @insert_abbreviation(i8* %6, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.11, i64 0, i64 0), i32* %2)
br label %49
40: ; preds = %35
%41 = load i32, i32* %3
%42 = zext i32 %41 to i64
%43 = getelementptr inbounds i8, i8* %0, i64 %42
%44 = load i8, i8* %43
%45 = load i32, i32* %2
%46 = zext i32 %45 to i64
%47 = getelementptr inbounds i8, i8* %6, i64 %46
store i8 %44, i8* %47
%48 = add i32 %45, 1
store i32 %48, i32* %2
br label %49
49: ; preds = %13, %23, %33, %40, %38, %28, %18
%50 = load i32, i32* %3
%51 = add i32 %50, 1
store i32 %51, i32* %3
%52 = icmp ult i32 %51, %4
br i1 %52, label %10, label %53
53: ; preds = %49, %1
ret i8* %6
}