#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 */
scalar_t__ execve(char *, char **, char **);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ printf(char *);
int main(int argc, char **argv, char **envp) {
  char *arguments[10] = {"name", "-l", "-R", "/", "\0"};
  if (execve("./u03s04e10-argv", arguments, envp) < 0) {
    printf("error exec\n");
    exit(1);
  }
  printf("listing complete !!!\n");
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
lea    -0x70(%rbp),%rdi
xor    %esi,%esi
mov    $0x50,%edx
call   1040 <memset@plt>
lea    0xe8f(%rip),%rax
mov    %rax,-0x70(%rbp)
lea    0xe89(%rip),%rax
mov    %rax,-0x68(%rbp)
lea    0xe81(%rip),%rax
mov    %rax,-0x60(%rbp)
lea    0xe79(%rip),%rax
mov    %rax,-0x58(%rbp)
lea    0xea3(%rip),%rax
mov    %rax,-0x50(%rbp)
lea    -0x70(%rbp),%rsi
mov    -0x18(%rbp),%rdx
lea    0xe5d(%rip),%rdi
call   1050 <execve@plt>
cmp    $0x0,%rax
jge    11d5 <main+0x95>
lea    0xe58(%rip),%rdi
call   1030 <printf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
lea    0xe4e(%rip),%rdi
call   1030 <printf@plt>
xor    %edi,%edi
call   1060 <exit@plt>

x86 assembly (clang, -O2):
<main>:
sub    $0x58,%rsp
xorps  %xmm0,%xmm0
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
lea    0xeb3(%rip),%rax
mov    %rax,(%rsp)
lea    0xead(%rip),%rax
mov    %rax,0x8(%rsp)
lea    0xea4(%rip),%rax
mov    %rax,0x10(%rsp)
lea    0xe9b(%rip),%rax
mov    %rax,0x18(%rsp)
lea    0xec2(%rip),%rax
mov    %rax,0x20(%rsp)
lea    0xe85(%rip),%rdi
mov    %rsp,%rsi
call   1040 <execve@plt>
test   %rax,%rax
jns    11ab <main+0x7b>
lea    0xe97(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%edi
call   1050 <exit@plt>
lea    0xe6c(%rip),%rdi
call   1030 <puts@plt>
xor    %edi,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@.str = [5 x i8] c"name\00"
@.str.1 = [3 x i8] c"-l\00"
@.str.2 = [3 x i8] c"-R\00"
@.str.3 = [2 x i8] c"/\00"
@.str.4 = [2 x i8] zeroinitializer
@.str.5 = [17 x i8] c"./u03s04e10-argv\00"
@.str.6 = [12 x i8] c"error exec\0A\00"
@.str.7 = [22 x i8] c"listing complete !!!\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 [10 x i8*]
store i32 0, i32* %4
store i32 %0, i32* %5
store i8** %1, i8*** %6
store i8** %2, i8*** %7
%9 = bitcast [10 x i8*]* %8 to i8*
%10 = bitcast i8* %9 to [10 x i8*]*
%11 = getelementptr inbounds [10 x i8*], [10 x i8*]* %10, i32 0, i32 0
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i32 0, i32 0), i8** %11
%12 = getelementptr inbounds [10 x i8*], [10 x i8*]* %10, i32 0, i32 1
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i32 0, i32 0), i8** %12
%13 = getelementptr inbounds [10 x i8*], [10 x i8*]* %10, i32 0, i32 2
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i32 0, i32 0), i8** %13
%14 = getelementptr inbounds [10 x i8*], [10 x i8*]* %10, i32 0, i32 3
store i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i32 0, i32 0), i8** %14
%15 = getelementptr inbounds [10 x i8*], [10 x i8*]* %10, i32 0, i32 4
store i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i32 0, i32 0), i8** %15
%16 = getelementptr inbounds [10 x i8*], [10 x i8*]* %8, i64 0, i64 0
%17 = load i8**, i8*** %7
%18 = call i64 @execve(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0), i8** %16, i8** %17)
%19 = icmp slt i64 %18, 0
br i1 %19, label %20, label %23
20: ; preds = %3
%21 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.6, i64 0, i64 0))
%22 = call i32 @exit(i32 1)
unreachable
23: ; preds = %3
%24 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.7, i64 0, i64 0))
%25 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@.str = [5 x i8] c"name\00"
@.str.1 = [3 x i8] c"-l\00"
@.str.2 = [3 x i8] c"-R\00"
@.str.3 = [2 x i8] c"/\00"
@.str.4 = [2 x i8] zeroinitializer
@.str.5 = [17 x i8] c"./u03s04e10-argv\00"
@str = [21 x i8] c"listing complete !!!\00"
@str.8 = [11 x i8] c"error exec\00"
define i32 @main(i32 %0, i8** nocapture readnone %1, i8** %2) {
%4 = alloca [10 x i8*]
%5 = bitcast [10 x i8*]* %4 to i8*
%6 = getelementptr inbounds [10 x i8*], [10 x i8*]* %4, i64 0, i64 4
%7 = bitcast i8** %6 to i8*
%8 = getelementptr inbounds [10 x i8*], [10 x i8*]* %4, i64 0, i64 0
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8** %8
%9 = getelementptr inbounds [10 x i8*], [10 x i8*]* %4, i64 0, i64 1
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8** %9
%10 = getelementptr inbounds [10 x i8*], [10 x i8*]* %4, i64 0, i64 2
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8** %10
%11 = getelementptr inbounds [10 x i8*], [10 x i8*]* %4, i64 0, i64 3
store i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), i8** %11
%12 = getelementptr inbounds [10 x i8*], [10 x i8*]* %4, i64 0, i64 4
store i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0), i8** %12
%13 = call i64 @execve(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0), i8** %8, i8** %2)
%14 = icmp slt i64 %13, 0
br i1 %14, label %15, label %18
15: ; preds = %3
%16 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str.8, i64 0, i64 0))
%17 = call i32 @exit(i32 1)
unreachable
18: ; preds = %3
%19 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str, i64 0, i64 0))
%20 = call i32 @exit(i32 0)
unreachable
}