#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(void) {
  char *p;
  char *pp[] = {"COLUMNS", "DATEMSK", "HOME", "LANG"};
  int i;
  for (i = 0; i < 4; i++) {
    if ((p = getenv(pp[i])))
      printf("USER=%s\n", p);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2cca(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0x2cc7(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    0x2cc4(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0x2cc1(%rip),%rax
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x34(%rbp)
cmpl   $0x4,-0x34(%rbp)
jge    11ab <main+0x8b>
movslq -0x34(%rbp),%rax
mov    -0x30(%rbp,%rax,8),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
je     1198 <main+0x78>
mov    -0x10(%rbp),%rsi
lea    0xe87(%rip),%rdi
call   1040 <printf@plt>
jmp    119d <main+0x7d>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1162 <main+0x42>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xed8(%rip),%rdi
call   1030 <getenv@plt>
test   %rax,%rax
je     1141 <main+0x21>
lea    0xee1(%rip),%rdi
mov    %rax,%rsi
call   1040 <printf@plt>
lea    0xec0(%rip),%rdi
call   1030 <getenv@plt>
test   %rax,%rax
je     1161 <main+0x41>
lea    0xec1(%rip),%rdi
mov    %rax,%rsi
call   1040 <printf@plt>
lea    0xea8(%rip),%rdi
call   1030 <getenv@plt>
test   %rax,%rax
je     1181 <main+0x61>
lea    0xea1(%rip),%rdi
mov    %rax,%rsi
call   1040 <printf@plt>
lea    0xe8d(%rip),%rdi
call   1030 <getenv@plt>
test   %rax,%rax
je     11a1 <main+0x81>
lea    0xe81(%rip),%rdi
mov    %rax,%rsi
call   1040 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [8 x i8] c"COLUMNS\00"
@.str.1 = [8 x i8] c"DATEMSK\00"
@.str.2 = [5 x i8] c"HOME\00"
@.str.3 = [5 x i8] c"LANG\00"
@__const.main.pp = [4 x i8*] [i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i32 0, i32 0)]
@.str.4 = [9 x i8] c"USER=%s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca [4 x i8*]
%4 = alloca i32
store i32 0, i32* %1
%5 = bitcast [4 x i8*]* %3 to i8*
store i32 0, i32* %4
br label %6
6: ; preds = %20, %0
%7 = load i32, i32* %4
%8 = icmp slt i32 %7, 4
br i1 %8, label %9, label %23
9: ; preds = %6
%10 = load i32, i32* %4
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds [4 x i8*], [4 x i8*]* %3, i64 0, i64 %11
%13 = load i8*, i8** %12
%14 = call i8* @getenv(i8* %13)
store i8* %14, i8** %2
%15 = icmp ne i8* %14, null
br i1 %15, label %16, label %19
16: ; preds = %9
%17 = load i8*, i8** %2
%18 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i8* %17)
br label %19
19: ; preds = %16, %9
br label %20
20: ; preds = %19
%21 = load i32, i32* %4
%22 = add nsw i32 %21, 1
store i32 %22, i32* %4
br label %6
23: ; preds = %6
ret i32 0
}

LLVM IR (-O2):
@.str = [8 x i8] c"COLUMNS\00"
@.str.1 = [8 x i8] c"DATEMSK\00"
@.str.2 = [5 x i8] c"HOME\00"
@.str.3 = [5 x i8] c"LANG\00"
@.str.4 = [9 x i8] c"USER=%s\0A\00"
define i32 @main() {
%1 = tail call i8* @getenv(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%2 = icmp eq i8* %1, null
br i1 %2, label %5, label %3
3: ; preds = %0
%4 = tail call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i8* %1)
br label %5
5: ; preds = %0, %3
%6 = tail call i8* @getenv(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%7 = icmp eq i8* %6, null
br i1 %7, label %10, label %8
8: ; preds = %5
%9 = tail call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i8* %6)
br label %10
10: ; preds = %8, %5
%11 = tail call i8* @getenv(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%12 = icmp eq i8* %11, null
br i1 %12, label %15, label %13
13: ; preds = %10
%14 = tail call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i8* %11)
br label %15
15: ; preds = %13, %10
%16 = tail call i8* @getenv(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%17 = icmp eq i8* %16, null
br i1 %17, label %20, label %18
18: ; preds = %15
%19 = tail call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i8* %16)
br label %20
20: ; preds = %18, %15
ret i32 0
}