#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 /*<<< orphan*/ uid_t;
struct spwd {
  char *sp_pwdp;
  char *sp_lstchg;
};
struct passwd {
  char *pw_name;
  char *pw_dir;
  char *pw_shell;
  char *pw_passwd;
};

/* Variables and functions */
struct passwd *getpwuid(int /*<<< orphan*/);
struct spwd *getspnam(char *);
int /*<<< orphan*/ name_to_uid(char *);
int /*<<< orphan*/ printf(char *, char *);
int main(int argc, char **argv) {
  struct passwd *userinfo;
  struct spwd *passw;
  uid_t userid;
  userinfo = getpwuid(name_to_uid(argv[1]));
  if (userinfo != NULL) {
    passw = getspnam(userinfo->pw_name);
    if (passw != NULL) {
      printf("user login: %s\n", userinfo->pw_name);
      printf("user home: %s\n", userinfo->pw_dir);
      printf("user shell: %s\n", userinfo->pw_shell);
      printf("user password: %s\n", userinfo->pw_passwd);
      printf("user shadow password: %s\n", passw->sp_pwdp);
      printf("user last change: %ld\n", passw->sp_lstchg);
    };
  };
  return 0;
}


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    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1050 <name_to_uid@plt>
mov    %eax,%edi
call   1030 <getpwuid@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     120f <main+0xcf>
mov    -0x18(%rbp),%rax
mov    (%rax),%rdi
call   1060 <getspnam@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     120a <main+0xca>
mov    -0x18(%rbp),%rax
mov    (%rax),%rsi
lea    0xe5e(%rip),%rdi
call   1040 <printf@plt>
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xe5a(%rip),%rdi
call   1040 <printf@plt>
mov    -0x18(%rbp),%rax
mov    0x10(%rax),%rsi
lea    0xe55(%rip),%rdi
call   1040 <printf@plt>
mov    -0x18(%rbp),%rax
mov    0x18(%rax),%rsi
lea    0xe51(%rip),%rdi
call   1040 <printf@plt>
mov    -0x20(%rbp),%rax
mov    (%rax),%rsi
lea    0xe51(%rip),%rdi
call   1040 <printf@plt>
mov    -0x20(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xe57(%rip),%rdi
call   1040 <printf@plt>
jmp    120f <main+0xcf>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
mov    0x8(%rsi),%rdi
call   1050 <name_to_uid@plt>
mov    %eax,%edi
call   1030 <getpwuid@plt>
test   %rax,%rax
je     11ca <main+0x8a>
mov    %rax,%rbx
mov    (%rax),%rdi
call   1060 <getspnam@plt>
test   %rax,%rax
je     11ca <main+0x8a>
mov    %rax,%r14
mov    (%rbx),%rsi
lea    0xe8a(%rip),%rdi
call   1040 <printf@plt>
mov    0x8(%rbx),%rsi
lea    0xe8a(%rip),%rdi
call   1040 <printf@plt>
mov    0x10(%rbx),%rsi
lea    0xe89(%rip),%rdi
call   1040 <printf@plt>
mov    0x18(%rbx),%rsi
lea    0xe89(%rip),%rdi
call   1040 <printf@plt>
mov    (%r14),%rsi
lea    0xe8d(%rip),%rdi
call   1040 <printf@plt>
mov    0x8(%r14),%rsi
lea    0xe97(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.passwd = type { i8*, i8*, i8*, i8* }
%struct.spwd = type { i8*, i8* }
@.str = [16 x i8] c"user login: %s\0A\00"
@.str.1 = [15 x i8] c"user home: %s\0A\00"
@.str.2 = [16 x i8] c"user shell: %s\0A\00"
@.str.3 = [19 x i8] c"user password: %s\0A\00"
@.str.4 = [26 x i8] c"user shadow password: %s\0A\00"
@.str.5 = [23 x i8] c"user last change: %ld\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %struct.passwd*
%7 = alloca %struct.spwd*
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i8**, i8*** %5
%10 = getelementptr inbounds i8*, i8** %9, i64 1
%11 = load i8*, i8** %10
%12 = call i32 @name_to_uid(i8* %11)
%13 = call %struct.passwd* @getpwuid(i32 %12)
store %struct.passwd* %13, %struct.passwd** %6
%14 = load %struct.passwd*, %struct.passwd** %6
%15 = icmp ne %struct.passwd* %14, null
br i1 %15, label %16, label %49
16: ; preds = %2
%17 = load %struct.passwd*, %struct.passwd** %6
%18 = getelementptr inbounds %struct.passwd, %struct.passwd* %17, i32 0, i32 0
%19 = load i8*, i8** %18
%20 = call %struct.spwd* @getspnam(i8* %19)
store %struct.spwd* %20, %struct.spwd** %7
%21 = load %struct.spwd*, %struct.spwd** %7
%22 = icmp ne %struct.spwd* %21, null
br i1 %22, label %23, label %48
23: ; preds = %16
%24 = load %struct.passwd*, %struct.passwd** %6
%25 = getelementptr inbounds %struct.passwd, %struct.passwd* %24, i32 0, i32 0
%26 = load i8*, i8** %25
%27 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* %26)
%28 = load %struct.passwd*, %struct.passwd** %6
%29 = getelementptr inbounds %struct.passwd, %struct.passwd* %28, i32 0, i32 1
%30 = load i8*, i8** %29
%31 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i8* %30)
%32 = load %struct.passwd*, %struct.passwd** %6
%33 = getelementptr inbounds %struct.passwd, %struct.passwd* %32, i32 0, i32 2
%34 = load i8*, i8** %33
%35 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i8* %34)
%36 = load %struct.passwd*, %struct.passwd** %6
%37 = getelementptr inbounds %struct.passwd, %struct.passwd* %36, i32 0, i32 3
%38 = load i8*, i8** %37
%39 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), i8* %38)
%40 = load %struct.spwd*, %struct.spwd** %7
%41 = getelementptr inbounds %struct.spwd, %struct.spwd* %40, i32 0, i32 0
%42 = load i8*, i8** %41
%43 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0), i8* %42)
%44 = load %struct.spwd*, %struct.spwd** %7
%45 = getelementptr inbounds %struct.spwd, %struct.spwd* %44, i32 0, i32 1
%46 = load i8*, i8** %45
%47 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.5, i64 0, i64 0), i8* %46)
br label %48
48: ; preds = %23, %16
br label %49
49: ; preds = %48, %2
ret i32 0
}

LLVM IR (-O2):
%struct.passwd = type { i8*, i8*, i8*, i8* }
%struct.spwd = type { i8*, i8* }
@.str = [16 x i8] c"user login: %s\0A\00"
@.str.1 = [15 x i8] c"user home: %s\0A\00"
@.str.2 = [16 x i8] c"user shell: %s\0A\00"
@.str.3 = [19 x i8] c"user password: %s\0A\00"
@.str.4 = [26 x i8] c"user shadow password: %s\0A\00"
@.str.5 = [23 x i8] c"user last change: %ld\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = getelementptr inbounds i8*, i8** %1, i64 1
%4 = load i8*, i8** %3
%5 = tail call i32 @name_to_uid(i8* %4)
%6 = tail call %struct.passwd* @getpwuid(i32 %5)
%7 = icmp eq %struct.passwd* %6, null
br i1 %7, label %31, label %8
8: ; preds = %2
%9 = getelementptr inbounds %struct.passwd, %struct.passwd* %6, i64 0, i32 0
%10 = load i8*, i8** %9
%11 = tail call %struct.spwd* @getspnam(i8* %10)
%12 = icmp eq %struct.spwd* %11, null
br i1 %12, label %31, label %13
13: ; preds = %8
%14 = load i8*, i8** %9
%15 = tail call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* %14)
%16 = getelementptr inbounds %struct.passwd, %struct.passwd* %6, i64 0, i32 1
%17 = load i8*, i8** %16
%18 = tail call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i8* %17)
%19 = getelementptr inbounds %struct.passwd, %struct.passwd* %6, i64 0, i32 2
%20 = load i8*, i8** %19
%21 = tail call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i8* %20)
%22 = getelementptr inbounds %struct.passwd, %struct.passwd* %6, i64 0, i32 3
%23 = load i8*, i8** %22
%24 = tail call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), i8* %23)
%25 = getelementptr inbounds %struct.spwd, %struct.spwd* %11, i64 0, i32 0
%26 = load i8*, i8** %25
%27 = tail call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0), i8* %26)
%28 = getelementptr inbounds %struct.spwd, %struct.spwd* %11, i64 0, i32 1
%29 = load i8*, i8** %28
%30 = tail call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.5, i64 0, i64 0), i8* %29)
br label %31
31: ; preds = %8, %13, %2
ret i32 0
}