#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 main() {
  char *newargv[] = {"/bin/true", "a", "b", "cde", NULL};
  char *newenv[] = {"FOO=10", "BAR=20", NULL};
  execve((char *)-1, NULL, NULL);
  execve(NULL, (char **)-1, NULL);
  execve(NULL, NULL, (char **)-1);
  execve(newargv[0], newargv, newenv);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x30(%rbp),%rdi
xor    %esi,%esi
mov    $0x28,%edx
call   1030 <memset@plt>
lea    0xeba(%rip),%rax
mov    %rax,-0x30(%rbp)
lea    0xeb9(%rip),%rax
mov    %rax,-0x28(%rbp)
lea    0xeb0(%rip),%rax
mov    %rax,-0x20(%rbp)
lea    0xea7(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0x2c8e(%rip),%rax
mov    %rax,-0x50(%rbp)
mov    0x2c8b(%rip),%rax
mov    %rax,-0x48(%rbp)
mov    0x2c88(%rip),%rax
mov    %rax,-0x40(%rbp)
mov    $0xffffffffffffffff,%rdi
xor    %eax,%eax
mov    %eax,%edx
mov    %rdx,%rsi
call   1040 <execve@plt>
xor    %eax,%eax
mov    %eax,%edx
mov    $0xffffffffffffffff,%rsi
mov    %rdx,%rdi
call   1040 <execve@plt>
xor    %eax,%eax
mov    %eax,%esi
mov    $0xffffffffffffffff,%rdx
mov    %rsi,%rdi
call   1040 <execve@plt>
mov    -0x30(%rbp),%rdi
lea    -0x30(%rbp),%rsi
lea    -0x50(%rbp),%rdx
call   1040 <execve@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x50,%rsp
movq   $0x0,0x20(%rsp)
lea    0xedb(%rip),%rbx
mov    %rbx,(%rsp)
lea    0xeda(%rip),%rax
mov    %rax,0x8(%rsp)
lea    0xed0(%rip),%rax
mov    %rax,0x10(%rsp)
lea    0xec6(%rip),%rax
mov    %rax,0x18(%rsp)
mov    0x2cbc(%rip),%rax
mov    %rax,0x40(%rsp)
movaps 0x2ca0(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
mov    $0xffffffffffffffff,%rdi
xor    %esi,%esi
xor    %edx,%edx
call   1030 <execve@plt>
xor    %edi,%edi
mov    $0xffffffffffffffff,%rsi
xor    %edx,%edx
call   1030 <execve@plt>
xor    %edi,%edi
xor    %esi,%esi
mov    $0xffffffffffffffff,%rdx
call   1030 <execve@plt>
mov    %rsp,%rsi
lea    0x30(%rsp),%rdx
mov    %rbx,%rdi
call   1030 <execve@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [10 x i8] c"/bin/true\00"
@.str.1 = [2 x i8] c"a\00"
@.str.2 = [2 x i8] c"b\00"
@.str.3 = [4 x i8] c"cde\00"
@.str.4 = [7 x i8] c"FOO=10\00"
@.str.5 = [7 x i8] c"BAR=20\00"
@__const.main.newenv = [3 x i8*] [i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i32 0, i32 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i32 0, i32 0), i8* null]
define i32 @main() {
%1 = alloca i32
%2 = alloca [5 x i8*]
%3 = alloca [3 x i8*]
store i32 0, i32* %1
%4 = bitcast [5 x i8*]* %2 to i8*
%5 = bitcast i8* %4 to [5 x i8*]*
%6 = getelementptr inbounds [5 x i8*], [5 x i8*]* %5, i32 0, i32 0
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i32 0, i32 0), i8** %6
%7 = getelementptr inbounds [5 x i8*], [5 x i8*]* %5, i32 0, i32 1
store i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i32 0, i32 0), i8** %7
%8 = getelementptr inbounds [5 x i8*], [5 x i8*]* %5, i32 0, i32 2
store i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i32 0, i32 0), i8** %8
%9 = getelementptr inbounds [5 x i8*], [5 x i8*]* %5, i32 0, i32 3
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i32 0, i32 0), i8** %9
%10 = bitcast [3 x i8*]* %3 to i8*
%11 = call i32 @execve(i8* inttoptr (i64 -1 to i8*), i8** null, i8** null)
%12 = call i32 @execve(i8* null, i8** inttoptr (i64 -1 to i8**), i8** null)
%13 = call i32 @execve(i8* null, i8** null, i8** inttoptr (i64 -1 to i8**))
%14 = getelementptr inbounds [5 x i8*], [5 x i8*]* %2, i64 0, i64 0
%15 = load i8*, i8** %14
%16 = getelementptr inbounds [5 x i8*], [5 x i8*]* %2, i64 0, i64 0
%17 = getelementptr inbounds [3 x i8*], [3 x i8*]* %3, i64 0, i64 0
%18 = call i32 @execve(i8* %15, i8** %16, i8** %17)
ret i32 0
}

LLVM IR (-O2):
@.str = [10 x i8] c"/bin/true\00"
@.str.1 = [2 x i8] c"a\00"
@.str.2 = [2 x i8] c"b\00"
@.str.3 = [4 x i8] c"cde\00"
@.str.4 = [7 x i8] c"FOO=10\00"
@.str.5 = [7 x i8] c"BAR=20\00"
@__const.main.newenv = [3 x i8*] [i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i32 0, i32 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i32 0, i32 0), i8* null]
define i32 @main() {
%1 = alloca [5 x i8*]
%2 = alloca [3 x i8*]
%3 = bitcast [5 x i8*]* %1 to i8*
%4 = getelementptr inbounds [5 x i8*], [5 x i8*]* %1, i64 0, i64 4
%5 = bitcast i8** %4 to i64*
store i64 0, i64* %5
%6 = getelementptr inbounds [5 x i8*], [5 x i8*]* %1, i64 0, i64 0
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8** %6
%7 = getelementptr inbounds [5 x i8*], [5 x i8*]* %1, i64 0, i64 1
store i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8** %7
%8 = getelementptr inbounds [5 x i8*], [5 x i8*]* %1, i64 0, i64 2
store i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i8** %8
%9 = getelementptr inbounds [5 x i8*], [5 x i8*]* %1, i64 0, i64 3
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8** %9
%10 = bitcast [3 x i8*]* %2 to i8*
%11 = tail call i32 @execve(i8* inttoptr (i64 -1 to i8*), i8** null, i8** null)
%12 = tail call i32 @execve(i8* null, i8** inttoptr (i64 -1 to i8**), i8** null)
%13 = tail call i32 @execve(i8* null, i8** null, i8** inttoptr (i64 -1 to i8**))
%14 = getelementptr inbounds [3 x i8*], [3 x i8*]* %2, i64 0, i64 0
%15 = call i32 @execve(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8** %6, i8** %14)
ret i32 0
}