#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*/ printenv();
int /*<<< orphan*/ puts(char *);
int main(int argc, char **argv) {
  if (argc < 2) {
    printenv();
    return 0;
  }
  int i, err = 0;
  for (i = 1; i < argc; i++) {
    char *env = getenv(argv[i]);
    if (!env)
      err = 1;
    else
      puts(env);
  }
  return err;
}


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)
cmpl   $0x2,-0x8(%rbp)
jge    1163 <main+0x33>
mov    $0x0,%al
call   1050 <printenv@plt>
movl   $0x0,-0x4(%rbp)
jmp    11cb <main+0x9b>
movl   $0x0,-0x18(%rbp)
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11c5 <main+0x95>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    11a9 <main+0x79>
movl   $0x1,-0x18(%rbp)
jmp    11b2 <main+0x82>
mov    -0x20(%rbp),%rdi
call   1040 <puts@plt>
jmp    11b7 <main+0x87>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1171 <main+0x41>
mov    -0x18(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
cmp    $0x2,%edi
jge    1154 <main+0x24>
xor    %r14d,%r14d
xor    %eax,%eax
call   1050 <printenv@plt>
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %rsi,%r15
mov    %edi,%ebp
xor    %r14d,%r14d
mov    $0x1,%ebx
jmp    1181 <main+0x51>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %rax,%rdi
call   1040 <puts@plt>
add    $0x1,%rbx
cmp    %rbx,%rbp
je     1146 <main+0x16>
mov    (%r15,%rbx,8),%rdi
call   1030 <getenv@plt>
test   %rax,%rax
jne    1170 <main+0x40>
mov    $0x1,%r14d
jmp    1178 <main+0x48>

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

LLVM IR (-O2):
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 2
br i1 %3, label %6, label %4
4: ; preds = %2
%5 = zext i32 %0 to i64
br label %8
6: ; preds = %2
%7 = tail call i32 (...) @printenv()
br label %21
8: ; preds = %4, %17
%9 = phi i64 [ 1, %4 ], [ %19, %17 ]
%10 = phi i32 [ 0, %4 ], [ %18, %17 ]
%11 = getelementptr inbounds i8*, i8** %1, i64 %9
%12 = load i8*, i8** %11
%13 = tail call i8* @getenv(i8* %12)
%14 = icmp eq i8* %13, null
br i1 %14, label %17, label %15
15: ; preds = %8
%16 = tail call i32 @puts(i8* %13)
br label %17
17: ; preds = %8, %15
%18 = phi i32 [ %10, %15 ], [ 1, %8 ]
%19 = add nuw nsw i64 %9, 1
%20 = icmp eq i64 %19, %5
br i1 %20, label %21, label %8
21: ; preds = %17, %6
%22 = phi i32 [ 0, %6 ], [ %18, %17 ]
ret i32 %22
}