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

/* Variables and functions */
int getresgid(scalar_t__ *, scalar_t__ *, scalar_t__ *);
int getresuid(scalar_t__ *, scalar_t__ *, scalar_t__ *);
int /*<<< orphan*/ printf(char *, int, int, int, int);
int main(void) {
  uid_t ruid, euid, suid;
  gid_t rgid, egid, sgid;
  int rc;
  rc = getresuid(&ruid, &euid, &suid);
  printf("getresuid(%d): ruid=%d, euid=%d, suid=%d\n", rc, (int)ruid, (int)euid,
         (int)suid);
  rc = getresgid(&rgid, &egid, &sgid);
  printf("getresgid(%d): rgid=%d, egid=%d, sgid=%d\n", rc, (int)rgid, (int)egid,
         (int)sgid);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x10(%rbp),%rdi
lea    -0x18(%rbp),%rsi
lea    -0x20(%rbp),%rdx
call   1050 <getresuid@plt>
mov    %eax,-0x3c(%rbp)
mov    -0x3c(%rbp),%esi
mov    -0x10(%rbp),%rax
mov    %eax,%edx
mov    -0x18(%rbp),%rax
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
mov    %eax,%r8d
lea    0xe90(%rip),%rdi
call   1040 <printf@plt>
lea    -0x28(%rbp),%rdi
lea    -0x30(%rbp),%rsi
lea    -0x38(%rbp),%rdx
call   1030 <getresgid@plt>
mov    %eax,-0x3c(%rbp)
mov    -0x3c(%rbp),%esi
mov    -0x28(%rbp),%rax
mov    %eax,%edx
mov    -0x30(%rbp),%rax
mov    %eax,%ecx
mov    -0x38(%rbp),%rax
mov    %eax,%r8d
lea    0xe84(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x38,%rsp
lea    0x30(%rsp),%rdi
lea    0x28(%rsp),%rsi
lea    0x20(%rsp),%rdx
call   1050 <getresuid@plt>
mov    0x30(%rsp),%edx
mov    0x28(%rsp),%ecx
mov    0x20(%rsp),%r8d
lea    0xea4(%rip),%rdi
mov    %eax,%esi
call   1040 <printf@plt>
lea    0x18(%rsp),%rdi
lea    0x10(%rsp),%rsi
lea    0x8(%rsp),%rdx
call   1030 <getresgid@plt>
mov    0x18(%rsp),%edx
mov    0x10(%rsp),%ecx
mov    0x8(%rsp),%r8d
lea    0xe9f(%rip),%rdi
mov    %eax,%esi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x38,%rsp
ret

LLVM IR (-O0):
@.str = [42 x i8] c"getresuid(%d): ruid=%d, euid=%d, suid=%d\0A\00"
@.str.1 = [42 x i8] c"getresgid(%d): rgid=%d, egid=%d, sgid=%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i64
%3 = alloca i64
%4 = alloca i64
%5 = alloca i64
%6 = alloca i64
%7 = alloca i64
%8 = alloca i32
store i32 0, i32* %1
%9 = call i32 @getresuid(i64* %2, i64* %3, i64* %4)
store i32 %9, i32* %8
%10 = load i32, i32* %8
%11 = load i64, i64* %2
%12 = trunc i64 %11 to i32
%13 = load i64, i64* %3
%14 = trunc i64 %13 to i32
%15 = load i64, i64* %4
%16 = trunc i64 %15 to i32
%17 = call i32 @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0), i32 %10, i32 %12, i32 %14, i32 %16)
%18 = call i32 @getresgid(i64* %5, i64* %6, i64* %7)
store i32 %18, i32* %8
%19 = load i32, i32* %8
%20 = load i64, i64* %5
%21 = trunc i64 %20 to i32
%22 = load i64, i64* %6
%23 = trunc i64 %22 to i32
%24 = load i64, i64* %7
%25 = trunc i64 %24 to i32
%26 = call i32 @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.1, i64 0, i64 0), i32 %19, i32 %21, i32 %23, i32 %25)
ret i32 0
}

LLVM IR (-O2):
@.str = [42 x i8] c"getresuid(%d): ruid=%d, euid=%d, suid=%d\0A\00"
@.str.1 = [42 x i8] c"getresgid(%d): rgid=%d, egid=%d, sgid=%d\0A\00"
define i32 @main() {
%1 = alloca i64
%2 = alloca i64
%3 = alloca i64
%4 = alloca i64
%5 = alloca i64
%6 = alloca i64
%7 = bitcast i64* %1 to i8*
%8 = bitcast i64* %2 to i8*
%9 = bitcast i64* %3 to i8*
%10 = bitcast i64* %4 to i8*
%11 = bitcast i64* %5 to i8*
%12 = bitcast i64* %6 to i8*
%13 = call i32 @getresuid(i64* %1, i64* %2, i64* %3)
%14 = load i64, i64* %1
%15 = trunc i64 %14 to i32
%16 = load i64, i64* %2
%17 = trunc i64 %16 to i32
%18 = load i64, i64* %3
%19 = trunc i64 %18 to i32
%20 = call i32 @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0), i32 %13, i32 %15, i32 %17, i32 %19)
%21 = call i32 @getresgid(i64* %4, i64* %5, i64* %6)
%22 = load i64, i64* %4
%23 = trunc i64 %22 to i32
%24 = load i64, i64* %5
%25 = trunc i64 %24 to i32
%26 = load i64, i64* %6
%27 = trunc i64 %26 to i32
%28 = call i32 @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.1, i64 0, i64 0), i32 %21, i32 %23, i32 %25, i32 %27)
ret i32 0
}