#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 *, char *);
int main(int argc, char *argv[]) {
  char *hostname = getenv("HOSTNAME");
  char *user_name = getenv("USER");
  char *user_shell = getenv("SHELL");
  char *user_home = getenv("HOME");
  if (hostname == NULL) {
    hostname = "unknown hostname";
  }
  if (user_name == NULL) {
    user_name = "unknown user";
  }
  if (user_shell == NULL) {
    user_shell = "unknown shell";
  }
  if (user_home == NULL) {
    user_home = "unknown home";
  }
  printf("The hostname is: %s\n", hostname);
  printf("The current user is: %s\n", user_name);
  printf("The current user login shell is: %s\n", user_shell);
  printf("The current user home is: %s\n", user_home);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xec3(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x18(%rbp)
lea    0xebc(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x20(%rbp)
lea    0xeb1(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x28(%rbp)
lea    0xea7(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    118c <main+0x6c>
lea    0xe91(%rip),%rax
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    11a2 <main+0x82>
lea    0xe8c(%rip),%rax
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    11b8 <main+0x98>
lea    0xe83(%rip),%rax
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    11ce <main+0xae>
lea    0xe7b(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%rsi
lea    0xe79(%rip),%rdi
call   1040 <printf@plt>
mov    -0x20(%rbp),%rsi
lea    0xe7e(%rip),%rdi
call   1040 <printf@plt>
mov    -0x28(%rbp),%rsi
lea    0xe87(%rip),%rdi
call   1040 <printf@plt>
mov    -0x30(%rbp),%rsi
lea    0xe9c(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
lea    0xed1(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,%r14
lea    0xecb(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,%r15
lea    0xec1(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,%r12
lea    0xeb8(%rip),%rdi
call   1030 <getenv@plt>
test   %r14,%r14
lea    0xeae(%rip),%rsi
cmovne %r14,%rsi
test   %r15,%r15
lea    0xeb1(%rip),%rbx
cmovne %r15,%rbx
test   %r12,%r12
lea    0xeb0(%rip),%r14
cmovne %r12,%r14
test   %rax,%rax
lea    0xeb0(%rip),%r15
cmovne %rax,%r15
lea    0xeb2(%rip),%rdi
call   1040 <printf@plt>
lea    0xebb(%rip),%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
lea    0xec5(%rip),%rdi
mov    %r14,%rsi
call   1040 <printf@plt>
lea    0xedb(%rip),%rdi
mov    %r15,%rsi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [9 x i8] c"HOSTNAME\00"
@.str.1 = [5 x i8] c"USER\00"
@.str.2 = [6 x i8] c"SHELL\00"
@.str.3 = [5 x i8] c"HOME\00"
@.str.4 = [17 x i8] c"unknown hostname\00"
@.str.5 = [13 x i8] c"unknown user\00"
@.str.6 = [14 x i8] c"unknown shell\00"
@.str.7 = [13 x i8] c"unknown home\00"
@.str.8 = [21 x i8] c"The hostname is: %s\0A\00"
@.str.9 = [25 x i8] c"The current user is: %s\0A\00"
@.str.10 = [37 x i8] c"The current user login shell is: %s\0A\00"
@.str.11 = [30 x i8] c"The current user home is: %s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = call i8* @getenv(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
store i8* %10, i8** %6
%11 = call i8* @getenv(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
store i8* %11, i8** %7
%12 = call i8* @getenv(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
store i8* %12, i8** %8
%13 = call i8* @getenv(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
store i8* %13, i8** %9
%14 = load i8*, i8** %6
%15 = icmp eq i8* %14, null
br i1 %15, label %16, label %17
16: ; preds = %2
store i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0), i8** %6
br label %17
17: ; preds = %16, %2
%18 = load i8*, i8** %7
%19 = icmp eq i8* %18, null
br i1 %19, label %20, label %21
20: ; preds = %17
store i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0), i8** %7
br label %21
21: ; preds = %20, %17
%22 = load i8*, i8** %8
%23 = icmp eq i8* %22, null
br i1 %23, label %24, label %25
24: ; preds = %21
store i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.6, i64 0, i64 0), i8** %8
br label %25
25: ; preds = %24, %21
%26 = load i8*, i8** %9
%27 = icmp eq i8* %26, null
br i1 %27, label %28, label %29
28: ; preds = %25
store i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.7, i64 0, i64 0), i8** %9
br label %29
29: ; preds = %28, %25
%30 = load i8*, i8** %6
%31 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.8, i64 0, i64 0), i8* %30)
%32 = load i8*, i8** %7
%33 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.9, i64 0, i64 0), i8* %32)
%34 = load i8*, i8** %8
%35 = call i32 @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.10, i64 0, i64 0), i8* %34)
%36 = load i8*, i8** %9
%37 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.11, i64 0, i64 0), i8* %36)
ret i32 0
}

LLVM IR (-O2):
@.str = [9 x i8] c"HOSTNAME\00"
@.str.1 = [5 x i8] c"USER\00"
@.str.2 = [6 x i8] c"SHELL\00"
@.str.3 = [5 x i8] c"HOME\00"
@.str.4 = [17 x i8] c"unknown hostname\00"
@.str.5 = [13 x i8] c"unknown user\00"
@.str.6 = [14 x i8] c"unknown shell\00"
@.str.7 = [13 x i8] c"unknown home\00"
@.str.8 = [21 x i8] c"The hostname is: %s\0A\00"
@.str.9 = [25 x i8] c"The current user is: %s\0A\00"
@.str.10 = [37 x i8] c"The current user login shell is: %s\0A\00"
@.str.11 = [30 x i8] c"The current user home is: %s\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i8* @getenv(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%4 = tail call i8* @getenv(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%5 = tail call i8* @getenv(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%6 = tail call i8* @getenv(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%7 = icmp eq i8* %3, null
%8 = select i1 %7, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0), i8* %3
%9 = icmp eq i8* %4, null
%10 = select i1 %9, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0), i8* %4
%11 = icmp eq i8* %5, null
%12 = select i1 %11, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.6, i64 0, i64 0), i8* %5
%13 = icmp eq i8* %6, null
%14 = select i1 %13, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.7, i64 0, i64 0), i8* %6
%15 = tail call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.8, i64 0, i64 0), i8* %8)
%16 = tail call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.9, i64 0, i64 0), i8* %10)
%17 = tail call i32 @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.10, i64 0, i64 0), i8* %12)
%18 = tail call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.11, i64 0, i64 0), i8* %14)
ret i32 0
}