#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");
  printf("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)
lea    0xe55(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
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    0xdf1(%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   1050 <getuid@plt>
mov    %eax,%ebx
xor    %eax,%eax
call   1080 <getgid@plt>
mov    %eax,%ebp
xor    %eax,%eax
call   1090 <getlogin@plt>
lea    0xe5d(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xe58(%rip),%rdi
mov    %ebx,%esi
mov    %ebp,%edx
xor    %eax,%eax
call   1060 <printf@plt>
mov    %ebx,%edi
call   1040 <getpwuid@plt>
mov    (%rax),%rsi
mov    0x8(%rax),%edx
mov    0xc(%rax),%ecx
mov    0x10(%rax),%r8
mov    0x18(%rax),%r9
lea    0xe48(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xe79(%rip),%rdi
call   1070 <getpwnam@plt>
mov    %rax,%rbx
lea    0xe6f(%rip),%rdi
call   1030 <puts@plt>
mov    (%rbx),%rsi
mov    0x8(%rbx),%edx
mov    0xc(%rbx),%ecx
mov    0x10(%rbx),%r8
mov    0x18(%rbx),%r9
lea    0xe21(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
xor    %edi,%edi
call   10a0 <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 = [20 x i8] c"root passwd entry:\0A\00"
@.str.5 = [44 x i8] c"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 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0))
%32 = load %struct.passwd*, %struct.passwd** %4
%33 = getelementptr inbounds %struct.passwd, %struct.passwd* %32, i32 0, i32 0
%34 = load i8*, i8** %33
%35 = load %struct.passwd*, %struct.passwd** %4
%36 = getelementptr inbounds %struct.passwd, %struct.passwd* %35, i32 0, i32 1
%37 = load i32, i32* %36
%38 = load %struct.passwd*, %struct.passwd** %4
%39 = getelementptr inbounds %struct.passwd, %struct.passwd* %38, i32 0, i32 2
%40 = load i32, i32* %39
%41 = load %struct.passwd*, %struct.passwd** %4
%42 = getelementptr inbounds %struct.passwd, %struct.passwd* %41, i32 0, i32 3
%43 = load i8*, i8** %42
%44 = load %struct.passwd*, %struct.passwd** %4
%45 = getelementptr inbounds %struct.passwd, %struct.passwd* %44, i32 0, i32 4
%46 = load i8*, i8** %45
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.5, i64 0, i64 0), i8* %34, i32 %37, i32 %40, i8* %43, i8* %46)
%48 = 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.5 = [44 x i8] c"name=%s, uid=%d, gid=%d, home=%s, shell=%s\0A\00"
@str = [19 x i8] c"root passwd entry:\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 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str, i64 0, i64 0))
%20 = getelementptr inbounds %struct.passwd, %struct.passwd* %18, i64 0, i32 0
%21 = load i8*, i8** %20
%22 = getelementptr inbounds %struct.passwd, %struct.passwd* %18, i64 0, i32 1
%23 = load i32, i32* %22
%24 = getelementptr inbounds %struct.passwd, %struct.passwd* %18, i64 0, i32 2
%25 = load i32, i32* %24
%26 = getelementptr inbounds %struct.passwd, %struct.passwd* %18, i64 0, i32 3
%27 = load i8*, i8** %26
%28 = getelementptr inbounds %struct.passwd, %struct.passwd* %18, i64 0, i32 4
%29 = load i8*, i8** %28
%30 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @.str.5, i64 0, i64 0), i8* %21, i32 %23, i32 %25, i8* %27, i8* %29)
%31 = tail call i32 @exit(i32 0)
unreachable
}