#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*/ _exit(int /*<<< orphan*/);
int execlp(char *, char *, char *, ...);
int fork();
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ strchr(char *, char);
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ unlink(char *);
int /*<<< orphan*/ waitpid(int, int *, int /*<<< orphan*/);
int execute_command(char *command, char *arguments) {
  int cpid;
  int rtrnstatus;
  int cstatus;
  cpid = fork();
  if (cpid == 0) {
    if (strcmp(command, "kill") == 0)
      execlp(command, command, arguments, NULL);
    else if (strcmp(command, "rm") == 0)
      unlink(arguments);
    else {
      if (strcmp(arguments, "\0") != 0)
        cstatus = execlp(command, command, arguments, NULL);
      else
        cstatus = execlp(command, command, NULL);
      if (cstatus && !strchr(command, '&'))
        printf("%s: command not found\n", command);
    }
    if (!strchr(command, '&'))
      _exit(0);
  } else {
    waitpid(cpid, &rtrnstatus, 0);
  }
  return 0;
}


x86 assembly (clang, -O0):
<execute_command>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x0,%al
call   10a0 <fork@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jne    12af <execute_command+0x12f>
mov    -0x8(%rbp),%rdi
lea    0xe51(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    11da <execute_command+0x5a>
mov    -0x8(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    -0x10(%rbp),%rdx
xor    %eax,%eax
mov    %eax,%ecx
mov    $0x0,%al
call   1090 <execlp@plt>
jmp    128c <execute_command+0x10c>
mov    -0x8(%rbp),%rdi
lea    0xe20(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    1202 <execute_command+0x82>
mov    -0x10(%rbp),%rdi
call   1030 <unlink@plt>
jmp    1287 <execute_command+0x107>
mov    -0x10(%rbp),%rdi
lea    0xe12(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
je     123b <execute_command+0xbb>
mov    -0x8(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    -0x10(%rbp),%rdx
xor    %eax,%eax
mov    %eax,%ecx
mov    $0x0,%al
call   1090 <execlp@plt>
mov    %eax,-0x1c(%rbp)
jmp    1251 <execute_command+0xd1>
mov    -0x8(%rbp),%rdi
mov    -0x8(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
mov    $0x0,%al
call   1090 <execlp@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
je     1282 <execute_command+0x102>
mov    -0x8(%rbp),%rdi
mov    $0x26,%esi
call   1050 <strchr@plt>
cmp    $0x0,%eax
jne    1282 <execute_command+0x102>
mov    -0x8(%rbp),%rsi
lea    0xd8b(%rip),%rdi
call   1060 <printf@plt>
jmp    1287 <execute_command+0x107>
jmp    128c <execute_command+0x10c>
mov    -0x8(%rbp),%rdi
mov    $0x26,%esi
call   1050 <strchr@plt>
cmp    $0x0,%eax
jne    12aa <execute_command+0x12a>
xor    %edi,%edi
call   1040 <_exit@plt>
jmp    12bd <execute_command+0x13d>
mov    -0x14(%rbp),%edi
lea    -0x18(%rbp),%rsi
xor    %edx,%edx
call   1080 <waitpid@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<execute_command>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
xor    %eax,%eax
call   10a0 <fork@plt>
test   %eax,%eax
je     11a8 <execute_command+0x28>
lea    0x4(%rsp),%rsi
mov    %eax,%edi
xor    %edx,%edx
call   1080 <waitpid@plt>
jmp    1258 <execute_command+0xd8>
lea    0xe51(%rip),%rsi
mov    %rbx,%rdi
call   1070 <strcmp@plt>
test   %rax,%rax
je     11fc <execute_command+0x7c>
lea    0xe42(%rip),%rsi
mov    %rbx,%rdi
call   1070 <strcmp@plt>
test   %rax,%rax
je     1210 <execute_command+0x90>
lea    0xe48(%rip),%rsi
mov    %r14,%rdi
call   1070 <strcmp@plt>
mov    %rbx,%rdi
mov    %rbx,%rsi
test   %rax,%rax
je     121a <execute_command+0x9a>
mov    %r14,%rdx
xor    %ecx,%ecx
xor    %eax,%eax
call   1090 <execlp@plt>
test   %eax,%eax
jne    1227 <execute_command+0xa7>
jmp    1247 <execute_command+0xc7>
mov    %rbx,%rdi
mov    %rbx,%rsi
mov    %r14,%rdx
xor    %ecx,%ecx
xor    %eax,%eax
call   1090 <execlp@plt>
jmp    1247 <execute_command+0xc7>
mov    %r14,%rdi
call   1030 <unlink@plt>
jmp    1247 <execute_command+0xc7>
xor    %edx,%edx
xor    %eax,%eax
call   1090 <execlp@plt>
test   %eax,%eax
je     1247 <execute_command+0xc7>
mov    %rbx,%rdi
mov    $0x26,%esi
call   1050 <strchr@plt>
test   %eax,%eax
jne    1247 <execute_command+0xc7>
lea    0xdc9(%rip),%rdi
mov    %rbx,%rsi
call   1060 <printf@plt>
mov    %rbx,%rdi
mov    $0x26,%esi
call   1050 <strchr@plt>
test   %eax,%eax
je     1262 <execute_command+0xe2>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
xor    %edi,%edi
call   1040 <_exit@plt>

LLVM IR (-O0):
@.str = [5 x i8] c"kill\00"
@.str.1 = [3 x i8] c"rm\00"
@.str.2 = [2 x i8] zeroinitializer
@.str.3 = [23 x i8] c"%s: command not found\0A\00"
define i32 @execute_command(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i8* %0, i8** %3
store i8* %1, i8** %4
%8 = call i32 (...) @fork()
store i32 %8, i32* %5
%9 = load i32, i32* %5
%10 = icmp eq i32 %9, 0
br i1 %10, label %11, label %59
11: ; preds = %2
%12 = load i8*, i8** %3
%13 = call i64 @strcmp(i8* %12, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%14 = icmp eq i64 %13, 0
br i1 %14, label %15, label %20
15: ; preds = %11
%16 = load i8*, i8** %3
%17 = load i8*, i8** %3
%18 = load i8*, i8** %4
%19 = call i32 (i8*, i8*, i8*, ...) @execlp(i8* %16, i8* %17, i8* %18, i8* null)
br label %52
20: ; preds = %11
%21 = load i8*, i8** %3
%22 = call i64 @strcmp(i8* %21, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%23 = icmp eq i64 %22, 0
br i1 %23, label %24, label %27
24: ; preds = %20
%25 = load i8*, i8** %4
%26 = call i32 @unlink(i8* %25)
br label %51
27: ; preds = %20
%28 = load i8*, i8** %4
%29 = call i64 @strcmp(i8* %28, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%30 = icmp ne i64 %29, 0
br i1 %30, label %31, label %36
31: ; preds = %27
%32 = load i8*, i8** %3
%33 = load i8*, i8** %3
%34 = load i8*, i8** %4
%35 = call i32 (i8*, i8*, i8*, ...) @execlp(i8* %32, i8* %33, i8* %34, i8* null)
store i32 %35, i32* %7
br label %40
36: ; preds = %27
%37 = load i8*, i8** %3
%38 = load i8*, i8** %3
%39 = call i32 (i8*, i8*, i8*, ...) @execlp(i8* %37, i8* %38, i8* null)
store i32 %39, i32* %7
br label %40
40: ; preds = %36, %31
%41 = load i32, i32* %7
%42 = icmp ne i32 %41, 0
br i1 %42, label %43, label %50
43: ; preds = %40
%44 = load i8*, i8** %3
%45 = call i32 @strchr(i8* %44, i8 signext 38)
%46 = icmp ne i32 %45, 0
br i1 %46, label %50, label %47
47: ; preds = %43
%48 = load i8*, i8** %3
%49 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0), i8* %48)
br label %50
50: ; preds = %47, %43, %40
br label %51
51: ; preds = %50, %24
br label %52
52: ; preds = %51, %15
%53 = load i8*, i8** %3
%54 = call i32 @strchr(i8* %53, i8 signext 38)
%55 = icmp ne i32 %54, 0
br i1 %55, label %58, label %56
56: ; preds = %52
%57 = call i32 @_exit(i32 0)
unreachable
58: ; preds = %52
br label %62
59: ; preds = %2
%60 = load i32, i32* %5
%61 = call i32 @waitpid(i32 %60, i32* %6, i32 0)
br label %62
62: ; preds = %59, %58
ret i32 0
}

LLVM IR (-O2):
@.str = [5 x i8] c"kill\00"
@.str.1 = [3 x i8] c"rm\00"
@.str.2 = [2 x i8] zeroinitializer
@.str.3 = [23 x i8] c"%s: command not found\0A\00"
define i32 @execute_command(i8* %0, i8* %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
%5 = tail call i32 (...) @fork()
%6 = icmp eq i32 %5, 0
br i1 %6, label %7, label %37
7: ; preds = %2
%8 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%9 = icmp eq i64 %8, 0
br i1 %9, label %10, label %12
10: ; preds = %7
%11 = tail call i32 (i8*, i8*, i8*, ...) @execlp(i8* %0, i8* %0, i8* %1, i8* null)
br label %32
12: ; preds = %7
%13 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%14 = icmp eq i64 %13, 0
br i1 %14, label %15, label %17
15: ; preds = %12
%16 = tail call i32 @unlink(i8* %1)
br label %32
17: ; preds = %12
%18 = tail call i64 @strcmp(i8* %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%19 = icmp eq i64 %18, 0
br i1 %19, label %22, label %20
20: ; preds = %17
%21 = tail call i32 (i8*, i8*, i8*, ...) @execlp(i8* %0, i8* %0, i8* %1, i8* null)
br label %24
22: ; preds = %17
%23 = tail call i32 (i8*, i8*, i8*, ...) @execlp(i8* %0, i8* %0, i8* null)
br label %24
24: ; preds = %22, %20
%25 = phi i32 [ %21, %20 ], [ %23, %22 ]
%26 = icmp eq i32 %25, 0
br i1 %26, label %32, label %27
27: ; preds = %24
%28 = tail call i32 @strchr(i8* %0, i8 signext 38)
%29 = icmp eq i32 %28, 0
br i1 %29, label %30, label %32
30: ; preds = %27
%31 = tail call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0), i8* %0)
br label %32
32: ; preds = %15, %30, %27, %24, %10
%33 = tail call i32 @strchr(i8* %0, i8 signext 38)
%34 = icmp eq i32 %33, 0
br i1 %34, label %35, label %39
35: ; preds = %32
%36 = tail call i32 @_exit(i32 0)
unreachable
37: ; preds = %2
%38 = call i32 @waitpid(i32 %5, i32* %3, i32 0)
br label %39
39: ; preds = %32, %37
ret i32 0
}