#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*/ getdomainname(char *, int);
int innetgr(char const *, char const *, char const *, char *);
int netgroup_match(const char *group, const char *machine, const char *user) {
  static char *mydomain = 0;
  if (mydomain == 0) {
    static char domain[256 + 1];
    getdomainname(domain, 256);
    mydomain = domain;
  }
  return innetgr(group, machine, user, mydomain);
}


x86 assembly (clang, -O0):
<netgroup_match>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
cmpq   $0x0,0x2f04(%rip)
jne    1161 <netgroup_match+0x41>
lea    0x2f07(%rip),%rdi
mov    $0x100,%esi
call   1030 <getdomainname@plt>
lea    0x2ef6(%rip),%rax
mov    %rax,0x2edf(%rip)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    0x2ecc(%rip),%rcx
call   1040 <innetgr@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<netgroup_match>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%r12
mov    0x2f08(%rip),%rbx
test   %rbx,%rbx
jne    1158 <netgroup_match+0x38>
lea    0x2f0c(%rip),%rbx
mov    %rbx,%rdi
mov    $0x100,%esi
call   1030 <getdomainname@plt>
mov    %rbx,0x2ee8(%rip)
mov    %r12,%rdi
mov    %r15,%rsi
mov    %r14,%rdx
mov    %rbx,%rcx
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1040 <innetgr@plt>

LLVM IR (-O0):
@netgroup_match.mydomain = internal global i8* null
@netgroup_match.domain = internal global [257 x i8] zeroinitializer
define i32 @netgroup_match(i8* %0, i8* %1, i8* %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
store i8* %0, i8** %4
store i8* %1, i8** %5
store i8* %2, i8** %6
%7 = load i8*, i8** @netgroup_match.mydomain
%8 = icmp eq i8* %7, null
br i1 %8, label %9, label %11
9: ; preds = %3
%10 = call i32 @getdomainname(i8* getelementptr inbounds ([257 x i8], [257 x i8]* @netgroup_match.domain, i64 0, i64 0), i32 256)
store i8* getelementptr inbounds ([257 x i8], [257 x i8]* @netgroup_match.domain, i64 0, i64 0), i8** @netgroup_match.mydomain
br label %11
11: ; preds = %9, %3
%12 = load i8*, i8** %4
%13 = load i8*, i8** %5
%14 = load i8*, i8** %6
%15 = load i8*, i8** @netgroup_match.mydomain
%16 = call i32 @innetgr(i8* %12, i8* %13, i8* %14, i8* %15)
ret i32 %16
}

LLVM IR (-O2):
@netgroup_match.mydomain = internal unnamed_addr global i8* null
@netgroup_match.domain = internal global [257 x i8] zeroinitializer
define i32 @netgroup_match(i8* %0, i8* %1, i8* %2) {
%4 = load i8*, i8** @netgroup_match.mydomain
%5 = icmp eq i8* %4, null
br i1 %5, label %6, label %8
6: ; preds = %3
%7 = tail call i32 @getdomainname(i8* getelementptr inbounds ([257 x i8], [257 x i8]* @netgroup_match.domain, i64 0, i64 0), i32 256)
store i8* getelementptr inbounds ([257 x i8], [257 x i8]* @netgroup_match.domain, i64 0, i64 0), i8** @netgroup_match.mydomain
br label %8
8: ; preds = %6, %3
%9 = phi i8* [ getelementptr inbounds ([257 x i8], [257 x i8]* @netgroup_match.domain, i64 0, i64 0), %6 ], [ %4, %3 ]
%10 = tail call i32 @innetgr(i8* %0, i8* %1, i8* %2, i8* %9)
ret i32 %10
}