#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 *envVal;
  int i;
  for (i = 1; i < argc; ++i) {
    if (!(envVal = getenv(argv[i]))) {
      printf("%s doesnot exist\n", argv[i]);
      continue;
    }
    printf("%s :: %s\n", argv[i], envVal);
  }
  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)
movl   $0x1,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11b3 <main+0x93>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    1187 <main+0x67>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xe85(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11a5 <main+0x85>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
mov    -0x18(%rbp),%rdx
lea    0xe74(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    113d <main+0x1d>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
cmp    $0x2,%edi
jl     1189 <main+0x69>
mov    %rsi,%r12
mov    %edi,%r13d
mov    $0x1,%ebp
lea    0xebe(%rip),%r14
lea    0xec9(%rip),%r15
jmp    1169 <main+0x49>
nopl   0x0(%rax,%rax,1)
mov    %r15,%rdi
mov    %rbx,%rsi
mov    %rax,%rdx
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%rbp
cmp    %rbp,%r13
je     1189 <main+0x69>
mov    (%r12,%rbp,8),%rbx
mov    %rbx,%rdi
call   1030 <getenv@plt>
test   %rax,%rax
jne    1150 <main+0x30>
mov    %r14,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1160 <main+0x40>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [18 x i8] c"%s doesnot exist\0A\00"
@.str.1 = [10 x i8] c"%s :: %s\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp sgt i32 %0, 1
br i1 %3, label %4, label %19
4: ; preds = %2
%5 = zext i32 %0 to i64
br label %6
6: ; preds = %4, %16
%7 = phi i64 [ 1, %4 ], [ %17, %16 ]
%8 = getelementptr inbounds i8*, i8** %1, i64 %7
%9 = load i8*, i8** %8
%10 = tail call i8* @getenv(i8* %9)
%11 = icmp eq i8* %10, null
br i1 %11, label %12, label %14
12: ; preds = %6
%13 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* %9)
br label %16
14: ; preds = %6
%15 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8* %9, i8* %10)
br label %16
16: ; preds = %14, %12
%17 = add nuw nsw i64 %7, 1
%18 = icmp eq i64 %17, %5
br i1 %18, label %19, label %6
19: ; preds = %16, %2
ret i32 0
}