#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 *);
void 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
movw   $0x1,-0x6(%rbp)
movw   $0x1,-0x8(%rbp)
lea    -0x8(%rbp),%rsi
mov    $0x1,%edi
call   1050 <getgroups@plt>
cmp    $0x0,%eax
jne    1181 <main+0x51>
lea    -0x8(%rbp),%rsi
mov    $0x1,%edi
call   1040 <setgroups@plt>
cmp    $0xffffffff,%eax
jne    117c <main+0x4c>
mov    $0x1,%edi
call   1030 <_exit@plt>
jmp    1181 <main+0x51>
lea    -0x8(%rbp),%rsi
mov    $0x1,%edi
call   1050 <getgroups@plt>
cmp    $0xffffffff,%eax
jne    11a2 <main+0x72>
mov    $0x1,%edi
call   1030 <_exit@plt>
movswl -0x6(%rbp),%eax
cmp    $0x1,%eax
je     11b9 <main+0x89>
mov    $0x1,%edi
call   1030 <_exit@plt>
movw   $0x2,-0x6(%rbp)
lea    -0x8(%rbp),%rsi
mov    $0x1,%edi
call   1050 <getgroups@plt>
cmp    $0xffffffff,%eax
jne    11e0 <main+0xb0>
mov    $0x1,%edi
call   1030 <_exit@plt>
movswl -0x6(%rbp),%eax
cmp    $0x2,%eax
je     11f7 <main+0xc7>
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 void @main() {
%1 = alloca [4 x i16]
%2 = getelementptr inbounds [4 x i16], [4 x i16]* %1, i64 0, i64 1
store i16 1, i16* %2
%3 = getelementptr inbounds [4 x i16], [4 x i16]* %1, i64 0, i64 0
store i16 1, i16* %3
%4 = getelementptr inbounds [4 x i16], [4 x i16]* %1, i64 0, i64 0
%5 = call i32 @getgroups(i32 1, i16* %4)
%6 = icmp eq i32 %5, 0
br i1 %6, label %7, label %14
7: ; preds = %0
%8 = getelementptr inbounds [4 x i16], [4 x i16]* %1, i64 0, i64 0
%9 = call i32 @setgroups(i32 1, i16* %8)
%10 = icmp eq i32 %9, -1
br i1 %10, label %11, label %13
11: ; preds = %7
%12 = call i32 @_exit(i32 1)
unreachable
13: ; preds = %7
br label %14
14: ; preds = %13, %0
%15 = getelementptr inbounds [4 x i16], [4 x i16]* %1, i64 0, i64 0
%16 = call i32 @getgroups(i32 1, i16* %15)
%17 = icmp eq i32 %16, -1
br i1 %17, label %18, label %20
18: ; preds = %14
%19 = call i32 @_exit(i32 1)
unreachable
20: ; preds = %14
%21 = getelementptr inbounds [4 x i16], [4 x i16]* %1, i64 0, i64 1
%22 = load i16, i16* %21
%23 = sext i16 %22 to i32
%24 = icmp ne i32 %23, 1
br i1 %24, label %25, label %27
25: ; preds = %20
%26 = call i32 @_exit(i32 1)
unreachable
27: ; preds = %20
%28 = getelementptr inbounds [4 x i16], [4 x i16]* %1, i64 0, i64 1
store i16 2, i16* %28
%29 = getelementptr inbounds [4 x i16], [4 x i16]* %1, i64 0, i64 0
%30 = call i32 @getgroups(i32 1, i16* %29)
%31 = icmp eq i32 %30, -1
br i1 %31, label %32, label %34
32: ; preds = %27
%33 = call i32 @_exit(i32 1)
unreachable
34: ; preds = %27
%35 = getelementptr inbounds [4 x i16], [4 x i16]* %1, i64 0, i64 1
%36 = load i16, i16* %35
%37 = sext i16 %36 to i32
%38 = icmp ne i32 %37, 2
br i1 %38, label %39, label %41
39: ; preds = %34
%40 = call i32 @_exit(i32 1)
unreachable
41: ; preds = %34
%42 = call i32 @_exit(i32 0)
unreachable
}

LLVM IR (-O2):
define void @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
}