#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*/ execvp(char *, char **);
int /*<<< orphan*/ printf(char *);
int main() {
  char *arglist[3];
  arglist[0] = "ls";
  arglist[1] = "-l";
  arglist[2] = 0;
  printf("*** About to exec ls -l\n");
  execvp("ls", arglist);
  printf("*** ls is done, bye\n");
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
lea    0xed1(%rip),%rax
mov    %rax,-0x20(%rbp)
lea    0xec9(%rip),%rax
mov    %rax,-0x18(%rbp)
movq   $0x0,-0x10(%rbp)
lea    0xeb9(%rip),%rdi
call   1030 <printf@plt>
lea    -0x20(%rbp),%rsi
lea    0xea3(%rip),%rdi
call   1040 <execvp@plt>
lea    0xeb6(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x20,%rsp
lea    0xed4(%rip),%rbx
mov    %rbx,(%rsp)
lea    0xee1(%rip),%rax
mov    %rax,0x8(%rsp)
movq   $0x0,0x10(%rsp)
lea    0xeb7(%rip),%rdi
call   1030 <puts@plt>
mov    %rsp,%rsi
mov    %rbx,%rdi
call   1040 <execvp@plt>
lea    0xeb8(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [3 x i8] c"ls\00"
@.str.1 = [3 x i8] c"-l\00"
@.str.2 = [25 x i8] c"*** About to exec ls -l\0A\00"
@.str.3 = [21 x i8] c"*** ls is done, bye\0A\00"
define i32 @main() {
%1 = alloca [3 x i8*]
%2 = getelementptr inbounds [3 x i8*], [3 x i8*]* %1, i64 0, i64 0
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8** %2
%3 = getelementptr inbounds [3 x i8*], [3 x i8*]* %1, i64 0, i64 1
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8** %3
%4 = getelementptr inbounds [3 x i8*], [3 x i8*]* %1, i64 0, i64 2
store i8* null, i8** %4
%5 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0))
%6 = getelementptr inbounds [3 x i8*], [3 x i8*]* %1, i64 0, i64 0
%7 = call i32 @execvp(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8** %6)
%8 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"ls\00"
@.str.1 = [3 x i8] c"-l\00"
@str = [24 x i8] c"*** About to exec ls -l\00"
@str.4 = [20 x i8] c"*** ls is done, bye\00"
define i32 @main() {
%1 = alloca [3 x i8*]
%2 = bitcast [3 x i8*]* %1 to i8*
%3 = getelementptr inbounds [3 x i8*], [3 x i8*]* %1, i64 0, i64 0
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8** %3
%4 = getelementptr inbounds [3 x i8*], [3 x i8*]* %1, i64 0, i64 1
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8** %4
%5 = getelementptr inbounds [3 x i8*], [3 x i8*]* %1, i64 0, i64 2
store i8* null, i8** %5
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str, i64 0, i64 0))
%7 = call i32 @execvp(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8** %3)
%8 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str.4, i64 0, i64 0))
ret i32 0
}