#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 */
char *getenv(char *);
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ putenv(char *);
int main(int argc, char *argv[]) {
  printf("%s\n", getenv("USER"));
  if (putenv("WEIBO=taihejin_weibo") != 0) {
    printf("put env of weibo failed!\n");
  }
  char *env = getenv("WEIBO");
  if (env != NULL) {
    printf("WEIBO = %s\n", env);
  }
  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)
lea    0xeb3(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,%rsi
lea    0xee6(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe9b(%rip),%rdi
call   1050 <putenv@plt>
cmp    $0x0,%rax
je     1187 <main+0x57>
lea    0xe9a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xea6(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     11b4 <main+0x84>
mov    -0x18(%rbp),%rsi
lea    0xe8d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xeb8(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,%rdi
call   1040 <puts@plt>
lea    0xea9(%rip),%rdi
call   1060 <putenv@plt>
test   %rax,%rax
je     1172 <main+0x32>
lea    0xebf(%rip),%rdi
call   1040 <puts@plt>
lea    0xea1(%rip),%rdi
call   1030 <getenv@plt>
test   %rax,%rax
je     1194 <main+0x54>
lea    0xe96(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%s\0A\00"
@.str.1 = [5 x i8] c"USER\00"
@.str.2 = [21 x i8] c"WEIBO=taihejin_weibo\00"
@.str.3 = [26 x i8] c"put env of weibo failed!\0A\00"
@.str.4 = [6 x i8] c"WEIBO\00"
@.str.5 = [12 x i8] c"WEIBO = %s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = call i8* @getenv(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %7)
%9 = call i64 @putenv(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0))
%10 = icmp ne i64 %9, 0
br i1 %10, label %11, label %13
11: ; preds = %2
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0))
br label %13
13: ; preds = %11, %2
%14 = call i8* @getenv(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
store i8* %14, i8** %6
%15 = load i8*, i8** %6
%16 = icmp ne i8* %15, null
br i1 %16, label %17, label %20
17: ; preds = %13
%18 = load i8*, i8** %6
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0), i8* %18)
br label %20
20: ; preds = %17, %13
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [5 x i8] c"USER\00"
@.str.2 = [21 x i8] c"WEIBO=taihejin_weibo\00"
@.str.4 = [6 x i8] c"WEIBO\00"
@.str.5 = [12 x i8] c"WEIBO = %s\0A\00"
@str = [25 x i8] c"put env of weibo failed!\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i8* @getenv(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%4 = tail call i32 @puts(i8* dereferenceable(1) %3)
%5 = tail call i64 @putenv(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0))
%6 = icmp eq i64 %5, 0
br i1 %6, label %9, label %7
7: ; preds = %2
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str, i64 0, i64 0))
br label %9
9: ; preds = %7, %2
%10 = tail call i8* @getenv(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
%11 = icmp eq i8* %10, null
br i1 %11, label %14, label %12
12: ; preds = %9
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0), i8* %10)
br label %14
14: ; preds = %12, %9
ret i32 0
}