#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*/ _getopt_reset(int, char **);
int _unset_usage();
int getopt(int, char **, char *);
int optind;
int /*<<< orphan*/ unsetenv(char *);
int builtin_unset(int argc, char *argv[]) {
  int o;
  _getopt_reset(argc, argv);
  while ((o = getopt(argc, argv, "fv")) != -1)
    switch (o) {
    case 'f':
    case 'v':
      break;
    default:
      return _unset_usage();
    }
  if (optind == argc)
    return _unset_usage();
  for (; optind < argc; optind++)
    unsetenv(argv[optind]);
  return 0;
}


x86 assembly (clang, -O0):
<builtin_unset>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1040 <_getopt_reset@plt>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xe97(%rip),%rdx
call   1050 <getopt@plt>
mov    %eax,-0x14(%rbp)
cmp    $0xffffffff,%eax
je     11a7 <builtin_unset+0x67>
mov    -0x14(%rbp),%eax
or     $0x10,%eax
sub    $0x76,%eax
je     118e <builtin_unset+0x4e>
jmp    1193 <builtin_unset+0x53>
jmp    11a2 <builtin_unset+0x62>
mov    $0x0,%al
call   1030 <_unset_usage@plt>
mov    %eax,-0x4(%rbp)
jmp    1217 <builtin_unset+0xd7>
jmp    115b <builtin_unset+0x1b>
mov    0x2e3a(%rip),%rax
mov    (%rax),%eax
cmp    -0x8(%rbp),%eax
jne    11c8 <builtin_unset+0x88>
mov    $0x0,%al
call   1030 <_unset_usage@plt>
mov    %eax,-0x4(%rbp)
jmp    1217 <builtin_unset+0xd7>
jmp    11cd <builtin_unset+0x8d>
mov    0x2e14(%rip),%rax
mov    (%rax),%eax
cmp    -0x8(%rbp),%eax
jge    1210 <builtin_unset+0xd0>
mov    -0x10(%rbp),%rax
mov    0x2dfe(%rip),%rcx
movslq (%rcx),%rcx
mov    (%rax,%rcx,8),%rdi
call   1060 <unsetenv@plt>
mov    0x2deb(%rip),%rax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    0x2ddf(%rip),%rax
mov    %ecx,(%rax)
jmp    11cd <builtin_unset+0x8d>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<builtin_unset>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%rbx
mov    %edi,%ebp
call   1040 <_getopt_reset@plt>
lea    0xeab(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
nop
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r14,%rdx
call   1050 <getopt@plt>
cmp    $0x66,%eax
je     1160 <builtin_unset+0x20>
cmp    $0x76,%eax
je     1160 <builtin_unset+0x20>
cmp    $0xffffffff,%eax
jne    118a <builtin_unset+0x4a>
mov    0x2e65(%rip),%r14
mov    (%r14),%eax
cmp    %ebp,%eax
jne    1195 <builtin_unset+0x55>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <_unset_usage@plt>
jge    11b8 <builtin_unset+0x78>
nopw   0x0(%rax,%rax,1)
cltq
mov    (%rbx,%rax,8),%rdi
call   1060 <unsetenv@plt>
mov    (%r14),%eax
add    $0x1,%eax
mov    %eax,(%r14)
cmp    %ebp,%eax
jl     11a0 <builtin_unset+0x60>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"fv\00"
@optind = global i32 0
define i32 @builtin_unset(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = load i32, i32* %4
%8 = load i8**, i8*** %5
%9 = call i32 @_getopt_reset(i32 %7, i8** %8)
br label %10
10: ; preds = %20, %2
%11 = load i32, i32* %4
%12 = load i8**, i8*** %5
%13 = call i32 @getopt(i32 %11, i8** %12, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32 %13, i32* %6
%14 = icmp ne i32 %13, -1
br i1 %14, label %15, label %21
15: ; preds = %10
%16 = load i32, i32* %6
switch i32 %16, label %18 [
i32 102, label %17
i32 118, label %17
]
17: ; preds = %15, %15
br label %20
18: ; preds = %15
%19 = call i32 (...) @_unset_usage()
store i32 %19, i32* %3
br label %43
20: ; preds = %17
br label %10
21: ; preds = %10
%22 = load i32, i32* @optind
%23 = load i32, i32* %4
%24 = icmp eq i32 %22, %23
br i1 %24, label %25, label %27
25: ; preds = %21
%26 = call i32 (...) @_unset_usage()
store i32 %26, i32* %3
br label %43
27: ; preds = %21
br label %28
28: ; preds = %39, %27
%29 = load i32, i32* @optind
%30 = load i32, i32* %4
%31 = icmp slt i32 %29, %30
br i1 %31, label %32, label %42
32: ; preds = %28
%33 = load i8**, i8*** %5
%34 = load i32, i32* @optind
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds i8*, i8** %33, i64 %35
%37 = load i8*, i8** %36
%38 = call i32 @unsetenv(i8* %37)
br label %39
39: ; preds = %32
%40 = load i32, i32* @optind
%41 = add nsw i32 %40, 1
store i32 %41, i32* @optind
br label %28
42: ; preds = %28
store i32 0, i32* %3
br label %43
43: ; preds = %42, %25, %18
%44 = load i32, i32* %3
ret i32 %44
}

LLVM IR (-O2):
@.str = [3 x i8] c"fv\00"
@optind = global i32 0
define i32 @builtin_unset(i32 %0, i8** %1) {
%3 = tail call i32 @_getopt_reset(i32 %0, i8** %1)
br label %4
4: ; preds = %6, %2
%5 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
switch i32 %5, label %21 [
i32 -1, label %7
i32 102, label %6
i32 118, label %6
]
6: ; preds = %4, %4
br label %4
7: ; preds = %4
%8 = load i32, i32* @optind
%9 = icmp eq i32 %8, %0
br i1 %9, label %21, label %10
10: ; preds = %7
%11 = icmp slt i32 %8, %0
br i1 %11, label %12, label %23
12: ; preds = %10, %12
%13 = phi i32 [ %19, %12 ], [ %8, %10 ]
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds i8*, i8** %1, i64 %14
%16 = load i8*, i8** %15
%17 = tail call i32 @unsetenv(i8* %16)
%18 = load i32, i32* @optind
%19 = add nsw i32 %18, 1
store i32 %19, i32* @optind
%20 = icmp slt i32 %19, %0
br i1 %20, label %12, label %23
21: ; preds = %4, %7
%22 = tail call i32 (...) @_unset_usage()
br label %23
23: ; preds = %12, %21, %10
%24 = phi i32 [ 0, %10 ], [ %22, %21 ], [ 0, %12 ]
ret i32 %24
}