#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 */
scalar_t__ execl(char *, char *, char *, char *);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
scalar_t__ fork();
int /*<<< orphan*/ printf(char *);
scalar_t__ waitpid(scalar_t__, int /*<<< orphan*/ *, int /*<<< orphan*/);
int main(int argc, char *argv[]) {
  pid_t pid;
  if ((pid = fork()) < 0) {
    printf("fork error.\n");
    exit(0);
  } else if (pid == 0) {
    if (execl("/usr/bin/interprete", "interprete", "arg1", "arg2") < 0) {
      printf("execl error.\n");
    }
  }
  if (waitpid(pid, NULL, 0) < 0) {
    printf("wait error.\n");
  }
  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   1070 <fork@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jge    118e <main+0x3e>
lea    0xe7e(%rip),%rdi
call   1030 <printf@plt>
xor    %edi,%edi
call   1050 <exit@plt>
cmpq   $0x0,-0x18(%rbp)
jne    11d5 <main+0x85>
lea    0xe6d(%rip),%rdi
lea    0xe6f(%rip),%rsi
lea    0xe73(%rip),%rdx
lea    0xe71(%rip),%rcx
call   1060 <execl@plt>
cmp    $0x0,%rax
jge    11d0 <main+0x80>
lea    0xe60(%rip),%rdi
call   1030 <printf@plt>
jmp    11d5 <main+0x85>
jmp    11da <main+0x8a>
mov    -0x18(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
xor    %edx,%edx
call   1040 <waitpid@plt>
cmp    $0x0,%rax
jge    11ff <main+0xaf>
lea    0xe3f(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
xor    %eax,%eax
call   1070 <fork@plt>
test   %rax,%rax
js     11b5 <main+0x65>
mov    %rax,%rbx
jne    1194 <main+0x44>
lea    0xe97(%rip),%rdi
lea    0xe99(%rip),%rsi
lea    0xe9d(%rip),%rdx
lea    0xe9b(%rip),%rcx
call   1060 <execl@plt>
test   %rax,%rax
jns    1194 <main+0x44>
lea    0xe9b(%rip),%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
xor    %esi,%esi
xor    %edx,%edx
call   1040 <waitpid@plt>
test   %rax,%rax
jns    11b1 <main+0x61>
lea    0xe72(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
pop    %rbx
ret
lea    0xe7b(%rip),%rdi
call   1030 <puts@plt>
xor    %edi,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@.str = [13 x i8] c"fork error.\0A\00"
@.str.1 = [20 x i8] c"/usr/bin/interprete\00"
@.str.2 = [11 x i8] c"interprete\00"
@.str.3 = [5 x i8] c"arg1\00"
@.str.4 = [5 x i8] c"arg2\00"
@.str.5 = [14 x i8] c"execl error.\0A\00"
@.str.6 = [13 x i8] c"wait error.\0A\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 %12
9: ; preds = %2
%10 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%11 = call i32 @exit(i32 0)
unreachable
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 @execl(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%17 = icmp slt i64 %16, 0
br i1 %17, label %18, label %20
18: ; preds = %15
%19 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0))
br label %20
20: ; preds = %18, %15
br label %21
21: ; preds = %20, %12
br label %22
22: ; preds = %21
%23 = load i64, i64* %6
%24 = call i64 @waitpid(i64 %23, i32* null, i32 0)
%25 = icmp slt i64 %24, 0
br i1 %25, label %26, label %28
26: ; preds = %22
%27 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.6, i64 0, i64 0))
br label %28
28: ; preds = %26, %22
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [20 x i8] c"/usr/bin/interprete\00"
@.str.2 = [11 x i8] c"interprete\00"
@.str.3 = [5 x i8] c"arg1\00"
@.str.4 = [5 x i8] c"arg2\00"
@str = [12 x i8] c"wait error.\00"
@str.7 = [13 x i8] c"execl error.\00"
@str.8 = [12 x i8] c"fork error.\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 %5, label %8
5: ; preds = %2
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str.8, i64 0, i64 0))
%7 = tail call i32 @exit(i32 0)
unreachable
8: ; preds = %2
%9 = icmp eq i64 %3, 0
br i1 %9, label %10, label %15
10: ; preds = %8
%11 = tail call i64 @execl(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%12 = icmp slt i64 %11, 0
br i1 %12, label %13, label %15
13: ; preds = %10
%14 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str.7, i64 0, i64 0))
br label %15
15: ; preds = %8, %13, %10
%16 = tail call i64 @waitpid(i64 %3, i32* null, i32 0)
%17 = icmp slt i64 %16, 0
br i1 %17, label %18, label %20
18: ; preds = %15
%19 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str, i64 0, i64 0))
br label %20
20: ; preds = %18, %15
ret i32 0
}