#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 *, int /*<<< orphan*/ *);
int /*<<< orphan*/ exit(int);
scalar_t__ fork();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ wait(int /*<<< orphan*/ *);
void exec0() {
  if (fork() == 0) {
    execl("/bin/ls", "ls", "-F", NULL);
    printf("Child: Should never get here!\n");
    exit(1);
  }
  wait(NULL);
  printf("Command completed\n");
}


x86 assembly (clang, -O0):
<exec0>:
push   %rbp
mov    %rsp,%rbp
mov    $0x0,%al
call   1070 <fork@plt>
cmp    $0x0,%rax
jne    1199 <exec0+0x49>
lea    0xe94(%rip),%rdi
lea    0xe92(%rip),%rsi
lea    0xe8e(%rip),%rdx
xor    %eax,%eax
mov    %eax,%ecx
call   1050 <execl@plt>
lea    0xe81(%rip),%rdi
call   1030 <printf@plt>
mov    $0x1,%edi
call   1040 <exit@plt>
xor    %eax,%eax
mov    %eax,%edi
call   1060 <wait@plt>
lea    0xe81(%rip),%rdi
call   1030 <printf@plt>
pop    %rbp
ret

x86 assembly (clang, -O2):
<exec0>:
push   %rax
xor    %eax,%eax
call   1070 <fork@plt>
test   %rax,%rax
je     1171 <exec0+0x21>
xor    %edi,%edi
call   1060 <wait@plt>
lea    0xea0(%rip),%rdi
pop    %rax
jmp    1030 <puts@plt>
lea    0xe88(%rip),%rdi
lea    0xe86(%rip),%rsi
lea    0xe82(%rip),%rdx
xor    %ecx,%ecx
call   1050 <execl@plt>
lea    0xe89(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%edi
call   1040 <exit@plt>

LLVM IR (-O0):
@.str = [8 x i8] c"/bin/ls\00"
@.str.1 = [3 x i8] c"ls\00"
@.str.2 = [3 x i8] c"-F\00"
@.str.3 = [31 x i8] c"Child: Should never get here!\0A\00"
@.str.4 = [19 x i8] c"Command completed\0A\00"
define void @exec0() {
%1 = call i64 (...) @fork()
%2 = icmp eq i64 %1, 0
br i1 %2, label %3, label %7
3: ; preds = %0
%4 = call i32 @execl(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* null)
%5 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0))
%6 = call i32 @exit(i32 1)
unreachable
7: ; preds = %0
%8 = call i32 @wait(i32* null)
%9 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [8 x i8] c"/bin/ls\00"
@.str.1 = [3 x i8] c"ls\00"
@.str.2 = [3 x i8] c"-F\00"
@str = [18 x i8] c"Command completed\00"
@str.5 = [30 x i8] c"Child: Should never get here!\00"
define void @exec0() {
%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 ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* null)
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @str.5, i64 0, i64 0))
%6 = tail call i32 @exit(i32 1)
unreachable
7: ; preds = %0
%8 = tail call i32 @wait(i32* null)
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str, i64 0, i64 0))
ret void
}