#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 **);
int /*<<< orphan*/ perror(char *);
int main(int argc, char *argv[]) {
  char *arg[] = {"test", NULL};
  char *env[] = {"USER=LINUX", NULL};
  execve("./test", arg, env);
  perror("execvp");
  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    0x2cc3(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0x2cc0(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0x2cbd(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0x2cba(%rip),%rax
mov    %rax,-0x28(%rbp)
lea    -0x20(%rbp),%rsi
lea    -0x30(%rbp),%rdx
lea    0xe9a(%rip),%rdi
call   1030 <execve@plt>
lea    0xe95(%rip),%rdi
call   1040 <perror@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x28,%rsp
movaps 0x2cd5(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0x2cd9(%rip),%xmm0
movaps %xmm0,(%rsp)
lea    0xec9(%rip),%rdi
lea    0x10(%rsp),%rsi
mov    %rsp,%rdx
call   1030 <execve@plt>
lea    0xebc(%rip),%rdi
call   1040 <perror@plt>
xor    %eax,%eax
add    $0x28,%rsp
ret

LLVM IR (-O0):
@.str = [5 x i8] c"test\00"
@__const.main.arg = [2 x i8*] [i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i32 0, i32 0), i8* null]
@.str.1 = [11 x i8] c"USER=LINUX\00"
@__const.main.env = [2 x i8*] [i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i32 0, i32 0), i8* null]
@.str.2 = [7 x i8] c"./test\00"
@.str.3 = [7 x i8] c"execvp\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [2 x i8*]
%7 = alloca [2 x i8*]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = bitcast [2 x i8*]* %6 to i8*
%9 = bitcast [2 x i8*]* %7 to i8*
%10 = getelementptr inbounds [2 x i8*], [2 x i8*]* %6, i64 0, i64 0
%11 = getelementptr inbounds [2 x i8*], [2 x i8*]* %7, i64 0, i64 0
%12 = call i32 @execve(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i8** %10, i8** %11)
%13 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [5 x i8] c"test\00"
@__const.main.arg = [2 x i8*] [i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i32 0, i32 0), i8* null]
@.str.1 = [11 x i8] c"USER=LINUX\00"
@__const.main.env = [2 x i8*] [i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i32 0, i32 0), i8* null]
@.str.2 = [7 x i8] c"./test\00"
@.str.3 = [7 x i8] c"execvp\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [2 x i8*]
%4 = alloca [2 x i8*]
%5 = bitcast [2 x i8*]* %3 to i8*
%6 = bitcast [2 x i8*]* %4 to i8*
%7 = getelementptr inbounds [2 x i8*], [2 x i8*]* %3, i64 0, i64 0
%8 = getelementptr inbounds [2 x i8*], [2 x i8*]* %4, i64 0, i64 0
%9 = call i32 @execve(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i8** %7, i8** %8)
%10 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
ret i32 0
}