#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*/ strlen(char const *);
int /*<<< orphan*/ strncmp(char *, char const *, int /*<<< orphan*/);
void unset_in_env(char **envp, const char *name) {
  int i;
  for (i = 0; envp[i]; i++)
    if (!strncmp(envp[i], name, strlen(name)))
      envp[i][0] = '\0';
}


x86 assembly (clang, -O0):
<unset_in_env>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
cmpq   $0x0,(%rax,%rcx,8)
je     11a5 <unset_in_env+0x85>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x28(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    %eax,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
jne    1192 <unset_in_env+0x72>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movb   $0x0,(%rax)
jmp    1197 <unset_in_env+0x77>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1137 <unset_in_env+0x17>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<unset_in_env>:
push   %r15
push   %r14
push   %rbx
mov    (%rdi),%r15
test   %r15,%r15
je     116e <unset_in_env+0x4e>
mov    %rsi,%r14
mov    %rdi,%rbx
add    $0x8,%rbx
jmp    114c <unset_in_env+0x2c>
nopl   0x0(%rax)
mov    (%rbx),%r15
add    $0x8,%rbx
test   %r15,%r15
je     116e <unset_in_env+0x4e>
mov    %r14,%rdi
call   1040 <strlen@plt>
mov    %r15,%rdi
mov    %r14,%rsi
mov    %eax,%edx
call   1030 <strncmp@plt>
test   %eax,%eax
jne    1140 <unset_in_env+0x20>
mov    -0x8(%rbx),%rax
movb   $0x0,(%rax)
jmp    1140 <unset_in_env+0x20>
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @unset_in_env(i8** %0, i8* %1) {
%3 = alloca i8**
%4 = alloca i8*
%5 = alloca i32
store i8** %0, i8*** %3
store i8* %1, i8** %4
store i32 0, i32* %5
br label %6
6: ; preds = %32, %2
%7 = load i8**, i8*** %3
%8 = load i32, i32* %5
%9 = sext i32 %8 to i64
%10 = getelementptr inbounds i8*, i8** %7, i64 %9
%11 = load i8*, i8** %10
%12 = icmp ne i8* %11, null
br i1 %12, label %13, label %35
13: ; preds = %6
%14 = load i8**, i8*** %3
%15 = load i32, i32* %5
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds i8*, i8** %14, i64 %16
%18 = load i8*, i8** %17
%19 = load i8*, i8** %4
%20 = load i8*, i8** %4
%21 = call i32 @strlen(i8* %20)
%22 = call i32 @strncmp(i8* %18, i8* %19, i32 %21)
%23 = icmp ne i32 %22, 0
br i1 %23, label %31, label %24
24: ; preds = %13
%25 = load i8**, i8*** %3
%26 = load i32, i32* %5
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds i8*, i8** %25, i64 %27
%29 = load i8*, i8** %28
%30 = getelementptr inbounds i8, i8* %29, i64 0
store i8 0, i8* %30
br label %31
31: ; preds = %24, %13
br label %32
32: ; preds = %31
%33 = load i32, i32* %5
%34 = add nsw i32 %33, 1
store i32 %34, i32* %5
br label %6
35: ; preds = %6
ret void
}

LLVM IR (-O2):
define void @unset_in_env(i8** nocapture %0, i8* %1) {
%3 = load i8*, i8** %0
%4 = icmp eq i8* %3, null
br i1 %4, label %19, label %5
5: ; preds = %2, %14
%6 = phi i64 [ %15, %14 ], [ 0, %2 ]
%7 = phi i8* [ %17, %14 ], [ %3, %2 ]
%8 = phi i8** [ %16, %14 ], [ %0, %2 ]
%9 = tail call i32 @strlen(i8* %1)
%10 = tail call i32 @strncmp(i8* %7, i8* %1, i32 %9)
%11 = icmp eq i32 %10, 0
br i1 %11, label %12, label %14
12: ; preds = %5
%13 = load i8*, i8** %8
store i8 0, i8* %13
br label %14
14: ; preds = %5, %12
%15 = add nuw i64 %6, 1
%16 = getelementptr inbounds i8*, i8** %0, i64 %15
%17 = load i8*, i8** %16
%18 = icmp eq i8* %17, null
br i1 %18, label %19, label %5
19: ; preds = %14, %2
ret void
}