#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: createCover <message file> <output .ppm file> [<CA padding "
           "rule file>]\n");
    return 1;
  }
  char syst[200] = "./embed ";
  strcat(syst, argv[1]);
  strcat(syst, " out.txt 4 7 ");
  if (argc == 4)
    strcat(syst, argv[3]);
  if (system(syst)) {
    printf("Fatal error\n");
    return 1;
  }
  strcpy(syst, "./makeCA out.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    1272 <main+0x122>
lea    -0xe0(%rbp),%rdi
lea    0xee7(%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    0xe9f(%rip),%rsi
call   1070 <strcat@plt>
cmpl   $0x4,-0x8(%rbp)
jne    11e8 <main+0x98>
lea    -0xe0(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rsi
call   1070 <strcat@plt>
lea    -0xe0(%rbp),%rdi
call   1040 <system@plt>
cmp    $0x0,%rax
je     1216 <main+0xc6>
lea    0xe4a(%rip),%rdi
call   1050 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1272 <main+0x122>
lea    -0xe0(%rbp),%rdi
lea    0xe38(%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     126b <main+0x11b>
lea    0xdf5(%rip),%rdi
call   1050 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1272 <main+0x122>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xe0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0xd0,%rsp
cmp    $0x2,%edi
jg     116c <main+0x1c>
lea    0xf83(%rip),%rdi
jmp    11f3 <main+0xa3>
mov    %rsi,%r14
mov    %edi,%ebp
lea    0xe88(%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    0xf35(%rip),%rsi
mov    %rbx,%rdi
call   1070 <strcat@plt>
cmp    $0x4,%ebp
jne    11b4 <main+0x64>
mov    0x18(%r14),%rsi
mov    %rsp,%rdi
call   1070 <strcat@plt>
mov    %rsp,%rdi
call   1050 <system@plt>
test   %rax,%rax
jne    11ec <main+0x9c>
lea    0xf00(%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     1209 <main+0xb9>
lea    0xeeb(%rip),%rdi
call   1040 <puts@plt>
mov    $0x1,%eax
add    $0xd0,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret
xor    %eax,%eax
jmp    11fd <main+0xad>

LLVM IR (-O0):
@.str = [79 x i8] c"Usage: createCover <message file> <output .ppm file> [<CA padding rule file>]\0A\00"
@__const.main.syst = [200 x i8] c"./embed \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\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" out.txt 4 7 \00"
@.str.2 = [13 x i8] c"Fatal error\0A\00"
@.str.3 = [22 x i8] c"./makeCA out.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 ([79 x i8], [79 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %3
br label %48
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 = load i32, i32* %4
%21 = icmp eq i32 %20, 4
br i1 %21, label %22, label %28
22: ; preds = %11
%23 = getelementptr inbounds [200 x i8], [200 x i8]* %6, i64 0, i64 0
%24 = load i8**, i8*** %5
%25 = getelementptr inbounds i8*, i8** %24, i64 3
%26 = load i8*, i8** %25
%27 = call i32 @strcat(i8* %23, i8* %26)
br label %28
28: ; preds = %22, %11
%29 = getelementptr inbounds [200 x i8], [200 x i8]* %6, i64 0, i64 0
%30 = call i64 @system(i8* %29)
%31 = icmp ne i64 %30, 0
br i1 %31, label %32, label %34
32: ; preds = %28
%33 = 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 %48
34: ; preds = %28
%35 = getelementptr inbounds [200 x i8], [200 x i8]* %6, i64 0, i64 0
%36 = call i32 @strcpy(i8* %35, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0))
%37 = getelementptr inbounds [200 x i8], [200 x i8]* %6, i64 0, i64 0
%38 = load i8**, i8*** %5
%39 = getelementptr inbounds i8*, i8** %38, i64 2
%40 = load i8*, i8** %39
%41 = call i32 @strcat(i8* %37, i8* %40)
%42 = getelementptr inbounds [200 x i8], [200 x i8]* %6, i64 0, i64 0
%43 = call i64 @system(i8* %42)
%44 = icmp ne i64 %43, 0
br i1 %44, label %45, label %47
45: ; preds = %34
%46 = 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 %48
47: ; preds = %34
store i32 0, i32* %3
br label %48
48: ; preds = %47, %45, %32, %9
%49 = load i32, i32* %3
ret i32 %49
}

LLVM IR (-O2):
@__const.main.syst = [200 x i8] c"./embed \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\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" out.txt 4 7 \00"
@.str.3 = [22 x i8] c"./makeCA out.txt 4 7 \00"
@str.4 = [12 x i8] c"Fatal error\00"
@str.5 = [78 x i8] c"Usage: createCover <message file> <output .ppm file> [<CA padding rule 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 ([78 x i8], [78 x i8]* @str.5, i64 0, i64 0))
br label %33
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 = icmp eq i32 %0, 4
br i1 %13, label %14, label %18
14: ; preds = %7
%15 = getelementptr inbounds i8*, i8** %1, i64 3
%16 = load i8*, i8** %15
%17 = call i32 @strcat(i8* %8, i8* %16)
br label %18
18: ; preds = %14, %7
%19 = call i64 @system(i8* %8)
%20 = icmp eq i64 %19, 0
br i1 %20, label %21, label %28
21: ; preds = %18
%22 = call i32 @strcpy(i8* %8, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0))
%23 = getelementptr inbounds i8*, i8** %1, i64 2
%24 = load i8*, i8** %23
%25 = call i32 @strcat(i8* %8, i8* %24)
%26 = call i64 @system(i8* %8)
%27 = icmp eq i64 %26, 0
br i1 %27, label %31, label %28
28: ; preds = %21, %18
%29 = phi i8* [ getelementptr inbounds ([12 x i8], [12 x i8]* @str.4, i64 0, i64 0), %18 ], [ getelementptr inbounds ([12 x i8], [12 x i8]* @str.4, i64 0, i64 0), %21 ]
%30 = call i32 @puts(i8* dereferenceable(1) %29)
br label %31
31: ; preds = %28, %21
%32 = phi i32 [ 0, %21 ], [ 1, %28 ]
br label %33
33: ; preds = %31, %5
%34 = phi i32 [ 1, %5 ], [ %32, %31 ]
ret i32 %34
}