#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 pid_t;

/* Variables and functions */
int getegid();
int geteuid();
int getgid();
int getpid();
int getppid();
int getuid();
int /*<<< orphan*/ printf(char *, int);
int main() {
  pid_t pid, ppid, uid, euid, gid, egid;
  pid = getpid();
  ppid = getppid();
  uid = getuid();
  euid = geteuid();
  gid = getgid();
  egid = getegid();
  printf("id of current process : %u\n", pid);
  printf("parent id of current process : %u\n", ppid);
  printf("user id of current process : %u\n", uid);
  printf("effective user id of current process : %u\n", euid);
  printf("group id of current process : %u\n", gid);
  printf("effective group id of current process : %u\n", egid);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1030 <getpid@plt>
mov    %eax,-0x8(%rbp)
mov    $0x0,%al
call   1090 <getppid@plt>
mov    %eax,-0xc(%rbp)
mov    $0x0,%al
call   1040 <getuid@plt>
mov    %eax,-0x10(%rbp)
mov    $0x0,%al
call   1060 <geteuid@plt>
mov    %eax,-0x14(%rbp)
mov    $0x0,%al
call   1070 <getgid@plt>
mov    %eax,-0x18(%rbp)
mov    $0x0,%al
call   1080 <getegid@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%esi
lea    0xe99(%rip),%rdi
call   1050 <printf@plt>
mov    -0xc(%rbp),%esi
lea    0xe2c(%rip),%rdi
call   1050 <printf@plt>
mov    -0x10(%rbp),%esi
lea    0xe4a(%rip),%rdi
call   1050 <printf@plt>
mov    -0x14(%rbp),%esi
lea    0xe31(%rip),%rdi
call   1050 <printf@plt>
mov    -0x18(%rbp),%esi
lea    0xe57(%rip),%rdi
call   1050 <printf@plt>
mov    -0x1c(%rbp),%esi
lea    0xe3e(%rip),%rdi
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
xor    %eax,%eax
call   1030 <getpid@plt>
mov    %eax,%ebx
xor    %eax,%eax
call   1090 <getppid@plt>
mov    %eax,%ebp
xor    %eax,%eax
call   1040 <getuid@plt>
mov    %eax,%r13d
xor    %eax,%eax
call   1060 <geteuid@plt>
mov    %eax,%r12d
xor    %eax,%eax
call   1070 <getgid@plt>
mov    %eax,%r15d
xor    %eax,%eax
call   1080 <getegid@plt>
mov    %eax,%r14d
lea    0xea2(%rip),%rdi
mov    %ebx,%esi
call   1050 <printf@plt>
lea    0xe36(%rip),%rdi
mov    %ebp,%esi
call   1050 <printf@plt>
lea    0xe55(%rip),%rdi
mov    %r13d,%esi
call   1050 <printf@plt>
lea    0xe3c(%rip),%rdi
mov    %r12d,%esi
call   1050 <printf@plt>
lea    0xe62(%rip),%rdi
mov    %r15d,%esi
call   1050 <printf@plt>
lea    0xe49(%rip),%rdi
mov    %r14d,%esi
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [28 x i8] c"id of current process : %u\0A\00"
@.str.1 = [35 x i8] c"parent id of current process : %u\0A\00"
@.str.2 = [33 x i8] c"user id of current process : %u\0A\00"
@.str.3 = [43 x i8] c"effective user id of current process : %u\0A\00"
@.str.4 = [34 x i8] c"group id of current process : %u\0A\00"
@.str.5 = [44 x i8] c"effective group id of current process : %u\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %1
%8 = call i32 (...) @getpid()
store i32 %8, i32* %2
%9 = call i32 (...) @getppid()
store i32 %9, i32* %3
%10 = call i32 (...) @getuid()
store i32 %10, i32* %4
%11 = call i32 (...) @geteuid()
store i32 %11, i32* %5
%12 = call i32 (...) @getgid()
store i32 %12, i32* %6
%13 = call i32 (...) @getegid()
store i32 %13, i32* %7
%14 = load i32, i32* %2
%15 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i32 %14)
%16 = load i32, i32* %3
%17 = call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0), i32 %16)
%18 = load i32, i32* %4
%19 = call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0), i32 %18)
%20 = load i32, i32* %5
%21 = call i32 @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.3, i64 0, i64 0), i32 %20)
%22 = load i32, i32* %6
%23 = call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.4, i64 0, i64 0), i32 %22)
%24 = load i32, i32* %7
%25 = call i32 @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.5, i64 0, i64 0), i32 %24)
ret i32 0
}

LLVM IR (-O2):
@.str = [28 x i8] c"id of current process : %u\0A\00"
@.str.1 = [35 x i8] c"parent id of current process : %u\0A\00"
@.str.2 = [33 x i8] c"user id of current process : %u\0A\00"
@.str.3 = [43 x i8] c"effective user id of current process : %u\0A\00"
@.str.4 = [34 x i8] c"group id of current process : %u\0A\00"
@.str.5 = [44 x i8] c"effective group id of current process : %u\0A\00"
define i32 @main() {
%1 = tail call i32 (...) @getpid()
%2 = tail call i32 (...) @getppid()
%3 = tail call i32 (...) @getuid()
%4 = tail call i32 (...) @geteuid()
%5 = tail call i32 (...) @getgid()
%6 = tail call i32 (...) @getegid()
%7 = tail call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i32 %1)
%8 = tail call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0), i32 %2)
%9 = tail call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0), i32 %3)
%10 = tail call i32 @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.3, i64 0, i64 0), i32 %4)
%11 = tail call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.4, i64 0, i64 0), i32 %5)
%12 = tail call i32 @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.5, i64 0, i64 0), i32 %6)
ret i32 0
}