#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*/ setenv(char *, char *, int);
int /*<<< orphan*/ stack_pop();
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ strcpy(char *, int /*<<< orphan*/);
int /*<<< orphan*/ unsetenv(char *);
void set_variable() {
  char name[255] = {'\0'};
  char value[255] = {'\0'};
  strcpy(name, stack_pop());
  if (name == NULL)
    return;
  strcpy(value, stack_pop());
  if (value == NULL)
    return;
  if (strcmp(value, "()") == 0)
    unsetenv(name);
  else
    setenv(name, value, 1);
}


x86 assembly (clang, -O0):
<set_variable>:
push   %rbp
mov    %rsp,%rbp
sub    $0x210,%rsp
lea    -0x100(%rbp),%rdi
xor    %esi,%esi
mov    $0xff,%edx
call   1050 <memset@plt>
lea    -0x200(%rbp),%rdi
xor    %esi,%esi
mov    $0xff,%edx
call   1050 <memset@plt>
lea    -0x100(%rbp),%rax
mov    %rax,-0x210(%rbp)
mov    $0x0,%al
call   1080 <stack_pop@plt>
mov    -0x210(%rbp),%rdi
mov    %eax,%esi
call   1030 <strcpy@plt>
lea    -0x200(%rbp),%rax
mov    %rax,-0x208(%rbp)
mov    $0x0,%al
call   1080 <stack_pop@plt>
mov    -0x208(%rbp),%rdi
mov    %eax,%esi
call   1030 <strcpy@plt>
lea    -0x200(%rbp),%rdi
lea    0xe1b(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    1205 <set_variable+0xa5>
lea    -0x100(%rbp),%rdi
call   1070 <unsetenv@plt>
jmp    121d <set_variable+0xbd>
lea    -0x100(%rbp),%rdi
lea    -0x200(%rbp),%rsi
mov    $0x1,%edx
call   1040 <setenv@plt>
add    $0x210,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<set_variable>:
push   %rbx
sub    $0x200,%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)
movups %xmm0,0x1ef(%rsp)
movaps %xmm0,0x1e0(%rsp)
movaps %xmm0,0x1d0(%rsp)
movaps %xmm0,0x1c0(%rsp)
movaps %xmm0,0x1b0(%rsp)
movaps %xmm0,0x1a0(%rsp)
movaps %xmm0,0x190(%rsp)
movaps %xmm0,0x180(%rsp)
movaps %xmm0,0x170(%rsp)
movaps %xmm0,0x160(%rsp)
movaps %xmm0,0x150(%rsp)
movaps %xmm0,0x140(%rsp)
movaps %xmm0,0x130(%rsp)
movaps %xmm0,0x120(%rsp)
movaps %xmm0,0x110(%rsp)
movaps %xmm0,0x100(%rsp)
xor    %eax,%eax
call   1070 <stack_pop@plt>
mov    %rsp,%rdi
mov    %eax,%esi
call   1030 <strcpy@plt>
xor    %eax,%eax
call   1070 <stack_pop@plt>
lea    0x100(%rsp),%rbx
mov    %rbx,%rdi
mov    %eax,%esi
call   1030 <strcpy@plt>
lea    0xd8d(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcmp@plt>
mov    %rsp,%rdi
test   %rax,%rax
je     1297 <set_variable+0x147>
lea    0x100(%rsp),%rsi
mov    $0x1,%edx
call   1040 <setenv@plt>
jmp    129c <set_variable+0x14c>
call   1060 <unsetenv@plt>
add    $0x200,%rsp
pop    %rbx
ret

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

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