#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 */
typedef int pid_t;
typedef int /*<<< orphan*/ input;

/* Variables and functions */
int /*<<< orphan*/ execvp(char *, char **);
int fork();
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ free(char *);
char *malloc(int);
int /*<<< orphan*/ stdout;
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
char *strtok(char *, char *);
pid_t execution(char *input) {
  char *prog;
  char *istr[100];
  int i = 0;
  pid_t pid;
  prog = malloc(sizeof(input) + 1);
  strcpy(prog, input);
  istr[0] = strtok(prog, " ");
  if (istr[0] == NULL) {
    istr[0] = malloc(strlen(prog));
    strcpy(istr[0], prog);
  } else {
    while (istr[i] != NULL) {
      istr[i + 1] = strtok(NULL, " ");
      i++;
    }
  }
  i = 0;
  if ((pid = fork()) == -1) {
    fprintf(stdout, "Fork failure.\n");
    return -1;
  } else if (pid == 0) {
    execvp(istr[0], istr);
    fprintf(stdout, "Command running failure.\n");
    return -1;
  }
  i = 0;
  free(prog);
  return pid;
}


x86 assembly (clang, -O0):
<execution>:
push   %rbp
mov    %rsp,%rbp
sub    $0x350,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x0,-0x344(%rbp)
mov    $0x9,%edi
call   1070 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1040 <strcpy@plt>
mov    -0x18(%rbp),%rdi
lea    0xe41(%rip),%rsi
call   1080 <strtok@plt>
mov    %rax,-0x340(%rbp)
cmpq   $0x0,-0x340(%rbp)
jne    1205 <execution+0x85>
mov    -0x18(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,%edi
call   1070 <malloc@plt>
mov    %rax,-0x340(%rbp)
mov    -0x340(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <strcpy@plt>
jmp    125f <execution+0xdf>
jmp    120a <execution+0x8a>
movslq -0x344(%rbp),%rax
cmpq   $0x0,-0x340(%rbp,%rax,8)
je     125a <execution+0xda>
xor    %eax,%eax
mov    %eax,%edi
lea    0xdd5(%rip),%rsi
call   1080 <strtok@plt>
mov    %rax,%rcx
mov    -0x344(%rbp),%eax
add    $0x1,%eax
cltq
mov    %rcx,-0x340(%rbp,%rax,8)
ff
mov    -0x344(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x344(%rbp)
jmp    120a <execution+0x8a>
jmp    125f <execution+0xdf>
movl   $0x0,-0x344(%rbp)
mov    $0x0,%al
call   10a0 <fork@plt>
mov    %eax,-0x348(%rbp)
cmp    $0xffffffff,%eax
jne    12a0 <execution+0x120>
mov    0x2d5a(%rip),%rax
mov    (%rax),%edi
lea    0xd73(%rip),%rsi
call   1060 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1302 <execution+0x182>
cmpl   $0x0,-0x348(%rbp)
jne    12e1 <execution+0x161>
mov    -0x340(%rbp),%rdi
lea    -0x340(%rbp),%rsi
call   1090 <execvp@plt>
mov    0x2d19(%rip),%rax
mov    (%rax),%edi
lea    0xd41(%rip),%rsi
call   1060 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1302 <execution+0x182>
jmp    12e6 <execution+0x166>
movl   $0x0,-0x344(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
mov    -0x348(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x350,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<execution>:
push   %rbp
push   %r14
push   %rbx
sub    $0x320,%rsp
mov    %rdi,%rbp
mov    $0x9,%edi
call   1070 <malloc@plt>
mov    %rax,%r14
mov    %rax,%rdi
mov    %rbp,%rsi
call   1040 <strcpy@plt>
lea    0xe53(%rip),%rsi
mov    %r14,%rdi
call   1080 <strtok@plt>
mov    %rax,(%rsp)
test   %rax,%rax
je     11e8 <execution+0x68>
lea    0x8(%rsp),%rbx
lea    0xe36(%rip),%rbp
nopw   0x0(%rax,%rax,1)
xor    %edi,%edi
mov    %rbp,%rsi
call   1080 <strtok@plt>
mov    %rax,(%rbx)
add    $0x8,%rbx
test   %rax,%rax
jne    11d0 <execution+0x50>
jmp    1206 <execution+0x86>
mov    %r14,%rdi
call   1050 <strlen@plt>
mov    %eax,%edi
call   1070 <malloc@plt>
mov    %rax,(%rsp)
mov    %rax,%rdi
mov    %r14,%rsi
call   1040 <strcpy@plt>
xor    %eax,%eax
call   10a0 <fork@plt>
test   %eax,%eax
je     122a <execution+0xaa>
mov    %eax,%ebp
cmp    $0xffffffff,%eax
jne    1252 <execution+0xd2>
mov    0x2dc1(%rip),%rax
mov    (%rax),%edi
lea    0xdda(%rip),%rsi
jmp    1246 <execution+0xc6>
mov    (%rsp),%rdi
mov    %rsp,%rsi
call   1090 <execvp@plt>
mov    0x2da3(%rip),%rax
mov    (%rax),%edi
lea    0xdcb(%rip),%rsi
call   1060 <fprintf@plt>
mov    $0xffffffff,%ebp
jmp    125a <execution+0xda>
mov    %r14,%rdi
call   1030 <free@plt>
mov    %ebp,%eax
add    $0x320,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c" \00"
@stdout = global i32 0
@.str.1 = [15 x i8] c"Fork failure.\0A\00"
@.str.2 = [26 x i8] c"Command running failure.\0A\00"
define i32 @execution(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca [100 x i8*]
%6 = alloca i32
%7 = alloca i32
store i8* %0, i8** %3
store i32 0, i32* %6
%8 = call i8* @malloc(i32 9)
store i8* %8, i8** %4
%9 = load i8*, i8** %4
%10 = load i8*, i8** %3
%11 = call i32 @strcpy(i8* %9, i8* %10)
%12 = load i8*, i8** %4
%13 = call i8* @strtok(i8* %12, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%14 = getelementptr inbounds [100 x i8*], [100 x i8*]* %5, i64 0, i64 0
store i8* %13, i8** %14
%15 = getelementptr inbounds [100 x i8*], [100 x i8*]* %5, i64 0, i64 0
%16 = load i8*, i8** %15
%17 = icmp eq i8* %16, null
br i1 %17, label %18, label %27
18: ; preds = %1
%19 = load i8*, i8** %4
%20 = call i32 @strlen(i8* %19)
%21 = call i8* @malloc(i32 %20)
%22 = getelementptr inbounds [100 x i8*], [100 x i8*]* %5, i64 0, i64 0
store i8* %21, i8** %22
%23 = getelementptr inbounds [100 x i8*], [100 x i8*]* %5, i64 0, i64 0
%24 = load i8*, i8** %23
%25 = load i8*, i8** %4
%26 = call i32 @strcpy(i8* %24, i8* %25)
br label %43
27: ; preds = %1
br label %28
28: ; preds = %34, %27
%29 = load i32, i32* %6
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds [100 x i8*], [100 x i8*]* %5, i64 0, i64 %30
%32 = load i8*, i8** %31
%33 = icmp ne i8* %32, null
br i1 %33, label %34, label %42
34: ; preds = %28
%35 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%36 = load i32, i32* %6
%37 = add nsw i32 %36, 1
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds [100 x i8*], [100 x i8*]* %5, i64 0, i64 %38
store i8* %35, i8** %39
%40 = load i32, i32* %6
%41 = add nsw i32 %40, 1
store i32 %41, i32* %6
br label %28
42: ; preds = %28
br label %43
43: ; preds = %42, %18
store i32 0, i32* %6
%44 = call i32 (...) @fork()
store i32 %44, i32* %7
%45 = icmp eq i32 %44, -1
br i1 %45, label %46, label %49
46: ; preds = %43
%47 = load i32, i32* @stdout
%48 = call i32 @fprintf(i32 %47, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0))
store i32 -1, i32* %2
br label %64
49: ; preds = %43
%50 = load i32, i32* %7
%51 = icmp eq i32 %50, 0
br i1 %51, label %52, label %59
52: ; preds = %49
%53 = getelementptr inbounds [100 x i8*], [100 x i8*]* %5, i64 0, i64 0
%54 = load i8*, i8** %53
%55 = getelementptr inbounds [100 x i8*], [100 x i8*]* %5, i64 0, i64 0
%56 = call i32 @execvp(i8* %54, i8** %55)
%57 = load i32, i32* @stdout
%58 = call i32 @fprintf(i32 %57, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0))
store i32 -1, i32* %2
br label %64
59: ; preds = %49
br label %60
60: ; preds = %59
store i32 0, i32* %6
%61 = load i8*, i8** %4
%62 = call i32 @free(i8* %61)
%63 = load i32, i32* %7
store i32 %63, i32* %2
br label %64
64: ; preds = %60, %52, %46
%65 = load i32, i32* %2
ret i32 %65
}

LLVM IR (-O2):
@.str = [2 x i8] c" \00"
@stdout = global i32 0
@.str.1 = [15 x i8] c"Fork failure.\0A\00"
@.str.2 = [26 x i8] c"Command running failure.\0A\00"
define i32 @execution(i8* %0) {
%2 = alloca [100 x i8*]
%3 = bitcast [100 x i8*]* %2 to i8*
%4 = tail call dereferenceable_or_null(9) i8* @malloc(i32 9)
%5 = tail call i32 @strcpy(i8* %4, i8* %0)
%6 = tail call i8* @strtok(i8* %4, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%7 = getelementptr inbounds [100 x i8*], [100 x i8*]* %2, i64 0, i64 0
store i8* %6, i8** %7
%8 = icmp eq i8* %6, null
br i1 %8, label %9, label %13
9: ; preds = %1
%10 = tail call i32 @strlen(i8* %4)
%11 = tail call i8* @malloc(i32 %10)
store i8* %11, i8** %7
%12 = tail call i32 @strcpy(i8* %11, i8* %4)
br label %19
13: ; preds = %1, %13
%14 = phi i64 [ %16, %13 ], [ 0, %1 ]
%15 = tail call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%16 = add nuw nsw i64 %14, 1
%17 = getelementptr inbounds [100 x i8*], [100 x i8*]* %2, i64 0, i64 %16
store i8* %15, i8** %17
%18 = icmp eq i8* %15, null
br i1 %18, label %19, label %13
19: ; preds = %13, %9
%20 = tail call i32 (...) @fork()
switch i32 %20, label %29 [
i32 -1, label %21
i32 0, label %24
]
21: ; preds = %19
%22 = load i32, i32* @stdout
%23 = tail call i32 @fprintf(i32 %22, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0))
br label %31
24: ; preds = %19
%25 = load i8*, i8** %7
%26 = call i32 @execvp(i8* %25, i8** %7)
%27 = load i32, i32* @stdout
%28 = call i32 @fprintf(i32 %27, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0))
br label %31
29: ; preds = %19
%30 = tail call i32 @free(i8* %4)
br label %31
31: ; preds = %29, %24, %21
%32 = phi i32 [ -1, %21 ], [ -1, %24 ], [ %20, %29 ]
ret i32 %32
}