#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*/ execvp(char *, char **);
int fork();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ waitpid(int, int *, int /*<<< orphan*/);
int main(int argc, char **argv, char **envp) {
  char *newEnv[] = {"PS=byj>", "WINDOW=1", NULL};
  int pid = fork();
  if (pid == 0) {
    execve("./printEnv", argv, newEnv);
  } else {
    int returnStatus;
    waitpid(pid, &returnStatus, 0);
    printf("\n\n");
    execvp("./printEnv", argv);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    0x2c8f(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0x2c8c(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    0x2c89(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    $0x0,%al
call   1070 <fork@plt>
mov    %eax,-0x34(%rbp)
cmpl   $0x0,-0x34(%rbp)
jne    11b8 <main+0x68>
mov    -0x10(%rbp),%rsi
lea    -0x30(%rbp),%rdx
lea    0xe63(%rip),%rdi
call   1040 <execve@plt>
jmp    11e2 <main+0x92>
mov    -0x34(%rbp),%edi
lea    -0x38(%rbp),%rsi
xor    %edx,%edx
call   1050 <waitpid@plt>
lea    0xe4f(%rip),%rdi
call   1030 <printf@plt>
mov    -0x10(%rbp),%rsi
lea    0xe34(%rip),%rdi
call   1060 <execvp@plt>
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x30,%rsp
mov    %rsi,%rbx
mov    0x2cb1(%rip),%rax
mov    %rax,0x20(%rsp)
movaps 0x2c95(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
xor    %eax,%eax
call   1070 <fork@plt>
test   %eax,%eax
je     11a6 <main+0x56>
lea    0xc(%rsp),%rsi
mov    %eax,%edi
xor    %edx,%edx
call   1050 <waitpid@plt>
lea    0xe8c(%rip),%rdi
call   1030 <puts@plt>
lea    0xe75(%rip),%rdi
mov    %rbx,%rsi
call   1060 <execvp@plt>
jmp    11ba <main+0x6a>
lea    0xe64(%rip),%rdi
lea    0x10(%rsp),%rdx
mov    %rbx,%rsi
call   1040 <execve@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [8 x i8] c"PS=byj>\00"
@.str.1 = [9 x i8] c"WINDOW=1\00"
@__const.main.newEnv = [3 x i8*] [i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i32 0, i32 0), i8* null]
@.str.2 = [11 x i8] c"./printEnv\00"
@.str.3 = [3 x i8] c"\0A\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 [3 x i8*]
%9 = alloca i32
%10 = alloca i32
store i32 0, i32* %4
store i32 %0, i32* %5
store i8** %1, i8*** %6
store i8** %2, i8*** %7
%11 = bitcast [3 x i8*]* %8 to i8*
%12 = call i32 (...) @fork()
store i32 %12, i32* %9
%13 = load i32, i32* %9
%14 = icmp eq i32 %13, 0
br i1 %14, label %15, label %19
15: ; preds = %3
%16 = load i8**, i8*** %6
%17 = getelementptr inbounds [3 x i8*], [3 x i8*]* %8, i64 0, i64 0
%18 = call i32 @execve(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i8** %16, i8** %17)
br label %25
19: ; preds = %3
%20 = load i32, i32* %9
%21 = call i32 @waitpid(i32 %20, i32* %10, i32 0)
%22 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%23 = load i8**, i8*** %6
%24 = call i32 @execvp(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i8** %23)
br label %25
25: ; preds = %19, %15
%26 = load i32, i32* %4
ret i32 %26
}

LLVM IR (-O2):
@.str = [8 x i8] c"PS=byj>\00"
@.str.1 = [9 x i8] c"WINDOW=1\00"
@__const.main.newEnv = [3 x i8*] [i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i32 0, i32 0), i8* null]
@.str.2 = [11 x i8] c"./printEnv\00"
@str = [2 x i8] c"\0A\00"
define i32 @main(i32 %0, i8** %1, i8** nocapture readnone %2) {
%4 = alloca [3 x i8*]
%5 = alloca i32
%6 = bitcast [3 x i8*]* %4 to i8*
%7 = tail call i32 (...) @fork()
%8 = icmp eq i32 %7, 0
br i1 %8, label %9, label %12
9: ; preds = %3
%10 = getelementptr inbounds [3 x i8*], [3 x i8*]* %4, i64 0, i64 0
%11 = call i32 @execve(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i8** %1, i8** %10)
br label %17
12: ; preds = %3
%13 = bitcast i32* %5 to i8*
%14 = call i32 @waitpid(i32 %7, i32* %5, i32 0)
%15 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str, i64 0, i64 0))
%16 = call i32 @execvp(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i8** %1)
br label %17
17: ; preds = %12, %9
ret i32 0
}