#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 scalar_t__ gid_t;
typedef int /*<<< orphan*/ AUTH;

/* Variables and functions */
int MAX_MACHINE_NAME;
int NGROUPS;
int NGRPS;
int /*<<< orphan*/ abort();
int /*<<< orphan*/ *authunix_create(char *, int, int, int, int *);
scalar_t__ getegid();
scalar_t__ geteuid();
int getgroups(int, scalar_t__ *);
int gethostname(char *, int);
AUTH *authunix_create_default(void) {
  register int len;
  char machname[MAX_MACHINE_NAME + 1];
  register int uid;
  register int gid;
  int gids[NGRPS];
  int i;
  gid_t real_gids[NGROUPS];
  if (gethostname(machname, MAX_MACHINE_NAME) == -1)
    abort();
  machname[MAX_MACHINE_NAME] = 0;
  uid = (int)geteuid();
  gid = (int)getegid();
  if ((len = getgroups(NGROUPS, real_gids)) < 0)
    abort();
  if (len > NGRPS)
    len = NGRPS;
  for (i = 0; i < len; i++) {
    gids[i] = (int)real_gids[i];
  }
  return (authunix_create(machname, uid, gid, len, gids));
}


x86 assembly (clang, -O0):
<authunix_create_default>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    0x2e79(%rip),%rax
mov    (%rax),%eax
add    $0x1,%eax
mov    %rsp,%rcx
mov    %rcx,-0x10(%rbp)
mov    %rax,%rcx
add    $0xf,%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rdi
sub    %rcx,%rdi
mov    %rdi,-0x50(%rbp)
mov    %rdi,%rsp
mov    %rax,-0x18(%rbp)
mov    0x2e32(%rip),%rax
mov    (%rax),%eax
lea    0xf(,%rax,4),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x48(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x28(%rbp)
mov    0x2e14(%rip),%rax
mov    (%rax),%eax
lea    0xf(,%rax,8),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x40(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x38(%rbp)
mov    0x2dfe(%rip),%rax
mov    (%rax),%esi
call   1070 <gethostname@plt>
cmp    $0xffffffff,%eax
jne    1201 <authunix_create_default+0xa1>
mov    $0x0,%al
call   1030 <abort@plt>
mov    -0x50(%rbp),%rax
mov    0x2ddc(%rip),%rcx
movslq (%rcx),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    $0x0,%al
call   1040 <geteuid@plt>
mov    %eax,-0x1c(%rbp)
mov    $0x0,%al
call   1060 <getegid@plt>
mov    -0x40(%rbp),%rsi
mov    %eax,-0x20(%rbp)
mov    0x2da6(%rip),%rax
mov    (%rax),%edi
call   1050 <getgroups@plt>
mov    %eax,-0x4(%rbp)
cmp    $0x0,%eax
jge    124c <authunix_create_default+0xec>
mov    $0x0,%al
call   1030 <abort@plt>
mov    -0x4(%rbp),%eax
mov    0x2d7a(%rip),%rcx
cmp    (%rcx),%eax
jle    126a <authunix_create_default+0x10a>
mov    0x2d6b(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    12a4 <authunix_create_default+0x144>
mov    -0x48(%rbp),%rax
mov    -0x40(%rbp),%rcx
movslq -0x2c(%rbp),%rdx
mov    (%rcx,%rdx,8),%rcx
mov    %ecx,%edx
movslq -0x2c(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1271 <authunix_create_default+0x111>
mov    -0x48(%rbp),%r8
mov    -0x50(%rbp),%rdi
mov    -0x1c(%rbp),%esi
mov    -0x20(%rbp),%edx
mov    -0x4(%rbp),%ecx
call   1080 <authunix_create@plt>
mov    -0x10(%rbp),%rcx
mov    %rcx,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<authunix_create_default>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    0x2e73(%rip),%r13
mov    0x0(%r13),%esi
lea    0x1(%rsi),%eax
mov    %rsp,%r14
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r14
mov    %r14,%rsp
mov    0x2e3c(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%r15
lea    0xf(,%rax,4),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r15
mov    %r15,%rsp
mov    0x2e26(%rip),%r12
mov    (%r12),%eax
mov    %rsp,%rbx
lea    0xf(,%rax,8),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
mov    %r14,%rdi
call   1070 <gethostname@plt>
cmp    $0xffffffff,%eax
je     12fd <authunix_create_default+0x19d>
movslq 0x0(%r13),%rax
movb   $0x0,(%r14,%rax,1)
xor    %eax,%eax
call   1040 <geteuid@plt>
mov    %rax,-0x30(%rbp)
xor    %eax,%eax
call   1060 <getegid@plt>
mov    %rax,%r13
mov    (%r12),%edi
mov    %rbx,%rsi
call   1050 <getgroups@plt>
test   %eax,%eax
js     12fd <authunix_create_default+0x19d>
mov    0x2dbb(%rip),%rcx
mov    (%rcx),%ecx
cmp    %ecx,%eax
cmovg  %ecx,%eax
test   %eax,%eax
jle    12d0 <authunix_create_default+0x170>
mov    %eax,%ecx
cmp    $0x4,%eax
jae    1232 <authunix_create_default+0xd2>
xor    %edx,%edx
jmp    12c0 <authunix_create_default+0x160>
mov    %ecx,%edx
and    $0xfffffffc,%edx
lea    -0x4(%rdx),%rsi
mov    %rsi,%r8
shr    $0x2,%r8
add    $0x1,%r8
test   %rsi,%rsi
je     12f3 <authunix_create_default+0x193>
mov    %r8,%rsi
and    $0xfffffffffffffffe,%rsi
xor    %edi,%edi
nopl   0x0(%rax,%rax,1)
pshufd $0xe8,(%rbx,%rdi,8),%xmm0
pshufd $0xe8,0x10(%rbx,%rdi,8),%xmm1
punpcklqdq %xmm1,%xmm0
movdqa %xmm0,(%r15,%rdi,4)
pshufd $0xe8,0x20(%rbx,%rdi,8),%xmm0
pshufd $0xe8,0x30(%rbx,%rdi,8),%xmm1
punpcklqdq %xmm1,%xmm0
movdqa %xmm0,0x10(%r15,%rdi,4)
add    $0x8,%rdi
add    $0xfffffffffffffffe,%rsi
jne    1260 <authunix_create_default+0x100>
test   $0x1,%r8b
je     12b7 <authunix_create_default+0x157>
pshufd $0xe8,(%rbx,%rdi,8),%xmm0
pshufd $0xe8,0x10(%rbx,%rdi,8),%xmm1
punpcklqdq %xmm1,%xmm0
movdqa %xmm0,(%r15,%rdi,4)
cmp    %rcx,%rdx
je     12d0 <authunix_create_default+0x170>
nopl   0x0(%rax)
mov    (%rbx,%rdx,8),%esi
mov    %esi,(%r15,%rdx,4)
add    $0x1,%rdx
cmp    %rdx,%rcx
jne    12c0 <authunix_create_default+0x160>
mov    %r14,%rdi
mov    -0x30(%rbp),%rsi
mov    %r13d,%edx
mov    %eax,%ecx
mov    %r15,%r8
call   1080 <authunix_create@plt>
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %edi,%edi
test   $0x1,%r8b
jne    12a0 <authunix_create_default+0x140>
jmp    12b7 <authunix_create_default+0x157>
xor    %eax,%eax
call   1030 <abort@plt>

LLVM IR (-O0):
@MAX_MACHINE_NAME = global i32 0
@NGRPS = global i32 0
@NGROUPS = global i32 0
define i32* @authunix_create_default() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca i64
%4 = alloca i32
%5 = alloca i32
%6 = alloca i64
%7 = alloca i32
%8 = alloca i64
%9 = load i32, i32* @MAX_MACHINE_NAME
%10 = add nsw i32 %9, 1
%11 = zext i32 %10 to i64
%12 = call i8* @llvm.stacksave()
store i8* %12, i8** %2
%13 = alloca i8, i64 %11
store i64 %11, i64* %3
%14 = load i32, i32* @NGRPS
%15 = zext i32 %14 to i64
%16 = alloca i32, i64 %15
store i64 %15, i64* %6
%17 = load i32, i32* @NGROUPS
%18 = zext i32 %17 to i64
%19 = alloca i64, i64 %18
store i64 %18, i64* %8
%20 = load i32, i32* @MAX_MACHINE_NAME
%21 = call i32 @gethostname(i8* %13, i32 %20)
%22 = icmp eq i32 %21, -1
br i1 %22, label %23, label %25
23: ; preds = %0
%24 = call i32 (...) @abort()
unreachable
25: ; preds = %0
%26 = load i32, i32* @MAX_MACHINE_NAME
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds i8, i8* %13, i64 %27
store i8 0, i8* %28
%29 = call i64 (...) @geteuid()
%30 = trunc i64 %29 to i32
store i32 %30, i32* %4
%31 = call i64 (...) @getegid()
%32 = trunc i64 %31 to i32
store i32 %32, i32* %5
%33 = load i32, i32* @NGROUPS
%34 = call i32 @getgroups(i32 %33, i64* %19)
store i32 %34, i32* %1
%35 = icmp slt i32 %34, 0
br i1 %35, label %36, label %38
36: ; preds = %25
%37 = call i32 (...) @abort()
unreachable
38: ; preds = %25
%39 = load i32, i32* %1
%40 = load i32, i32* @NGRPS
%41 = icmp sgt i32 %39, %40
br i1 %41, label %42, label %44
42: ; preds = %38
%43 = load i32, i32* @NGRPS
store i32 %43, i32* %1
br label %44
44: ; preds = %42, %38
store i32 0, i32* %7
br label %45
45: ; preds = %58, %44
%46 = load i32, i32* %7
%47 = load i32, i32* %1
%48 = icmp slt i32 %46, %47
br i1 %48, label %49, label %61
49: ; preds = %45
%50 = load i32, i32* %7
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds i64, i64* %19, i64 %51
%53 = load i64, i64* %52
%54 = trunc i64 %53 to i32
%55 = load i32, i32* %7
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds i32, i32* %16, i64 %56
store i32 %54, i32* %57
br label %58
58: ; preds = %49
%59 = load i32, i32* %7
%60 = add nsw i32 %59, 1
store i32 %60, i32* %7
br label %45
61: ; preds = %45
%62 = load i32, i32* %4
%63 = load i32, i32* %5
%64 = load i32, i32* %1
%65 = call i32* @authunix_create(i8* %13, i32 %62, i32 %63, i32 %64, i32* %16)
%66 = load i8*, i8** %2
ret i32* %65
}

LLVM IR (-O2):
@MAX_MACHINE_NAME = global i32 0
@NGRPS = global i32 0
@NGROUPS = global i32 0
define i32* @authunix_create_default() {
%1 = load i32, i32* @MAX_MACHINE_NAME
%2 = add nsw i32 %1, 1
%3 = zext i32 %2 to i64
%4 = alloca i8, i64 %3
%5 = load i32, i32* @NGRPS
%6 = zext i32 %5 to i64
%7 = alloca i32, i64 %6
%8 = load i32, i32* @NGROUPS
%9 = zext i32 %8 to i64
%10 = alloca i64, i64 %9
%11 = call i32 @gethostname(i8* %4, i32 %1)
%12 = icmp eq i32 %11, -1
br i1 %12, label %13, label %15
13: ; preds = %0
%14 = call i32 (...) @abort()
unreachable
15: ; preds = %0
%16 = load i32, i32* @MAX_MACHINE_NAME
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds i8, i8* %4, i64 %17
store i8 0, i8* %18
%19 = call i64 (...) @geteuid()
%20 = call i64 (...) @getegid()
%21 = load i32, i32* @NGROUPS
%22 = call i32 @getgroups(i32 %21, i64* %10)
%23 = icmp slt i32 %22, 0
br i1 %23, label %24, label %26
24: ; preds = %15
%25 = call i32 (...) @abort()
unreachable
26: ; preds = %15
%27 = load i32, i32* @NGRPS
%28 = icmp sgt i32 %22, %27
%29 = select i1 %28, i32 %27, i32 %22
%30 = icmp sgt i32 %29, 0
br i1 %30, label %31, label %102
31: ; preds = %26
%32 = zext i32 %29 to i64
%33 = icmp ult i32 %29, 4
br i1 %33, label %92, label %34
34: ; preds = %31
%35 = and i64 %32, 4294967292
%36 = add nsw i64 %35, -4
%37 = lshr exact i64 %36, 2
%38 = add nuw nsw i64 %37, 1
%39 = and i64 %38, 1
%40 = icmp eq i64 %36, 0
br i1 %40, label %74, label %41
41: ; preds = %34
%42 = and i64 %38, 9223372036854775806
br label %43
43: ; preds = %43, %41
%44 = phi i64 [ 0, %41 ], [ %71, %43 ]
%45 = phi i64 [ 0, %41 ], [ %72, %43 ]
%46 = getelementptr inbounds i64, i64* %10, i64 %44
%47 = bitcast i64* %46 to <2 x i64>*
%48 = load <2 x i64>, <2 x i64>* %47
%49 = getelementptr inbounds i64, i64* %46, i64 2
%50 = bitcast i64* %49 to <2 x i64>*
%51 = load <2 x i64>, <2 x i64>* %50
%52 = trunc <2 x i64> %48 to <2 x i32>
%53 = trunc <2 x i64> %51 to <2 x i32>
%54 = getelementptr inbounds i32, i32* %7, i64 %44
%55 = bitcast i32* %54 to <2 x i32>*
store <2 x i32> %52, <2 x i32>* %55
%56 = getelementptr inbounds i32, i32* %54, i64 2
%57 = bitcast i32* %56 to <2 x i32>*
store <2 x i32> %53, <2 x i32>* %57
%58 = or i64 %44, 4
%59 = getelementptr inbounds i64, i64* %10, i64 %58
%60 = bitcast i64* %59 to <2 x i64>*
%61 = load <2 x i64>, <2 x i64>* %60
%62 = getelementptr inbounds i64, i64* %59, i64 2
%63 = bitcast i64* %62 to <2 x i64>*
%64 = load <2 x i64>, <2 x i64>* %63
%65 = trunc <2 x i64> %61 to <2 x i32>
%66 = trunc <2 x i64> %64 to <2 x i32>
%67 = getelementptr inbounds i32, i32* %7, i64 %58
%68 = bitcast i32* %67 to <2 x i32>*
store <2 x i32> %65, <2 x i32>* %68
%69 = getelementptr inbounds i32, i32* %67, i64 2
%70 = bitcast i32* %69 to <2 x i32>*
store <2 x i32> %66, <2 x i32>* %70
%71 = add nuw i64 %44, 8
%72 = add i64 %45, 2
%73 = icmp eq i64 %72, %42
br i1 %73, label %74, label %43
74: ; preds = %43, %34
%75 = phi i64 [ 0, %34 ], [ %71, %43 ]
%76 = icmp eq i64 %39, 0
br i1 %76, label %90, label %77
77: ; preds = %74
%78 = getelementptr inbounds i64, i64* %10, i64 %75
%79 = bitcast i64* %78 to <2 x i64>*
%80 = load <2 x i64>, <2 x i64>* %79
%81 = getelementptr inbounds i64, i64* %78, i64 2
%82 = bitcast i64* %81 to <2 x i64>*
%83 = load <2 x i64>, <2 x i64>* %82
%84 = trunc <2 x i64> %80 to <2 x i32>
%85 = trunc <2 x i64> %83 to <2 x i32>
%86 = getelementptr inbounds i32, i32* %7, i64 %75
%87 = bitcast i32* %86 to <2 x i32>*
store <2 x i32> %84, <2 x i32>* %87
%88 = getelementptr inbounds i32, i32* %86, i64 2
%89 = bitcast i32* %88 to <2 x i32>*
store <2 x i32> %85, <2 x i32>* %89
br label %90
90: ; preds = %74, %77
%91 = icmp eq i64 %35, %32
br i1 %91, label %102, label %92
92: ; preds = %31, %90
%93 = phi i64 [ 0, %31 ], [ %35, %90 ]
br label %94
94: ; preds = %92, %94
%95 = phi i64 [ %100, %94 ], [ %93, %92 ]
%96 = getelementptr inbounds i64, i64* %10, i64 %95
%97 = load i64, i64* %96
%98 = trunc i64 %97 to i32
%99 = getelementptr inbounds i32, i32* %7, i64 %95
store i32 %98, i32* %99
%100 = add nuw nsw i64 %95, 1
%101 = icmp eq i64 %100, %32
br i1 %101, label %102, label %94
102: ; preds = %94, %90, %26
%103 = trunc i64 %20 to i32
%104 = trunc i64 %19 to i32
%105 = call i32* @authunix_create(i8* %4, i32 %104, i32 %103, i32 %29, i32* %7)
ret i32* %105
}