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

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, int, int);
int getgrouplist(char *, int, int *, int *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ stderr;
int main(void) {
  int count = 100;
  gid_t groups[100];
  int ret;
  ret = getgrouplist("nobodyisreallyhere", 1337, groups, &count);
  if (ret != 1) {
    fprintf(stderr, "getgrouplist() returned %d (expecting 1), ngroups=%d\n",
            ret, count);
    return 1;
  }
  if (groups[0] != 1337) {
    fprintf(stderr, "getgrouplist() returned group %d (expecting %d)\n",
            groups[0], 1337);
    return 1;
  }
  printf("ok\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1b0,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x64,-0x8(%rbp)
lea    -0x1a0(%rbp),%rdx
lea    0xea9(%rip),%rdi
mov    $0x539,%esi
lea    -0x8(%rbp),%rcx
call   1050 <getgrouplist@plt>
mov    %eax,-0x1a4(%rbp)
cmpl   $0x1,-0x1a4(%rbp)
je     11a2 <main+0x72>
mov    0x2e61(%rip),%rax
mov    (%rax),%edi
mov    -0x1a4(%rbp),%edx
mov    -0x8(%rbp),%ecx
lea    0xe82(%rip),%rsi
call   1040 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    11f1 <main+0xc1>
cmpl   $0x539,-0x1a0(%rbp)
je     11de <main+0xae>
mov    0x2e27(%rip),%rax
mov    (%rax),%edi
mov    -0x1a0(%rbp),%edx
lea    0xe81(%rip),%rsi
mov    $0x539,%ecx
call   1040 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    11f1 <main+0xc1>
lea    0xe95(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x1b0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x1a8,%rsp
movl   $0x64,0xc(%rsp)
lea    0xeba(%rip),%rdi
lea    0x10(%rsp),%rdx
lea    0xc(%rsp),%rcx
mov    $0x539,%esi
call   1050 <getgrouplist@plt>
cmp    $0x1,%eax
jne    1181 <main+0x51>
mov    0x10(%rsp),%edx
cmp    $0x539,%edx
jne    1199 <main+0x69>
lea    0xf08(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x1a8,%rsp
ret
mov    0x2e58(%rip),%rcx
mov    (%rcx),%edi
mov    0xc(%rsp),%ecx
lea    0xe7e(%rip),%rsi
mov    %eax,%edx
jmp    11ae <main+0x7e>
mov    0x2e40(%rip),%rax
mov    (%rax),%edi
lea    0xea0(%rip),%rsi
mov    $0x539,%ecx
call   1040 <fprintf@plt>
mov    $0x1,%eax
add    $0x1a8,%rsp
ret

LLVM IR (-O0):
@.str = [19 x i8] c"nobodyisreallyhere\00"
@stderr = global i32 0
@.str.1 = [54 x i8] c"getgrouplist() returned %d (expecting 1), ngroups=%d\0A\00"
@.str.2 = [49 x i8] c"getgrouplist() returned group %d (expecting %d)\0A\00"
@.str.3 = [4 x i8] c"ok\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [100 x i32]
%4 = alloca i32
store i32 0, i32* %1
store i32 100, i32* %2
%5 = getelementptr inbounds [100 x i32], [100 x i32]* %3, i64 0, i64 0
%6 = call i32 @getgrouplist(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i32 1337, i32* %5, i32* %2)
store i32 %6, i32* %4
%7 = load i32, i32* %4
%8 = icmp ne i32 %7, 1
br i1 %8, label %9, label %14
9: ; preds = %0
%10 = load i32, i32* @stderr
%11 = load i32, i32* %4
%12 = load i32, i32* %2
%13 = call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.1, i64 0, i64 0), i32 %11, i32 %12)
store i32 1, i32* %1
br label %25
14: ; preds = %0
%15 = getelementptr inbounds [100 x i32], [100 x i32]* %3, i64 0, i64 0
%16 = load i32, i32* %15
%17 = icmp ne i32 %16, 1337
br i1 %17, label %18, label %23
18: ; preds = %14
%19 = load i32, i32* @stderr
%20 = getelementptr inbounds [100 x i32], [100 x i32]* %3, i64 0, i64 0
%21 = load i32, i32* %20
%22 = call i32 @fprintf(i32 %19, i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.2, i64 0, i64 0), i32 %21, i32 1337)
store i32 1, i32* %1
br label %25
23: ; preds = %14
%24 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %1
br label %25
25: ; preds = %23, %18, %9
%26 = load i32, i32* %1
ret i32 %26
}

LLVM IR (-O2):
@.str = [19 x i8] c"nobodyisreallyhere\00"
@stderr = global i32 0
@.str.1 = [54 x i8] c"getgrouplist() returned %d (expecting 1), ngroups=%d\0A\00"
@.str.2 = [49 x i8] c"getgrouplist() returned group %d (expecting %d)\0A\00"
@str = [3 x i8] c"ok\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [100 x i32]
%3 = bitcast i32* %1 to i8*
store i32 100, i32* %1
%4 = bitcast [100 x i32]* %2 to i8*
%5 = getelementptr inbounds [100 x i32], [100 x i32]* %2, i64 0, i64 0
%6 = call i32 @getgrouplist(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i32 1337, i32* %5, i32* %1)
%7 = icmp eq i32 %6, 1
br i1 %7, label %12, label %8
8: ; preds = %0
%9 = load i32, i32* @stderr
%10 = load i32, i32* %1
%11 = call i32 @fprintf(i32 %9, i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.1, i64 0, i64 0), i32 %6, i32 %10)
br label %20
12: ; preds = %0
%13 = load i32, i32* %5
%14 = icmp eq i32 %13, 1337
br i1 %14, label %18, label %15
15: ; preds = %12
%16 = load i32, i32* @stderr
%17 = call i32 @fprintf(i32 %16, i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.2, i64 0, i64 0), i32 %13, i32 1337)
br label %20
18: ; preds = %12
%19 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @str, i64 0, i64 0))
br label %20
20: ; preds = %18, %15, %8
%21 = phi i32 [ 1, %8 ], [ 1, %15 ], [ 0, %18 ]
ret i32 %21
}