#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;
struct passwd {
  char *pw_name;
  char *pw_passwd;
  char *pw_gecos;
  char *pw_dir;
  char *pw_shell;
};
typedef int pid_t;
typedef int gid_t;

/* Variables and functions */
int EXIT_SUCCESS;
int getegid();
int geteuid();
int getgid();
int getpid();
int getppid();
struct passwd *getpwuid(int);
int getuid();
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char **argv) {
  pid_t pid = getpid();
  pid_t ppid = getppid();
  printf("Process Id:%d, Parent Process Id:%d\n", pid, ppid);
  uid_t uid = getuid();
  gid_t gid = getgid();
  uid_t euid = geteuid();
  gid_t egid = getegid();
  printf(
      "User Id:%d, Group Id:%d, Effective User Id:%d, Effective Group Id:%d\n",
      uid, gid, euid, egid);
  struct passwd *user_info = getpwuid(uid);
  printf("Login Name:%s, Login Password:%s, Real Name:%s, Home Dir:%s, Work "
         "Shell:%s\n",
         user_info->pw_name, user_info->pw_passwd, user_info->pw_gecos,
         user_info->pw_dir, user_info->pw_shell);
  return 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)
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   1060 <printf@plt>
mov    $0x0,%al
call   1050 <getuid@plt>
mov    %eax,-0x1c(%rbp)
mov    $0x0,%al
call   1080 <getgid@plt>
mov    %eax,-0x20(%rbp)
mov    $0x0,%al
call   1070 <geteuid@plt>
mov    %eax,-0x24(%rbp)
mov    $0x0,%al
call   1090 <getegid@plt>
mov    %eax,-0x28(%rbp)
mov    -0x1c(%rbp),%esi
mov    -0x20(%rbp),%edx
mov    -0x24(%rbp),%ecx
mov    -0x28(%rbp),%r8d
lea    0xe2b(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x1c(%rbp),%edi
call   1040 <getpwuid@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
mov    (%rax),%rsi
mov    -0x30(%rbp),%rax
mov    0x8(%rax),%rdx
mov    -0x30(%rbp),%rax
mov    0x10(%rax),%rcx
mov    -0x30(%rbp),%rax
mov    0x18(%rax),%r8
mov    -0x30(%rbp),%rax
mov    0x20(%rax),%r9
lea    0xe30(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    0x2d97(%rip),%rax
mov    (%rax),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
xor    %eax,%eax
call   1030 <getpid@plt>
mov    %eax,%ebx
xor    %eax,%eax
call   10a0 <getppid@plt>
lea    0xe65(%rip),%rdi
mov    %ebx,%esi
mov    %eax,%edx
xor    %eax,%eax
call   1060 <printf@plt>
xor    %eax,%eax
call   1050 <getuid@plt>
mov    %eax,%ebx
xor    %eax,%eax
call   1080 <getgid@plt>
mov    %eax,%r14d
xor    %eax,%eax
call   1070 <geteuid@plt>
mov    %eax,%ebp
xor    %eax,%eax
call   1090 <getegid@plt>
lea    0xe55(%rip),%rdi
mov    %ebx,%esi
mov    %r14d,%edx
mov    %ebp,%ecx
mov    %eax,%r8d
xor    %eax,%eax
call   1060 <printf@plt>
mov    %ebx,%edi
call   1040 <getpwuid@plt>
mov    (%rax),%rsi
mov    0x8(%rax),%rdx
mov    0x10(%rax),%rcx
mov    0x18(%rax),%r8
mov    0x20(%rax),%r9
lea    0xe69(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x2dd0(%rip),%rax
mov    (%rax),%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.passwd = type { i8*, i8*, i8*, i8*, i8* }
@.str = [37 x i8] c"Process Id:%d, Parent Process Id:%d\0A\00"
@.str.1 = [70 x i8] c"User Id:%d, Group Id:%d, Effective User Id:%d, Effective Group Id:%d\0A\00"
@.str.2 = [76 x i8] c"Login Name:%s, Login Password:%s, Real Name:%s, Home Dir:%s, Work Shell:%s\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
%12 = alloca %struct.passwd*
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*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0), i32 %15, i32 %16)
%18 = call i32 (...) @getuid()
store i32 %18, i32* %8
%19 = call i32 (...) @getgid()
store i32 %19, i32* %9
%20 = call i32 (...) @geteuid()
store i32 %20, i32* %10
%21 = call i32 (...) @getegid()
store i32 %21, i32* %11
%22 = load i32, i32* %8
%23 = load i32, i32* %9
%24 = load i32, i32* %10
%25 = load i32, i32* %11
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([70 x i8], [70 x i8]* @.str.1, i64 0, i64 0), i32 %22, i32 %23, i32 %24, i32 %25)
%27 = load i32, i32* %8
%28 = call %struct.passwd* @getpwuid(i32 %27)
store %struct.passwd* %28, %struct.passwd** %12
%29 = load %struct.passwd*, %struct.passwd** %12
%30 = getelementptr inbounds %struct.passwd, %struct.passwd* %29, i32 0, i32 0
%31 = load i8*, i8** %30
%32 = load %struct.passwd*, %struct.passwd** %12
%33 = getelementptr inbounds %struct.passwd, %struct.passwd* %32, i32 0, i32 1
%34 = load i8*, i8** %33
%35 = load %struct.passwd*, %struct.passwd** %12
%36 = getelementptr inbounds %struct.passwd, %struct.passwd* %35, i32 0, i32 2
%37 = load i8*, i8** %36
%38 = load %struct.passwd*, %struct.passwd** %12
%39 = getelementptr inbounds %struct.passwd, %struct.passwd* %38, i32 0, i32 3
%40 = load i8*, i8** %39
%41 = load %struct.passwd*, %struct.passwd** %12
%42 = getelementptr inbounds %struct.passwd, %struct.passwd* %41, i32 0, i32 4
%43 = load i8*, i8** %42
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([76 x i8], [76 x i8]* @.str.2, i64 0, i64 0), i8* %31, i8* %34, i8* %37, i8* %40, i8* %43)
%45 = load i32, i32* @EXIT_SUCCESS
ret i32 %45
}

LLVM IR (-O2):
%struct.passwd = type { i8*, i8*, i8*, i8*, i8* }
@.str = [37 x i8] c"Process Id:%d, Parent Process Id:%d\0A\00"
@.str.1 = [70 x i8] c"User Id:%d, Group Id:%d, Effective User Id:%d, Effective Group Id:%d\0A\00"
@.str.2 = [76 x i8] c"Login Name:%s, Login Password:%s, Real Name:%s, Home Dir:%s, Work Shell:%s\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32 (...) @getpid()
%4 = tail call i32 (...) @getppid()
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0), i32 %3, i32 %4)
%6 = tail call i32 (...) @getuid()
%7 = tail call i32 (...) @getgid()
%8 = tail call i32 (...) @geteuid()
%9 = tail call i32 (...) @getegid()
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([70 x i8], [70 x i8]* @.str.1, i64 0, i64 0), i32 %6, i32 %7, i32 %8, i32 %9)
%11 = tail call %struct.passwd* @getpwuid(i32 %6)
%12 = getelementptr inbounds %struct.passwd, %struct.passwd* %11, i64 0, i32 0
%13 = load i8*, i8** %12
%14 = getelementptr inbounds %struct.passwd, %struct.passwd* %11, i64 0, i32 1
%15 = load i8*, i8** %14
%16 = getelementptr inbounds %struct.passwd, %struct.passwd* %11, i64 0, i32 2
%17 = load i8*, i8** %16
%18 = getelementptr inbounds %struct.passwd, %struct.passwd* %11, i64 0, i32 3
%19 = load i8*, i8** %18
%20 = getelementptr inbounds %struct.passwd, %struct.passwd* %11, i64 0, i32 4
%21 = load i8*, i8** %20
%22 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([76 x i8], [76 x i8]* @.str.2, i64 0, i64 0), i8* %13, i8* %15, i8* %17, i8* %19, i8* %21)
%23 = load i32, i32* @EXIT_SUCCESS
ret i32 %23
}