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

/* Variables and functions */
int /*<<< orphan*/ _exit(int);
int getgroups(int, short *);
int setgroups(int, short *);
int main() {
  short x[4];
  x[0] = x[1] = 1;
  if (getgroups(1, x) == 0)
    if (setgroups(1, x) == -1)
      _exit(1);
  if (getgroups(1, x) == -1)
    _exit(1);
  if (x[1] != 1)
    _exit(1);
  x[1] = 2;
  if (getgroups(1, x) == -1)
    _exit(1);
  if (x[1] != 2)
    _exit(1);
  _exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movw   $0x1,-0xa(%rbp)
movw   $0x1,-0xc(%rbp)
lea    -0xc(%rbp),%rsi
mov    $0x1,%edi
call   1050 <getgroups@plt>
cmp    $0x0,%eax
jne    1188 <main+0x58>
lea    -0xc(%rbp),%rsi
mov    $0x1,%edi
call   1040 <setgroups@plt>
cmp    $0xffffffff,%eax
jne    1183 <main+0x53>
mov    $0x1,%edi
call   1030 <_exit@plt>
jmp    1188 <main+0x58>
lea    -0xc(%rbp),%rsi
mov    $0x1,%edi
call   1050 <getgroups@plt>
cmp    $0xffffffff,%eax
jne    11a9 <main+0x79>
mov    $0x1,%edi
call   1030 <_exit@plt>
movswl -0xa(%rbp),%eax
cmp    $0x1,%eax
je     11c0 <main+0x90>
mov    $0x1,%edi
call   1030 <_exit@plt>
movw   $0x2,-0xa(%rbp)
lea    -0xc(%rbp),%rsi
mov    $0x1,%edi
call   1050 <getgroups@plt>
cmp    $0xffffffff,%eax
jne    11e7 <main+0xb7>
mov    $0x1,%edi
call   1030 <_exit@plt>
movswl -0xa(%rbp),%eax
cmp    $0x2,%eax
je     11fe <main+0xce>
mov    $0x1,%edi
call   1030 <_exit@plt>
xor    %edi,%edi
call   1030 <_exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rax
movl   $0x10001,(%rsp)
mov    %rsp,%rsi
mov    $0x1,%edi
call   1050 <getgroups@plt>
test   %eax,%eax
jne    115b <main+0x2b>
mov    %rsp,%rsi
mov    $0x1,%edi
call   1040 <setgroups@plt>
cmp    $0xffffffff,%eax
je     119d <main+0x6d>
mov    %rsp,%rsi
mov    $0x1,%edi
call   1050 <getgroups@plt>
cmp    $0xffffffff,%eax
je     119d <main+0x6d>
cmpw   $0x1,0x2(%rsp)
jne    119d <main+0x6d>
movw   $0x2,0x2(%rsp)
mov    %rsp,%rsi
mov    $0x1,%edi
call   1050 <getgroups@plt>
cmp    $0xffffffff,%eax
je     119d <main+0x6d>
cmpw   $0x2,0x2(%rsp)
jne    119d <main+0x6d>
xor    %edi,%edi
call   1030 <_exit@plt>
mov    $0x1,%edi
call   1030 <_exit@plt>

LLVM IR (-O0):
define i32 @main() {
%1 = alloca i32
%2 = alloca [4 x i16]
store i32 0, i32* %1
%3 = getelementptr inbounds [4 x i16], [4 x i16]* %2, i64 0, i64 1
store i16 1, i16* %3
%4 = getelementptr inbounds [4 x i16], [4 x i16]* %2, i64 0, i64 0
store i16 1, i16* %4
%5 = getelementptr inbounds [4 x i16], [4 x i16]* %2, i64 0, i64 0
%6 = call i32 @getgroups(i32 1, i16* %5)
%7 = icmp eq i32 %6, 0
br i1 %7, label %8, label %15
8: ; preds = %0
%9 = getelementptr inbounds [4 x i16], [4 x i16]* %2, i64 0, i64 0
%10 = call i32 @setgroups(i32 1, i16* %9)
%11 = icmp eq i32 %10, -1
br i1 %11, label %12, label %14
12: ; preds = %8
%13 = call i32 @_exit(i32 1)
unreachable
14: ; preds = %8
br label %15
15: ; preds = %14, %0
%16 = getelementptr inbounds [4 x i16], [4 x i16]* %2, i64 0, i64 0
%17 = call i32 @getgroups(i32 1, i16* %16)
%18 = icmp eq i32 %17, -1
br i1 %18, label %19, label %21
19: ; preds = %15
%20 = call i32 @_exit(i32 1)
unreachable
21: ; preds = %15
%22 = getelementptr inbounds [4 x i16], [4 x i16]* %2, i64 0, i64 1
%23 = load i16, i16* %22
%24 = sext i16 %23 to i32
%25 = icmp ne i32 %24, 1
br i1 %25, label %26, label %28
26: ; preds = %21
%27 = call i32 @_exit(i32 1)
unreachable
28: ; preds = %21
%29 = getelementptr inbounds [4 x i16], [4 x i16]* %2, i64 0, i64 1
store i16 2, i16* %29
%30 = getelementptr inbounds [4 x i16], [4 x i16]* %2, i64 0, i64 0
%31 = call i32 @getgroups(i32 1, i16* %30)
%32 = icmp eq i32 %31, -1
br i1 %32, label %33, label %35
33: ; preds = %28
%34 = call i32 @_exit(i32 1)
unreachable
35: ; preds = %28
%36 = getelementptr inbounds [4 x i16], [4 x i16]* %2, i64 0, i64 1
%37 = load i16, i16* %36
%38 = sext i16 %37 to i32
%39 = icmp ne i32 %38, 2
br i1 %39, label %40, label %42
40: ; preds = %35
%41 = call i32 @_exit(i32 1)
unreachable
42: ; preds = %35
%43 = call i32 @_exit(i32 0)
unreachable
}

LLVM IR (-O2):
define i32 @main() {
%1 = alloca [4 x i16]
%2 = bitcast [4 x i16]* %1 to i8*
%3 = getelementptr inbounds [4 x i16], [4 x i16]* %1, i64 0, i64 1
store i16 1, i16* %3
%4 = getelementptr inbounds [4 x i16], [4 x i16]* %1, i64 0, i64 0
store i16 1, i16* %4
%5 = call i32 @getgroups(i32 1, i16* %4)
%6 = icmp eq i32 %5, 0
br i1 %6, label %7, label %12
7: ; preds = %0
%8 = call i32 @setgroups(i32 1, i16* %4)
%9 = icmp eq i32 %8, -1
br i1 %9, label %10, label %12
10: ; preds = %7
%11 = call i32 @_exit(i32 1)
unreachable
12: ; preds = %7, %0
%13 = call i32 @getgroups(i32 1, i16* %4)
%14 = icmp eq i32 %13, -1
br i1 %14, label %15, label %17
15: ; preds = %12
%16 = call i32 @_exit(i32 1)
unreachable
17: ; preds = %12
%18 = load i16, i16* %3
%19 = icmp eq i16 %18, 1
br i1 %19, label %22, label %20
20: ; preds = %17
%21 = call i32 @_exit(i32 1)
unreachable
22: ; preds = %17
store i16 2, i16* %3
%23 = call i32 @getgroups(i32 1, i16* %4)
%24 = icmp eq i32 %23, -1
br i1 %24, label %25, label %27
25: ; preds = %22
%26 = call i32 @_exit(i32 1)
unreachable
27: ; preds = %22
%28 = load i16, i16* %3
%29 = icmp eq i16 %28, 2
br i1 %29, label %32, label %30
30: ; preds = %27
%31 = call i32 @_exit(i32 1)
unreachable
32: ; preds = %27
%33 = call i32 @_exit(i32 0)
unreachable
}