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

/* Variables and functions */
int getegid();
int geteuid();
int getgid();
int getpid();
int getppid();
int getsid(int);
int getuid();
int /*<<< orphan*/ printf(char *, int, ...);
int main(int args, char *argv[]) {
  pid_t pid = getpid();
  pid_t ppid = getppid();
  printf("My pid is: %u, and my parent's: %u\n", pid, ppid);
  gid_t gid = getgid();
  gid_t egid = getegid();
  printf("My group's id is: %u, and my parent's: %u\n", gid, egid);
  pid_t sid = getsid(pid);
  printf("My session's id is:%d\n", sid);
  uid_t euid = geteuid();
  uid_t uid = getuid();
  printf("My effective usser id is: %u, and real is : %u", euid, uid);
  return 0;
}


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)
mov    $0x0,%al
call   1030 <getpid@plt>
mov    %eax,-0x14(%rbp)
mov    $0x0,%al
call   10a0 <getppid@plt>
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
lea    0xe49(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x0,%al
call   1080 <getgid@plt>
mov    %eax,-0x1c(%rbp)
mov    $0x0,%al
call   1090 <getegid@plt>
mov    %eax,-0x20(%rbp)
mov    -0x1c(%rbp),%esi
mov    -0x20(%rbp),%edx
lea    0xe45(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x14(%rbp),%edi
call   1060 <getsid@plt>
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%esi
lea    0xe54(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x0,%al
call   1070 <geteuid@plt>
mov    %eax,-0x28(%rbp)
mov    $0x0,%al
call   1040 <getuid@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x28(%rbp),%esi
mov    -0x2c(%rbp),%edx
lea    0xe43(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
xor    %eax,%eax
call   1030 <getpid@plt>
mov    %eax,%ebx
xor    %eax,%eax
call   10a0 <getppid@plt>
lea    0xe66(%rip),%rdi
mov    %ebx,%esi
mov    %eax,%edx
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
call   1080 <getgid@plt>
mov    %eax,%ebp
xor    %eax,%eax
call   1090 <getegid@plt>
lea    0xe68(%rip),%rdi
mov    %ebp,%esi
mov    %eax,%edx
xor    %eax,%eax
call   1050 <printf@plt>
mov    %ebx,%edi
call   1060 <getsid@plt>
lea    0xe7a(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
call   1070 <geteuid@plt>
mov    %eax,%ebx
xor    %eax,%eax
call   1040 <getuid@plt>
lea    0xe71(%rip),%rdi
mov    %ebx,%esi
mov    %eax,%edx
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [36 x i8] c"My pid is: %u, and my parent's: %u\0A\00"
@.str.1 = [43 x i8] c"My group's id is: %u, and my parent's: %u\0A\00"
@.str.2 = [23 x i8] c"My session's id is:%d\0A\00"
@.str.3 = [47 x i8] c"My effective usser id is: %u, and real is : %u\00"
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
%12 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%13 = call i32 (...) @getpid()
store i32 %13, i32* %6
%14 = call i32 (...) @getppid()
store i32 %14, i32* %7
%15 = load i32, i32* %6
%16 = load i32, i32* %7
%17 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), i32 %15, i32 %16)
%18 = call i32 (...) @getgid()
store i32 %18, i32* %8
%19 = call i32 (...) @getegid()
store i32 %19, i32* %9
%20 = load i32, i32* %8
%21 = load i32, i32* %9
%22 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.1, i64 0, i64 0), i32 %20, i32 %21)
%23 = load i32, i32* %6
%24 = call i32 @getsid(i32 %23)
store i32 %24, i32* %10
%25 = load i32, i32* %10
%26 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i32 %25)
%27 = call i32 (...) @geteuid()
store i32 %27, i32* %11
%28 = call i32 (...) @getuid()
store i32 %28, i32* %12
%29 = load i32, i32* %11
%30 = load i32, i32* %12
%31 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.3, i64 0, i64 0), i32 %29, i32 %30)
ret i32 0
}

LLVM IR (-O2):
@.str = [36 x i8] c"My pid is: %u, and my parent's: %u\0A\00"
@.str.1 = [43 x i8] c"My group's id is: %u, and my parent's: %u\0A\00"
@.str.2 = [23 x i8] c"My session's id is:%d\0A\00"
@.str.3 = [47 x i8] c"My effective usser id is: %u, and real is : %u\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32 (...) @getpid()
%4 = tail call i32 (...) @getppid()
%5 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), i32 %3, i32 %4)
%6 = tail call i32 (...) @getgid()
%7 = tail call i32 (...) @getegid()
%8 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.1, i64 0, i64 0), i32 %6, i32 %7)
%9 = tail call i32 @getsid(i32 %3)
%10 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i32 %9)
%11 = tail call i32 (...) @geteuid()
%12 = tail call i32 (...) @getuid()
%13 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.3, i64 0, i64 0), i32 %11, i32 %12)
ret i32 0
}