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

/* Variables and functions */
int /*<<< orphan*/ err_sys(char *);
scalar_t__ execlp(char *, char *, char *, char *, int /*<<< orphan*/ *);
scalar_t__ fork();
int /*<<< orphan*/ setenv(char *, char *, int /*<<< orphan*/);
scalar_t__ waitpid(scalar_t__, int /*<<< orphan*/ *, int /*<<< orphan*/);
int main(int argc, char **argv) {
  setenv("PATH", ".", 0);
  pid_t pid;
  if ((pid = fork()) < 0) {
    err_sys("error on fork");
  } else if (pid == 0) {
    if (execlp("testinterp", "testinterp", "myarg1", "MY ARG2", NULL) < 0) {
      err_sys("error on execl");
    }
  }
  if (waitpid(pid, NULL, 0) != pid) {
    err_sys("error on waitpid");
  }
  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)
lea    0xe93(%rip),%rdi
lea    0xe91(%rip),%rsi
xor    %edx,%edx
call   1040 <setenv@plt>
mov    $0x0,%al
call   1070 <fork@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jge    11a1 <main+0x51>
lea    0xe70(%rip),%rdi
call   1030 <err_sys@plt>
jmp    11ee <main+0x9e>
cmpq   $0x0,-0x18(%rbp)
jne    11e9 <main+0x99>
lea    0xe62(%rip),%rsi
lea    0xe66(%rip),%rdx
lea    0xe66(%rip),%rcx
xor    %eax,%eax
mov    %eax,%r8d
mov    %rsi,%rdi
call   1060 <execlp@plt>
cmp    $0x0,%rax
jge    11e4 <main+0x94>
lea    0xe50(%rip),%rdi
call   1030 <err_sys@plt>
jmp    11e9 <main+0x99>
jmp    11ee <main+0x9e>
mov    -0x18(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
xor    %edx,%edx
call   1050 <waitpid@plt>
cmp    -0x18(%rbp),%rax
je     1213 <main+0xc3>
lea    0xe30(%rip),%rdi
call   1030 <err_sys@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
lea    0xea8(%rip),%rdi
lea    0xea6(%rip),%rsi
xor    %edx,%edx
call   1040 <setenv@plt>
xor    %eax,%eax
call   1070 <fork@plt>
mov    %rax,%rbx
test   %rax,%rax
js     11a5 <main+0x55>
jne    11b1 <main+0x61>
lea    0xe97(%rip),%rdi
lea    0xe9b(%rip),%rdx
lea    0xe9b(%rip),%rcx
mov    %rdi,%rsi
xor    %r8d,%r8d
call   1060 <execlp@plt>
test   %rax,%rax
jns    11b1 <main+0x61>
lea    0xe8c(%rip),%rdi
jmp    11ac <main+0x5c>
lea    0xe5b(%rip),%rdi
call   1030 <err_sys@plt>
mov    %rbx,%rdi
xor    %esi,%esi
xor    %edx,%edx
call   1050 <waitpid@plt>
cmp    %rbx,%rax
je     11ce <main+0x7e>
lea    0xe75(%rip),%rdi
call   1030 <err_sys@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [5 x i8] c"PATH\00"
@.str.1 = [2 x i8] c".\00"
@.str.2 = [14 x i8] c"error on fork\00"
@.str.3 = [11 x i8] c"testinterp\00"
@.str.4 = [7 x i8] c"myarg1\00"
@.str.5 = [8 x i8] c"MY ARG2\00"
@.str.6 = [15 x i8] c"error on execl\00"
@.str.7 = [17 x i8] c"error on waitpid\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = call i32 @setenv(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 0)
%8 = call i64 (...) @fork()
store i64 %8, i64* %6
%9 = icmp slt i64 %8, 0
br i1 %9, label %10, label %12
10: ; preds = %2
%11 = call i32 @err_sys(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0))
br label %22
12: ; preds = %2
%13 = load i64, i64* %6
%14 = icmp eq i64 %13, 0
br i1 %14, label %15, label %21
15: ; preds = %12
%16 = call i64 @execlp(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0), i32* null)
%17 = icmp slt i64 %16, 0
br i1 %17, label %18, label %20
18: ; preds = %15
%19 = call i32 @err_sys(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.6, i64 0, i64 0))
br label %20
20: ; preds = %18, %15
br label %21
21: ; preds = %20, %12
br label %22
22: ; preds = %21, %10
%23 = load i64, i64* %6
%24 = call i64 @waitpid(i64 %23, i32* null, i32 0)
%25 = load i64, i64* %6
%26 = icmp ne i64 %24, %25
br i1 %26, label %27, label %29
27: ; preds = %22
%28 = call i32 @err_sys(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.7, i64 0, i64 0))
br label %29
29: ; preds = %27, %22
ret i32 0
}

LLVM IR (-O2):
@.str = [5 x i8] c"PATH\00"
@.str.1 = [2 x i8] c".\00"
@.str.2 = [14 x i8] c"error on fork\00"
@.str.3 = [11 x i8] c"testinterp\00"
@.str.4 = [7 x i8] c"myarg1\00"
@.str.5 = [8 x i8] c"MY ARG2\00"
@.str.6 = [15 x i8] c"error on execl\00"
@.str.7 = [17 x i8] c"error on waitpid\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32 @setenv(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 0)
%4 = tail call i64 (...) @fork()
%5 = icmp slt i64 %4, 0
br i1 %5, label %11, label %6
6: ; preds = %2
%7 = icmp eq i64 %4, 0
br i1 %7, label %8, label %14
8: ; preds = %6
%9 = tail call i64 @execlp(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0), i32* null)
%10 = icmp slt i64 %9, 0
br i1 %10, label %11, label %14
11: ; preds = %8, %2
%12 = phi i8* [ getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), %2 ], [ getelementptr inbounds ([15 x i8], [15 x i8]* @.str.6, i64 0, i64 0), %8 ]
%13 = tail call i32 @err_sys(i8* %12)
br label %14
14: ; preds = %11, %6, %8
%15 = tail call i64 @waitpid(i64 %4, i32* null, i32 0)
%16 = icmp eq i64 %15, %4
br i1 %16, label %19, label %17
17: ; preds = %14
%18 = tail call i32 @err_sys(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.7, i64 0, i64 0))
br label %19
19: ; preds = %17, %14
ret i32 0
}