#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 */
struct spwd {
  int sp_lstchg;
};

/* Variables and functions */
struct spwd *getspnam(char *);
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ time(int /*<<< orphan*/ *);
int main(int argc, char *argv[]) {
  if (argc > 1) {
    int lastpw = 0;
    struct spwd *spwd;
    char *user = argv[1];
    int now = (int)time(NULL);
    spwd = getspnam(user);
    if (spwd) {
      lastpw = (int)(spwd->sp_lstchg * 86400);
      int diff = (int)(now - lastpw);
      int daysdiff = diff / 86400;
      printf("%ld\n", spwd->sp_lstchg);
      printf("%d\n", lastpw);
      printf("%d\n", diff);
      printf("%d\n", daysdiff);
    }
  } else {
    printf("Usage: getlastpasschange <user> \n\n It returns: \n 1. Last change "
           "password date on days since 01/01/1970 \n 2. Timestamp of last "
           "password change \n 3. Difference between timestamp now and last "
           "password change \n 4. Difference in days \n\n ");
  }
  return 0;
}


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)
cmpl   $0x1,-0x8(%rbp)
jle    11f7 <main+0xc7>
movl   $0x0,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x28(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1040 <time@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x28(%rbp),%rdi
call   1050 <getspnam@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     11f2 <main+0xc2>
mov    -0x20(%rbp),%rax
imul   $0x15180,(%rax),%eax
mov    %eax,-0x14(%rbp)
mov    -0x2c(%rbp),%eax
sub    -0x14(%rbp),%eax
mov    %eax,-0x30(%rbp)
mov    -0x30(%rbp),%eax
mov    $0x15180,%ecx
cltd
idiv   %ecx
mov    %eax,-0x34(%rbp)
mov    -0x20(%rbp),%rax
mov    (%rax),%esi
lea    0xe48(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%esi
lea    0xe3c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x30(%rbp),%esi
lea    0xe2b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x34(%rbp),%esi
lea    0xe1a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1205 <main+0xd5>
lea    0xe0b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
cmp    $0x2,%edi
jl     11b8 <main+0x88>
mov    0x8(%rsi),%r14
xor    %edi,%edi
call   1040 <time@plt>
mov    %rax,%rbx
mov    %r14,%rdi
call   1050 <getspnam@plt>
test   %rax,%rax
je     11c6 <main+0x96>
mov    (%rax),%esi
imul   $0x15180,%esi,%ebp
sub    %ebp,%ebx
movslq %ebx,%r14
imul   $0xffffffffc22e4507,%r14,%rbx
shr    $0x20,%rbx
add    %r14d,%ebx
mov    %ebx,%eax
shr    $0x1f,%eax
sar    $0x10,%ebx
add    %eax,%ebx
lea    0xe7d(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe74(%rip),%r15
mov    %r15,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r15,%rdi
mov    %r14d,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r15,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1030 <printf@plt>
jmp    11c6 <main+0x96>
lea    0xe4a(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.spwd = type { i32 }
@.str = [5 x i8] c"%ld\0A\00"
@.str.1 = [4 x i8] c"%d\0A\00"
@.str.2 = [233 x i8] c"Usage: getlastpasschange <user> \0A\0A It returns: \0A 1. Last change password date on days since 01/01/1970 \0A 2. Timestamp of last password change \0A 3. Difference between timestamp now and last password change \0A 4. Difference in days \0A\0A \00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca %struct.spwd*
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%12 = load i32, i32* %4
%13 = icmp sgt i32 %12, 1
br i1 %13, label %14, label %45
14: ; preds = %2
store i32 0, i32* %6
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 1
%17 = load i8*, i8** %16
store i8* %17, i8** %8
%18 = call i64 @time(i32* null)
%19 = trunc i64 %18 to i32
store i32 %19, i32* %9
%20 = load i8*, i8** %8
%21 = call %struct.spwd* @getspnam(i8* %20)
store %struct.spwd* %21, %struct.spwd** %7
%22 = load %struct.spwd*, %struct.spwd** %7
%23 = icmp ne %struct.spwd* %22, null
br i1 %23, label %24, label %44
24: ; preds = %14
%25 = load %struct.spwd*, %struct.spwd** %7
%26 = getelementptr inbounds %struct.spwd, %struct.spwd* %25, i32 0, i32 0
%27 = load i32, i32* %26
%28 = mul nsw i32 %27, 86400
store i32 %28, i32* %6
%29 = load i32, i32* %9
%30 = load i32, i32* %6
%31 = sub nsw i32 %29, %30
store i32 %31, i32* %10
%32 = load i32, i32* %10
%33 = sdiv i32 %32, 86400
store i32 %33, i32* %11
%34 = load %struct.spwd*, %struct.spwd** %7
%35 = getelementptr inbounds %struct.spwd, %struct.spwd* %34, i32 0, i32 0
%36 = load i32, i32* %35
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %36)
%38 = load i32, i32* %6
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %38)
%40 = load i32, i32* %10
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %40)
%42 = load i32, i32* %11
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %42)
br label %44
44: ; preds = %24, %14
br label %47
45: ; preds = %2
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([233 x i8], [233 x i8]* @.str.2, i64 0, i64 0))
br label %47
47: ; preds = %45, %44
ret i32 0
}

LLVM IR (-O2):
%struct.spwd = type { i32 }
@.str = [5 x i8] c"%ld\0A\00"
@.str.1 = [4 x i8] c"%d\0A\00"
@.str.2 = [233 x i8] c"Usage: getlastpasschange <user> \0A\0A It returns: \0A 1. Last change password date on days since 01/01/1970 \0A 2. Timestamp of last password change \0A 3. Difference between timestamp now and last password change \0A 4. Difference in days \0A\0A \00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp sgt i32 %0, 1
br i1 %3, label %4, label %21
4: ; preds = %2
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = tail call i64 @time(i32* null)
%8 = tail call %struct.spwd* @getspnam(i8* %6)
%9 = icmp eq %struct.spwd* %8, null
br i1 %9, label %23, label %10
10: ; preds = %4
%11 = trunc i64 %7 to i32
%12 = getelementptr inbounds %struct.spwd, %struct.spwd* %8, i64 0, i32 0
%13 = load i32, i32* %12
%14 = mul nsw i32 %13, 86400
%15 = sub nsw i32 %11, %14
%16 = sdiv i32 %15, 86400
%17 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %13)
%18 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %14)
%19 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %15)
%20 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %16)
br label %23
21: ; preds = %2
%22 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([233 x i8], [233 x i8]* @.str.2, i64 0, i64 0))
br label %23
23: ; preds = %4, %10, %21
ret i32 0
}