#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*/ free(char *);
char *getenv(char const *);
int /*<<< orphan*/ pl_whitelist_env(char *);
char *strdup(char *);
char *strtok(char *, char *);
void pl_whitelist_envs_from_env(const char *export_env) {
  char *str;
  char *token;
  if ((str = getenv(export_env))) {
    str = strdup(str);
    token = strtok(str, ":");
    while (token) {
      pl_whitelist_env(token);
      token = strtok(NULL, ":");
    }
    free(str);
  }
}


x86 assembly (clang, -O0):
<pl_whitelist_envs_from_env>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
je     11ca <pl_whitelist_envs_from_env+0x7a>
mov    -0x10(%rbp),%rdi
call   1060 <strdup@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe75(%rip),%rsi
call   1050 <strtok@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     11c1 <pl_whitelist_envs_from_env+0x71>
mov    -0x18(%rbp),%rdi
call   1070 <pl_whitelist_env@plt>
xor    %eax,%eax
mov    %eax,%edi
lea    0xe4d(%rip),%rsi
call   1050 <strtok@plt>
mov    %rax,-0x18(%rbp)
jmp    1194 <pl_whitelist_envs_from_env+0x44>
mov    -0x10(%rbp),%rdi
call   1040 <free@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pl_whitelist_envs_from_env>:
push   %r14
push   %rbx
push   %rax
call   1030 <getenv@plt>
test   %rax,%rax
je     11b6 <pl_whitelist_envs_from_env+0x66>
mov    %rax,%rdi
call   1060 <strdup@plt>
mov    %rax,%r14
lea    0xe90(%rip),%rsi
mov    %rax,%rdi
call   1050 <strtok@plt>
test   %rax,%rax
je     11a7 <pl_whitelist_envs_from_env+0x57>
lea    0xe7c(%rip),%rbx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %rax,%rdi
call   1070 <pl_whitelist_env@plt>
xor    %edi,%edi
mov    %rbx,%rsi
call   1050 <strtok@plt>
test   %rax,%rax
jne    1190 <pl_whitelist_envs_from_env+0x40>
mov    %r14,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1040 <free@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [2 x i8] c":\00"
define void @pl_whitelist_envs_from_env(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
store i8* %0, i8** %2
%5 = load i8*, i8** %2
%6 = call i8* @getenv(i8* %5)
store i8* %6, i8** %3
%7 = icmp ne i8* %6, null
br i1 %7, label %8, label %23
8: ; preds = %1
%9 = load i8*, i8** %3
%10 = call i8* @strdup(i8* %9)
store i8* %10, i8** %3
%11 = load i8*, i8** %3
%12 = call i8* @strtok(i8* %11, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i8* %12, i8** %4
br label %13
13: ; preds = %16, %8
%14 = load i8*, i8** %4
%15 = icmp ne i8* %14, null
br i1 %15, label %16, label %20
16: ; preds = %13
%17 = load i8*, i8** %4
%18 = call i32 @pl_whitelist_env(i8* %17)
%19 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i8* %19, i8** %4
br label %13
20: ; preds = %13
%21 = load i8*, i8** %3
%22 = call i32 @free(i8* %21)
br label %23
23: ; preds = %20, %1
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c":\00"
define void @pl_whitelist_envs_from_env(i8* nocapture %0) {
%2 = tail call i8* @getenv(i8* %0)
%3 = icmp eq i8* %2, null
br i1 %3, label %15, label %4
4: ; preds = %1
%5 = tail call i8* @strdup(i8* %2)
%6 = tail call i8* @strtok(i8* %5, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%7 = icmp eq i8* %6, null
br i1 %7, label %13, label %8
8: ; preds = %4, %8
%9 = phi i8* [ %11, %8 ], [ %6, %4 ]
%10 = tail call i32 @pl_whitelist_env(i8* %9)
%11 = tail call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%12 = icmp eq i8* %11, null
br i1 %12, label %13, label %8
13: ; preds = %8, %4
%14 = tail call i32 @free(i8* %5)
br label %15
15: ; preds = %13, %1
ret void
}