#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;

/* Variables and functions */
scalar_t__ execlp(char *, char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ exit(int);
int fork();
int /*<<< orphan*/ printf(char *, char *);
pid_t myCreateProcess(char *input) {
  pid_t pid1;
  if ((pid1 = fork()) < 0) {
    return -1;
  } else if (pid1 == 0) {
    if (execlp(input, input, NULL) < 0) {
      printf("command not found: %s\n", input);
      exit(1);
    }
  } else {
    return pid1;
  }
}


x86 assembly (clang, -O0):
<myCreateProcess>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    $0x0,%al
call   1060 <fork@plt>
mov    %eax,-0x14(%rbp)
cmp    $0x0,%eax
jge    116b <myCreateProcess+0x2b>
movl   $0xffffffff,-0x4(%rbp)
jmp    11bf <myCreateProcess+0x7f>
cmpl   $0x0,-0x14(%rbp)
jne    11af <myCreateProcess+0x6f>
mov    -0x10(%rbp),%rdi
mov    -0x10(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1050 <execlp@plt>
cmp    $0x0,%rax
jge    11aa <myCreateProcess+0x6a>
mov    -0x10(%rbp),%rsi
lea    0xe65(%rip),%rdi
call   1030 <printf@plt>
mov    $0x1,%edi
call   1040 <exit@plt>
jmp    11ba <myCreateProcess+0x7a>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11bf <myCreateProcess+0x7f>
jmp    11bf <myCreateProcess+0x7f>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<myCreateProcess>:
push   %rbx
mov    %rdi,%rbx
xor    %eax,%eax
call   1060 <fork@plt>
test   %eax,%eax
js     1168 <myCreateProcess+0x28>
jne    1166 <myCreateProcess+0x26>
mov    %rbx,%rdi
mov    %rbx,%rsi
xor    %edx,%edx
call   1050 <execlp@plt>
mov    %rax,%rcx
test   %rcx,%rcx
js     116f <myCreateProcess+0x2f>
pop    %rbx
ret
mov    $0xffffffff,%eax
pop    %rbx
ret
lea    0xe8a(%rip),%rdi
mov    %rbx,%rsi
call   1030 <printf@plt>
mov    $0x1,%edi
call   1040 <exit@plt>

LLVM IR (-O0):
@.str = [23 x i8] c"command not found: %s\0A\00"
define i32 @myCreateProcess(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
store i8* %0, i8** %3
%5 = call i32 (...) @fork()
store i32 %5, i32* %4
%6 = icmp slt i32 %5, 0
br i1 %6, label %7, label %8
7: ; preds = %1
store i32 -1, i32* %2
br label %24
8: ; preds = %1
%9 = load i32, i32* %4
%10 = icmp eq i32 %9, 0
br i1 %10, label %11, label %21
11: ; preds = %8
%12 = load i8*, i8** %3
%13 = load i8*, i8** %3
%14 = call i64 @execlp(i8* %12, i8* %13, i32* null)
%15 = icmp slt i64 %14, 0
br i1 %15, label %16, label %20
16: ; preds = %11
%17 = load i8*, i8** %3
%18 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i8* %17)
%19 = call i32 @exit(i32 1)
unreachable
20: ; preds = %11
br label %23
21: ; preds = %8
%22 = load i32, i32* %4
store i32 %22, i32* %2
br label %24
23: ; preds = %20
br label %24
24: ; preds = %7, %21, %23
%25 = load i32, i32* %2
ret i32 %25
}

LLVM IR (-O2):
@.str = [23 x i8] c"command not found: %s\0A\00"
define i32 @myCreateProcess(i8* %0) {
%2 = tail call i32 (...) @fork()
%3 = icmp slt i32 %2, 0
br i1 %3, label %12, label %4
4: ; preds = %1
%5 = icmp eq i32 %2, 0
br i1 %5, label %6, label %12
6: ; preds = %4
%7 = tail call i64 @execlp(i8* %0, i8* %0, i32* null)
%8 = icmp slt i64 %7, 0
br i1 %8, label %9, label %12
9: ; preds = %6
%10 = tail call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i8* %0)
%11 = tail call i32 @exit(i32 1)
unreachable
12: ; preds = %6, %4, %1
%13 = phi i32 [ -1, %1 ], [ %2, %4 ], [ undef, %6 ]
ret i32 %13
}