#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;

/* Variables and functions */
long getnids(int, scalar_t__ *);
long getrnid();
int /*<<< orphan*/ printf(char *, ...);
int main() {
  int i;
  long ret_nid = getrnid();
  printf("%lu\n", ret_nid);
  gid_t grps[32] = {0};
  long nngroups = getnids(32, grps);
  for (i = 0; i < nngroups; i++)
    printf("%i ", (int)grps[i]);
  if (nngroups)
    printf("\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1060 <getrnid@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rsi
lea    0xe98(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x110(%rbp),%rdi
xor    %esi,%esi
mov    $0x100,%edx
call   1050 <memset@plt>
lea    -0x110(%rbp),%rsi
mov    $0x20,%edi
call   1030 <getnids@plt>
mov    %rax,-0x118(%rbp)
movl   $0x0,-0x8(%rbp)
movslq -0x8(%rbp),%rax
cmp    -0x118(%rbp),%rax
jge    11dc <main+0x9c>
movslq -0x8(%rbp),%rax
mov    -0x110(%rbp,%rax,8),%rax
ff
mov    %eax,%esi
lea    0xe3e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11a1 <main+0x61>
cmpq   $0x0,-0x118(%rbp)
je     11f8 <main+0xb8>
lea    0xe12(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x120,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x100,%rsp
xor    %eax,%eax
call   1060 <getrnid@plt>
lea    0xea6(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
xorps  %xmm0,%xmm0
movaps %xmm0,0xf0(%rsp)
movaps %xmm0,0xe0(%rsp)
movaps %xmm0,0xd0(%rsp)
movaps %xmm0,0xc0(%rsp)
movaps %xmm0,0xb0(%rsp)
movaps %xmm0,0xa0(%rsp)
movaps %xmm0,0x90(%rsp)
movaps %xmm0,0x80(%rsp)
movaps %xmm0,0x70(%rsp)
movaps %xmm0,0x60(%rsp)
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movaps %xmm0,(%rsp)
mov    %rsp,%rsi
mov    $0x20,%edi
call   1040 <getnids@plt>
mov    %rax,%r15
test   %rax,%rax
jle    1206 <main+0xc6>
lea    0xe1b(%rip),%r14
xor    %ebx,%ebx
nopl   0x0(%rax)
mov    (%rsp,%rbx,8),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%rbx
cmp    %rbx,%r15
jne    11f0 <main+0xb0>
test   %r15,%r15
je     1215 <main+0xd5>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x100,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [5 x i8] c"%lu\0A\00"
@.str.1 = [4 x i8] c"%i \00"
@.str.2 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i64
%4 = alloca [32 x i64]
%5 = alloca i64
store i32 0, i32* %1
%6 = call i64 (...) @getrnid()
store i64 %6, i64* %3
%7 = load i64, i64* %3
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i64 %7)
%9 = bitcast [32 x i64]* %4 to i8*
%10 = getelementptr inbounds [32 x i64], [32 x i64]* %4, i64 0, i64 0
%11 = call i64 @getnids(i32 32, i64* %10)
store i64 %11, i64* %5
store i32 0, i32* %2
br label %12
12: ; preds = %24, %0
%13 = load i32, i32* %2
%14 = sext i32 %13 to i64
%15 = load i64, i64* %5
%16 = icmp slt i64 %14, %15
br i1 %16, label %17, label %27
17: ; preds = %12
%18 = load i32, i32* %2
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds [32 x i64], [32 x i64]* %4, i64 0, i64 %19
%21 = load i64, i64* %20
%22 = trunc i64 %21 to i32
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %22)
br label %24
24: ; preds = %17
%25 = load i32, i32* %2
%26 = add nsw i32 %25, 1
store i32 %26, i32* %2
br label %12
27: ; preds = %12
%28 = load i64, i64* %5
%29 = icmp ne i64 %28, 0
br i1 %29, label %30, label %32
30: ; preds = %27
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %32
32: ; preds = %30, %27
ret i32 0
}

LLVM IR (-O2):
@.str = [5 x i8] c"%lu\0A\00"
@.str.1 = [4 x i8] c"%i \00"
define i32 @main() {
%1 = alloca [32 x i64]
%2 = tail call i64 (...) @getrnid()
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i64 %2)
%4 = bitcast [32 x i64]* %1 to i8*
%5 = getelementptr inbounds [32 x i64], [32 x i64]* %1, i64 0, i64 0
%6 = call i64 @getnids(i32 32, i64* %5)
%7 = icmp sgt i64 %6, 0
br i1 %7, label %8, label %16
8: ; preds = %0, %8
%9 = phi i64 [ %14, %8 ], [ 0, %0 ]
%10 = getelementptr inbounds [32 x i64], [32 x i64]* %1, i64 0, i64 %9
%11 = load i64, i64* %10
%12 = trunc i64 %11 to i32
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %12)
%14 = add nuw nsw i64 %9, 1
%15 = icmp eq i64 %14, %6
br i1 %15, label %16, label %8
16: ; preds = %8, %0
%17 = icmp eq i64 %6, 0
br i1 %17, label %20, label %18
18: ; preds = %16
%19 = call i32 @putchar(i32 10)
br label %20
20: ; preds = %18, %16
ret i32 0
}