#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*/ fprintf(int /*<<< orphan*/, char *, char *);
char *get_shell_var(char const *);
int /*<<< orphan*/ print_shell_var();
int /*<<< orphan*/ printf(char *, char *, char *);
int /*<<< orphan*/ stderr;
int rashenv(char **args) {
  if (args[1]) {
    char *value = get_shell_var((const char *)args[1]);
    if (value)
      printf("%s=%s\n", args[1], value);
    else {
      fprintf(stderr, "No variable: %s.", args[1]);
      return -1;
    }
  } else {
    print_shell_var();
  }
  return 0;
}


x86 assembly (clang, -O0):
<rashenv>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
cmpq   $0x0,0x8(%rax)
je     11c2 <rashenv+0x82>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1060 <get_shell_var@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     1194 <rashenv+0x54>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
mov    -0x18(%rbp),%rdx
lea    0xe76(%rip),%rdi
call   1030 <printf@plt>
jmp    11bd <rashenv+0x7d>
mov    0x2e45(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xe5b(%rip),%rsi
call   1050 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11d0 <rashenv+0x90>
jmp    11c9 <rashenv+0x89>
mov    $0x0,%al
call   1040 <print_shell_var@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rashenv>:
push   %rbx
mov    %rdi,%rbx
mov    0x8(%rdi),%rdi
test   %rdi,%rdi
je     116e <rashenv+0x2e>
call   1060 <get_shell_var@plt>
test   %rax,%rax
je     1179 <rashenv+0x39>
mov    0x8(%rbx),%rsi
lea    0xe9e(%rip),%rdi
mov    %rax,%rdx
call   1030 <printf@plt>
xor    %ebx,%ebx
jmp    1197 <rashenv+0x57>
xor    %ebx,%ebx
xor    %eax,%eax
call   1040 <print_shell_var@plt>
jmp    1197 <rashenv+0x57>
mov    0x2e60(%rip),%rax
mov    (%rax),%edi
mov    0x8(%rbx),%rdx
lea    0xe7a(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0xffffffff,%ebx
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [7 x i8] c"%s=%s\0A\00"
@stderr = global i32 0
@.str.1 = [17 x i8] c"No variable: %s.\00"
define i32 @rashenv(i8** %0) {
%2 = alloca i32
%3 = alloca i8**
%4 = alloca i8*
store i8** %0, i8*** %3
%5 = load i8**, i8*** %3
%6 = getelementptr inbounds i8*, i8** %5, i64 1
%7 = load i8*, i8** %6
%8 = icmp ne i8* %7, null
br i1 %8, label %9, label %29
9: ; preds = %1
%10 = load i8**, i8*** %3
%11 = getelementptr inbounds i8*, i8** %10, i64 1
%12 = load i8*, i8** %11
%13 = call i8* @get_shell_var(i8* %12)
store i8* %13, i8** %4
%14 = load i8*, i8** %4
%15 = icmp ne i8* %14, null
br i1 %15, label %16, label %22
16: ; preds = %9
%17 = load i8**, i8*** %3
%18 = getelementptr inbounds i8*, i8** %17, i64 1
%19 = load i8*, i8** %18
%20 = load i8*, i8** %4
%21 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %19, i8* %20)
br label %28
22: ; preds = %9
%23 = load i32, i32* @stderr
%24 = load i8**, i8*** %3
%25 = getelementptr inbounds i8*, i8** %24, i64 1
%26 = load i8*, i8** %25
%27 = call i32 @fprintf(i32 %23, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i8* %26)
store i32 -1, i32* %2
br label %32
28: ; preds = %16
br label %31
29: ; preds = %1
%30 = call i32 (...) @print_shell_var()
br label %31
31: ; preds = %29, %28
store i32 0, i32* %2
br label %32
32: ; preds = %31, %22
%33 = load i32, i32* %2
ret i32 %33
}

LLVM IR (-O2):
@.str = [7 x i8] c"%s=%s\0A\00"
@stderr = global i32 0
@.str.1 = [17 x i8] c"No variable: %s.\00"
define i32 @rashenv(i8** nocapture %0) {
%2 = getelementptr inbounds i8*, i8** %0, i64 1
%3 = load i8*, i8** %2
%4 = icmp eq i8* %3, null
br i1 %4, label %15, label %5
5: ; preds = %1
%6 = tail call i8* @get_shell_var(i8* %3)
%7 = icmp eq i8* %6, null
br i1 %7, label %11, label %8
8: ; preds = %5
%9 = load i8*, i8** %2
%10 = tail call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %9, i8* %6)
br label %17
11: ; preds = %5
%12 = load i32, i32* @stderr
%13 = load i8*, i8** %2
%14 = tail call i32 @fprintf(i32 %12, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i8* %13)
br label %17
15: ; preds = %1
%16 = tail call i32 (...) @print_shell_var()
br label %17
17: ; preds = %15, %8, %11
%18 = phi i32 [ -1, %11 ], [ 0, %8 ], [ 0, %15 ]
ret i32 %18
}