#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 scalar_t__ uid_t;
struct spwd {
  char *sp_namp;
  char *sp_pwdp;
  char *sp_lstchg;
  char *sp_min;
  char *sp_max;
  char *sp_warn;
  char *sp_inact;
  char *sp_expire;
};
struct passwd {
  char *pw_name;
};

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
int EXIT_SUCCESS;
int /*<<< orphan*/ errno;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
struct passwd *getpwuid(int);
struct spwd *getspnam(char *);
scalar_t__ getuid();
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ stderr;
char *strerror(int /*<<< orphan*/);
int main(int argc, char *argv[]) {
  uid_t my_uid = getuid();
  struct spwd *sp;
  struct passwd *pwd;
  char *user;
  if (my_uid != 0) {
    fprintf(stderr, "Ops! Only root can read shadow password file.!\n");
    exit(EXIT_FAILURE);
  }
  pwd = getpwuid(1000);
  user = pwd->pw_name;
  if ((sp = getspnam(user)) == NULL) {
    fprintf(stderr, "Err. %s reading gestpnam()\n", strerror(errno));
    exit(EXIT_FAILURE);
  }
  printf("     user name: %s\n", sp->sp_namp);
  printf("encrypted pass: %s\n", sp->sp_pwdp);
  printf("last changes: %ld\n", sp->sp_lstchg);
  printf("min of days between changes: %ld\n", sp->sp_min);
  printf("max of days between changes: %ld\n", sp->sp_max);
  printf("days before pass expires to warn user to change it: %ld\n",
         sp->sp_warn);
  printf("days before password exipires until account disabled: %ld\n",
         sp->sp_inact);
  printf("date when account expires %ld\n", sp->sp_expire);
  return (EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x0,%al
call   1040 <getuid@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     11c1 <main+0x51>
mov    0x2e3d(%rip),%rax
mov    (%rax),%edi
lea    0xe54(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    0x2e16(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
mov    $0x3e8,%edi
call   1030 <getpwuid@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rdi
call   1070 <getspnam@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
jne    122d <main+0xbd>
mov    0x2de8(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x34(%rbp)
mov    0x2dd4(%rip),%rax
mov    (%rax),%edi
call   1090 <strerror@plt>
mov    -0x34(%rbp),%edi
mov    %rax,%rdx
lea    0xe18(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    0x2daa(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
mov    -0x20(%rbp),%rax
mov    (%rax),%rsi
lea    0xe11(%rip),%rdi
call   1050 <printf@plt>
mov    -0x20(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xe11(%rip),%rdi
call   1050 <printf@plt>
mov    -0x20(%rbp),%rax
mov    0x10(%rax),%rsi
lea    0xe11(%rip),%rdi
call   1050 <printf@plt>
mov    -0x20(%rbp),%rax
mov    0x18(%rax),%rsi
lea    0xe10(%rip),%rdi
call   1050 <printf@plt>
mov    -0x20(%rbp),%rax
mov    0x20(%rax),%rsi
lea    0xe1e(%rip),%rdi
call   1050 <printf@plt>
mov    -0x20(%rbp),%rax
mov    0x28(%rax),%rsi
lea    0xe2c(%rip),%rdi
call   1050 <printf@plt>
mov    -0x20(%rbp),%rax
mov    0x30(%rax),%rsi
lea    0xe51(%rip),%rdi
call   1050 <printf@plt>
mov    -0x20(%rbp),%rax
mov    0x38(%rax),%rsi
lea    0xe78(%rip),%rdi
call   1050 <printf@plt>
mov    0x2cf5(%rip),%rax
mov    (%rax),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
xor    %eax,%eax
call   1040 <getuid@plt>
test   %rax,%rax
jne    1229 <main+0xb9>
mov    $0x3e8,%edi
call   1030 <getpwuid@plt>
mov    (%rax),%rdi
call   1070 <getspnam@plt>
test   %rax,%rax
je     1242 <main+0xd2>
mov    %rax,%rbx
mov    (%rax),%rsi
lea    0xea3(%rip),%rdi
call   1050 <printf@plt>
mov    0x8(%rbx),%rsi
lea    0xea7(%rip),%rdi
call   1050 <printf@plt>
mov    0x10(%rbx),%rsi
lea    0xeab(%rip),%rdi
call   1050 <printf@plt>
mov    0x18(%rbx),%rsi
lea    0xeae(%rip),%rdi
call   1050 <printf@plt>
mov    0x20(%rbx),%rsi
lea    0xec0(%rip),%rdi
call   1050 <printf@plt>
mov    0x28(%rbx),%rsi
lea    0xed2(%rip),%rdi
call   1050 <printf@plt>
mov    0x30(%rbx),%rsi
lea    0xefb(%rip),%rdi
call   1050 <printf@plt>
mov    0x38(%rbx),%rsi
lea    0xf26(%rip),%rdi
call   1050 <printf@plt>
mov    0x2da3(%rip),%rax
mov    (%rax),%eax
pop    %rbx
ret
mov    0x2db0(%rip),%rax
mov    (%rax),%edi
lea    0xdc7(%rip),%rsi
xor    %eax,%eax
call   1060 <fprintf@plt>
jmp    126c <main+0xfc>
mov    0x2d97(%rip),%rax
mov    (%rax),%ebx
mov    0x2d86(%rip),%rax
mov    (%rax),%edi
call   1090 <strerror@plt>
lea    0xdd0(%rip),%rsi
mov    %ebx,%edi
mov    %rax,%rdx
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    0x2d5d(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>

LLVM IR (-O0):
%struct.spwd = type { i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8* }
%struct.passwd = type { i8* }
@stderr = global i32 0
@.str = [48 x i8] c"Ops! Only root can read shadow password file.!\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [28 x i8] c"Err. %s reading gestpnam()\0A\00"
@errno = global i32 0
@.str.2 = [20 x i8] c" user name: %s\0A\00"
@.str.3 = [20 x i8] c"encrypted pass: %s\0A\00"
@.str.4 = [19 x i8] c"last changes: %ld\0A\00"
@.str.5 = [34 x i8] c"min of days between changes: %ld\0A\00"
@.str.6 = [34 x i8] c"max of days between changes: %ld\0A\00"
@.str.7 = [57 x i8] c"days before pass expires to warn user to change it: %ld\0A\00"
@.str.8 = [59 x i8] c"days before password exipires until account disabled: %ld\0A\00"
@.str.9 = [31 x i8] c"date when account expires %ld\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 i64
%7 = alloca %struct.spwd*
%8 = alloca %struct.passwd*
%9 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = call i64 (...) @getuid()
store i64 %10, i64* %6
%11 = load i64, i64* %6
%12 = icmp ne i64 %11, 0
br i1 %12, label %13, label %18
13: ; preds = %2
%14 = load i32, i32* @stderr
%15 = call i32 (i32, i8*, ...) @fprintf(i32 %14, i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str, i64 0, i64 0))
%16 = load i32, i32* @EXIT_FAILURE
%17 = call i32 @exit(i32 %16)
unreachable
18: ; preds = %2
%19 = call %struct.passwd* @getpwuid(i32 1000)
store %struct.passwd* %19, %struct.passwd** %8
%20 = load %struct.passwd*, %struct.passwd** %8
%21 = getelementptr inbounds %struct.passwd, %struct.passwd* %20, i32 0, i32 0
%22 = load i8*, i8** %21
store i8* %22, i8** %9
%23 = load i8*, i8** %9
%24 = call %struct.spwd* @getspnam(i8* %23)
store %struct.spwd* %24, %struct.spwd** %7
%25 = icmp eq %struct.spwd* %24, null
br i1 %25, label %26, label %33
26: ; preds = %18
%27 = load i32, i32* @stderr
%28 = load i32, i32* @errno
%29 = call i8* @strerror(i32 %28)
%30 = call i32 (i32, i8*, ...) @fprintf(i32 %27, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0), i8* %29)
%31 = load i32, i32* @EXIT_FAILURE
%32 = call i32 @exit(i32 %31)
unreachable
33: ; preds = %18
%34 = load %struct.spwd*, %struct.spwd** %7
%35 = getelementptr inbounds %struct.spwd, %struct.spwd* %34, i32 0, i32 0
%36 = load i8*, i8** %35
%37 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i8* %36)
%38 = load %struct.spwd*, %struct.spwd** %7
%39 = getelementptr inbounds %struct.spwd, %struct.spwd* %38, i32 0, i32 1
%40 = load i8*, i8** %39
%41 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0), i8* %40)
%42 = load %struct.spwd*, %struct.spwd** %7
%43 = getelementptr inbounds %struct.spwd, %struct.spwd* %42, i32 0, i32 2
%44 = load i8*, i8** %43
%45 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0), i8* %44)
%46 = load %struct.spwd*, %struct.spwd** %7
%47 = getelementptr inbounds %struct.spwd, %struct.spwd* %46, i32 0, i32 3
%48 = load i8*, i8** %47
%49 = call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.5, i64 0, i64 0), i8* %48)
%50 = load %struct.spwd*, %struct.spwd** %7
%51 = getelementptr inbounds %struct.spwd, %struct.spwd* %50, i32 0, i32 4
%52 = load i8*, i8** %51
%53 = call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.6, i64 0, i64 0), i8* %52)
%54 = load %struct.spwd*, %struct.spwd** %7
%55 = getelementptr inbounds %struct.spwd, %struct.spwd* %54, i32 0, i32 5
%56 = load i8*, i8** %55
%57 = call i32 @printf(i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.7, i64 0, i64 0), i8* %56)
%58 = load %struct.spwd*, %struct.spwd** %7
%59 = getelementptr inbounds %struct.spwd, %struct.spwd* %58, i32 0, i32 6
%60 = load i8*, i8** %59
%61 = call i32 @printf(i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str.8, i64 0, i64 0), i8* %60)
%62 = load %struct.spwd*, %struct.spwd** %7
%63 = getelementptr inbounds %struct.spwd, %struct.spwd* %62, i32 0, i32 7
%64 = load i8*, i8** %63
%65 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.9, i64 0, i64 0), i8* %64)
%66 = load i32, i32* @EXIT_SUCCESS
ret i32 %66
}

LLVM IR (-O2):
%struct.passwd = type { i8* }
%struct.spwd = type { i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8* }
@stderr = global i32 0
@.str = [48 x i8] c"Ops! Only root can read shadow password file.!\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [28 x i8] c"Err. %s reading gestpnam()\0A\00"
@errno = global i32 0
@.str.2 = [20 x i8] c" user name: %s\0A\00"
@.str.3 = [20 x i8] c"encrypted pass: %s\0A\00"
@.str.4 = [19 x i8] c"last changes: %ld\0A\00"
@.str.5 = [34 x i8] c"min of days between changes: %ld\0A\00"
@.str.6 = [34 x i8] c"max of days between changes: %ld\0A\00"
@.str.7 = [57 x i8] c"days before pass expires to warn user to change it: %ld\0A\00"
@.str.8 = [59 x i8] c"days before password exipires until account disabled: %ld\0A\00"
@.str.9 = [31 x i8] c"date when account expires %ld\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i64 (...) @getuid()
%4 = icmp eq i64 %3, 0
br i1 %4, label %10, label %5
5: ; preds = %2
%6 = load i32, i32* @stderr
%7 = tail call i32 (i32, i8*, ...) @fprintf(i32 %6, i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str, i64 0, i64 0))
%8 = load i32, i32* @EXIT_FAILURE
%9 = tail call i32 @exit(i32 %8)
unreachable
10: ; preds = %2
%11 = tail call %struct.passwd* @getpwuid(i32 1000)
%12 = getelementptr inbounds %struct.passwd, %struct.passwd* %11, i64 0, i32 0
%13 = load i8*, i8** %12
%14 = tail call %struct.spwd* @getspnam(i8* %13)
%15 = icmp eq %struct.spwd* %14, null
br i1 %15, label %16, label %23
16: ; preds = %10
%17 = load i32, i32* @stderr
%18 = load i32, i32* @errno
%19 = tail call i8* @strerror(i32 %18)
%20 = tail call i32 (i32, i8*, ...) @fprintf(i32 %17, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0), i8* %19)
%21 = load i32, i32* @EXIT_FAILURE
%22 = tail call i32 @exit(i32 %21)
unreachable
23: ; preds = %10
%24 = getelementptr inbounds %struct.spwd, %struct.spwd* %14, i64 0, i32 0
%25 = load i8*, i8** %24
%26 = tail call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i8* %25)
%27 = getelementptr inbounds %struct.spwd, %struct.spwd* %14, i64 0, i32 1
%28 = load i8*, i8** %27
%29 = tail call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0), i8* %28)
%30 = getelementptr inbounds %struct.spwd, %struct.spwd* %14, i64 0, i32 2
%31 = load i8*, i8** %30
%32 = tail call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0), i8* %31)
%33 = getelementptr inbounds %struct.spwd, %struct.spwd* %14, i64 0, i32 3
%34 = load i8*, i8** %33
%35 = tail call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.5, i64 0, i64 0), i8* %34)
%36 = getelementptr inbounds %struct.spwd, %struct.spwd* %14, i64 0, i32 4
%37 = load i8*, i8** %36
%38 = tail call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.6, i64 0, i64 0), i8* %37)
%39 = getelementptr inbounds %struct.spwd, %struct.spwd* %14, i64 0, i32 5
%40 = load i8*, i8** %39
%41 = tail call i32 @printf(i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.7, i64 0, i64 0), i8* %40)
%42 = getelementptr inbounds %struct.spwd, %struct.spwd* %14, i64 0, i32 6
%43 = load i8*, i8** %42
%44 = tail call i32 @printf(i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str.8, i64 0, i64 0), i8* %43)
%45 = getelementptr inbounds %struct.spwd, %struct.spwd* %14, i64 0, i32 7
%46 = load i8*, i8** %45
%47 = tail call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.9, i64 0, i64 0), i8* %46)
%48 = load i32, i32* @EXIT_SUCCESS
ret i32 %48
}