#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 find_inenv(char **, char *);
int /*<<< orphan*/ pprint(char *, int);
char **strto_wordtab(char *, char *);
char **unset_environ(char *buff, char **environ) {
  static int i = 0;
  char **buffer;
  buffer = strto_wordtab(buff, " ");
  if (!(buffer[1])) {
    pprint("unsetenv: Too few arguments\n", 2);
    return (environ);
  }
  i = find_inenv(environ, buffer[1]);
  if (!(i)) {
    return (environ);
  }
  environ[i] = 0;
  return (environ);
}


x86 assembly (clang, -O0):
<unset_environ>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xeb5(%rip),%rsi
call   1050 <strto_wordtab@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmpq   $0x0,0x8(%rax)
jne    1181 <unset_environ+0x51>
lea    0xe98(%rip),%rdi
mov    $0x2,%esi
call   1040 <pprint@plt>
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    11cd <unset_environ+0x9d>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rax
mov    0x8(%rax),%rsi
call   1030 <find_inenv@plt>
mov    %eax,0x2ea4(%rip)
cmpl   $0x0,0x2e9d(%rip)
jne    11b2 <unset_environ+0x82>
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    11cd <unset_environ+0x9d>
mov    -0x18(%rbp),%rax
movslq 0x2e7f(%rip),%rcx
movq   $0x0,(%rax,%rcx,8)
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<unset_environ>:
push   %rbx
mov    %rsi,%rbx
lea    0xec5(%rip),%rsi
call   1050 <strto_wordtab@plt>
mov    0x8(%rax),%rsi
test   %rsi,%rsi
je     1161 <unset_environ+0x31>
mov    %rbx,%rdi
call   1030 <find_inenv@plt>
test   %eax,%eax
je     1172 <unset_environ+0x42>
cltq
movq   $0x0,(%rbx,%rax,8)
jmp    1172 <unset_environ+0x42>
lea    0xe9a(%rip),%rdi
mov    $0x2,%esi
call   1040 <pprint@plt>
mov    %rbx,%rax
pop    %rbx
ret

LLVM IR (-O0):
@unset_environ.i = internal global i32 0
@.str = [2 x i8] c" \00"
@.str.1 = [29 x i8] c"unsetenv: Too few arguments\0A\00"
define i8** @unset_environ(i8* %0, i8** %1) {
%3 = alloca i8**
%4 = alloca i8*
%5 = alloca i8**
%6 = alloca i8**
store i8* %0, i8** %4
store i8** %1, i8*** %5
%7 = load i8*, i8** %4
%8 = call i8** @strto_wordtab(i8* %7, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i8** %8, i8*** %6
%9 = load i8**, i8*** %6
%10 = getelementptr inbounds i8*, i8** %9, i64 1
%11 = load i8*, i8** %10
%12 = icmp ne i8* %11, null
br i1 %12, label %16, label %13
13: ; preds = %2
%14 = call i32 @pprint(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), i32 2)
%15 = load i8**, i8*** %5
store i8** %15, i8*** %3
br label %32
16: ; preds = %2
%17 = load i8**, i8*** %5
%18 = load i8**, i8*** %6
%19 = getelementptr inbounds i8*, i8** %18, i64 1
%20 = load i8*, i8** %19
%21 = call i32 @find_inenv(i8** %17, i8* %20)
store i32 %21, i32* @unset_environ.i
%22 = load i32, i32* @unset_environ.i
%23 = icmp ne i32 %22, 0
br i1 %23, label %26, label %24
24: ; preds = %16
%25 = load i8**, i8*** %5
store i8** %25, i8*** %3
br label %32
26: ; preds = %16
%27 = load i8**, i8*** %5
%28 = load i32, i32* @unset_environ.i
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds i8*, i8** %27, i64 %29
store i8* null, i8** %30
%31 = load i8**, i8*** %5
store i8** %31, i8*** %3
br label %32
32: ; preds = %26, %24, %13
%33 = load i8**, i8*** %3
ret i8** %33
}

LLVM IR (-O2):
@.str = [2 x i8] c" \00"
@.str.1 = [29 x i8] c"unsetenv: Too few arguments\0A\00"
define i8** @unset_environ(i8* %0, i8** returned %1) {
%3 = tail call i8** @strto_wordtab(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%4 = getelementptr inbounds i8*, i8** %3, i64 1
%5 = load i8*, i8** %4
%6 = icmp eq i8* %5, null
br i1 %6, label %7, label %9
7: ; preds = %2
%8 = tail call i32 @pprint(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), i32 2)
br label %15
9: ; preds = %2
%10 = tail call i32 @find_inenv(i8** %1, i8* %5)
%11 = icmp eq i32 %10, 0
br i1 %11, label %15, label %12
12: ; preds = %9
%13 = sext i32 %10 to i64
%14 = getelementptr inbounds i8*, i8** %1, i64 %13
store i8* null, i8** %14
br label %15
15: ; preds = %9, %12, %7
ret i8** %1
}