#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 */
int /*<<< orphan*/ assert(int);
int setregid(scalar_t__, scalar_t__);
int /*<<< orphan*/ warn(char *);
int setresgid(gid_t rgid, gid_t egid, gid_t sgid) {
  assert(rgid == egid && egid == sgid);
  if (-1 == setregid(egid, egid)) {
    warn("setregid");
    return (-1);
  }
  return (0);
}


x86 assembly (clang, -O0):
<setresgid>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x10(%rbp),%rcx
xor    %eax,%eax
cmp    -0x18(%rbp),%rcx
mov    %al,-0x21(%rbp)
jne    1165 <setresgid+0x35>
mov    -0x18(%rbp),%rax
cmp    -0x20(%rbp),%rax
sete   %al
mov    %al,-0x21(%rbp)
mov    -0x21(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
mov    -0x18(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1050 <setregid@plt>
mov    %eax,%ecx
mov    $0xffffffff,%eax
cmp    %ecx,%eax
jne    11a6 <setresgid+0x76>
lea    0xe6b(%rip),%rdi
call   1030 <warn@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11ad <setresgid+0x7d>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<setresgid>:
push   %rbx
mov    %rsi,%rbx
xor    %rsi,%rdi
xor    %rsi,%rdx
xor    %eax,%eax
or     %rdi,%rdx
sete   %al
mov    %eax,%edi
call   1040 <assert@plt>
mov    %rbx,%rdi
mov    %rbx,%rsi
call   1050 <setregid@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    $0xffffffff,%ecx
je     115f <setresgid+0x2f>
pop    %rbx
ret
lea    0xe9a(%rip),%rdi
call   1030 <warn@plt>
mov    $0xffffffff,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [9 x i8] c"setregid\00"
define i32 @setresgid(i64 %0, i64 %1, i64 %2) {
%4 = alloca i32
%5 = alloca i64
%6 = alloca i64
%7 = alloca i64
store i64 %0, i64* %5
store i64 %1, i64* %6
store i64 %2, i64* %7
%8 = load i64, i64* %5
%9 = load i64, i64* %6
%10 = icmp eq i64 %8, %9
br i1 %10, label %11, label %15
11: ; preds = %3
%12 = load i64, i64* %6
%13 = load i64, i64* %7
%14 = icmp eq i64 %12, %13
br label %15
15: ; preds = %11, %3
%16 = phi i1 [ false, %3 ], [ %14, %11 ]
%17 = zext i1 %16 to i32
%18 = call i32 @assert(i32 %17)
%19 = load i64, i64* %6
%20 = load i64, i64* %6
%21 = call i32 @setregid(i64 %19, i64 %20)
%22 = icmp eq i32 -1, %21
br i1 %22, label %23, label %25
23: ; preds = %15
%24 = call i32 @warn(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %4
br label %26
25: ; preds = %15
store i32 0, i32* %4
br label %26
26: ; preds = %25, %23
%27 = load i32, i32* %4
ret i32 %27
}

LLVM IR (-O2):
@.str = [9 x i8] c"setregid\00"
define i32 @setresgid(i64 %0, i64 %1, i64 %2) {
%4 = icmp eq i64 %0, %1
%5 = icmp eq i64 %1, %2
%6 = and i1 %4, %5
%7 = zext i1 %6 to i32
%8 = tail call i32 @assert(i32 %7)
%9 = tail call i32 @setregid(i64 %1, i64 %1)
%10 = icmp eq i32 %9, -1
br i1 %10, label %11, label %13
11: ; preds = %3
%12 = tail call i32 @warn(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
br label %13
13: ; preds = %3, %11
%14 = phi i32 [ -1, %11 ], [ 0, %3 ]
ret i32 %14
}