#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*/ stack_pop();
int /*<<< orphan*/ stack_push(char *);
int /*<<< orphan*/ strcpy(char *, int /*<<< orphan*/);
void get_variable() {
  char name[255] = {'\0'};
  strcpy(name, stack_pop());
  char *value = getenv(name);
  if (value == NULL)
    stack_push("()");
  else
    stack_push(value);
}


x86 assembly (clang, -O0):
<get_variable>:
push   %rbp
mov    %rsp,%rbp
sub    $0x110,%rsp
lea    -0x100(%rbp),%rdi
xor    %esi,%esi
mov    $0xff,%edx
call   1050 <memset@plt>
lea    -0x100(%rbp),%rax
mov    %rax,-0x110(%rbp)
mov    $0x0,%al
call   1070 <stack_pop@plt>
mov    -0x110(%rbp),%rdi
mov    %eax,%esi
call   1040 <strcpy@plt>
lea    -0x100(%rbp),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x108(%rbp)
cmpq   $0x0,-0x108(%rbp)
jne    11c3 <get_variable+0x73>
lea    0xe47(%rip),%rdi
call   1060 <stack_push@plt>
jmp    11cf <get_variable+0x7f>
mov    -0x108(%rbp),%rdi
call   1060 <stack_push@plt>
add    $0x110,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_variable>:
push   %rbx
sub    $0x100,%rsp
xorps  %xmm0,%xmm0
movups %xmm0,0xef(%rsp)
movaps %xmm0,0xe0(%rsp)
movaps %xmm0,0xd0(%rsp)
movaps %xmm0,0xc0(%rsp)
movaps %xmm0,0xb0(%rsp)
movaps %xmm0,0xa0(%rsp)
movaps %xmm0,0x90(%rsp)
movaps %xmm0,0x80(%rsp)
movaps %xmm0,0x70(%rsp)
movaps %xmm0,0x60(%rsp)
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movaps %xmm0,(%rsp)
xor    %eax,%eax
call   1060 <stack_pop@plt>
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    %eax,%esi
call   1040 <strcpy@plt>
mov    %rbx,%rdi
call   1030 <getenv@plt>
test   %rax,%rax
je     11d8 <get_variable+0x98>
mov    %rax,%rdi
jmp    11df <get_variable+0x9f>
lea    0xe21(%rip),%rdi
call   1050 <stack_push@plt>
add    $0x100,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [3 x i8] c"()\00"
define void @get_variable() {
%1 = alloca [255 x i8]
%2 = alloca i8*
%3 = bitcast [255 x i8]* %1 to i8*
%4 = getelementptr inbounds [255 x i8], [255 x i8]* %1, i64 0, i64 0
%5 = call i32 (...) @stack_pop()
%6 = call i32 @strcpy(i8* %4, i32 %5)
%7 = getelementptr inbounds [255 x i8], [255 x i8]* %1, i64 0, i64 0
%8 = call i8* @getenv(i8* %7)
store i8* %8, i8** %2
%9 = load i8*, i8** %2
%10 = icmp eq i8* %9, null
br i1 %10, label %11, label %13
11: ; preds = %0
%12 = call i32 @stack_push(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
br label %16
13: ; preds = %0
%14 = load i8*, i8** %2
%15 = call i32 @stack_push(i8* %14)
br label %16
16: ; preds = %13, %11
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"()\00"
define void @get_variable() {
%1 = alloca [255 x i8]
%2 = getelementptr inbounds [255 x i8], [255 x i8]* %1, i64 0, i64 0
%3 = tail call i32 (...) @stack_pop()
%4 = call i32 @strcpy(i8* %2, i32 %3)
%5 = call i8* @getenv(i8* %2)
%6 = icmp eq i8* %5, null
br i1 %6, label %7, label %9
7: ; preds = %0
%8 = call i32 @stack_push(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
br label %11
9: ; preds = %0
%10 = call i32 @stack_push(i8* %5)
br label %11
11: ; preds = %9, %7
ret void
}