#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 uid_t;
typedef int gid_t;

/* Variables and functions */
int /*<<< orphan*/ EXIT_SUCCESS;
int /*<<< orphan*/ err_exit(char *, int /*<<< orphan*/);
int /*<<< orphan*/ errno;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int getresgid(int *, int *, int *);
int getresuid(int *, int *, int *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ strerror(int /*<<< orphan*/);
int main(int argc, char *argv[]) {
  uid_t ruid, euid, suid;
  gid_t rgid, egid, sgid;
  if (getresuid(&ruid, &euid, &suid) == -1) {
    err_exit("Error on getresuid, %s\n", strerror(errno));
  }
  if (getresgid(&rgid, &egid, &sgid) == -1) {
    err_exit("Error on getresuid, %s\n", strerror(errno));
  }
  if (getresuid(&ruid, &euid, &suid) == -1) {
    err_exit("Error on getresuid, %s\n", strerror(errno));
  }
  printf("Real User ID: %d\nEffective User ID: %d\nSaved Set User ID: %d\n",
         ruid, euid, suid);
  printf("\n");
  printf("Real Group ID: %d\nEffective Group ID: %d\nSaved Set Group ID: %d\n",
         rgid, egid, sgid);
  exit(EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x14(%rbp),%rdi
lea    -0x18(%rbp),%rsi
lea    -0x1c(%rbp),%rdx
call   1050 <getresuid@plt>
cmp    $0xffffffff,%eax
jne    11ac <main+0x4c>
mov    0x2e49(%rip),%rax
mov    (%rax),%edi
call   1080 <strerror@plt>
mov    %eax,%esi
lea    0xe59(%rip),%rdi
call   1060 <err_exit@plt>
lea    -0x20(%rbp),%rdi
lea    -0x24(%rbp),%rsi
lea    -0x28(%rbp),%rdx
call   1030 <getresgid@plt>
cmp    $0xffffffff,%eax
jne    11e2 <main+0x82>
mov    0x2e13(%rip),%rax
mov    (%rax),%edi
call   1080 <strerror@plt>
mov    %eax,%esi
lea    0xe23(%rip),%rdi
call   1060 <err_exit@plt>
lea    -0x14(%rbp),%rdi
lea    -0x18(%rbp),%rsi
lea    -0x1c(%rbp),%rdx
call   1050 <getresuid@plt>
cmp    $0xffffffff,%eax
jne    1218 <main+0xb8>
mov    0x2ddd(%rip),%rax
mov    (%rax),%edi
call   1080 <strerror@plt>
mov    %eax,%esi
lea    0xded(%rip),%rdi
call   1060 <err_exit@plt>
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
mov    -0x1c(%rbp),%ecx
lea    0xdf0(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe5f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x20(%rbp),%esi
mov    -0x24(%rbp),%edx
mov    -0x28(%rbp),%ecx
lea    0xe09(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x2d7d(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>

x86 assembly (clang, -O2):
<main>:
sub    $0x18,%rsp
lea    0x8(%rsp),%rdi
lea    0x4(%rsp),%rsi
mov    %rsp,%rdx
call   1060 <getresuid@plt>
cmp    $0xffffffff,%eax
jne    11a7 <main+0x37>
mov    0x2e4e(%rip),%rax
mov    (%rax),%edi
call   1090 <strerror@plt>
lea    0xe60(%rip),%rdi
mov    %eax,%esi
call   1070 <err_exit@plt>
lea    0x14(%rsp),%rdi
lea    0x10(%rsp),%rsi
lea    0xc(%rsp),%rdx
call   1040 <getresgid@plt>
cmp    $0xffffffff,%eax
jne    11dc <main+0x6c>
mov    0x2e19(%rip),%rax
mov    (%rax),%edi
call   1090 <strerror@plt>
lea    0xe2b(%rip),%rdi
mov    %eax,%esi
call   1070 <err_exit@plt>
lea    0x8(%rsp),%rdi
lea    0x4(%rsp),%rsi
mov    %rsp,%rdx
call   1060 <getresuid@plt>
cmp    $0xffffffff,%eax
jne    120f <main+0x9f>
mov    0x2de6(%rip),%rax
mov    (%rax),%edi
call   1090 <strerror@plt>
lea    0xdf8(%rip),%rdi
mov    %eax,%esi
call   1070 <err_exit@plt>
mov    0x8(%rsp),%esi
mov    0x4(%rsp),%edx
mov    (%rsp),%ecx
lea    0xdf7(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    0x14(%rsp),%esi
mov    0x10(%rsp),%edx
mov    0xc(%rsp),%ecx
lea    0xe11(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x2d85(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@.str = [24 x i8] c"Error on getresuid, %s\0A\00"
@errno = global i32 0
@.str.1 = [62 x i8] c"Real User ID: %d\0AEffective User ID: %d\0ASaved Set User ID: %d\0A\00"
@.str.2 = [2 x i8] c"\0A\00"
@.str.3 = [65 x i8] c"Real Group ID: %d\0AEffective Group ID: %d\0ASaved Set Group ID: %d\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%12 = call i32 @getresuid(i32* %6, i32* %7, i32* %8)
%13 = icmp eq i32 %12, -1
br i1 %13, label %14, label %18
14: ; preds = %2
%15 = load i32, i32* @errno
%16 = call i32 @strerror(i32 %15)
%17 = call i32 @err_exit(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i32 %16)
br label %18
18: ; preds = %14, %2
%19 = call i32 @getresgid(i32* %9, i32* %10, i32* %11)
%20 = icmp eq i32 %19, -1
br i1 %20, label %21, label %25
21: ; preds = %18
%22 = load i32, i32* @errno
%23 = call i32 @strerror(i32 %22)
%24 = call i32 @err_exit(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i32 %23)
br label %25
25: ; preds = %21, %18
%26 = call i32 @getresuid(i32* %6, i32* %7, i32* %8)
%27 = icmp eq i32 %26, -1
br i1 %27, label %28, label %32
28: ; preds = %25
%29 = load i32, i32* @errno
%30 = call i32 @strerror(i32 %29)
%31 = call i32 @err_exit(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i32 %30)
br label %32
32: ; preds = %28, %25
%33 = load i32, i32* %6
%34 = load i32, i32* %7
%35 = load i32, i32* %8
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str.1, i64 0, i64 0), i32 %33, i32 %34, i32 %35)
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%38 = load i32, i32* %9
%39 = load i32, i32* %10
%40 = load i32, i32* %11
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str.3, i64 0, i64 0), i32 %38, i32 %39, i32 %40)
%42 = load i32, i32* @EXIT_SUCCESS
%43 = call i32 @exit(i32 %42)
unreachable
}

LLVM IR (-O2):
@.str = [24 x i8] c"Error on getresuid, %s\0A\00"
@errno = global i32 0
@.str.1 = [62 x i8] c"Real User ID: %d\0AEffective User ID: %d\0ASaved Set User ID: %d\0A\00"
@.str.3 = [65 x i8] c"Real Group ID: %d\0AEffective Group ID: %d\0ASaved Set Group ID: %d\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = bitcast i32* %3 to i8*
%10 = bitcast i32* %4 to i8*
%11 = bitcast i32* %5 to i8*
%12 = bitcast i32* %6 to i8*
%13 = bitcast i32* %7 to i8*
%14 = bitcast i32* %8 to i8*
%15 = call i32 @getresuid(i32* %3, i32* %4, i32* %5)
%16 = icmp eq i32 %15, -1
br i1 %16, label %17, label %21
17: ; preds = %2
%18 = load i32, i32* @errno
%19 = call i32 @strerror(i32 %18)
%20 = call i32 @err_exit(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i32 %19)
br label %21
21: ; preds = %17, %2
%22 = call i32 @getresgid(i32* %6, i32* %7, i32* %8)
%23 = icmp eq i32 %22, -1
br i1 %23, label %24, label %28
24: ; preds = %21
%25 = load i32, i32* @errno
%26 = call i32 @strerror(i32 %25)
%27 = call i32 @err_exit(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i32 %26)
br label %28
28: ; preds = %24, %21
%29 = call i32 @getresuid(i32* %3, i32* %4, i32* %5)
%30 = icmp eq i32 %29, -1
br i1 %30, label %31, label %35
31: ; preds = %28
%32 = load i32, i32* @errno
%33 = call i32 @strerror(i32 %32)
%34 = call i32 @err_exit(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i32 %33)
br label %35
35: ; preds = %31, %28
%36 = load i32, i32* %3
%37 = load i32, i32* %4
%38 = load i32, i32* %5
%39 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([62 x i8], [62 x i8]* @.str.1, i64 0, i64 0), i32 %36, i32 %37, i32 %38)
%40 = call i32 @putchar(i32 10)
%41 = load i32, i32* %6
%42 = load i32, i32* %7
%43 = load i32, i32* %8
%44 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([65 x i8], [65 x i8]* @.str.3, i64 0, i64 0), i32 %41, i32 %42, i32 %43)
%45 = load i32, i32* @EXIT_SUCCESS
%46 = call i32 @exit(i32 %45)
unreachable
}