#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*/ putenv(char *);
int /*<<< orphan*/ puts(char *);
int main(int argc, char *argv[], char *envp[]) {
  int i;
  extern char **environ;
  for (i = 0; envp[i]; i++) {
    puts(envp[i]);
  }
  putenv("DonaldZhuang=/");
  for (i = 0; environ[i]; i++) {
    puts(environ[i]);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
cmpq   $0x0,(%rax,%rcx,8)
je     1173 <main+0x53>
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1030 <puts@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1141 <main+0x21>
lea    0xe86(%rip),%rdi
call   1040 <putenv@plt>
movl   $0x0,-0x1c(%rbp)
mov    0x2e5b(%rip),%rax
mov    (%rax),%rax
movslq -0x1c(%rbp),%rcx
cmpq   $0x0,(%rax,%rcx,8)
je     11c4 <main+0xa4>
mov    0x2e42(%rip),%rax
mov    (%rax),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1030 <puts@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1186 <main+0x66>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
mov    (%rdx),%rdi
test   %rdi,%rdi
je     1151 <main+0x31>
mov    %rdx,%rbx
add    $0x8,%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
call   1030 <puts@plt>
mov    (%rbx),%rdi
add    $0x8,%rbx
test   %rdi,%rdi
jne    1140 <main+0x20>
lea    0xea8(%rip),%rdi
call   1040 <putenv@plt>
mov    0x2e84(%rip),%r14
mov    (%r14),%rax
mov    (%rax),%rdi
test   %rdi,%rdi
je     1195 <main+0x75>
mov    $0x8,%ebx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
call   1030 <puts@plt>
mov    (%r14),%rax
mov    (%rax,%rbx,1),%rdi
add    $0x8,%rbx
test   %rdi,%rdi
jne    1180 <main+0x60>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [15 x i8] c"DonaldZhuang=/\00"
@environ = external global i8**
define i32 @main(i32 %0, i8** %1, i8** %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8**
%7 = alloca i8**
%8 = alloca i32
store i32 0, i32* %4
store i32 %0, i32* %5
store i8** %1, i8*** %6
store i8** %2, i8*** %7
store i32 0, i32* %8
br label %9
9: ; preds = %23, %3
%10 = load i8**, i8*** %7
%11 = load i32, i32* %8
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds i8*, i8** %10, i64 %12
%14 = load i8*, i8** %13
%15 = icmp ne i8* %14, null
br i1 %15, label %16, label %26
16: ; preds = %9
%17 = load i8**, i8*** %7
%18 = load i32, i32* %8
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i8*, i8** %17, i64 %19
%21 = load i8*, i8** %20
%22 = call i32 @puts(i8* %21)
br label %23
23: ; preds = %16
%24 = load i32, i32* %8
%25 = add nsw i32 %24, 1
store i32 %25, i32* %8
br label %9
26: ; preds = %9
%27 = call i32 @putenv(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %8
br label %28
28: ; preds = %42, %26
%29 = load i8**, i8*** @environ
%30 = load i32, i32* %8
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds i8*, i8** %29, i64 %31
%33 = load i8*, i8** %32
%34 = icmp ne i8* %33, null
br i1 %34, label %35, label %45
35: ; preds = %28
%36 = load i8**, i8*** @environ
%37 = load i32, i32* %8
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds i8*, i8** %36, i64 %38
%40 = load i8*, i8** %39
%41 = call i32 @puts(i8* %40)
br label %42
42: ; preds = %35
%43 = load i32, i32* %8
%44 = add nsw i32 %43, 1
store i32 %44, i32* %8
br label %28
45: ; preds = %28
ret i32 0
}

LLVM IR (-O2):
@.str = [15 x i8] c"DonaldZhuang=/\00"
@environ = external global i8**
define i32 @main(i32 %0, i8** nocapture readnone %1, i8** nocapture %2) {
%4 = load i8*, i8** %2
%5 = icmp eq i8* %4, null
br i1 %5, label %14, label %6
6: ; preds = %3, %6
%7 = phi i64 [ %10, %6 ], [ 0, %3 ]
%8 = phi i8* [ %12, %6 ], [ %4, %3 ]
%9 = tail call i32 @puts(i8* %8)
%10 = add nuw i64 %7, 1
%11 = getelementptr inbounds i8*, i8** %2, i64 %10
%12 = load i8*, i8** %11
%13 = icmp eq i8* %12, null
br i1 %13, label %14, label %6
14: ; preds = %6, %3
%15 = tail call i32 @putenv(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%16 = load i8**, i8*** @environ
%17 = load i8*, i8** %16
%18 = icmp eq i8* %17, null
br i1 %18, label %28, label %19
19: ; preds = %14, %19
%20 = phi i64 [ %23, %19 ], [ 0, %14 ]
%21 = phi i8* [ %26, %19 ], [ %17, %14 ]
%22 = tail call i32 @puts(i8* %21)
%23 = add nuw i64 %20, 1
%24 = load i8**, i8*** @environ
%25 = getelementptr inbounds i8*, i8** %24, i64 %23
%26 = load i8*, i8** %25
%27 = icmp eq i8* %26, null
br i1 %27, label %28, label %19
28: ; preds = %19, %14
ret i32 0
}