#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*/ execve(char *, char **, char **);
void run_test() {
  char *path = "/bin/echo";
  char *argv[] = {path, "hello world", NULL};
  char *envp[] = {"LD_PRELOAD=./libnull.so", NULL};
  execve(path, argv, envp);
}


x86 assembly (clang, -O0):
<run_test>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
lea    0xee1(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
lea    0xed8(%rip),%rax
mov    %rax,-0x18(%rbp)
movq   $0x0,-0x10(%rbp)
mov    0x2ccb(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0x2cc8(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x20(%rbp),%rsi
lea    -0x30(%rbp),%rdx
call   1030 <execve@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<run_test>:
sub    $0x38,%rsp
lea    0xee5(%rip),%rdi
mov    %rdi,(%rsp)
lea    0xee4(%rip),%rax
mov    %rax,0x8(%rsp)
movq   $0x0,0x10(%rsp)
movaps 0x2cd5(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
mov    %rsp,%rsi
lea    0x20(%rsp),%rdx
call   1030 <execve@plt>
add    $0x38,%rsp
ret

LLVM IR (-O0):
@.str = [10 x i8] c"/bin/echo\00"
@.str.1 = [12 x i8] c"hello world\00"
@.str.2 = [24 x i8] c"LD_PRELOAD=./libnull.so\00"
@__const.run_test.envp = [2 x i8*] [i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i32 0, i32 0), i8* null]
define void @run_test() {
%1 = alloca i8*
%2 = alloca [3 x i8*]
%3 = alloca [2 x i8*]
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8** %1
%4 = getelementptr inbounds [3 x i8*], [3 x i8*]* %2, i64 0, i64 0
%5 = load i8*, i8** %1
store i8* %5, i8** %4
%6 = getelementptr inbounds i8*, i8** %4, i64 1
store i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8** %6
%7 = getelementptr inbounds i8*, i8** %6, i64 1
store i8* null, i8** %7
%8 = bitcast [2 x i8*]* %3 to i8*
%9 = load i8*, i8** %1
%10 = getelementptr inbounds [3 x i8*], [3 x i8*]* %2, i64 0, i64 0
%11 = getelementptr inbounds [2 x i8*], [2 x i8*]* %3, i64 0, i64 0
%12 = call i32 @execve(i8* %9, i8** %10, i8** %11)
ret void
}

LLVM IR (-O2):
@.str = [10 x i8] c"/bin/echo\00"
@.str.1 = [12 x i8] c"hello world\00"
@.str.2 = [24 x i8] c"LD_PRELOAD=./libnull.so\00"
@__const.run_test.envp = [2 x i8*] [i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i32 0, i32 0), i8* null]
define void @run_test() {
%1 = alloca [3 x i8*]
%2 = alloca [2 x i8*]
%3 = bitcast [3 x i8*]* %1 to i8*
%4 = getelementptr inbounds [3 x i8*], [3 x i8*]* %1, i64 0, i64 0
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8** %4
%5 = getelementptr inbounds [3 x i8*], [3 x i8*]* %1, i64 0, i64 1
store i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8** %5
%6 = getelementptr inbounds [3 x i8*], [3 x i8*]* %1, i64 0, i64 2
store i8* null, i8** %6
%7 = bitcast [2 x i8*]* %2 to i8*
%8 = getelementptr inbounds [2 x i8*], [2 x i8*]* %2, i64 0, i64 0
%9 = call i32 @execve(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8** %4, i8** %8)
ret void
}