#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*/ execlp(char *, char *, char *, char *);
int /*<<< orphan*/ exit(int);
scalar_t__ fork();
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char *argv[], char *envp[]) {
  pid_t pid;
  if (argc != 2) {
    printf("usage: %s <dirname>\n", argv[0]);
    exit(1);
  }
  pid = fork();
  if (pid > 0)
    printf("My child is going to execute command \"ls -laR %s\"\n", argv[1]);
  else if (pid == 0) {
    execlp("ls", "ls", "-laR", argv[1]);
    printf("Command not executed !\n");
    exit(1);
  }
  exit(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    %rdx,-0x18(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     1183 <main+0x43>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe8e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x1,%edi
call   1040 <exit@plt>
mov    $0x0,%al
call   1060 <fork@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jle    11b4 <main+0x74>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xe6d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11fa <main+0xba>
cmpq   $0x0,-0x20(%rbp)
jne    11f5 <main+0xb5>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rcx
lea    0xe7a(%rip),%rsi
lea    0xe76(%rip),%rdx
mov    %rsi,%rdi
call   1050 <execlp@plt>
lea    0xe6c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x1,%edi
call   1040 <exit@plt>
jmp    11fa <main+0xba>
xor    %edi,%edi
call   1040 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbx
mov    %rsi,%rbx
cmp    $0x2,%edi
jne    117e <main+0x2e>
xor    %eax,%eax
call   1070 <fork@plt>
test   %rax,%rax
jle    1199 <main+0x49>
mov    0x8(%rbx),%rsi
lea    0xea5(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %edi,%edi
call   1050 <exit@plt>
mov    (%rbx),%rsi
lea    0xe78(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>
jne    11cb <main+0x7b>
mov    0x8(%rbx),%rcx
lea    0xea2(%rip),%rdi
lea    0xe9e(%rip),%rdx
mov    %rdi,%rsi
call   1060 <execlp@plt>
lea    0xe94(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%edi
call   1050 <exit@plt>
xor    %edi,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@.str = [21 x i8] c"usage: %s <dirname>\0A\00"
@.str.1 = [51 x i8] c"My child is going to execute command \22ls -laR %s\22\0A\00"
@.str.2 = [3 x i8] c"ls\00"
@.str.3 = [5 x i8] c"-laR\00"
@.str.4 = [24 x i8] c"Command not executed !\0A\00"
define i32 @main(i32 %0, i8** %1, i8** %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8**
%7 = alloca i8**
%8 = alloca i64
store i32 0, i32* %4
store i32 %0, i32* %5
store i8** %1, i8*** %6
store i8** %2, i8*** %7
%9 = load i32, i32* %5
%10 = icmp ne i32 %9, 2
br i1 %10, label %11, label %17
11: ; preds = %3
%12 = load i8**, i8*** %6
%13 = getelementptr inbounds i8*, i8** %12, i64 0
%14 = load i8*, i8** %13
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i8* %14)
%16 = call i32 @exit(i32 1)
unreachable
17: ; preds = %3
%18 = call i64 (...) @fork()
store i64 %18, i64* %8
%19 = load i64, i64* %8
%20 = icmp sgt i64 %19, 0
br i1 %20, label %21, label %26
21: ; preds = %17
%22 = load i8**, i8*** %6
%23 = getelementptr inbounds i8*, i8** %22, i64 1
%24 = load i8*, i8** %23
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.1, i64 0, i64 0), i8* %24)
br label %37
26: ; preds = %17
%27 = load i64, i64* %8
%28 = icmp eq i64 %27, 0
br i1 %28, label %29, label %36
29: ; preds = %26
%30 = load i8**, i8*** %6
%31 = getelementptr inbounds i8*, i8** %30, i64 1
%32 = load i8*, i8** %31
%33 = call i32 @execlp(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i8* %32)
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0))
%35 = call i32 @exit(i32 1)
unreachable
36: ; preds = %26
br label %37
37: ; preds = %36, %21
%38 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@.str = [21 x i8] c"usage: %s <dirname>\0A\00"
@.str.1 = [51 x i8] c"My child is going to execute command \22ls -laR %s\22\0A\00"
@.str.2 = [3 x i8] c"ls\00"
@.str.3 = [5 x i8] c"-laR\00"
@str = [23 x i8] c"Command not executed !\00"
define i32 @main(i32 %0, i8** nocapture %1, i8** nocapture readnone %2) {
%4 = icmp eq i32 %0, 2
br i1 %4, label %9, label %5
5: ; preds = %3
%6 = load i8*, i8** %1
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i8* %6)
%8 = tail call i32 @exit(i32 1)
unreachable
9: ; preds = %3
%10 = tail call i64 (...) @fork()
%11 = icmp sgt i64 %10, 0
br i1 %11, label %12, label %16
12: ; preds = %9
%13 = getelementptr inbounds i8*, i8** %1, i64 1
%14 = load i8*, i8** %13
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([51 x i8], [51 x i8]* @.str.1, i64 0, i64 0), i8* %14)
br label %24
16: ; preds = %9
%17 = icmp eq i64 %10, 0
br i1 %17, label %18, label %24
18: ; preds = %16
%19 = getelementptr inbounds i8*, i8** %1, i64 1
%20 = load i8*, i8** %19
%21 = tail call i32 @execlp(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i8* %20)
%22 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str, i64 0, i64 0))
%23 = tail call i32 @exit(i32 1)
unreachable
24: ; preds = %16, %12
%25 = tail call i32 @exit(i32 0)
unreachable
}