#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 */
int /*<<< orphan*/ _exit(int);
int /*<<< orphan*/ execv(char *, char **);
int fork();
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ stderr;
int main(int argc, char *argv[]) {
  if (argc < 2) {
    fprintf(stderr, "SYNTAX:\t%s <command> [<arguments...>]\n", argv[0]);
    fprintf(stderr,
            "\tRun the specified command as a separate process and exit.\n");
    return 1;
  };
  pid_t pid = fork();
  if (pid == -1) {
    perror(argv[0]);
    return 1;
  } else if (pid == 0) {
    argv[0] = "env";
    execv("/usr/bin/env", argv);
    _exit(1);
  } else {
    return 0;
  };
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    11b1 <main+0x61>
mov    0x2e69(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe79(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    0x2e4b(%rip),%rax
mov    (%rax),%edi
lea    0xe89(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1216 <main+0xc6>
mov    $0x0,%al
call   1070 <fork@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0xffffffff,-0x14(%rbp)
jne    11dd <main+0x8d>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1050 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    1216 <main+0xc6>
cmpl   $0x0,-0x14(%rbp)
jne    120f <main+0xbf>
mov    -0x10(%rbp),%rax
lea    0xe7a(%rip),%rcx
mov    %rcx,(%rax)
mov    -0x10(%rbp),%rsi
lea    0xe63(%rip),%rdi
call   1060 <execv@plt>
mov    $0x1,%edi
call   1030 <_exit@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
mov    %rsi,%rbx
cmp    $0x1,%edi
jg     118e <main+0x3e>
mov    0x2e7e(%rip),%rbp
mov    0x0(%rbp),%edi
mov    (%rbx),%rdx
lea    0xe91(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    0x0(%rbp),%edi
lea    0xea7(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    $0x1,%ebp
jmp    11a0 <main+0x50>
xor    %ebp,%ebp
xor    %eax,%eax
call   1070 <fork@plt>
cmp    $0xffffffff,%eax
je     11a9 <main+0x59>
test   %eax,%eax
je     11b3 <main+0x63>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
mov    (%rbx),%rdi
call   1050 <perror@plt>
jmp    1187 <main+0x37>
lea    0xeb2(%rip),%rax
mov    %rax,(%rbx)
lea    0xe9f(%rip),%rdi
mov    %rbx,%rsi
call   1060 <execv@plt>
mov    $0x1,%edi
call   1030 <_exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [39 x i8] c"SYNTAX:\09%s <command> [<arguments...>]\0A\00"
@.str.1 = [60 x i8] c"\09Run the specified command as a separate process and exit.\0A\00"
@.str.2 = [4 x i8] c"env\00"
@.str.3 = [13 x i8] c"/usr/bin/env\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = load i32, i32* %4
%8 = icmp slt i32 %7, 2
br i1 %8, label %9, label %17
9: ; preds = %2
%10 = load i32, i32* @stderr
%11 = load i8**, i8*** %5
%12 = getelementptr inbounds i8*, i8** %11, i64 0
%13 = load i8*, i8** %12
%14 = call i32 (i32, i8*, ...) @fprintf(i32 %10, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0), i8* %13)
%15 = load i32, i32* @stderr
%16 = call i32 (i32, i8*, ...) @fprintf(i32 %15, i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str.1, i64 0, i64 0))
store i32 1, i32* %3
br label %36
17: ; preds = %2
%18 = call i32 (...) @fork()
store i32 %18, i32* %6
%19 = load i32, i32* %6
%20 = icmp eq i32 %19, -1
br i1 %20, label %21, label %26
21: ; preds = %17
%22 = load i8**, i8*** %5
%23 = getelementptr inbounds i8*, i8** %22, i64 0
%24 = load i8*, i8** %23
%25 = call i32 @perror(i8* %24)
store i32 1, i32* %3
br label %36
26: ; preds = %17
%27 = load i32, i32* %6
%28 = icmp eq i32 %27, 0
br i1 %28, label %29, label %35
29: ; preds = %26
%30 = load i8**, i8*** %5
%31 = getelementptr inbounds i8*, i8** %30, i64 0
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8** %31
%32 = load i8**, i8*** %5
%33 = call i32 @execv(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i8** %32)
%34 = call i32 @_exit(i32 1)
unreachable
35: ; preds = %26
store i32 0, i32* %3
br label %36
36: ; preds = %35, %21, %9
%37 = load i32, i32* %3
ret i32 %37
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [39 x i8] c"SYNTAX:\09%s <command> [<arguments...>]\0A\00"
@.str.1 = [60 x i8] c"\09Run the specified command as a separate process and exit.\0A\00"
@.str.2 = [4 x i8] c"env\00"
@.str.3 = [13 x i8] c"/usr/bin/env\00"
define i32 @main(i32 %0, i8** %1) {
%3 = icmp slt i32 %0, 2
br i1 %3, label %4, label %10
4: ; preds = %2
%5 = load i32, i32* @stderr
%6 = load i8*, i8** %1
%7 = tail call i32 (i32, i8*, ...) @fprintf(i32 %5, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0), i8* %6)
%8 = load i32, i32* @stderr
%9 = tail call i32 (i32, i8*, ...) @fprintf(i32 %8, i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str.1, i64 0, i64 0))
br label %18
10: ; preds = %2
%11 = tail call i32 (...) @fork()
switch i32 %11, label %18 [
i32 -1, label %12
i32 0, label %15
]
12: ; preds = %10
%13 = load i8*, i8** %1
%14 = tail call i32 @perror(i8* %13)
br label %18
15: ; preds = %10
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8** %1
%16 = tail call i32 @execv(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i8** %1)
%17 = tail call i32 @_exit(i32 1)
unreachable
18: ; preds = %12, %10, %4
%19 = phi i32 [ 1, %4 ], [ 1, %12 ], [ 0, %10 ]
ret i32 %19
}