#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 */
int /*<<< orphan*/ printf(char *, char *);
scalar_t__ strstr(char *, char *);
int main(int argc, char *argv[], char *envp[]) {
  int index = 0;
  while (envp[index])
    if (strstr(envp[index], "LD_"))
      printf("$%s\n\n", envp[index++]);
    else
      index++;
  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)
movl   $0x0,-0x1c(%rbp)
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
cmpq   $0x0,(%rax,%rcx,8)
je     11ab <main+0x8b>
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xe99(%rip),%rsi
call   1040 <strstr@plt>
cmp    $0x0,%rax
je     119d <main+0x7d>
mov    -0x18(%rbp),%rax
mov    -0x1c(%rbp),%ecx
mov    %ecx,%edx
add    $0x1,%edx
mov    %edx,-0x1c(%rbp)
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xe71(%rip),%rdi
call   1030 <printf@plt>
jmp    11a6 <main+0x86>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1141 <main+0x21>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
mov    (%rdx),%rdi
test   %rdi,%rdi
je     1177 <main+0x57>
mov    %rdx,%rbx
add    $0x8,%rbx
lea    0xec5(%rip),%r14
lea    0xec2(%rip),%r15
jmp    115c <main+0x3c>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    (%rbx),%rdi
add    $0x8,%rbx
test   %rdi,%rdi
je     1177 <main+0x57>
mov    %r14,%rsi
call   1040 <strstr@plt>
test   %rax,%rax
je     1150 <main+0x30>
mov    -0x8(%rbx),%rsi
mov    %r15,%rdi
call   1030 <printf@plt>
jmp    1150 <main+0x30>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

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

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