#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 */
typedef int /*<<< orphan*/ domain;

/* Variables and functions */
int /*<<< orphan*/ LOG_ERR;
scalar_t__ getdomainname(char *, int);
int innetgr(char const *, char const *, char const *, char *);
int /*<<< orphan*/ syslog(int /*<<< orphan*/, char *);
int netgroup_match(const char *group, const char *machine, const char *user) {
  char domain[1024];
  unsigned int i;
  if (getdomainname(domain, sizeof(domain)) != 0 || *domain == '\0') {
    syslog(LOG_ERR, "NIS netgroup support disabled: no NIS domain");
    return (0);
  }
  for (i = 0; i < sizeof(domain); ++i)
    if (domain[i] == '\0')
      break;
  if (i == sizeof(domain)) {
    syslog(LOG_ERR, "NIS netgroup support disabled: invalid NIS domain");
    return (0);
  }
  if (innetgr(group, machine, user, domain) == 1)
    return (1);
  return (0);
}


x86 assembly (clang, -O0):
<netgroup_match>:
push   %rbp
mov    %rsp,%rbp
sub    $0x430,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
lea    -0x420(%rbp),%rdi
mov    $0x400,%esi
call   1030 <getdomainname@plt>
cmp    $0x0,%rax
jne    1172 <netgroup_match+0x42>
movsbl -0x420(%rbp),%eax
cmp    $0x0,%eax
jne    1193 <netgroup_match+0x63>
mov    0x2e5f(%rip),%rax
mov    (%rax),%edi
lea    0xe7e(%rip),%rsi
call   1040 <syslog@plt>
movl   $0x0,-0x4(%rbp)
jmp    124b <netgroup_match+0x11b>
movl   $0x0,-0x424(%rbp)
mov    -0x424(%rbp),%eax
cmp    $0x400,%rax
jae    11e4 <netgroup_match+0xb4>
mov    -0x424(%rbp),%eax
movsbl -0x420(%rbp,%rax,1),%eax
ff
cmp    $0x0,%eax
jne    11cb <netgroup_match+0x9b>
jmp    11e4 <netgroup_match+0xb4>
jmp    11d0 <netgroup_match+0xa0>
mov    -0x424(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x424(%rbp)
jmp    119d <netgroup_match+0x6d>
mov    -0x424(%rbp),%eax
cmp    $0x400,%rax
jne    1217 <netgroup_match+0xe7>
mov    0x2ddb(%rip),%rax
mov    (%rax),%edi
lea    0xe27(%rip),%rsi
call   1040 <syslog@plt>
movl   $0x0,-0x4(%rbp)
jmp    124b <netgroup_match+0x11b>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
lea    -0x420(%rbp),%rcx
call   1050 <innetgr@plt>
cmp    $0x1,%eax
jne    1244 <netgroup_match+0x114>
movl   $0x1,-0x4(%rbp)
jmp    124b <netgroup_match+0x11b>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x430,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<netgroup_match>:
push   %r15
push   %r14
push   %rbx
sub    $0x400,%rsp
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
mov    %rsp,%rdi
mov    $0x400,%esi
call   1030 <getdomainname@plt>
test   %rax,%rax
jne    11b4 <netgroup_match+0x84>
cmpb   $0x0,(%rsp)
je     11b4 <netgroup_match+0x84>
mov    $0x4,%eax
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
cmpb   $0x0,-0x3(%rsp,%rax,1)
je     1197 <netgroup_match+0x67>
cmpb   $0x0,-0x2(%rsp,%rax,1)
je     1197 <netgroup_match+0x67>
cmpb   $0x0,-0x1(%rsp,%rax,1)
je     1197 <netgroup_match+0x67>
cmp    $0x400,%rax
je     11d8 <netgroup_match+0xa8>
cmpb   $0x0,(%rsp,%rax,1)
lea    0x4(%rax),%rax
jne    1170 <netgroup_match+0x40>
mov    %rsp,%rcx
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %r14,%rdx
call   1050 <innetgr@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    $0x1,%ecx
sete   %al
jmp    11cb <netgroup_match+0x9b>
mov    0x2e1d(%rip),%rax
mov    (%rax),%edi
lea    0xe3c(%rip),%rsi
call   1040 <syslog@plt>
xor    %eax,%eax
add    $0x400,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret
mov    0x2df9(%rip),%rax
mov    (%rax),%edi
lea    0xe45(%rip),%rsi
jmp    11c4 <netgroup_match+0x94>

LLVM IR (-O0):
@LOG_ERR = global i32 0
@.str = [45 x i8] c"NIS netgroup support disabled: no NIS domain\00"
@.str.1 = [50 x i8] c"NIS netgroup support disabled: invalid NIS domain\00"
define i32 @netgroup_match(i8* %0, i8* %1, i8* %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca [1024 x i8]
%9 = alloca i32
store i8* %0, i8** %5
store i8* %1, i8** %6
store i8* %2, i8** %7
%10 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%11 = call i64 @getdomainname(i8* %10, i32 1024)
%12 = icmp ne i64 %11, 0
br i1 %12, label %18, label %13
13: ; preds = %3
%14 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%15 = load i8, i8* %14
%16 = sext i8 %15 to i32
%17 = icmp eq i32 %16, 0
br i1 %17, label %18, label %21
18: ; preds = %13, %3
%19 = load i32, i32* @LOG_ERR
%20 = call i32 @syslog(i32 %19, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %4
br label %54
21: ; preds = %13
store i32 0, i32* %9
br label %22
22: ; preds = %35, %21
%23 = load i32, i32* %9
%24 = zext i32 %23 to i64
%25 = icmp ult i64 %24, 1024
br i1 %25, label %26, label %38
26: ; preds = %22
%27 = load i32, i32* %9
%28 = zext i32 %27 to i64
%29 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 %28
%30 = load i8, i8* %29
%31 = sext i8 %30 to i32
%32 = icmp eq i32 %31, 0
br i1 %32, label %33, label %34
33: ; preds = %26
br label %38
34: ; preds = %26
br label %35
35: ; preds = %34
%36 = load i32, i32* %9
%37 = add i32 %36, 1
store i32 %37, i32* %9
br label %22
38: ; preds = %33, %22
%39 = load i32, i32* %9
%40 = zext i32 %39 to i64
%41 = icmp eq i64 %40, 1024
br i1 %41, label %42, label %45
42: ; preds = %38
%43 = load i32, i32* @LOG_ERR
%44 = call i32 @syslog(i32 %43, i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %4
br label %54
45: ; preds = %38
%46 = load i8*, i8** %5
%47 = load i8*, i8** %6
%48 = load i8*, i8** %7
%49 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%50 = call i32 @innetgr(i8* %46, i8* %47, i8* %48, i8* %49)
%51 = icmp eq i32 %50, 1
br i1 %51, label %52, label %53
52: ; preds = %45
store i32 1, i32* %4
br label %54
53: ; preds = %45
store i32 0, i32* %4
br label %54
54: ; preds = %53, %52, %42, %18
%55 = load i32, i32* %4
ret i32 %55
}

LLVM IR (-O2):
@LOG_ERR = global i32 0
@.str = [45 x i8] c"NIS netgroup support disabled: no NIS domain\00"
@.str.1 = [50 x i8] c"NIS netgroup support disabled: invalid NIS domain\00"
define i32 @netgroup_match(i8* %0, i8* %1, i8* %2) {
%4 = alloca [1024 x i8]
%5 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%6 = call i64 @getdomainname(i8* %5, i32 1024)
%7 = icmp ne i64 %6, 0
%8 = load i8, i8* %5
%9 = icmp eq i8 %8, 0
%10 = select i1 %7, i1 true, i1 %9
br i1 %10, label %11, label %14
11: ; preds = %3
%12 = load i32, i32* @LOG_ERR
%13 = call i32 @syslog(i32 %12, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str, i64 0, i64 0))
br label %44
14: ; preds = %3, %33
%15 = phi i64 [ %31, %33 ], [ 0, %3 ]
%16 = or i64 %15, 1
%17 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 %16
%18 = load i8, i8* %17
%19 = icmp eq i8 %18, 0
br i1 %19, label %40, label %20
20: ; preds = %14
%21 = or i64 %15, 2
%22 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 %21
%23 = load i8, i8* %22
%24 = icmp eq i8 %23, 0
br i1 %24, label %40, label %25
25: ; preds = %20
%26 = or i64 %15, 3
%27 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 %26
%28 = load i8, i8* %27
%29 = icmp eq i8 %28, 0
br i1 %29, label %40, label %30
30: ; preds = %25
%31 = add nuw nsw i64 %15, 4
%32 = icmp eq i64 %31, 1024
br i1 %32, label %37, label %33
33: ; preds = %30
%34 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 %31
%35 = load i8, i8* %34
%36 = icmp eq i8 %35, 0
br i1 %36, label %40, label %14
37: ; preds = %30
%38 = load i32, i32* @LOG_ERR
%39 = call i32 @syslog(i32 %38, i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.1, i64 0, i64 0))
br label %44
40: ; preds = %33, %25, %20, %14
%41 = call i32 @innetgr(i8* %0, i8* %1, i8* %2, i8* %5)
%42 = icmp eq i32 %41, 1
%43 = zext i1 %42 to i32
br label %44
44: ; preds = %40, %37, %11
%45 = phi i32 [ 0, %11 ], [ 0, %37 ], [ %43, %40 ]
ret i32 %45
}