#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;
  int pw_uid;
  int pw_gid;
  char *pw_dir;
  char *pw_shell;
};
typedef int gid_t;

/* Variables and functions */
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int getgid();
char *getlogin();
struct passwd *getpwnam(char *);
struct passwd *getpwuid(int);
int getuid();
int /*<<< orphan*/ printf(char *, ...);
int main() {
  uid_t uid;
  gid_t gid;
  struct passwd *pw;
  uid = getuid();
  gid = getgid();
  printf("User is %s\n", getlogin());
  printf("User IDs: uid=%d, gid=%d\n", uid, gid);
  pw = getpwuid(uid);
  printf("UID passwd entry:\n name=%s, uid=%d, gid=%d, home=%s, shell=%s\n",
         pw->pw_name, pw->pw_uid, pw->pw_gid, pw->pw_dir, pw->pw_shell);
  pw = getpwnam("root");
  printf("root passwd entry:\n name=%s, uid=%d, gid=%d, home=%s, shell=%s\n",
         pw->pw_name, pw->pw_uid, pw->pw_gid, pw->pw_dir, pw->pw_shell);
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1040 <getuid@plt>
mov    %eax,-0x8(%rbp)
mov    $0x0,%al
call   1070 <getgid@plt>
mov    %eax,-0xc(%rbp)
mov    $0x0,%al
call   1080 <getlogin@plt>
mov    %rax,%rsi
lea    0xe5c(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
lea    0xe54(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x8(%rbp),%edi
call   1030 <getpwuid@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%rsi
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%edx
mov    -0x18(%rbp),%rax
mov    0xc(%rax),%ecx
mov    -0x18(%rbp),%rax
mov    0x10(%rax),%r8
mov    -0x18(%rbp),%rax
mov    0x18(%rax),%r9
lea    0xe2f(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xe60(%rip),%rdi
call   1060 <getpwnam@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%rsi
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%edx
mov    -0x18(%rbp),%rax
mov    0xc(%rax),%ecx
mov    -0x18(%rbp),%rax
mov    0x10(%rax),%r8
mov    -0x18(%rbp),%rax
mov    0x18(%rax),%r9
lea    0xe30(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
xor    %edi,%edi
call   1090 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
xor    %eax,%eax
call   1040 <getuid@plt>
mov    %eax,%ebx
xor    %eax,%eax
call   1070 <getgid@plt>
mov    %eax,%ebp
xor    %eax,%eax
call   1080 <getlogin@plt>
lea    0xe6d(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe68(%rip),%rdi
mov    %ebx,%esi
mov    %ebp,%edx
xor    %eax,%eax
call   1050 <printf@plt>
mov    %ebx,%edi
call   1030 <getpwuid@plt>
mov    (%rax),%rsi
mov    0x8(%rax),%edx
mov    0xc(%rax),%ecx
mov    0x10(%rax),%r8
mov    0x18(%rax),%r9
lea    0xe58(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe89(%rip),%rdi
call   1060 <getpwnam@plt>
mov    (%rax),%rsi
mov    0x8(%rax),%edx
mov    0xc(%rax),%ecx
mov    0x10(%rax),%r8
mov    0x18(%rax),%r9
lea    0xe71(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %edi,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
%struct.passwd = type { i8*, i32, i32, i8*, i8* }
@.str = [12 x i8] c"User is %s\0A\00"
@.str.1 = [26 x i8] c"User IDs: uid=%d, gid=%d\0A\00"
@.str.2 = [63 x i8] c"UID passwd entry:\0A name=%s, uid=%d, gid=%d, home=%s, shell=%s\0A\00"
@.str.3 = [5 x i8] c"root\00"
@.str.4 = [64 x i8] c"root passwd entry:\0A name=%s, uid=%d, gid=%d, home=%s, shell=%s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca %struct.passwd*
store i32 0, i32* %1
%5 = call i32 (...) @getuid()
store i32 %5, i32* %2
%6 = call i32 (...) @getgid()
store i32 %6, i32* %3
%7 = call i8* (...) @getlogin()
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* %7)
%9 = load i32, i32* %2
%10 = load i32, i32* %3
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i32 %9, i32 %10)
%12 = load i32, i32* %2
%13 = call %struct.passwd* @getpwuid(i32 %12)
store %struct.passwd* %13, %struct.passwd** %4
%14 = load %struct.passwd*, %struct.passwd** %4
%15 = getelementptr inbounds %struct.passwd, %struct.passwd* %14, i32 0, i32 0
%16 = load i8*, i8** %15
%17 = load %struct.passwd*, %struct.passwd** %4
%18 = getelementptr inbounds %struct.passwd, %struct.passwd* %17, i32 0, i32 1
%19 = load i32, i32* %18
%20 = load %struct.passwd*, %struct.passwd** %4
%21 = getelementptr inbounds %struct.passwd, %struct.passwd* %20, i32 0, i32 2
%22 = load i32, i32* %21
%23 = load %struct.passwd*, %struct.passwd** %4
%24 = getelementptr inbounds %struct.passwd, %struct.passwd* %23, i32 0, i32 3
%25 = load i8*, i8** %24
%26 = load %struct.passwd*, %struct.passwd** %4
%27 = getelementptr inbounds %struct.passwd, %struct.passwd* %26, i32 0, i32 4
%28 = load i8*, i8** %27
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([63 x i8], [63 x i8]* @.str.2, i64 0, i64 0), i8* %16, i32 %19, i32 %22, i8* %25, i8* %28)
%30 = call %struct.passwd* @getpwnam(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
store %struct.passwd* %30, %struct.passwd** %4
%31 = load %struct.passwd*, %struct.passwd** %4
%32 = getelementptr inbounds %struct.passwd, %struct.passwd* %31, i32 0, i32 0
%33 = load i8*, i8** %32
%34 = load %struct.passwd*, %struct.passwd** %4
%35 = getelementptr inbounds %struct.passwd, %struct.passwd* %34, i32 0, i32 1
%36 = load i32, i32* %35
%37 = load %struct.passwd*, %struct.passwd** %4
%38 = getelementptr inbounds %struct.passwd, %struct.passwd* %37, i32 0, i32 2
%39 = load i32, i32* %38
%40 = load %struct.passwd*, %struct.passwd** %4
%41 = getelementptr inbounds %struct.passwd, %struct.passwd* %40, i32 0, i32 3
%42 = load i8*, i8** %41
%43 = load %struct.passwd*, %struct.passwd** %4
%44 = getelementptr inbounds %struct.passwd, %struct.passwd* %43, i32 0, i32 4
%45 = load i8*, i8** %44
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([64 x i8], [64 x i8]* @.str.4, i64 0, i64 0), i8* %33, i32 %36, i32 %39, i8* %42, i8* %45)
%47 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
%struct.passwd = type { i8*, i32, i32, i8*, i8* }
@.str = [12 x i8] c"User is %s\0A\00"
@.str.1 = [26 x i8] c"User IDs: uid=%d, gid=%d\0A\00"
@.str.2 = [63 x i8] c"UID passwd entry:\0A name=%s, uid=%d, gid=%d, home=%s, shell=%s\0A\00"
@.str.3 = [5 x i8] c"root\00"
@.str.4 = [64 x i8] c"root passwd entry:\0A name=%s, uid=%d, gid=%d, home=%s, shell=%s\0A\00"
define i32 @main() {
%1 = tail call i32 (...) @getuid()
%2 = tail call i32 (...) @getgid()
%3 = tail call i8* (...) @getlogin()
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* %3)
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i32 %1, i32 %2)
%6 = tail call %struct.passwd* @getpwuid(i32 %1)
%7 = getelementptr inbounds %struct.passwd, %struct.passwd* %6, i64 0, i32 0
%8 = load i8*, i8** %7
%9 = getelementptr inbounds %struct.passwd, %struct.passwd* %6, i64 0, i32 1
%10 = load i32, i32* %9
%11 = getelementptr inbounds %struct.passwd, %struct.passwd* %6, i64 0, i32 2
%12 = load i32, i32* %11
%13 = getelementptr inbounds %struct.passwd, %struct.passwd* %6, i64 0, i32 3
%14 = load i8*, i8** %13
%15 = getelementptr inbounds %struct.passwd, %struct.passwd* %6, i64 0, i32 4
%16 = load i8*, i8** %15
%17 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([63 x i8], [63 x i8]* @.str.2, i64 0, i64 0), i8* %8, i32 %10, i32 %12, i8* %14, i8* %16)
%18 = tail call %struct.passwd* @getpwnam(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%19 = getelementptr inbounds %struct.passwd, %struct.passwd* %18, i64 0, i32 0
%20 = load i8*, i8** %19
%21 = getelementptr inbounds %struct.passwd, %struct.passwd* %18, i64 0, i32 1
%22 = load i32, i32* %21
%23 = getelementptr inbounds %struct.passwd, %struct.passwd* %18, i64 0, i32 2
%24 = load i32, i32* %23
%25 = getelementptr inbounds %struct.passwd, %struct.passwd* %18, i64 0, i32 3
%26 = load i8*, i8** %25
%27 = getelementptr inbounds %struct.passwd, %struct.passwd* %18, i64 0, i32 4
%28 = load i8*, i8** %27
%29 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([64 x i8], [64 x i8]* @.str.4, i64 0, i64 0), i8* %20, i32 %22, i32 %24, i8* %26, i8* %28)
%30 = tail call i32 @exit(i32 0)
unreachable
}