#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*/ printf(char *);
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
scalar_t__ system(char *);
int main(int argc, char *argv[]) {
  if (argc < 3) {
    printf("Usage: recoverMessage <input .ppm file>  <message file>\n");
    return 1;
  }
  char syst[200] = "./extractRule ";
  strcat(syst, argv[1]);
  strcat(syst, " 4 7 temp.txt");
  if (system(syst)) {
    printf("Fatal error\n");
    return 1;
  }
  strcpy(syst, "./extract temp.txt 4 7 ");
  strcat(syst, argv[2]);
  if (system(syst)) {
    printf("Fatal error\n");
    return 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xe0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x3,-0x8(%rbp)
jge    118b <main+0x3b>
lea    0xe86(%rip),%rdi
call   1050 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1254 <main+0x104>
lea    -0xe0(%rbp),%rdi
lea    0xed7(%rip),%rsi
mov    $0xc8,%edx
call   1060 <memcpy@plt>
lea    -0xe0(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
call   1070 <strcat@plt>
lea    -0xe0(%rbp),%rdi
lea    0xe74(%rip),%rsi
call   1070 <strcat@plt>
lea    -0xe0(%rbp),%rdi
call   1040 <system@plt>
cmp    $0x0,%rax
je     11f8 <main+0xa8>
lea    0xe60(%rip),%rdi
call   1050 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1254 <main+0x104>
lea    -0xe0(%rbp),%rdi
lea    0xe4e(%rip),%rsi
call   1030 <strcpy@plt>
lea    -0xe0(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rsi
call   1070 <strcat@plt>
lea    -0xe0(%rbp),%rdi
call   1040 <system@plt>
cmp    $0x0,%rax
je     124d <main+0xfd>
lea    0xe0b(%rip),%rdi
call   1050 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1254 <main+0x104>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xe0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0xc8,%rsp
cmp    $0x2,%edi
jg     1168 <main+0x18>
lea    0xf94(%rip),%rdi
jmp    11dc <main+0x8c>
mov    %rsi,%r14
lea    0xe8e(%rip),%rsi
mov    %rsp,%rbx
mov    $0xc8,%edx
mov    %rbx,%rdi
call   1060 <memcpy@plt>
mov    0x8(%r14),%rsi
mov    %rbx,%rdi
call   1070 <strcat@plt>
lea    0xf33(%rip),%rsi
mov    %rbx,%rdi
call   1070 <strcat@plt>
mov    %rbx,%rdi
call   1050 <system@plt>
test   %rax,%rax
jne    11d5 <main+0x85>
lea    0xf25(%rip),%rsi
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1030 <strcpy@plt>
mov    0x10(%r14),%rsi
mov    %rbx,%rdi
call   1070 <strcat@plt>
mov    %rbx,%rdi
call   1050 <system@plt>
test   %rax,%rax
je     11f1 <main+0xa1>
lea    0xf12(%rip),%rdi
call   1040 <puts@plt>
mov    $0x1,%eax
add    $0xc8,%rsp
pop    %rbx
pop    %r14
ret
xor    %eax,%eax
jmp    11e6 <main+0x96>

LLVM IR (-O0):
@.str = [57 x i8] c"Usage: recoverMessage <input .ppm file> <message file>\0A\00"
@__const.main.syst = [200 x i8] c"./extractRule \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00"
@.str.1 = [14 x i8] c" 4 7 temp.txt\00"
@.str.2 = [13 x i8] c"Fatal error\0A\00"
@.str.3 = [24 x i8] c"./extract temp.txt 4 7 \00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [200 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = load i32, i32* %4
%8 = icmp slt i32 %7, 3
br i1 %8, label %9, label %11
9: ; preds = %2
%10 = call i32 @printf(i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %3
br label %39
11: ; preds = %2
%12 = bitcast [200 x i8]* %6 to i8*
%13 = getelementptr inbounds [200 x i8], [200 x i8]* %6, i64 0, i64 0
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 1
%16 = load i8*, i8** %15
%17 = call i32 @strcat(i8* %13, i8* %16)
%18 = getelementptr inbounds [200 x i8], [200 x i8]* %6, i64 0, i64 0
%19 = call i32 @strcat(i8* %18, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
%20 = getelementptr inbounds [200 x i8], [200 x i8]* %6, i64 0, i64 0
%21 = call i64 @system(i8* %20)
%22 = icmp ne i64 %21, 0
br i1 %22, label %23, label %25
23: ; preds = %11
%24 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
store i32 1, i32* %3
br label %39
25: ; preds = %11
%26 = getelementptr inbounds [200 x i8], [200 x i8]* %6, i64 0, i64 0
%27 = call i32 @strcpy(i8* %26, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0))
%28 = getelementptr inbounds [200 x i8], [200 x i8]* %6, i64 0, i64 0
%29 = load i8**, i8*** %5
%30 = getelementptr inbounds i8*, i8** %29, i64 2
%31 = load i8*, i8** %30
%32 = call i32 @strcat(i8* %28, i8* %31)
%33 = getelementptr inbounds [200 x i8], [200 x i8]* %6, i64 0, i64 0
%34 = call i64 @system(i8* %33)
%35 = icmp ne i64 %34, 0
br i1 %35, label %36, label %38
36: ; preds = %25
%37 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
store i32 1, i32* %3
br label %39
38: ; preds = %25
store i32 0, i32* %3
br label %39
39: ; preds = %38, %36, %23, %9
%40 = load i32, i32* %3
ret i32 %40
}

LLVM IR (-O2):
@__const.main.syst = [200 x i8] c"./extractRule \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00"
@.str.1 = [14 x i8] c" 4 7 temp.txt\00"
@.str.3 = [24 x i8] c"./extract temp.txt 4 7 \00"
@str.4 = [12 x i8] c"Fatal error\00"
@str.5 = [56 x i8] c"Usage: recoverMessage <input .ppm file> <message file>\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [200 x i8]
%4 = icmp slt i32 %0, 3
br i1 %4, label %5, label %7
5: ; preds = %2
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([56 x i8], [56 x i8]* @str.5, i64 0, i64 0))
br label %27
7: ; preds = %2
%8 = getelementptr inbounds [200 x i8], [200 x i8]* %3, i64 0, i64 0
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = call i32 @strcat(i8* %8, i8* %10)
%12 = call i32 @strcat(i8* %8, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
%13 = call i64 @system(i8* %8)
%14 = icmp eq i64 %13, 0
br i1 %14, label %15, label %22
15: ; preds = %7
%16 = call i32 @strcpy(i8* %8, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0))
%17 = getelementptr inbounds i8*, i8** %1, i64 2
%18 = load i8*, i8** %17
%19 = call i32 @strcat(i8* %8, i8* %18)
%20 = call i64 @system(i8* %8)
%21 = icmp eq i64 %20, 0
br i1 %21, label %25, label %22
22: ; preds = %15, %7
%23 = phi i8* [ getelementptr inbounds ([12 x i8], [12 x i8]* @str.4, i64 0, i64 0), %7 ], [ getelementptr inbounds ([12 x i8], [12 x i8]* @str.4, i64 0, i64 0), %15 ]
%24 = call i32 @puts(i8* dereferenceable(1) %23)
br label %25
25: ; preds = %22, %15
%26 = phi i32 [ 0, %15 ], [ 1, %22 ]
br label %27
27: ; preds = %25, %5
%28 = phi i32 [ 1, %5 ], [ %26, %25 ]
ret i32 %28
}