#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*/ doit(char *, char *);
int /*<<< orphan*/ setenv(char *, char *, int);
int /*<<< orphan*/ unsetenv(char *);
void test_setunset(void) {
  setenv("x", "x", 1);
  doit("x", "x");
  setenv("x", "y", 1);
  doit("x", "y");
  unsetenv("x");
  doit("x", 0);
}


x86 assembly (clang, -O0):
<test_setunset>:
push   %rbp
mov    %rsp,%rbp
lea    0xec5(%rip),%rsi
mov    $0x1,%edx
mov    %rsi,%rdi
call   1030 <setenv@plt>
lea    0xeb1(%rip),%rsi
mov    %rsi,%rdi
call   1040 <doit@plt>
lea    0xea2(%rip),%rdi
lea    0xe9d(%rip),%rsi
mov    $0x1,%edx
call   1030 <setenv@plt>
lea    0xe8a(%rip),%rdi
lea    0xe85(%rip),%rsi
call   1040 <doit@plt>
lea    0xe77(%rip),%rdi
call   1050 <unsetenv@plt>
lea    0xe6b(%rip),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1040 <doit@plt>
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_setunset>:
push   %r14
push   %rbx
push   %rax
lea    0xec5(%rip),%rbx
mov    %rbx,%rdi
mov    %rbx,%rsi
mov    $0x1,%edx
call   1030 <setenv@plt>
mov    %rbx,%rdi
mov    %rbx,%rsi
call   1040 <doit@plt>
lea    0xea5(%rip),%r14
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x1,%edx
call   1030 <setenv@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1040 <doit@plt>
mov    %rbx,%rdi
call   1050 <unsetenv@plt>
mov    %rbx,%rdi
xor    %esi,%esi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1040 <doit@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"x\00"
@.str.1 = [2 x i8] c"y\00"
define void @test_setunset() {
%1 = call i32 @setenv(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 1)
%2 = call i32 @doit(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%3 = call i32 @setenv(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 1)
%4 = call i32 @doit(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%5 = call i32 @unsetenv(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @doit(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8* null)
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"x\00"
@.str.1 = [2 x i8] c"y\00"
define void @test_setunset() {
%1 = tail call i32 @setenv(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 1)
%2 = tail call i32 @doit(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%3 = tail call i32 @setenv(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 1)
%4 = tail call i32 @doit(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%5 = tail call i32 @unsetenv(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%6 = tail call i32 @doit(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8* null)
ret void
}