int main(int argc, char *argv[]) {
  if (argc > 3) {
    printf("Too many arguments.\n Usage: mpa /patch/directory [OPTIONS: -s "
           "(--solo: Do not search for patches recursively)]\n");
    exit(1);
  } else if (argc < 2) {
    printf("No directory defined.\n Usage: mpa /patch/directory [OPTIONS: -s "
           "(--solo: Do not search for patches recursively)]\n");
    exit(1);
  } else {
    printf("Using directory %s\n", argv[1]);
  }
  const char *sflag = argv[2];
  const char *nada;
  const char *find = "find ";
  const char *dir = argv[1];
  const char *args = " -name '*.patch' -print0 | xargs -0 patch -p1";
  const char *maxdepth = " -maxdepth 1";
  char *mpa_patcher[1000];
  strcpy(mpa_patcher, find);
  strcat(mpa_patcher, dir);
  if (sflag != nada) {
    strcat(mpa_patcher, maxdepth);
  }
  strcat(mpa_patcher, args);
  int ret = system(mpa_patcher);
  if (ret == nada) {
    return 1;
    printf("Error code 1: No patch result");
    exit(1);
  } else {
    return 0;
    exit(0);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1f90,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x3,-0x8(%rbp)
jle    118b <main+0x3b>
lea    0xe86(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
cmpl   $0x2,-0x8(%rbp)
jge    11ad <main+0x5d>
lea    0xed4(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xf26(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    11c8 <main+0x78>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x18(%rbp)
lea    0xf1b(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x30(%rbp)
lea    0xf0a(%rip),%rax
mov    %rax,-0x38(%rbp)
lea    0xf2d(%rip),%rax
mov    %rax,-0x40(%rbp)
lea    -0x1f80(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1030 <strcpy@plt>
lea    -0x1f80(%rbp),%rdi
mov    -0x30(%rbp),%rsi
call   1060 <strcat@plt>
mov    -0x18(%rbp),%rax
cmp    -0x20(%rbp),%rax
je     123f <main+0xef>
lea    -0x1f80(%rbp),%rdi
mov    -0x40(%rbp),%rsi
call   1060 <strcat@plt>
lea    -0x1f80(%rbp),%rdi
mov    -0x38(%rbp),%rsi
call   1060 <strcat@plt>
lea    -0x1f80(%rbp),%rdi
mov    $0x0,%al
call   1040 <system@plt>
mov    %eax,-0x1f84(%rbp)
movslq -0x1f84(%rbp),%rax
cmp    -0x20(%rbp),%rax
jne    1280 <main+0x130>
movl   $0x1,-0x4(%rbp)
jmp    1287 <main+0x137>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x1f90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x1f40,%rsp
cmp    $0x4,%edi
jge    11e4 <main+0x84>
cmp    $0x1,%edi
jle    11ed <main+0x8d>
mov    %rsi,%rbx
mov    0x8(%rsi),%rsi
lea    0xe80(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x8(%rbx),%rsi
movw   $0x20,0x4(%rsp)
movl   $0x646e6966,(%rsp)
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1070 <strcat@plt>
mov    %rbx,%rdi
call   1040 <strlen@plt>
movups 0xe67(%rip),%xmm0
movups %xmm0,(%rsp,%rax,1)
movups 0xe6c(%rip),%xmm0
movups %xmm0,0x10(%rsp,%rax,1)
movups 0xe6e(%rip),%xmm0
movups %xmm0,0x1e(%rsp,%rax,1)
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <system@plt>
xor    %eax,%eax
add    $0x1f40,%rsp
pop    %rbx
ret
lea    0xece(%rip),%rdi
jmp    11f4 <main+0x94>
lea    0xe54(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@.str = [112 x i8] c"Too many arguments.\0A Usage: mpa /patch/directory [OPTIONS: -s (--solo: Do not search for patches recursively)]\0A\00"
@.str.1 = [114 x i8] c"No directory defined.\0A Usage: mpa /patch/directory [OPTIONS: -s (--solo: Do not search for patches recursively)]\0A\00"
@.str.2 = [20 x i8] c"Using directory %s\0A\00"
@.str.3 = [6 x i8] c"find \00"
@.str.4 = [46 x i8] c" -name '*.patch' -print0 | xargs -0 patch -p1\00"
@.str.5 = [13 x i8] c" -maxdepth 1\00"
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 i8*
%12 = alloca [1000 x i8*]
%13 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%14 = load i32, i32* %4
%15 = icmp sgt i32 %14, 3
br i1 %15, label %16, label %18
16: ; preds = %2
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([112 x i8], [112 x i8]* @.str, i64 0, i64 0))
unreachable
18: ; preds = %2
%19 = load i32, i32* %4
%20 = icmp slt i32 %19, 2
br i1 %20, label %21, label %23
21: ; preds = %18
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([114 x i8], [114 x i8]* @.str.1, i64 0, i64 0))
unreachable
23: ; preds = %18
%24 = load i8**, i8*** %5
%25 = getelementptr inbounds i8*, i8** %24, i64 1
%26 = load i8*, i8** %25
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i8* %26)
br label %28
28: ; preds = %23
br label %29
29: ; preds = %28
%30 = load i8**, i8*** %5
%31 = getelementptr inbounds i8*, i8** %30, i64 2
%32 = load i8*, i8** %31
store i8* %32, i8** %6
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i8** %8
%33 = load i8**, i8*** %5
%34 = getelementptr inbounds i8*, i8** %33, i64 1
%35 = load i8*, i8** %34
store i8* %35, i8** %9
store i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.4, i64 0, i64 0), i8** %10
store i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0), i8** %11
%36 = getelementptr inbounds [1000 x i8*], [1000 x i8*]* %12, i64 0, i64 0
%37 = bitcast i8** %36 to i8*
%38 = load i8*, i8** %8
%39 = call i8* @strcpy(i8* %37, i8* %38)
%40 = getelementptr inbounds [1000 x i8*], [1000 x i8*]* %12, i64 0, i64 0
%41 = bitcast i8** %40 to i8*
%42 = load i8*, i8** %9
%43 = call i8* @strcat(i8* %41, i8* %42)
%44 = load i8*, i8** %6
%45 = load i8*, i8** %7
%46 = icmp ne i8* %44, %45
br i1 %46, label %47, label %52
47: ; preds = %29
%48 = getelementptr inbounds [1000 x i8*], [1000 x i8*]* %12, i64 0, i64 0
%49 = bitcast i8** %48 to i8*
%50 = load i8*, i8** %11
%51 = call i8* @strcat(i8* %49, i8* %50)
br label %52
52: ; preds = %47, %29
%53 = getelementptr inbounds [1000 x i8*], [1000 x i8*]* %12, i64 0, i64 0
%54 = bitcast i8** %53 to i8*
%55 = load i8*, i8** %10
%56 = call i8* @strcat(i8* %54, i8* %55)
%57 = getelementptr inbounds [1000 x i8*], [1000 x i8*]* %12, i64 0, i64 0
%58 = call i32 (i8**, ...) bitcast (i32 (...)* @system to i32 (i8**, ...)*)(i8** %57)
store i32 %58, i32* %13
%59 = load i32, i32* %13
%60 = sext i32 %59 to i64
%61 = inttoptr i64 %60 to i8*
%62 = load i8*, i8** %7
%63 = icmp eq i8* %61, %62
br i1 %63, label %64, label %65
64: ; preds = %52
store i32 1, i32* %3
br label %66
65: ; preds = %52
store i32 0, i32* %3
br label %66
66: ; preds = %65, %64
%67 = load i32, i32* %3
ret i32 %67
}

LLVM IR (-O2):
@.str.2 = [20 x i8] c"Using directory %s\0A\00"
@.str.3 = [6 x i8] c"find \00"
@.str.4 = [46 x i8] c" -name '*.patch' -print0 | xargs -0 patch -p1\00"
@str = [113 x i8] c"No directory defined.\0A Usage: mpa /patch/directory [OPTIONS: -s (--solo: Do not search for patches recursively)]\00"
@str.6 = [111 x i8] c"Too many arguments.\0A Usage: mpa /patch/directory [OPTIONS: -s (--solo: Do not search for patches recursively)]\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [1000 x i8*]
%4 = icmp sgt i32 %0, 3
br i1 %4, label %5, label %7
5: ; preds = %2
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([111 x i8], [111 x i8]* @str.6, i64 0, i64 0))
tail call void @exit(i32 1)
unreachable
7: ; preds = %2
%8 = icmp slt i32 %0, 2
br i1 %8, label %9, label %11
9: ; preds = %7
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([113 x i8], [113 x i8]* @str, i64 0, i64 0))
tail call void @exit(i32 1)
unreachable
11: ; preds = %7
%12 = getelementptr inbounds i8*, i8** %1, i64 1
%13 = load i8*, i8** %12
%14 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i8* %13)
%15 = load i8*, i8** %12
%16 = bitcast [1000 x i8*]* %3 to i8*
%17 = call i8* @strcat(i8* %16, i8* dereferenceable(1) %15)
%18 = getelementptr inbounds [1000 x i8*], [1000 x i8*]* %3, i64 0, i64 0
%19 = call i64 @strlen(i8* %16)
%20 = getelementptr i8, i8* %16, i64 %19
%21 = call i32 (i8**, ...) bitcast (i32 (...)* @system to i32 (i8**, ...)*)(i8** %18)
ret i32 0
}