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

/* Variables and functions */
int /*<<< orphan*/ endpwent();
int getgid();
char *getlogin();
struct passwd *getpwent();
struct passwd *getpwnam(char *);
int getuid();
int /*<<< orphan*/ printf(char *, ...);
int main() {
  uid_t uid;
  gid_t gid;
  uid = getuid();
  gid = getgid();
  printf("user name: %s \n", getlogin());
  printf("uid = %d\n", uid);
  printf("gid = %d\n", gid);
  struct passwd *user;
  user = getpwent();
  while (user != NULL) {
    printf("%s:%d:%d:%s:%s:%s\n", user->pw_name, user->pw_uid, user->pw_gid,
           user->pw_gecos, user->pw_dir, user->pw_shell);
    user = getpwent();
  }
  endpwent();
  user = getpwnam("root");
  printf("%s:%d:%d:%s:%s:%s\n", user->pw_name, user->pw_uid, user->pw_gid,
         user->pw_gecos, user->pw_dir, user->pw_shell);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1030 <getuid@plt>
mov    %eax,-0x8(%rbp)
mov    $0x0,%al
call   1070 <getgid@plt>
mov    %eax,-0xc(%rbp)
mov    $0x0,%al
call   1090 <getlogin@plt>
mov    %rax,%rsi
lea    0xe5c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%esi
lea    0xe5b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0xc(%rbp),%esi
lea    0xe54(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1060 <getpwent@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     1232 <main+0xc2>
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
mov    -0x18(%rbp),%rax
mov    0x20(%rax),%rax
lea    0xe0d(%rip),%rdi
mov    %rax,(%rsp)
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1060 <getpwent@plt>
mov    %rax,-0x18(%rbp)
jmp    11d8 <main+0x68>
mov    $0x0,%al
call   1080 <endpwent@plt>
lea    0xdf7(%rip),%rdi
call   1050 <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
mov    -0x18(%rbp),%rax
mov    0x20(%rax),%rax
lea    0xda7(%rip),%rdi
mov    %rax,(%rsp)
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
xor    %eax,%eax
call   1030 <getuid@plt>
mov    %eax,%ebx
xor    %eax,%eax
call   1070 <getgid@plt>
mov    %eax,%ebp
xor    %eax,%eax
call   1090 <getlogin@plt>
lea    0xe6d(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe6c(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe66(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
call   1060 <getpwent@plt>
test   %rax,%rax
je     11ff <main+0x8f>
lea    0xe54(%rip),%rbx
mov    (%rax),%rsi
mov    0x8(%rax),%edx
mov    0xc(%rax),%ecx
mov    0x10(%rax),%r8
mov    0x18(%rax),%r9
mov    0x20(%rax),%rax
mov    %rax,(%rsp)
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
call   1060 <getpwent@plt>
test   %rax,%rax
jne    11d0 <main+0x60>
xor    %eax,%eax
call   1080 <endpwent@plt>
lea    0xe2a(%rip),%rdi
call   1050 <getpwnam@plt>
mov    (%rax),%rsi
mov    0x8(%rax),%edx
mov    0xc(%rax),%ecx
mov    0x10(%rax),%r8
mov    0x18(%rax),%r9
mov    0x20(%rax),%rax
mov    %rax,(%rsp)
lea    0xdf2(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
%struct.passwd = type { i8*, i32, i32, i8*, i8*, i8* }
@.str = [16 x i8] c"user name: %s \0A\00"
@.str.1 = [10 x i8] c"uid = %d\0A\00"
@.str.2 = [10 x i8] c"gid = %d\0A\00"
@.str.3 = [19 x i8] c"%s:%d:%d:%s:%s:%s\0A\00"
@.str.4 = [5 x i8] c"root\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 ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* %7)
%9 = load i32, i32* %2
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32 %9)
%11 = load i32, i32* %3
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i32 %11)
%13 = call %struct.passwd* (...) @getpwent()
store %struct.passwd* %13, %struct.passwd** %4
br label %14
14: ; preds = %17, %0
%15 = load %struct.passwd*, %struct.passwd** %4
%16 = icmp ne %struct.passwd* %15, null
br i1 %16, label %17, label %38
17: ; preds = %14
%18 = load %struct.passwd*, %struct.passwd** %4
%19 = getelementptr inbounds %struct.passwd, %struct.passwd* %18, i32 0, i32 0
%20 = load i8*, i8** %19
%21 = load %struct.passwd*, %struct.passwd** %4
%22 = getelementptr inbounds %struct.passwd, %struct.passwd* %21, i32 0, i32 1
%23 = load i32, i32* %22
%24 = load %struct.passwd*, %struct.passwd** %4
%25 = getelementptr inbounds %struct.passwd, %struct.passwd* %24, i32 0, i32 2
%26 = load i32, i32* %25
%27 = load %struct.passwd*, %struct.passwd** %4
%28 = getelementptr inbounds %struct.passwd, %struct.passwd* %27, i32 0, i32 3
%29 = load i8*, i8** %28
%30 = load %struct.passwd*, %struct.passwd** %4
%31 = getelementptr inbounds %struct.passwd, %struct.passwd* %30, i32 0, i32 4
%32 = load i8*, i8** %31
%33 = load %struct.passwd*, %struct.passwd** %4
%34 = getelementptr inbounds %struct.passwd, %struct.passwd* %33, i32 0, i32 5
%35 = load i8*, i8** %34
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), i8* %20, i32 %23, i32 %26, i8* %29, i8* %32, i8* %35)
%37 = call %struct.passwd* (...) @getpwent()
store %struct.passwd* %37, %struct.passwd** %4
br label %14
38: ; preds = %14
%39 = call i32 (...) @endpwent()
%40 = call %struct.passwd* @getpwnam(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
store %struct.passwd* %40, %struct.passwd** %4
%41 = load %struct.passwd*, %struct.passwd** %4
%42 = getelementptr inbounds %struct.passwd, %struct.passwd* %41, i32 0, i32 0
%43 = load i8*, i8** %42
%44 = load %struct.passwd*, %struct.passwd** %4
%45 = getelementptr inbounds %struct.passwd, %struct.passwd* %44, i32 0, i32 1
%46 = load i32, i32* %45
%47 = load %struct.passwd*, %struct.passwd** %4
%48 = getelementptr inbounds %struct.passwd, %struct.passwd* %47, i32 0, i32 2
%49 = load i32, i32* %48
%50 = load %struct.passwd*, %struct.passwd** %4
%51 = getelementptr inbounds %struct.passwd, %struct.passwd* %50, i32 0, i32 3
%52 = load i8*, i8** %51
%53 = load %struct.passwd*, %struct.passwd** %4
%54 = getelementptr inbounds %struct.passwd, %struct.passwd* %53, i32 0, i32 4
%55 = load i8*, i8** %54
%56 = load %struct.passwd*, %struct.passwd** %4
%57 = getelementptr inbounds %struct.passwd, %struct.passwd* %56, i32 0, i32 5
%58 = load i8*, i8** %57
%59 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), i8* %43, i32 %46, i32 %49, i8* %52, i8* %55, i8* %58)
ret i32 0
}

LLVM IR (-O2):
%struct.passwd = type { i8*, i32, i32, i8*, i8*, i8* }
@.str = [16 x i8] c"user name: %s \0A\00"
@.str.1 = [10 x i8] c"uid = %d\0A\00"
@.str.2 = [10 x i8] c"gid = %d\0A\00"
@.str.3 = [19 x i8] c"%s:%d:%d:%s:%s:%s\0A\00"
@.str.4 = [5 x i8] c"root\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 ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* %3)
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32 %1)
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i32 %2)
%7 = tail call %struct.passwd* (...) @getpwent()
%8 = icmp eq %struct.passwd* %7, null
br i1 %8, label %26, label %9
9: ; preds = %0, %9
%10 = phi %struct.passwd* [ %24, %9 ], [ %7, %0 ]
%11 = getelementptr inbounds %struct.passwd, %struct.passwd* %10, i64 0, i32 0
%12 = load i8*, i8** %11
%13 = getelementptr inbounds %struct.passwd, %struct.passwd* %10, i64 0, i32 1
%14 = load i32, i32* %13
%15 = getelementptr inbounds %struct.passwd, %struct.passwd* %10, i64 0, i32 2
%16 = load i32, i32* %15
%17 = getelementptr inbounds %struct.passwd, %struct.passwd* %10, i64 0, i32 3
%18 = load i8*, i8** %17
%19 = getelementptr inbounds %struct.passwd, %struct.passwd* %10, i64 0, i32 4
%20 = load i8*, i8** %19
%21 = getelementptr inbounds %struct.passwd, %struct.passwd* %10, i64 0, i32 5
%22 = load i8*, i8** %21
%23 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), i8* %12, i32 %14, i32 %16, i8* %18, i8* %20, i8* %22)
%24 = tail call %struct.passwd* (...) @getpwent()
%25 = icmp eq %struct.passwd* %24, null
br i1 %25, label %26, label %9
26: ; preds = %9, %0
%27 = tail call i32 (...) @endpwent()
%28 = tail call %struct.passwd* @getpwnam(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%29 = getelementptr inbounds %struct.passwd, %struct.passwd* %28, i64 0, i32 0
%30 = load i8*, i8** %29
%31 = getelementptr inbounds %struct.passwd, %struct.passwd* %28, i64 0, i32 1
%32 = load i32, i32* %31
%33 = getelementptr inbounds %struct.passwd, %struct.passwd* %28, i64 0, i32 2
%34 = load i32, i32* %33
%35 = getelementptr inbounds %struct.passwd, %struct.passwd* %28, i64 0, i32 3
%36 = load i8*, i8** %35
%37 = getelementptr inbounds %struct.passwd, %struct.passwd* %28, i64 0, i32 4
%38 = load i8*, i8** %37
%39 = getelementptr inbounds %struct.passwd, %struct.passwd* %28, i64 0, i32 5
%40 = load i8*, i8** %39
%41 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), i8* %30, i32 %32, i32 %34, i8* %36, i8* %38, i8* %40)
ret i32 0
}