#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*/ EXIT_FAILURE;
int /*<<< orphan*/ errno;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, int, char *,
                           char *);
char *getenv(char *);
int /*<<< orphan*/ printf(char *, char *);
scalar_t__ putenv(char *);
int /*<<< orphan*/ stderr;
char *strerror(int /*<<< orphan*/);
int main(void) {
  if (putenv("PP=Live") != 0)
    do {
      fprintf(stderr, "[%s][%d]:%s %s\n",
              "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
              "2022-01-22/02-19-57/repos/drsin/linuxCoreLearn/refs/heads/"
              "master/apue/day06/putenv.c",
              19, "putenv", strerror(errno));
      exit(EXIT_FAILURE);
    } while (0);
  char *val = getenv("USER");
  printf("%s\n", val);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe8a(%rip),%rdi
call   1050 <putenv@plt>
cmp    $0x0,%rax
je     11d7 <main+0x77>
jmp    118a <main+0x2a>
mov    0x2e4f(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
mov    0x2e3b(%rip),%rax
mov    (%rax),%edi
call   1080 <strerror@plt>
mov    -0x14(%rbp),%edi
mov    %rax,%r9
lea    0xe57(%rip),%rsi
lea    0xe60(%rip),%rdx
mov    $0x13,%ecx
lea    0xee9(%rip),%r8
call   1060 <fprintf@plt>
mov    0x2e00(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>
lea    0xed6(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rsi
lea    0xe22(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
lea    0xe98(%rip),%rdi
call   1050 <putenv@plt>
test   %rax,%rax
jne    1191 <main+0x31>
lea    0xf3b(%rip),%rdi
call   1030 <getenv@plt>
lea    0xe8f(%rip),%rdi
mov    %rax,%rsi
call   1040 <printf@plt>
xor    %eax,%eax
pop    %rbx
ret
mov    0x2e48(%rip),%rax
mov    (%rax),%ebx
mov    0x2e37(%rip),%rax
mov    (%rax),%edi
call   1080 <strerror@plt>
lea    0xe59(%rip),%rsi
lea    0xe62(%rip),%rdx
lea    0xef0(%rip),%r8
mov    %ebx,%edi
mov    $0x13,%ecx
mov    %rax,%r9
call   1060 <fprintf@plt>
mov    0x2dfd(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@.str = [8 x i8] c"PP=Live\00"
@stderr = global i32 0
@.str.1 = [16 x i8] c"[%s][%d]:%s %s\0A\00"
@.str.2 = [149 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/drsin/linuxCoreLearn/refs/heads/master/apue/day06/putenv.c\00"
@.str.3 = [7 x i8] c"putenv\00"
@errno = global i32 0
@EXIT_FAILURE = global i32 0
@.str.4 = [5 x i8] c"USER\00"
@.str.5 = [4 x i8] c"%s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
store i32 0, i32* %1
%3 = call i64 @putenv(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%4 = icmp ne i64 %3, 0
br i1 %4, label %5, label %14
5: ; preds = %0
br label %6
6: ; preds = %5
%7 = load i32, i32* @stderr
%8 = load i32, i32* @errno
%9 = call i8* @strerror(i32 %8)
%10 = call i32 @fprintf(i32 %7, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([149 x i8], [149 x i8]* @.str.2, i64 0, i64 0), i32 19, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i8* %9)
%11 = load i32, i32* @EXIT_FAILURE
%12 = call i32 @exit(i32 %11)
unreachable
13: ; No predecessors!
br label %14
14: ; preds = %13, %0
%15 = call i8* @getenv(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
store i8* %15, i8** %2
%16 = load i8*, i8** %2
%17 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i8* %16)
ret i32 0
}

LLVM IR (-O2):
@.str = [8 x i8] c"PP=Live\00"
@stderr = global i32 0
@.str.1 = [16 x i8] c"[%s][%d]:%s %s\0A\00"
@.str.2 = [149 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/drsin/linuxCoreLearn/refs/heads/master/apue/day06/putenv.c\00"
@.str.3 = [7 x i8] c"putenv\00"
@errno = global i32 0
@EXIT_FAILURE = global i32 0
@.str.4 = [5 x i8] c"USER\00"
@.str.5 = [4 x i8] c"%s\0A\00"
define i32 @main() {
%1 = tail call i64 @putenv(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%2 = icmp eq i64 %1, 0
br i1 %2, label %10, label %3
3: ; preds = %0
%4 = load i32, i32* @stderr
%5 = load i32, i32* @errno
%6 = tail call i8* @strerror(i32 %5)
%7 = tail call i32 @fprintf(i32 %4, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([149 x i8], [149 x i8]* @.str.2, i64 0, i64 0), i32 19, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i8* %6)
%8 = load i32, i32* @EXIT_FAILURE
%9 = tail call i32 @exit(i32 %8)
unreachable
10: ; preds = %0
%11 = tail call i8* @getenv(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%12 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i8* %11)
ret i32 0
}