#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*/ write(int, char *, int);
int /*<<< orphan*/ write_stdout(char *);
int main(int argc, char *argv[], char *envp[]) {
  if (argc == 1) {
    while (*envp) {
      write_stdout(*envp++);
      write(1, "\n", 1);
    }
  } else {
    while (*++argv) {
      char *var = getenv(*argv);
      if (var) {
        write_stdout(var);
        write(1, "\n", 1);
      }
    }
  }
  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)
mov    %rdx,-0x18(%rbp)
cmpl   $0x1,-0x8(%rbp)
jne    119b <main+0x6b>
jmp    1159 <main+0x29>
mov    -0x18(%rbp),%rax
cmpq   $0x0,(%rax)
je     1196 <main+0x66>
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x18(%rbp)
mov    (%rax),%rdi
call   1050 <write_stdout@plt>
mov    $0x1,%edx
lea    0xe76(%rip),%rsi
mov    %edx,%edi
call   1040 <write@plt>
jmp    1159 <main+0x29>
jmp    11fb <main+0xcb>
jmp    11a0 <main+0x70>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x10(%rbp)
cmpq   $0x0,0x8(%rax)
je     11f6 <main+0xc6>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     11f1 <main+0xc1>
mov    -0x20(%rbp),%rdi
call   1050 <write_stdout@plt>
mov    $0x1,%edx
lea    0xe16(%rip),%rsi
mov    %edx,%edi
call   1040 <write@plt>
jmp    11a0 <main+0x70>
jmp    11fb <main+0xcb>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
cmp    $0x1,%edi
jne    1175 <main+0x45>
mov    %rdx,%rbx
mov    (%rdx),%rdi
test   %rdi,%rdi
je     11c2 <main+0x92>
add    $0x8,%rbx
lea    0xeb1(%rip),%r14
nop
call   1050 <write_stdout@plt>
mov    $0x1,%edi
mov    %r14,%rsi
mov    $0x1,%edx
call   1040 <write@plt>
mov    (%rbx),%rdi
add    $0x8,%rbx
test   %rdi,%rdi
jne    1150 <main+0x20>
jmp    11c2 <main+0x92>
mov    %rsi,%r14
mov    0x8(%rsi),%rdi
test   %rdi,%rdi
je     11c2 <main+0x92>
add    $0x10,%r14
lea    0xe74(%rip),%rbx
jmp    119c <main+0x6c>
xchg   %ax,%ax
mov    (%r14),%rdi
add    $0x8,%r14
test   %rdi,%rdi
je     11c2 <main+0x92>
call   1030 <getenv@plt>
test   %rax,%rax
je     1190 <main+0x60>
mov    %rax,%rdi
call   1050 <write_stdout@plt>
mov    $0x1,%edi
mov    %rbx,%rsi
mov    $0x1,%edx
call   1040 <write@plt>
jmp    1190 <main+0x60>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
@.str = [2 x i8] c"\0A\00"
define i32 @main(i32 %0, i8** nocapture %1, i8** nocapture %2) {
%4 = icmp eq i32 %0, 1
br i1 %4, label %9, label %5
5: ; preds = %3
%6 = getelementptr inbounds i8*, i8** %1, i64 1
%7 = load i8*, i8** %6
%8 = icmp eq i8* %7, null
br i1 %8, label %32, label %20
9: ; preds = %3
%10 = load i8*, i8** %2
%11 = icmp eq i8* %10, null
br i1 %11, label %32, label %12
12: ; preds = %9, %12
%13 = phi i8* [ %18, %12 ], [ %10, %9 ]
%14 = phi i8** [ %15, %12 ], [ %2, %9 ]
%15 = getelementptr inbounds i8*, i8** %14, i64 1
%16 = tail call i32 @write_stdout(i8* %13)
%17 = tail call i32 @write(i32 1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 1)
%18 = load i8*, i8** %15
%19 = icmp eq i8* %18, null
br i1 %19, label %32, label %12
20: ; preds = %5, %28
%21 = phi i8* [ %30, %28 ], [ %7, %5 ]
%22 = phi i8** [ %29, %28 ], [ %6, %5 ]
%23 = tail call i8* @getenv(i8* %21)
%24 = icmp eq i8* %23, null
br i1 %24, label %28, label %25
25: ; preds = %20
%26 = tail call i32 @write_stdout(i8* %23)
%27 = tail call i32 @write(i32 1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 1)
br label %28
28: ; preds = %25, %20
%29 = getelementptr inbounds i8*, i8** %22, i64 1
%30 = load i8*, i8** %29
%31 = icmp eq i8* %30, null
br i1 %31, label %32, label %20
32: ; preds = %28, %12, %5, %9
ret i32 0
}