#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 EXIT_FAILURE;
int EXIT_SUCCESS;
int /*<<< orphan*/ printf(char *, ...);
char *replaceInString(char const *, char *, char const *);
int system(char *);
int main(int argc, char **argv) {
  if (argc != 5) {
    printf("program '%s' halted \n", argv[0]);
    printf(
        "exactly four arguments (transformation command line, transformation "
        "prefix, input file, output file without ending) expected \n");
    return EXIT_FAILURE;
  }
  const char *transformationCommand = argv[1];
  const char *transformationPrefix = argv[2];
  const char *inputFile = argv[3];
  const char *outputFile = argv[4];
  printf("transformationCommand is '%s'\n", transformationCommand);
  printf("transformationPrefix is '%s'\n", transformationPrefix);
  printf("inputFile is '%s'\n", inputFile);
  printf("outputFile is '%s'\n", outputFile);
  char *executingTransformationCommand =
      replaceInString(transformationCommand, "%IN", inputFile);
  executingTransformationCommand =
      replaceInString(executingTransformationCommand, "%OUT", outputFile);
  executingTransformationCommand = replaceInString(
      executingTransformationCommand, "%PRE", transformationPrefix);
  printf("\nrun following transformation command:\n'%s'\n",
         executingTransformationCommand);
  int returnOfTransformation = system(executingTransformationCommand);
  if (returnOfTransformation) {
    return EXIT_FAILURE;
  }
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x5,-0x8(%rbp)
je     1184 <main+0x54>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xea2(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xeaa(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x2e66(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1289 <main+0x159>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rax
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%rsi
lea    0xed6(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x20(%rbp),%rsi
lea    0xee3(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x28(%rbp),%rsi
lea    0xeef(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x30(%rbp),%rsi
lea    0xef0(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%rdi
mov    -0x28(%rbp),%rdx
lea    0xeee(%rip),%rsi
call   1050 <replaceInString@plt>
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rdi
mov    -0x30(%rbp),%rdx
lea    0xeda(%rip),%rsi
call   1050 <replaceInString@plt>
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rdi
mov    -0x20(%rbp),%rdx
lea    0xec7(%rip),%rsi
call   1050 <replaceInString@plt>
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rsi
lea    0xeb8(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x38(%rbp),%rdi
call   1030 <system@plt>
mov    %eax,-0x3c(%rbp)
cmpl   $0x0,-0x3c(%rbp)
je     127d <main+0x14d>
mov    0x2d6d(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1289 <main+0x159>
mov    0x2d54(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
cmp    $0x5,%edi
jne    1204 <main+0xc4>
mov    0x8(%rsi),%rbx
mov    0x10(%rsi),%r14
mov    0x18(%rsi),%r12
mov    0x20(%rsi),%r15
lea    0xeae(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xebc(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xec9(%rip),%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xecb(%rip),%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xece(%rip),%rsi
mov    %rbx,%rdi
mov    %r12,%rdx
call   1060 <replaceInString@plt>
lea    0xec0(%rip),%rsi
mov    %rax,%rdi
mov    %r15,%rdx
call   1060 <replaceInString@plt>
lea    0xeb3(%rip),%rsi
mov    %rax,%rdi
mov    %r14,%rdx
call   1060 <replaceInString@plt>
mov    %rax,%rbx
lea    0xea3(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
call   1040 <system@plt>
test   %eax,%eax
jne    1221 <main+0xe1>
mov    0x2dd6(%rip),%rax
jmp    1228 <main+0xe8>
mov    (%rsi),%rsi
lea    0xdf2(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe99(%rip),%rdi
call   1030 <puts@plt>
mov    0x2db8(%rip),%rax
mov    (%rax),%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [22 x i8] c"program '%s' halted \0A\00"
@.str.1 = [127 x i8] c"exactly four arguments (transformation command line, transformation prefix, input file, output file without ending) expected \0A\00"
@EXIT_FAILURE = global i32 0
@.str.2 = [31 x i8] c"transformationCommand is '%s'\0A\00"
@.str.3 = [30 x i8] c"transformationPrefix is '%s'\0A\00"
@.str.4 = [19 x i8] c"inputFile is '%s'\0A\00"
@.str.5 = [20 x i8] c"outputFile is '%s'\0A\00"
@.str.6 = [4 x i8] c"%IN\00"
@.str.7 = [5 x i8] c"%OUT\00"
@.str.8 = [5 x i8] c"%PRE\00"
@.str.9 = [45 x i8] c"\0Arun following transformation command:\0A'%s'\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%12 = load i32, i32* %4
%13 = icmp ne i32 %12, 5
br i1 %13, label %14, label %21
14: ; preds = %2
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 0
%17 = load i8*, i8** %16
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* %17)
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([127 x i8], [127 x i8]* @.str.1, i64 0, i64 0))
%20 = load i32, i32* @EXIT_FAILURE
store i32 %20, i32* %3
br label %61
21: ; preds = %2
%22 = load i8**, i8*** %5
%23 = getelementptr inbounds i8*, i8** %22, i64 1
%24 = load i8*, i8** %23
store i8* %24, i8** %6
%25 = load i8**, i8*** %5
%26 = getelementptr inbounds i8*, i8** %25, i64 2
%27 = load i8*, i8** %26
store i8* %27, i8** %7
%28 = load i8**, i8*** %5
%29 = getelementptr inbounds i8*, i8** %28, i64 3
%30 = load i8*, i8** %29
store i8* %30, i8** %8
%31 = load i8**, i8*** %5
%32 = getelementptr inbounds i8*, i8** %31, i64 4
%33 = load i8*, i8** %32
store i8* %33, i8** %9
%34 = load i8*, i8** %6
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0), i8* %34)
%36 = load i8*, i8** %7
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.3, i64 0, i64 0), i8* %36)
%38 = load i8*, i8** %8
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0), i8* %38)
%40 = load i8*, i8** %9
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.5, i64 0, i64 0), i8* %40)
%42 = load i8*, i8** %6
%43 = load i8*, i8** %8
%44 = call i8* @replaceInString(i8* %42, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i8* %43)
store i8* %44, i8** %10
%45 = load i8*, i8** %10
%46 = load i8*, i8** %9
%47 = call i8* @replaceInString(i8* %45, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0), i8* %46)
store i8* %47, i8** %10
%48 = load i8*, i8** %10
%49 = load i8*, i8** %7
%50 = call i8* @replaceInString(i8* %48, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0), i8* %49)
store i8* %50, i8** %10
%51 = load i8*, i8** %10
%52 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.9, i64 0, i64 0), i8* %51)
%53 = load i8*, i8** %10
%54 = call i32 @system(i8* %53)
store i32 %54, i32* %11
%55 = load i32, i32* %11
%56 = icmp ne i32 %55, 0
br i1 %56, label %57, label %59
57: ; preds = %21
%58 = load i32, i32* @EXIT_FAILURE
store i32 %58, i32* %3
br label %61
59: ; preds = %21
%60 = load i32, i32* @EXIT_SUCCESS
store i32 %60, i32* %3
br label %61
61: ; preds = %59, %57, %14
%62 = load i32, i32* %3
ret i32 %62
}

LLVM IR (-O2):
@.str = [22 x i8] c"program '%s' halted \0A\00"
@EXIT_FAILURE = global i32 0
@.str.2 = [31 x i8] c"transformationCommand is '%s'\0A\00"
@.str.3 = [30 x i8] c"transformationPrefix is '%s'\0A\00"
@.str.4 = [19 x i8] c"inputFile is '%s'\0A\00"
@.str.5 = [20 x i8] c"outputFile is '%s'\0A\00"
@.str.6 = [4 x i8] c"%IN\00"
@.str.7 = [5 x i8] c"%OUT\00"
@.str.8 = [5 x i8] c"%PRE\00"
@.str.9 = [45 x i8] c"\0Arun following transformation command:\0A'%s'\0A\00"
@EXIT_SUCCESS = global i32 0
@str = [126 x i8] c"exactly four arguments (transformation command line, transformation prefix, input file, output file without ending) expected \00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 5
br i1 %3, label %8, label %4
4: ; preds = %2
%5 = load i8*, i8** %1
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* %5)
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([126 x i8], [126 x i8]* @str, i64 0, i64 0))
br label %28
8: ; preds = %2
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = getelementptr inbounds i8*, i8** %1, i64 2
%12 = load i8*, i8** %11
%13 = getelementptr inbounds i8*, i8** %1, i64 3
%14 = load i8*, i8** %13
%15 = getelementptr inbounds i8*, i8** %1, i64 4
%16 = load i8*, i8** %15
%17 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0), i8* %10)
%18 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.3, i64 0, i64 0), i8* %12)
%19 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0), i8* %14)
%20 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.5, i64 0, i64 0), i8* %16)
%21 = tail call i8* @replaceInString(i8* %10, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i8* %14)
%22 = tail call i8* @replaceInString(i8* %21, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0), i8* %16)
%23 = tail call i8* @replaceInString(i8* %22, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0), i8* %12)
%24 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @.str.9, i64 0, i64 0), i8* %23)
%25 = tail call i32 @system(i8* %23)
%26 = icmp eq i32 %25, 0
%27 = select i1 %26, i32* @EXIT_SUCCESS, i32* @EXIT_FAILURE
br label %28
28: ; preds = %8, %4
%29 = phi i32* [ @EXIT_FAILURE, %4 ], [ %27, %8 ]
%30 = load i32, i32* %29
ret i32 %30
}