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

/* Variables and functions */
int MAX_MACHINE_NAME;
int NGRPS;
int /*<<< orphan*/ _SC_NGROUPS_MAX;
int /*<<< orphan*/ abort();
int /*<<< orphan*/ *authunix_create(char *, int /*<<< orphan*/,
                                    int /*<<< orphan*/, int,
                                    int /*<<< orphan*/ *);
int /*<<< orphan*/ getegid();
int /*<<< orphan*/ geteuid();
int getgroups(int, int /*<<< orphan*/ *);
int gethostname(char *, int);
int sysconf(int /*<<< orphan*/);
AUTH *authunix_create_default() {
  register int len;
  char machname[MAX_MACHINE_NAME + 1];
  register uid_t uid;
  register gid_t gid;
  int max_nr_groups = sysconf(_SC_NGROUPS_MAX);
  gid_t gids[max_nr_groups];
  if (gethostname(machname, MAX_MACHINE_NAME) == -1)
    abort();
  machname[MAX_MACHINE_NAME] = 0;
  uid = geteuid();
  gid = getegid();
  if ((len = getgroups(max_nr_groups, gids)) < 0)
    abort();
  return (authunix_create(machname, uid, gid,
                          (((NGRPS) < (len)) ? (NGRPS) : (len)), gids));
}


x86 assembly (clang, -O0):
<authunix_create_default>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    0x2e61(%rip),%rax
mov    (%rax),%eax
add    $0x1,%eax
mov    %rsp,%rcx
mov    %rcx,-0x10(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x40(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x18(%rbp)
mov    0x2e3a(%rip),%rax
mov    (%rax),%edi
call   1070 <sysconf@plt>
mov    -0x40(%rbp),%rdi
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
lea    0xf(,%rax,4),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x38(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x30(%rbp)
mov    0x2dfd(%rip),%rax
mov    (%rax),%esi
call   1080 <gethostname@plt>
cmp    $0xffffffff,%eax
jne    11fa <authunix_create_default+0x8a>
mov    $0x0,%al
call   1030 <abort@plt>
mov    -0x40(%rbp),%rax
mov    0x2ddb(%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    -0x38(%rbp),%rsi
mov    %eax,-0x20(%rbp)
mov    -0x24(%rbp),%edi
call   1050 <getgroups@plt>
mov    %eax,-0x4(%rbp)
cmp    $0x0,%eax
jge    123f <authunix_create_default+0xcf>
mov    $0x0,%al
call   1030 <abort@plt>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x48(%rbp)
mov    -0x20(%rbp),%eax
mov    %eax,-0x44(%rbp)
mov    0x2d7e(%rip),%rax
mov    (%rax),%eax
cmp    -0x4(%rbp),%eax
jge    126e <authunix_create_default+0xfe>
mov    0x2d6c(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4c(%rbp)
jmp    1274 <authunix_create_default+0x104>
mov    -0x4(%rbp),%eax
mov    %eax,-0x4c(%rbp)
mov    -0x38(%rbp),%r8
mov    -0x44(%rbp),%edx
mov    -0x48(%rbp),%esi
mov    -0x40(%rbp),%rdi
mov    -0x4c(%rbp),%ecx
call   1090 <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    0x2e5b(%rip),%r12
mov    (%r12),%eax
add    $0x1,%eax
mov    %rsp,%r14
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r14
mov    %r14,%rsp
mov    0x2e44(%rip),%rax
mov    (%rax),%edi
call   1070 <sysconf@plt>
mov    %eax,%r15d
mov    %eax,%eax
mov    %rsp,%rbx
lea    0xf(,%rax,4),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
mov    (%r12),%esi
mov    %r14,%rdi
call   1080 <gethostname@plt>
cmp    $0xffffffff,%eax
je     1232 <authunix_create_default+0xc2>
movslq (%r12),%rax
movb   $0x0,(%r14,%rax,1)
xor    %eax,%eax
call   1040 <geteuid@plt>
mov    %eax,%r12d
xor    %eax,%eax
call   1060 <getegid@plt>
mov    %eax,%r13d
mov    %r15d,%edi
mov    %rbx,%rsi
call   1050 <getgroups@plt>
test   %eax,%eax
js     1232 <authunix_create_default+0xc2>
mov    0x2dc7(%rip),%rcx
mov    (%rcx),%ecx
cmp    %eax,%ecx
cmovl  %ecx,%eax
mov    %r14,%rdi
mov    %r12d,%esi
mov    %r13d,%edx
mov    %eax,%ecx
mov    %rbx,%r8
call   1090 <authunix_create@plt>
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %eax,%eax
call   1030 <abort@plt>

LLVM IR (-O0):
@MAX_MACHINE_NAME = global i32 0
@_SC_NGROUPS_MAX = global i32 0
@NGRPS = 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 i32
%7 = alloca i64
%8 = load i32, i32* @MAX_MACHINE_NAME
%9 = add nsw i32 %8, 1
%10 = zext i32 %9 to i64
%11 = call i8* @llvm.stacksave()
store i8* %11, i8** %2
%12 = alloca i8, i64 %10
store i64 %10, i64* %3
%13 = load i32, i32* @_SC_NGROUPS_MAX
%14 = call i32 @sysconf(i32 %13)
store i32 %14, i32* %6
%15 = load i32, i32* %6
%16 = zext i32 %15 to i64
%17 = alloca i32, i64 %16
store i64 %16, i64* %7
%18 = load i32, i32* @MAX_MACHINE_NAME
%19 = call i32 @gethostname(i8* %12, i32 %18)
%20 = icmp eq i32 %19, -1
br i1 %20, label %21, label %23
21: ; preds = %0
%22 = call i32 (...) @abort()
unreachable
23: ; preds = %0
%24 = load i32, i32* @MAX_MACHINE_NAME
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i8, i8* %12, i64 %25
store i8 0, i8* %26
%27 = call i32 (...) @geteuid()
store i32 %27, i32* %4
%28 = call i32 (...) @getegid()
store i32 %28, i32* %5
%29 = load i32, i32* %6
%30 = call i32 @getgroups(i32 %29, i32* %17)
store i32 %30, i32* %1
%31 = icmp slt i32 %30, 0
br i1 %31, label %32, label %34
32: ; preds = %23
%33 = call i32 (...) @abort()
unreachable
34: ; preds = %23
%35 = load i32, i32* %4
%36 = load i32, i32* %5
%37 = load i32, i32* @NGRPS
%38 = load i32, i32* %1
%39 = icmp slt i32 %37, %38
br i1 %39, label %40, label %42
40: ; preds = %34
%41 = load i32, i32* @NGRPS
br label %44
42: ; preds = %34
%43 = load i32, i32* %1
br label %44
44: ; preds = %42, %40
%45 = phi i32 [ %41, %40 ], [ %43, %42 ]
%46 = call i32* @authunix_create(i8* %12, i32 %35, i32 %36, i32 %45, i32* %17)
%47 = load i8*, i8** %2
ret i32* %46
}

LLVM IR (-O2):
@MAX_MACHINE_NAME = global i32 0
@_SC_NGROUPS_MAX = global i32 0
@NGRPS = 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* @_SC_NGROUPS_MAX
%6 = tail call i32 @sysconf(i32 %5)
%7 = zext i32 %6 to i64
%8 = alloca i32, i64 %7
%9 = load i32, i32* @MAX_MACHINE_NAME
%10 = call i32 @gethostname(i8* %4, i32 %9)
%11 = icmp eq i32 %10, -1
br i1 %11, label %12, label %14
12: ; preds = %0
%13 = call i32 (...) @abort()
unreachable
14: ; preds = %0
%15 = load i32, i32* @MAX_MACHINE_NAME
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds i8, i8* %4, i64 %16
store i8 0, i8* %17
%18 = call i32 (...) @geteuid()
%19 = call i32 (...) @getegid()
%20 = call i32 @getgroups(i32 %6, i32* %8)
%21 = icmp slt i32 %20, 0
br i1 %21, label %22, label %24
22: ; preds = %14
%23 = call i32 (...) @abort()
unreachable
24: ; preds = %14
%25 = load i32, i32* @NGRPS
%26 = icmp slt i32 %25, %20
%27 = select i1 %26, i32 %25, i32 %20
%28 = call i32* @authunix_create(i8* %4, i32 %18, i32 %19, i32 %27, i32* %8)
ret i32* %28
}