#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*/ _SC_LOGIN_NAME_MAX;
int /*<<< orphan*/ free_values(char **);
char **get_values(char *);
scalar_t__ strncmp(char *, char const *, int /*<<< orphan*/);
int /*<<< orphan*/ sysconf(int /*<<< orphan*/);
int is_whitelisted(const char *user) {
  char **whitelist = get_values("allowed.system.users");
  char **users = whitelist;
  if (whitelist != NULL) {
    for (; *users; ++users) {
      if (strncmp(*users, user, sysconf(_SC_LOGIN_NAME_MAX)) == 0) {
        free_values(whitelist);
        return 1;
      }
    }
    free_values(whitelist);
  }
  return 0;
}


x86 assembly (clang, -O0):
<is_whitelisted>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
lea    0xead(%rip),%rdi
call   1050 <get_values@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     11f0 <is_whitelisted+0xb0>
jmp    1174 <is_whitelisted+0x34>
mov    -0x20(%rbp),%rax
cmpq   $0x0,(%rax)
je     11e7 <is_whitelisted+0xa7>
mov    -0x20(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    0x2e4c(%rip),%rax
mov    (%rax),%edi
call   1060 <sysconf@plt>
mov    -0x30(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    %eax,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    11d1 <is_whitelisted+0x91>
mov    -0x18(%rbp),%rdi
call   1040 <free_values@plt>
movl   $0x1,-0x4(%rbp)
jmp    11f7 <is_whitelisted+0xb7>
jmp    11d6 <is_whitelisted+0x96>
mov    -0x20(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x20(%rbp)
jmp    1174 <is_whitelisted+0x34>
mov    -0x18(%rbp),%rdi
call   1040 <free_values@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<is_whitelisted>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r12
lea    0xeab(%rip),%rdi
call   1050 <get_values@plt>
test   %rax,%rax
je     11aa <is_whitelisted+0x6a>
mov    %rax,%r15
mov    (%rax),%rbx
xor    %r14d,%r14d
test   %rbx,%rbx
je     11b5 <is_whitelisted+0x75>
mov    %r15,%rbp
add    $0x8,%rbp
mov    0x2e6d(%rip),%r13
nopl   0x0(%rax,%rax,1)
mov    0x0(%r13),%edi
call   1060 <sysconf@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
mov    %eax,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     11af <is_whitelisted+0x6f>
mov    0x0(%rbp),%rbx
add    $0x8,%rbp
test   %rbx,%rbx
jne    1180 <is_whitelisted+0x40>
jmp    11b5 <is_whitelisted+0x75>
xor    %r14d,%r14d
jmp    11bd <is_whitelisted+0x7d>
mov    $0x1,%r14d
mov    %r15,%rdi
call   1040 <free_values@plt>
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [21 x i8] c"allowed.system.users\00"
@_SC_LOGIN_NAME_MAX = global i32 0
define i32 @is_whitelisted(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i8**
%5 = alloca i8**
store i8* %0, i8** %3
%6 = call i8** @get_values(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
store i8** %6, i8*** %4
%7 = load i8**, i8*** %4
store i8** %7, i8*** %5
%8 = load i8**, i8*** %4
%9 = icmp ne i8** %8, null
br i1 %9, label %10, label %33
10: ; preds = %1
br label %11
11: ; preds = %27, %10
%12 = load i8**, i8*** %5
%13 = load i8*, i8** %12
%14 = icmp ne i8* %13, null
br i1 %14, label %15, label %30
15: ; preds = %11
%16 = load i8**, i8*** %5
%17 = load i8*, i8** %16
%18 = load i8*, i8** %3
%19 = load i32, i32* @_SC_LOGIN_NAME_MAX
%20 = call i32 @sysconf(i32 %19)
%21 = call i64 @strncmp(i8* %17, i8* %18, i32 %20)
%22 = icmp eq i64 %21, 0
br i1 %22, label %23, label %26
23: ; preds = %15
%24 = load i8**, i8*** %4
%25 = call i32 @free_values(i8** %24)
store i32 1, i32* %2
br label %34
26: ; preds = %15
br label %27
27: ; preds = %26
%28 = load i8**, i8*** %5
%29 = getelementptr inbounds i8*, i8** %28, i32 1
store i8** %29, i8*** %5
br label %11
30: ; preds = %11
%31 = load i8**, i8*** %4
%32 = call i32 @free_values(i8** %31)
br label %33
33: ; preds = %30, %1
store i32 0, i32* %2
br label %34
34: ; preds = %33, %23
%35 = load i32, i32* %2
ret i32 %35
}

LLVM IR (-O2):
@.str = [21 x i8] c"allowed.system.users\00"
@_SC_LOGIN_NAME_MAX = global i32 0
define i32 @is_whitelisted(i8* %0) {
%2 = tail call i8** @get_values(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
%3 = icmp eq i8** %2, null
br i1 %3, label %21, label %4
4: ; preds = %1
%5 = load i8*, i8** %2
%6 = icmp eq i8* %5, null
br i1 %6, label %18, label %10
7: ; preds = %10
%8 = load i8*, i8** %17
%9 = icmp eq i8* %8, null
br i1 %9, label %18, label %10
10: ; preds = %4, %7
%11 = phi i8* [ %8, %7 ], [ %5, %4 ]
%12 = phi i8** [ %17, %7 ], [ %2, %4 ]
%13 = load i32, i32* @_SC_LOGIN_NAME_MAX
%14 = tail call i32 @sysconf(i32 %13)
%15 = tail call i64 @strncmp(i8* %11, i8* %0, i32 %14)
%16 = icmp eq i64 %15, 0
%17 = getelementptr inbounds i8*, i8** %12, i64 1
br i1 %16, label %18, label %7
18: ; preds = %7, %10, %4
%19 = phi i32 [ 0, %4 ], [ 1, %10 ], [ 0, %7 ]
%20 = tail call i32 @free_values(i8** %2)
br label %21
21: ; preds = %18, %1
%22 = phi i32 [ 0, %1 ], [ %19, %18 ]
ret i32 %22
}