#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*/ free(char *);
int /*<<< orphan*/ printf(char *, char *);
char *romanSubtract(char *, char *);
char *romanSum(char *, char *);
scalar_t__ strcmp(char *, char *);
int main(int argc, char *argv[]) {
  int mainResult = 0;
  if (argc != 4) {
    mainResult = 1;
  } else {
    char *result = 0;
    if (strcmp(argv[2], "+") == 0) {
      result = romanSum(argv[1], argv[3]);
    } else if (strcmp(argv[2], "-") == 0) {
      result = romanSubtract(argv[1], argv[3]);
    } else {
      mainResult = 2;
    }
    if (result) {
      printf("%s\n", result);
      free(result);
    } else {
      mainResult = 3;
    }
  }
  return mainResult;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x4,-0x8(%rbp)
je     1183 <main+0x33>
movl   $0x1,-0x14(%rbp)
jmp    1244 <main+0xf4>
movq   $0x0,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xe66(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    11c7 <main+0x77>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rsi
call   1050 <romanSum@plt>
mov    %rax,-0x20(%rbp)
jmp    120f <main+0xbf>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xe2c(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    1203 <main+0xb3>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rsi
call   1040 <romanSubtract@plt>
mov    %rax,-0x20(%rbp)
jmp    120a <main+0xba>
movl   $0x2,-0x14(%rbp)
jmp    120f <main+0xbf>
cmpq   $0x0,-0x20(%rbp)
je     1238 <main+0xe8>
mov    -0x20(%rbp),%rsi
lea    0xddf(%rip),%rdi
call   1060 <printf@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
jmp    123f <main+0xef>
movl   $0x3,-0x14(%rbp)
jmp    1244 <main+0xf4>
mov    -0x14(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
mov    $0x1,%eax
cmp    $0x4,%edi
jne    1190 <main+0x40>
mov    %rsi,%rbx
mov    0x10(%rsi),%rdi
lea    0xe97(%rip),%rsi
call   1070 <strcmp@plt>
test   %rax,%rax
je     1192 <main+0x42>
mov    0x10(%rbx),%rdi
lea    0xe84(%rip),%rsi
call   1070 <strcmp@plt>
mov    %rax,%rcx
mov    $0x3,%eax
test   %rcx,%rcx
je     11a1 <main+0x51>
pop    %rbx
ret
mov    0x8(%rbx),%rdi
mov    0x18(%rbx),%rsi
call   1050 <romanSum@plt>
jmp    11ae <main+0x5e>
mov    0x8(%rbx),%rdi
mov    0x18(%rbx),%rsi
call   1040 <romanSubtract@plt>
mov    %rax,%rbx
test   %rax,%rax
je     11d1 <main+0x81>
lea    0xe47(%rip),%rdi
mov    %rbx,%rsi
call   1060 <printf@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
xor    %eax,%eax
pop    %rbx
ret
mov    $0x3,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [2 x i8] c"+\00"
@.str.1 = [2 x i8] c"-\00"
@.str.2 = [4 x i8] c"%s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
%8 = load i32, i32* %4
%9 = icmp ne i32 %8, 4
br i1 %9, label %10, label %11
10: ; preds = %2
store i32 1, i32* %6
br label %51
11: ; preds = %2
store i8* null, i8** %7
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i64 2
%14 = load i8*, i8** %13
%15 = call i64 @strcmp(i8* %14, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%16 = icmp eq i64 %15, 0
br i1 %16, label %17, label %25
17: ; preds = %11
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 1
%20 = load i8*, i8** %19
%21 = load i8**, i8*** %5
%22 = getelementptr inbounds i8*, i8** %21, i64 3
%23 = load i8*, i8** %22
%24 = call i8* @romanSum(i8* %20, i8* %23)
store i8* %24, i8** %7
br label %41
25: ; preds = %11
%26 = load i8**, i8*** %5
%27 = getelementptr inbounds i8*, i8** %26, i64 2
%28 = load i8*, i8** %27
%29 = call i64 @strcmp(i8* %28, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%30 = icmp eq i64 %29, 0
br i1 %30, label %31, label %39
31: ; preds = %25
%32 = load i8**, i8*** %5
%33 = getelementptr inbounds i8*, i8** %32, i64 1
%34 = load i8*, i8** %33
%35 = load i8**, i8*** %5
%36 = getelementptr inbounds i8*, i8** %35, i64 3
%37 = load i8*, i8** %36
%38 = call i8* @romanSubtract(i8* %34, i8* %37)
store i8* %38, i8** %7
br label %40
39: ; preds = %25
store i32 2, i32* %6
br label %40
40: ; preds = %39, %31
br label %41
41: ; preds = %40, %17
%42 = load i8*, i8** %7
%43 = icmp ne i8* %42, null
br i1 %43, label %44, label %49
44: ; preds = %41
%45 = load i8*, i8** %7
%46 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %45)
%47 = load i8*, i8** %7
%48 = call i32 @free(i8* %47)
br label %50
49: ; preds = %41
store i32 3, i32* %6
br label %50
50: ; preds = %49, %44
br label %51
51: ; preds = %50, %10
%52 = load i32, i32* %6
ret i32 %52
}

LLVM IR (-O2):
@.str = [2 x i8] c"+\00"
@.str.1 = [2 x i8] c"-\00"
@.str.2 = [4 x i8] c"%s\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 4
br i1 %3, label %4, label %31
4: ; preds = %2
%5 = getelementptr inbounds i8*, i8** %1, i64 2
%6 = load i8*, i8** %5
%7 = tail call i64 @strcmp(i8* %6, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %15
9: ; preds = %4
%10 = getelementptr inbounds i8*, i8** %1, i64 1
%11 = load i8*, i8** %10
%12 = getelementptr inbounds i8*, i8** %1, i64 3
%13 = load i8*, i8** %12
%14 = tail call i8* @romanSum(i8* %11, i8* %13)
br label %25
15: ; preds = %4
%16 = load i8*, i8** %5
%17 = tail call i64 @strcmp(i8* %16, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%18 = icmp eq i64 %17, 0
br i1 %18, label %19, label %31
19: ; preds = %15
%20 = getelementptr inbounds i8*, i8** %1, i64 1
%21 = load i8*, i8** %20
%22 = getelementptr inbounds i8*, i8** %1, i64 3
%23 = load i8*, i8** %22
%24 = tail call i8* @romanSubtract(i8* %21, i8* %23)
br label %25
25: ; preds = %19, %9
%26 = phi i8* [ %14, %9 ], [ %24, %19 ]
%27 = icmp eq i8* %26, null
br i1 %27, label %31, label %28
28: ; preds = %25
%29 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %26)
%30 = tail call i32 @free(i8* %26)
br label %31
31: ; preds = %15, %28, %25, %2
%32 = phi i32 [ 1, %2 ], [ 0, %28 ], [ 3, %25 ], [ 3, %15 ]
ret i32 %32
}