#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 */
scalar_t__ setgroups(int /*<<< orphan*/, int /*<<< orphan*/ *);
scalar_t__ setregid(int, int);
scalar_t__ setreuid(int, int);
int /*<<< orphan*/ xerror(char *);
void set_container_creds(void) {
  if (setgroups(0, NULL) != 0)
    xerror("setgroups to empty list");
  if (setreuid(2, 2) != 0)
    xerror("setuid for container setup");
  if (setregid(2, 2) != 0)
    xerror("setgid for container setup");
}


x86 assembly (clang, -O0):
<set_container_creds>:
push   %rbp
mov    %rsp,%rbp
xor    %edi,%edi
xor    %eax,%eax
mov    %eax,%esi
call   1040 <setgroups@plt>
cmp    $0x0,%rax
je     1165 <set_container_creds+0x25>
lea    0xea0(%rip),%rdi
call   1030 <xerror@plt>
mov    $0x2,%esi
mov    %esi,%edi
call   1050 <setreuid@plt>
cmp    $0x0,%rax
je     1187 <set_container_creds+0x47>
lea    0xe96(%rip),%rdi
call   1030 <xerror@plt>
mov    $0x2,%esi
mov    %esi,%edi
call   1060 <setregid@plt>
cmp    $0x0,%rax
je     11a9 <set_container_creds+0x69>
lea    0xe8f(%rip),%rdi
call   1030 <xerror@plt>
pop    %rbp
ret

x86 assembly (clang, -O2):
<set_container_creds>:
push   %rax
xor    %edi,%edi
xor    %esi,%esi
call   1040 <setgroups@plt>
test   %rax,%rax
je     115b <set_container_creds+0x1b>
lea    0xeaa(%rip),%rdi
call   1030 <xerror@plt>
mov    $0x2,%edi
mov    $0x2,%esi
call   1050 <setreuid@plt>
test   %rax,%rax
je     117b <set_container_creds+0x3b>
lea    0xea2(%rip),%rdi
call   1030 <xerror@plt>
mov    $0x2,%edi
mov    $0x2,%esi
call   1060 <setregid@plt>
test   %rax,%rax
je     119c <set_container_creds+0x5c>
lea    0xe9d(%rip),%rdi
pop    %rax
jmp    1030 <xerror@plt>
pop    %rax
ret

LLVM IR (-O0):
@.str = [24 x i8] c"setgroups to empty list\00"
@.str.1 = [27 x i8] c"setuid for container setup\00"
@.str.2 = [27 x i8] c"setgid for container setup\00"
define void @set_container_creds() {
%1 = call i64 @setgroups(i32 0, i32* null)
%2 = icmp ne i64 %1, 0
br i1 %2, label %3, label %5
3: ; preds = %0
%4 = call i32 @xerror(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
br label %5
5: ; preds = %3, %0
%6 = call i64 @setreuid(i32 2, i32 2)
%7 = icmp ne i64 %6, 0
br i1 %7, label %8, label %10
8: ; preds = %5
%9 = call i32 @xerror(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0))
br label %10
10: ; preds = %8, %5
%11 = call i64 @setregid(i32 2, i32 2)
%12 = icmp ne i64 %11, 0
br i1 %12, label %13, label %15
13: ; preds = %10
%14 = call i32 @xerror(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0))
br label %15
15: ; preds = %13, %10
ret void
}

LLVM IR (-O2):
@.str = [24 x i8] c"setgroups to empty list\00"
@.str.1 = [27 x i8] c"setuid for container setup\00"
@.str.2 = [27 x i8] c"setgid for container setup\00"
define void @set_container_creds() {
%1 = tail call i64 @setgroups(i32 0, i32* null)
%2 = icmp eq i64 %1, 0
br i1 %2, label %5, label %3
3: ; preds = %0
%4 = tail call i32 @xerror(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
br label %5
5: ; preds = %3, %0
%6 = tail call i64 @setreuid(i32 2, i32 2)
%7 = icmp eq i64 %6, 0
br i1 %7, label %10, label %8
8: ; preds = %5
%9 = tail call i32 @xerror(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0))
br label %10
10: ; preds = %8, %5
%11 = tail call i64 @setregid(i32 2, i32 2)
%12 = icmp eq i64 %11, 0
br i1 %12, label %15, label %13
13: ; preds = %10
%14 = tail call i32 @xerror(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0))
br label %15
15: ; preds = %13, %10
ret void
}