#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*/ AUTH;

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


x86 assembly (clang, -O0):
<authunix_create_default>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%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,-0x38(%rbp)
mov    %rdi,%rsp
mov    %rax,-0x18(%rbp)
mov    0x2e3a(%rip),%rax
mov    (%rax),%eax
lea    0xf(,%rax,4),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x30(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x28(%rbp)
mov    0x2e24(%rip),%rax
mov    (%rax),%esi
call   1070 <gethostname@plt>
cmp    $0xffffffff,%eax
jne    11db <authunix_create_default+0x7b>
mov    $0x0,%al
call   1030 <abort@plt>
mov    -0x38(%rbp),%rax
mov    0x2e02(%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    -0x30(%rbp),%rsi
mov    %eax,-0x20(%rbp)
mov    0x2dcc(%rip),%rax
mov    (%rax),%edi
call   1050 <getgroups@plt>
mov    %eax,-0x4(%rbp)
cmp    $0x0,%eax
jge    1226 <authunix_create_default+0xc6>
mov    $0x0,%al
call   1030 <abort@plt>
mov    -0x30(%rbp),%r8
mov    -0x38(%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),%r15
mov    (%r15),%esi
lea    0x1(%rsi),%eax
mov    %rsp,%rbx
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
mov    0x2e45(%rip),%r13
mov    0x0(%r13),%eax
mov    %rsp,%r14
lea    0xf(,%rax,4),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r14
mov    %r14,%rsp
mov    %rbx,%rdi
call   1070 <gethostname@plt>
cmp    $0xffffffff,%eax
je     1206 <authunix_create_default+0xa6>
movslq (%r15),%rax
movb   $0x0,(%rbx,%rax,1)
xor    %eax,%eax
call   1040 <geteuid@plt>
mov    %eax,%r15d
xor    %eax,%eax
call   1060 <getegid@plt>
mov    %eax,%r12d
mov    0x0(%r13),%edi
mov    %r14,%rsi
call   1050 <getgroups@plt>
test   %eax,%eax
js     1206 <authunix_create_default+0xa6>
mov    %rbx,%rdi
mov    %r15d,%esi
mov    %r12d,%edx
mov    %eax,%ecx
mov    %r14,%r8
call   1080 <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
@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 i64
%7 = load i32, i32* @MAX_MACHINE_NAME
%8 = add nsw i32 %7, 1
%9 = zext i32 %8 to i64
%10 = call i8* @llvm.stacksave()
store i8* %10, i8** %2
%11 = alloca i8, i64 %9
store i64 %9, i64* %3
%12 = load i32, i32* @NGRPS
%13 = zext i32 %12 to i64
%14 = alloca i32, i64 %13
store i64 %13, i64* %6
%15 = load i32, i32* @MAX_MACHINE_NAME
%16 = call i32 @gethostname(i8* %11, i32 %15)
%17 = icmp eq i32 %16, -1
br i1 %17, label %18, label %20
18: ; preds = %0
%19 = call i32 (...) @abort()
unreachable
20: ; preds = %0
%21 = load i32, i32* @MAX_MACHINE_NAME
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds i8, i8* %11, i64 %22
store i8 0, i8* %23
%24 = call i32 (...) @geteuid()
store i32 %24, i32* %4
%25 = call i32 (...) @getegid()
store i32 %25, i32* %5
%26 = load i32, i32* @NGRPS
%27 = call i32 @getgroups(i32 %26, i32* %14)
store i32 %27, i32* %1
%28 = icmp slt i32 %27, 0
br i1 %28, label %29, label %31
29: ; preds = %20
%30 = call i32 (...) @abort()
unreachable
31: ; preds = %20
%32 = load i32, i32* %4
%33 = load i32, i32* %5
%34 = load i32, i32* %1
%35 = call i32* @authunix_create(i8* %11, i32 %32, i32 %33, i32 %34, i32* %14)
%36 = load i8*, i8** %2
ret i32* %35
}

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