#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 */

/* Variables and functions */
int /*<<< orphan*/ execl(char *, char *, char *, char *, char *);
int /*<<< orphan*/ exit(int);
scalar_t__ fork();
int /*<<< orphan*/ printf(char *);
int main(void) {
  if (fork() == 0) {
    execl("/bin/echo", "echo", "this is", "message one", (char *)0);
    printf("exec one failed\n");
    exit(1);
  }
  if (fork() == 0) {
    execl("/bin/echo", "echo", "this is", "message two", (char *)0);
    printf("exec one failed\n");
    exit(1);
  }
  if (fork() == 0) {
    execl("/bin/echo", "echo", "this is", "message three", (char *)0);
    printf("exec one failed\n");
    exit(1);
  }
  printf("Parent program ending\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1060 <fork@plt>
cmp    $0x0,%rax
jne    119c <main+0x5c>
lea    0xe99(%rip),%rdi
lea    0xe97(%rip),%rsi
lea    0xe95(%rip),%rdx
lea    0xe96(%rip),%rcx
xor    %eax,%eax
mov    %eax,%r8d
call   1050 <execl@plt>
lea    0xe91(%rip),%rdi
call   1030 <printf@plt>
mov    $0x1,%edi
call   1040 <exit@plt>
mov    $0x0,%al
call   1060 <fork@plt>
cmp    $0x0,%rax
jne    11e9 <main+0xa9>
lea    0xe4c(%rip),%rdi
lea    0xe4a(%rip),%rsi
lea    0xe48(%rip),%rdx
lea    0xe66(%rip),%rcx
xor    %eax,%eax
mov    %eax,%r8d
call   1050 <execl@plt>
lea    0xe44(%rip),%rdi
call   1030 <printf@plt>
mov    $0x1,%edi
call   1040 <exit@plt>
mov    $0x0,%al
call   1060 <fork@plt>
cmp    $0x0,%rax
jne    1236 <main+0xf6>
lea    0xdff(%rip),%rdi
lea    0xdfd(%rip),%rsi
lea    0xdfb(%rip),%rdx
lea    0xe25(%rip),%rcx
xor    %eax,%eax
mov    %eax,%r8d
call   1050 <execl@plt>
lea    0xdf7(%rip),%rdi
call   1030 <printf@plt>
mov    $0x1,%edi
call   1040 <exit@plt>
lea    0xe0c(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
xor    %eax,%eax
call   1060 <fork@plt>
test   %rax,%rax
je     1175 <main+0x35>
xor    %eax,%eax
call   1060 <fork@plt>
test   %rax,%rax
je     1193 <main+0x53>
xor    %eax,%eax
call   1060 <fork@plt>
test   %rax,%rax
je     11b1 <main+0x71>
lea    0xecc(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
pop    %rcx
ret
lea    0xe84(%rip),%rdi
lea    0xe82(%rip),%rsi
lea    0xe80(%rip),%rdx
lea    0xe81(%rip),%rcx
jmp    11cd <main+0x8d>
lea    0xe66(%rip),%rdi
lea    0xe64(%rip),%rsi
lea    0xe62(%rip),%rdx
lea    0xe6f(%rip),%rcx
jmp    11cd <main+0x8d>
lea    0xe48(%rip),%rdi
lea    0xe46(%rip),%rsi
lea    0xe44(%rip),%rdx
lea    0xe5d(%rip),%rcx
xor    %r8d,%r8d
call   1050 <execl@plt>
lea    0xe72(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%edi
call   1040 <exit@plt>

LLVM IR (-O0):
@.str = [10 x i8] c"/bin/echo\00"
@.str.1 = [5 x i8] c"echo\00"
@.str.2 = [8 x i8] c"this is\00"
@.str.3 = [12 x i8] c"message one\00"
@.str.4 = [17 x i8] c"exec one failed\0A\00"
@.str.5 = [12 x i8] c"message two\00"
@.str.6 = [14 x i8] c"message three\00"
@.str.7 = [23 x i8] c"Parent program ending\0A\00"
define i32 @main() {
%1 = alloca i32
store i32 0, i32* %1
%2 = call i64 (...) @fork()
%3 = icmp eq i64 %2, 0
br i1 %3, label %4, label %8
4: ; preds = %0
%5 = call i32 @execl(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i8* null)
%6 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0))
%7 = call i32 @exit(i32 1)
unreachable
8: ; preds = %0
%9 = call i64 (...) @fork()
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %15
11: ; preds = %8
%12 = call i32 @execl(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0), i8* null)
%13 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0))
%14 = call i32 @exit(i32 1)
unreachable
15: ; preds = %8
%16 = call i64 (...) @fork()
%17 = icmp eq i64 %16, 0
br i1 %17, label %18, label %22
18: ; preds = %15
%19 = call i32 @execl(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.6, i64 0, i64 0), i8* null)
%20 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0))
%21 = call i32 @exit(i32 1)
unreachable
22: ; preds = %15
%23 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.7, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [10 x i8] c"/bin/echo\00"
@.str.1 = [5 x i8] c"echo\00"
@.str.2 = [8 x i8] c"this is\00"
@.str.3 = [12 x i8] c"message one\00"
@.str.5 = [12 x i8] c"message two\00"
@.str.6 = [14 x i8] c"message three\00"
@str = [22 x i8] c"Parent program ending\00"
@str.10 = [16 x i8] c"exec one failed\00"
define i32 @main() {
%1 = tail call i64 (...) @fork()
%2 = icmp eq i64 %1, 0
br i1 %2, label %3, label %7
3: ; preds = %0
%4 = tail call i32 @execl(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i8* null)
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str.10, i64 0, i64 0))
%6 = tail call i32 @exit(i32 1)
unreachable
7: ; preds = %0
%8 = tail call i64 (...) @fork()
%9 = icmp eq i64 %8, 0
br i1 %9, label %10, label %14
10: ; preds = %7
%11 = tail call i32 @execl(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0), i8* null)
%12 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str.10, i64 0, i64 0))
%13 = tail call i32 @exit(i32 1)
unreachable
14: ; preds = %7
%15 = tail call i64 (...) @fork()
%16 = icmp eq i64 %15, 0
br i1 %16, label %17, label %21
17: ; preds = %14
%18 = tail call i32 @execl(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.6, i64 0, i64 0), i8* null)
%19 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str.10, i64 0, i64 0))
%20 = tail call i32 @exit(i32 1)
unreachable
21: ; preds = %14
%22 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str, i64 0, i64 0))
ret i32 0
}