#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 {
  char *sp_pwdp;
  long sp_lstchg;
  int sp_min;
  int sp_max;
  int sp_warn;
  int sp_inact;
  int sp_expire;
  scalar_t__ sp_flag;
};
typedef enum nss_status { ____Placeholder_nss_status } nss_status;

/* Variables and functions */
int NSS_STATUS_SUCCESS;
int NSS_STATUS_UNAVAIL;
int time(int /*<<< orphan*/ *);
scalar_t__ unbit_magic_buf(char *, int, char **, size_t *);
enum nss_status unbit_sres(char *name, size_t name_len, struct spwd *res,
                           char **buffer, size_t *buflen) {
  res->sp_pwdp = *buffer;
  if (unbit_magic_buf("!", 1, buffer, buflen))
    return NSS_STATUS_UNAVAIL;
  res->sp_lstchg = (long)((time(NULL) / (3600 * 24)) - 1);
  res->sp_min = -1;
  res->sp_max = -1;
  res->sp_warn = -1;
  res->sp_inact = -1;
  res->sp_expire = -1;
  res->sp_flag = 0;
  return NSS_STATUS_SUCCESS;
}


x86 assembly (clang, -O0):
<unbit_sres>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8,-0x30(%rbp)
mov    -0x28(%rbp),%rax
mov    (%rax),%rcx
mov    -0x20(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x28(%rbp),%rdx
mov    -0x30(%rbp),%rcx
lea    0xea7(%rip),%rdi
mov    $0x1,%esi
call   1040 <unbit_magic_buf@plt>
cmp    $0x0,%rax
je     117e <unbit_sres+0x5e>
mov    0x2e74(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    11ec <unbit_sres+0xcc>
xor    %eax,%eax
mov    %eax,%edi
call   1030 <time@plt>
mov    $0x15180,%ecx
cltd
idiv   %ecx
sub    $0x1,%eax
movslq %eax,%rcx
mov    -0x20(%rbp),%rax
mov    %rcx,0x8(%rax)
mov    -0x20(%rbp),%rax
movl   $0xffffffff,0x10(%rax)
mov    -0x20(%rbp),%rax
movl   $0xffffffff,0x14(%rax)
mov    -0x20(%rbp),%rax
movl   $0xffffffff,0x18(%rax)
mov    -0x20(%rbp),%rax
movl   $0xffffffff,0x1c(%rax)
mov    -0x20(%rbp),%rax
movl   $0xffffffff,0x20(%rax)
mov    -0x20(%rbp),%rax
movq   $0x0,0x28(%rax)
mov    0x2df9(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<unbit_sres>:
push   %rbx
mov    %rdx,%rbx
mov    (%rcx),%rax
mov    %rax,(%rdx)
lea    0xecf(%rip),%rdi
mov    $0x1,%esi
mov    %rcx,%rdx
mov    %r8,%rcx
call   1040 <unbit_magic_buf@plt>
test   %rax,%rax
je     114f <unbit_sres+0x2f>
mov    0x2e9b(%rip),%rax
jmp    1197 <unbit_sres+0x77>
xor    %edi,%edi
call   1030 <time@plt>
cltq
imul   $0xffffffffc22e4507,%rax,%rcx
shr    $0x20,%rcx
add    %ecx,%eax
mov    %eax,%ecx
sar    $0x10,%ecx
shr    $0x1f,%eax
add    %ecx,%eax
add    $0xffffffff,%eax
cltq
mov    %rax,0x8(%rbx)
pcmpeqd %xmm0,%xmm0
movdqu %xmm0,0x10(%rbx)
movl   $0xffffffff,0x20(%rbx)
movq   $0x0,0x28(%rbx)
mov    0x2e49(%rip),%rax
mov    (%rax),%eax
pop    %rbx
ret

LLVM IR (-O0):
%struct.spwd = type { i8*, i64, i32, i32, i32, i32, i32, i64 }
@.str = [2 x i8] c"!\00"
@NSS_STATUS_UNAVAIL = global i32 0
@NSS_STATUS_SUCCESS = global i32 0
define i32 @unbit_sres(i8* %0, i64 %1, %struct.spwd* %2, i8** %3, i64* %4) {
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i64
%9 = alloca %struct.spwd*
%10 = alloca i8**
%11 = alloca i64*
store i8* %0, i8** %7
store i64 %1, i64* %8
store %struct.spwd* %2, %struct.spwd** %9
store i8** %3, i8*** %10
store i64* %4, i64** %11
%12 = load i8**, i8*** %10
%13 = load i8*, i8** %12
%14 = load %struct.spwd*, %struct.spwd** %9
%15 = getelementptr inbounds %struct.spwd, %struct.spwd* %14, i32 0, i32 0
store i8* %13, i8** %15
%16 = load i8**, i8*** %10
%17 = load i64*, i64** %11
%18 = call i64 @unbit_magic_buf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 1, i8** %16, i64* %17)
%19 = icmp ne i64 %18, 0
br i1 %19, label %20, label %22
20: ; preds = %5
%21 = load i32, i32* @NSS_STATUS_UNAVAIL
store i32 %21, i32* %6
br label %42
22: ; preds = %5
%23 = call i32 @time(i32* null)
%24 = sdiv i32 %23, 86400
%25 = sub nsw i32 %24, 1
%26 = sext i32 %25 to i64
%27 = load %struct.spwd*, %struct.spwd** %9
%28 = getelementptr inbounds %struct.spwd, %struct.spwd* %27, i32 0, i32 1
store i64 %26, i64* %28
%29 = load %struct.spwd*, %struct.spwd** %9
%30 = getelementptr inbounds %struct.spwd, %struct.spwd* %29, i32 0, i32 2
store i32 -1, i32* %30
%31 = load %struct.spwd*, %struct.spwd** %9
%32 = getelementptr inbounds %struct.spwd, %struct.spwd* %31, i32 0, i32 3
store i32 -1, i32* %32
%33 = load %struct.spwd*, %struct.spwd** %9
%34 = getelementptr inbounds %struct.spwd, %struct.spwd* %33, i32 0, i32 4
store i32 -1, i32* %34
%35 = load %struct.spwd*, %struct.spwd** %9
%36 = getelementptr inbounds %struct.spwd, %struct.spwd* %35, i32 0, i32 5
store i32 -1, i32* %36
%37 = load %struct.spwd*, %struct.spwd** %9
%38 = getelementptr inbounds %struct.spwd, %struct.spwd* %37, i32 0, i32 6
store i32 -1, i32* %38
%39 = load %struct.spwd*, %struct.spwd** %9
%40 = getelementptr inbounds %struct.spwd, %struct.spwd* %39, i32 0, i32 7
store i64 0, i64* %40
%41 = load i32, i32* @NSS_STATUS_SUCCESS
store i32 %41, i32* %6
br label %42
42: ; preds = %22, %20
%43 = load i32, i32* %6
ret i32 %43
}

LLVM IR (-O2):
%struct.spwd = type { i8*, i64, i32, i32, i32, i32, i32, i64 }
@.str = [2 x i8] c"!\00"
@NSS_STATUS_UNAVAIL = global i32 0
@NSS_STATUS_SUCCESS = global i32 0
define i32 @unbit_sres(i8* nocapture readnone %0, i64 %1, %struct.spwd* nocapture writeonly %2, i8** %3, i64* %4) {
%6 = load i8*, i8** %3
%7 = getelementptr inbounds %struct.spwd, %struct.spwd* %2, i64 0, i32 0
store i8* %6, i8** %7
%8 = tail call i64 @unbit_magic_buf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 1, i8** %3, i64* %4)
%9 = icmp eq i64 %8, 0
br i1 %9, label %10, label %19
10: ; preds = %5
%11 = tail call i32 @time(i32* null)
%12 = sdiv i32 %11, 86400
%13 = add nsw i32 %12, -1
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds %struct.spwd, %struct.spwd* %2, i64 0, i32 1
store i64 %14, i64* %15
%16 = getelementptr inbounds %struct.spwd, %struct.spwd* %2, i64 0, i32 2
%17 = getelementptr inbounds %struct.spwd, %struct.spwd* %2, i64 0, i32 7
%18 = bitcast i32* %16 to i8*
store i64 0, i64* %17
br label %19
19: ; preds = %5, %10
%20 = phi i32* [ @NSS_STATUS_SUCCESS, %10 ], [ @NSS_STATUS_UNAVAIL, %5 ]
%21 = load i32, i32* %20
ret i32 %21
}