int cmd_unset(ac, av)
int ac;
char *av[];
{
  int i;
  for (i = 1; i < ac; i++) {
    if (getenv(av[i])) {
      unsetenv(av[i]);
    } else {
      printf("%s: no matching variable\n", av[i]);
      return (1);
    }
  }
  return (0);
}


x86 assembly (clang, -O0):
<cmd_unset>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11bf <cmd_unset+0x8f>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    $0x0,%al
call   1030 <getenv@plt>
cmp    $0x0,%eax
je     1186 <cmd_unset+0x56>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    $0x0,%al
call   1050 <unsetenv@plt>
jmp    11ac <cmd_unset+0x7c>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xe67(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    11c6 <cmd_unset+0x96>
jmp    11b1 <cmd_unset+0x81>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1146 <cmd_unset+0x16>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cmd_unset>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
xor    %ebp,%ebp
cmp    $0x2,%edi
jl     118b <cmd_unset+0x5b>
mov    %rsi,%r15
mov    %edi,%r14d
mov    $0x1,%ebx
xor    %ebp,%ebp
nopl   0x0(%rax,%rax,1)
mov    (%r15,%rbx,8),%rdi
xor    %eax,%eax
call   1030 <getenv@plt>
mov    (%r15,%rbx,8),%rsi
test   %eax,%eax
je     1178 <cmd_unset+0x48>
mov    %rsi,%rdi
xor    %eax,%eax
call   1050 <unsetenv@plt>
add    $0x1,%rbx
cmp    %rbx,%r14
jne    1150 <cmd_unset+0x20>
jmp    118b <cmd_unset+0x5b>
lea    0xe81(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x1,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [26 x i8] c"%s: no matching variable\0A\00"
define i32 @cmd_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
store i32 1, i32* %6
br label %7
7: ; preds = %34, %2
%8 = load i32, i32* %6
%9 = load i32, i32* %4
%10 = icmp slt i32 %8, %9
br i1 %10, label %11, label %37
11: ; preds = %7
%12 = load i8**, i8*** %5
%13 = load i32, i32* %6
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds i8*, i8** %12, i64 %14
%16 = load i8*, i8** %15
%17 = call i32 (i8*, ...) bitcast (i32 (...)* @getenv to i32 (i8*, ...)*)(i8* %16)
%18 = icmp ne i32 %17, 0
br i1 %18, label %19, label %26
19: ; preds = %11
%20 = load i8**, i8*** %5
%21 = load i32, i32* %6
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds i8*, i8** %20, i64 %22
%24 = load i8*, i8** %23
%25 = call i32 (i8*, ...) bitcast (i32 (...)* @unsetenv to i32 (i8*, ...)*)(i8* %24)
br label %33
26: ; preds = %11
%27 = load i8**, i8*** %5
%28 = load i32, i32* %6
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds i8*, i8** %27, i64 %29
%31 = load i8*, i8** %30
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i8* %31)
store i32 1, i32* %3
br label %38
33: ; preds = %19
br label %34
34: ; preds = %33
%35 = load i32, i32* %6
%36 = add nsw i32 %35, 1
store i32 %36, i32* %6
br label %7
37: ; preds = %7
store i32 0, i32* %3
br label %38
38: ; preds = %37, %26
%39 = load i32, i32* %3
ret i32 %39
}

LLVM IR (-O2):
@.str = [26 x i8] c"%s: no matching variable\0A\00"
define i32 @cmd_unset(i32 %0, i8** nocapture %1) {
%3 = icmp sgt i32 %0, 1
br i1 %3, label %4, label %19
4: ; preds = %2
%5 = zext i32 %0 to i64
br label %6
6: ; preds = %4, %13
%7 = phi i64 [ 1, %4 ], [ %15, %13 ]
%8 = getelementptr inbounds i8*, i8** %1, i64 %7
%9 = load i8*, i8** %8
%10 = tail call i32 (i8*, ...) bitcast (i32 (...)* @getenv to i32 (i8*, ...)*)(i8* %9)
%11 = icmp eq i32 %10, 0
%12 = load i8*, i8** %8
br i1 %11, label %17, label %13
13: ; preds = %6
%14 = tail call i32 (i8*, ...) bitcast (i32 (...)* @unsetenv to i32 (i8*, ...)*)(i8* %12)
%15 = add nuw nsw i64 %7, 1
%16 = icmp eq i64 %15, %5
br i1 %16, label %19, label %6
17: ; preds = %6
%18 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i8* %12)
br label %19
19: ; preds = %13, %2, %17
%20 = phi i32 [ 1, %17 ], [ 0, %2 ], [ 0, %13 ]
ret i32 %20
}