#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*/ assert(int);
int execve(char *, char **, char **);
int fork();
int /*<<< orphan*/ waitpid(int, int /*<<< orphan*/ *, int /*<<< orphan*/);
int main(int argc, char const *argv[]) {
  int ret, pid;
  pid = fork();
  char *envp[] = {NULL};
  char *args[] = {"/bin/ls", NULL};
  if (pid == 0) {
    ret = execve("/bin/ls", args, envp);
    assert(ret != -1);
  } else
    waitpid(pid, NULL, 0);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x0,%al
call   1070 <fork@plt>
mov    %eax,-0x18(%rbp)
lea    -0x20(%rbp),%rdi
xor    %esi,%esi
mov    $0x8,%edx
call   1030 <memset@plt>
mov    0x2c89(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0x2c86(%rip),%rax
mov    %rax,-0x28(%rbp)
cmpl   $0x0,-0x18(%rbp)
jne    11cd <main+0x7d>
lea    -0x30(%rbp),%rsi
lea    -0x20(%rbp),%rdx
lea    0xe51(%rip),%rdi
call   1040 <execve@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0xffffffff,-0x14(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
jmp    11db <main+0x8b>
mov    -0x18(%rbp),%edi
xor    %eax,%eax
mov    %eax,%esi
xor    %edx,%edx
call   1060 <waitpid@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x28,%rsp
xor    %eax,%eax
call   1060 <fork@plt>
movq   $0x0,0x8(%rsp)
movaps 0x2cb5(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
test   %eax,%eax
je     1171 <main+0x31>
mov    %eax,%edi
xor    %esi,%esi
xor    %edx,%edx
call   1050 <waitpid@plt>
jmp    1195 <main+0x55>
lea    0xe88(%rip),%rdi
lea    0x10(%rsp),%rsi
lea    0x8(%rsp),%rdx
call   1030 <execve@plt>
xor    %edi,%edi
cmp    $0xffffffff,%eax
setne  %dil
call   1040 <assert@plt>
xor    %eax,%eax
add    $0x28,%rsp
ret

LLVM IR (-O0):
@.str = [8 x i8] c"/bin/ls\00"
@__const.main.args = [2 x i8*] [i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i32 0, i32 0), i8* null]
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca [1 x i8*]
%9 = alloca [2 x i8*]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = call i32 (...) @fork()
store i32 %10, i32* %7
%11 = bitcast [1 x i8*]* %8 to i8*
%12 = bitcast [2 x i8*]* %9 to i8*
%13 = load i32, i32* %7
%14 = icmp eq i32 %13, 0
br i1 %14, label %15, label %23
15: ; preds = %2
%16 = getelementptr inbounds [2 x i8*], [2 x i8*]* %9, i64 0, i64 0
%17 = getelementptr inbounds [1 x i8*], [1 x i8*]* %8, i64 0, i64 0
%18 = call i32 @execve(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8** %16, i8** %17)
store i32 %18, i32* %6
%19 = load i32, i32* %6
%20 = icmp ne i32 %19, -1
%21 = zext i1 %20 to i32
%22 = call i32 @assert(i32 %21)
br label %26
23: ; preds = %2
%24 = load i32, i32* %7
%25 = call i32 @waitpid(i32 %24, i32* null, i32 0)
br label %26
26: ; preds = %23, %15
ret i32 0
}

LLVM IR (-O2):
@.str = [8 x i8] c"/bin/ls\00"
@__const.main.args = [2 x i8*] [i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i32 0, i32 0), i8* null]
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [1 x i8*]
%4 = alloca [2 x i8*]
%5 = tail call i32 (...) @fork()
%6 = bitcast [1 x i8*]* %3 to i8*
%7 = bitcast [1 x i8*]* %3 to i64*
store i64 0, i64* %7
%8 = bitcast [2 x i8*]* %4 to i8*
%9 = icmp eq i32 %5, 0
br i1 %9, label %10, label %17
10: ; preds = %2
%11 = getelementptr inbounds [2 x i8*], [2 x i8*]* %4, i64 0, i64 0
%12 = getelementptr inbounds [1 x i8*], [1 x i8*]* %3, i64 0, i64 0
%13 = call i32 @execve(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8** %11, i8** %12)
%14 = icmp ne i32 %13, -1
%15 = zext i1 %14 to i32
%16 = call i32 @assert(i32 %15)
br label %19
17: ; preds = %2
%18 = tail call i32 @waitpid(i32 %5, i32* null, i32 0)
br label %19
19: ; preds = %17, %10
ret i32 0
}