char *masked_key(const unsigned char masked_key[32]) {
  const char *var = getenv("WG_HIDE_KEYS");
  if (var && !strcmp(var, "never"))
    return key(masked_key);
  return "(hidden)";
}


x86 assembly (clang, -O0):
<masked_key>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
lea    0xebd(%rip),%rdi
mov    $0x0,%al
call   1030 <getenv@plt>
cltq
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     118a <masked_key+0x5a>
mov    -0x18(%rbp),%rdi
lea    0xea7(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    118a <masked_key+0x5a>
mov    -0x10(%rbp),%rdi
mov    $0x0,%al
call   1040 <key@plt>
cltq
mov    %rax,-0x8(%rbp)
jmp    1195 <masked_key+0x65>
lea    0xe82(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<masked_key>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
lea    0xec2(%rip),%rdi
xor    %eax,%eax
call   1030 <getenv@plt>
lea    0xec7(%rip),%rbx
test   %eax,%eax
je     1170 <masked_key+0x40>
movslq %eax,%rdi
lea    0xeb3(%rip),%rsi
call   1050 <strcmp@plt>
test   %eax,%eax
jne    1170 <masked_key+0x40>
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <key@plt>
movslq %eax,%rbx
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [13 x i8] c"WG_HIDE_KEYS\00"
@.str.1 = [6 x i8] c"never\00"
@.str.2 = [9 x i8] c"(hidden)\00"
define i8* @masked_key(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
store i8* %0, i8** %3
%5 = call i32 (i8*, ...) bitcast (i32 (...)* @getenv to i32 (i8*, ...)*)(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%6 = sext i32 %5 to i64
%7 = inttoptr i64 %6 to i8*
store i8* %7, i8** %4
%8 = load i8*, i8** %4
%9 = icmp ne i8* %8, null
br i1 %9, label %10, label %19
10: ; preds = %1
%11 = load i8*, i8** %4
%12 = call i32 @strcmp(i8* %11, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%13 = icmp ne i32 %12, 0
br i1 %13, label %19, label %14
14: ; preds = %10
%15 = load i8*, i8** %3
%16 = call i32 (i8*, ...) bitcast (i32 (...)* @key to i32 (i8*, ...)*)(i8* %15)
%17 = sext i32 %16 to i64
%18 = inttoptr i64 %17 to i8*
store i8* %18, i8** %2
br label %20
19: ; preds = %10, %1
store i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8** %2
br label %20
20: ; preds = %19, %14
%21 = load i8*, i8** %2
ret i8* %21
}

LLVM IR (-O2):
@.str = [13 x i8] c"WG_HIDE_KEYS\00"
@.str.1 = [6 x i8] c"never\00"
@.str.2 = [9 x i8] c"(hidden)\00"
define i8* @masked_key(i8* %0) {
%2 = tail call i32 (i8*, ...) bitcast (i32 (...)* @getenv to i32 (i8*, ...)*)(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%3 = icmp eq i32 %2, 0
br i1 %3, label %13, label %4
4: ; preds = %1
%5 = sext i32 %2 to i64
%6 = inttoptr i64 %5 to i8*
%7 = tail call i32 @strcmp(i8* %6, i8* dereferenceable(6) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%8 = icmp eq i32 %7, 0
br i1 %8, label %9, label %13
9: ; preds = %4
%10 = tail call i32 (i8*, ...) bitcast (i32 (...)* @key to i32 (i8*, ...)*)(i8* %0)
%11 = sext i32 %10 to i64
%12 = inttoptr i64 %11 to i8*
br label %13
13: ; preds = %1, %4, %9
%14 = phi i8* [ %12, %9 ], [ getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), %4 ], [ getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), %1 ]
ret i8* %14
}