#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*/ execv(char *, char **);
int /*<<< orphan*/ printf(char *, char *);
int main(int argc, char *argv[]) {
  if (argc == 1) {
    char *args[] = {"ps", "aux", NULL};
    execv("/bin/ps", args);
  } else if (argc == 2) {
    printf("Finding... %s\n", argv[1]);
    char *args[] = {"pgrep", argv[1], NULL};
    execv("/usr/bin/pgrep", args);
  } else if (argc == 3) {
    printf("Killing... %s\n", argv[2]);
    char *args[] = {"kill", argv[2], NULL};
    execv("/bin/kill", args);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x1,-0x8(%rbp)
jne    1176 <main+0x56>
mov    0x2cb9(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0x2cb6(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    0x2cb3(%rip),%rax
mov    %rax,-0x20(%rbp)
lea    -0x30(%rbp),%rsi
lea    0xe98(%rip),%rdi
call   1040 <execv@plt>
jmp    121f <main+0xff>
cmpl   $0x2,-0x8(%rbp)
jne    11c8 <main+0xa8>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xe7d(%rip),%rdi
call   1030 <printf@plt>
lea    0xe89(%rip),%rax
mov    %rax,-0x50(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x48(%rbp)
movq   $0x0,-0x40(%rbp)
lea    -0x50(%rbp),%rsi
lea    0xe5d(%rip),%rdi
call   1040 <execv@plt>
jmp    121a <main+0xfa>
cmpl   $0x3,-0x8(%rbp)
jne    1215 <main+0xf5>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rsi
lea    0xe49(%rip),%rdi
call   1030 <printf@plt>
lea    0xe51(%rip),%rax
mov    %rax,-0x70(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x68(%rbp)
movq   $0x0,-0x60(%rbp)
lea    -0x70(%rbp),%rsi
lea    0xe29(%rip),%rdi
call   1040 <execv@plt>
jmp    121a <main+0xfa>
jmp    121f <main+0xff>
xor    %eax,%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x20,%rsp
mov    %rsi,%rbx
cmp    $0x3,%edi
je     115b <main+0x3b>
cmp    $0x2,%edi
je     1191 <main+0x71>
cmp    $0x1,%edi
jne    11cd <main+0xad>
mov    0x2cce(%rip),%rax
mov    %rax,0x10(%rsp)
movaps 0x2cb2(%rip),%xmm0
movaps %xmm0,(%rsp)
lea    0xeab(%rip),%rdi
jmp    11c5 <main+0xa5>
mov    0x10(%rbx),%rsi
lea    0xec4(%rip),%rdi
call   1030 <printf@plt>
lea    0xecc(%rip),%rax
mov    %rax,(%rsp)
mov    0x10(%rbx),%rax
mov    %rax,0x8(%rsp)
movq   $0x0,0x10(%rsp)
lea    0xeaa(%rip),%rdi
jmp    11c5 <main+0xa5>
mov    0x8(%rbx),%rsi
lea    0xe70(%rip),%rdi
call   1030 <printf@plt>
lea    0xe7c(%rip),%rax
mov    %rax,(%rsp)
mov    0x8(%rbx),%rax
mov    %rax,0x8(%rsp)
movq   $0x0,0x10(%rsp)
lea    0xe56(%rip),%rdi
mov    %rsp,%rsi
call   1040 <execv@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
ret

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

LLVM IR (-O2):
@.str = [3 x i8] c"ps\00"
@.str.1 = [4 x i8] c"aux\00"
@__const.main.args = [3 x i8*] [i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i32 0, i32 0), i8* null]
@.str.2 = [8 x i8] c"/bin/ps\00"
@.str.3 = [15 x i8] c"Finding... %s\0A\00"
@.str.4 = [6 x i8] c"pgrep\00"
@.str.5 = [15 x i8] c"/usr/bin/pgrep\00"
@.str.6 = [15 x i8] c"Killing... %s\0A\00"
@.str.7 = [5 x i8] c"kill\00"
@.str.8 = [10 x i8] c"/bin/kill\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [3 x i8*]
%4 = alloca [3 x i8*]
%5 = alloca [3 x i8*]
switch i32 %0, label %30 [
i32 1, label %6
i32 2, label %10
i32 3, label %20
]
6: ; preds = %2
%7 = bitcast [3 x i8*]* %3 to i8*
%8 = getelementptr inbounds [3 x i8*], [3 x i8*]* %3, i64 0, i64 0
%9 = call i32 @execv(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i8** %8)
br label %30
10: ; preds = %2
%11 = getelementptr inbounds i8*, i8** %1, i64 1
%12 = load i8*, i8** %11
%13 = tail call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), i8* %12)
%14 = bitcast [3 x i8*]* %4 to i8*
%15 = getelementptr inbounds [3 x i8*], [3 x i8*]* %4, i64 0, i64 0
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i8** %15
%16 = getelementptr inbounds [3 x i8*], [3 x i8*]* %4, i64 0, i64 1
%17 = load i8*, i8** %11
store i8* %17, i8** %16
%18 = getelementptr inbounds [3 x i8*], [3 x i8*]* %4, i64 0, i64 2
store i8* null, i8** %18
%19 = call i32 @execv(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0), i8** %15)
br label %30
20: ; preds = %2
%21 = getelementptr inbounds i8*, i8** %1, i64 2
%22 = load i8*, i8** %21
%23 = tail call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.6, i64 0, i64 0), i8* %22)
%24 = bitcast [3 x i8*]* %5 to i8*
%25 = getelementptr inbounds [3 x i8*], [3 x i8*]* %5, i64 0, i64 0
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0), i8** %25
%26 = getelementptr inbounds [3 x i8*], [3 x i8*]* %5, i64 0, i64 1
%27 = load i8*, i8** %21
store i8* %27, i8** %26
%28 = getelementptr inbounds [3 x i8*], [3 x i8*]* %5, i64 0, i64 2
store i8* null, i8** %28
%29 = call i32 @execv(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.8, i64 0, i64 0), i8** %25)
br label %30
30: ; preds = %2, %10, %20, %6
ret i32 0
}