#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__ execl(char *, char *, char *, char *, int /*<<< orphan*/ *);
scalar_t__ fork();
scalar_t__ waitpid(scalar_t__, int /*<<< orphan*/ *, int /*<<< orphan*/);
int main(int argc, char **argv) {
  pid_t pid;
  if ((pid = fork()) < 0) {
    err_sys("error on fork");
  } else if (pid == 0) {
    if (execl("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)
mov    $0x0,%al
call   1060 <fork@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jge    117c <main+0x3c>
lea    0xe8e(%rip),%rdi
call   1030 <err_sys@plt>
jmp    11c9 <main+0x89>
cmpq   $0x0,-0x18(%rbp)
jne    11c4 <main+0x84>
lea    0xe80(%rip),%rsi
lea    0xe84(%rip),%rdx
lea    0xe84(%rip),%rcx
xor    %eax,%eax
mov    %eax,%r8d
mov    %rsi,%rdi
call   1050 <execl@plt>
cmp    $0x0,%rax
jge    11bf <main+0x7f>
lea    0xe6e(%rip),%rdi
call   1030 <err_sys@plt>
jmp    11c4 <main+0x84>
jmp    11c9 <main+0x89>
mov    -0x18(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
xor    %edx,%edx
call   1040 <waitpid@plt>
cmp    -0x18(%rbp),%rax
je     11ee <main+0xae>
lea    0xe4e(%rip),%rdi
call   1030 <err_sys@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
xor    %eax,%eax
call   1060 <fork@plt>
mov    %rax,%rbx
test   %rax,%rax
js     1180 <main+0x40>
jne    118c <main+0x4c>
lea    0xeb5(%rip),%rdi
lea    0xeb9(%rip),%rdx
lea    0xeb9(%rip),%rcx
mov    %rdi,%rsi
xor    %r8d,%r8d
call   1050 <execl@plt>
test   %rax,%rax
jns    118c <main+0x4c>
lea    0xeaa(%rip),%rdi
jmp    1187 <main+0x47>
lea    0xe79(%rip),%rdi
call   1030 <err_sys@plt>
mov    %rbx,%rdi
xor    %esi,%esi
xor    %edx,%edx
call   1040 <waitpid@plt>
cmp    %rbx,%rax
je     11a9 <main+0x69>
lea    0xe93(%rip),%rdi
call   1030 <err_sys@plt>
xor    %eax,%eax
pop    %rbx
ret

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

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