#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 time_t;
struct tm {
  int dummy;
};
typedef int /*<<< orphan*/ db;

/* Variables and functions */
struct tm *localtime(int *);
int /*<<< orphan*/ memset(char *, int, int);
int strftime(char *, int, char *, struct tm const *const);
int time(int /*<<< orphan*/ *);
const char *asyslogd_sys_time(void) {
  static char db[64];
  memset(db, 0x00, sizeof(db));
  time_t lt = time(NULL);
  if (lt < 1)
    return NULL;
  const struct tm *const lts = localtime(&lt);
  if (lts == NULL)
    return NULL;
  if (strftime(db, sizeof db, "%Y-%m-%d %H:%M:%S", lts) < 16)
    return NULL;
  return db;
}


x86 assembly (clang, -O0):
<asyslogd_sys_time>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
lea    0x2f01(%rip),%rdi
xor    %esi,%esi
mov    $0x40,%edx
call   1040 <memset@plt>
xor    %eax,%eax
mov    %eax,%edi
call   1050 <time@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x1,-0xc(%rbp)
jge    117e <asyslogd_sys_time+0x3e>
movq   $0x0,-0x8(%rbp)
jmp    11e0 <asyslogd_sys_time+0xa0>
lea    -0xc(%rbp),%rdi
call   1030 <localtime@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11a3 <asyslogd_sys_time+0x63>
movq   $0x0,-0x8(%rbp)
jmp    11e0 <asyslogd_sys_time+0xa0>
mov    -0x18(%rbp),%rcx
lea    0x2ea2(%rip),%rdi
mov    $0x40,%esi
lea    0xe46(%rip),%rdx
call   1060 <strftime@plt>
cmp    $0x10,%eax
jge    11d5 <asyslogd_sys_time+0x95>
movq   $0x0,-0x8(%rbp)
jmp    11e0 <asyslogd_sys_time+0xa0>
lea    0x2e74(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<asyslogd_sys_time>:
push   %r14
push   %rbx
push   %rax
lea    0x2f05(%rip),%r14
xor    %ebx,%ebx
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x40,%edx
call   1040 <memset@plt>
xor    %edi,%edi
call   1050 <time@plt>
mov    %eax,0x4(%rsp)
test   %eax,%eax
jle    119e <asyslogd_sys_time+0x5e>
lea    0x4(%rsp),%rdi
call   1030 <localtime@plt>
test   %rax,%rax
je     119c <asyslogd_sys_time+0x5c>
lea    0xe7f(%rip),%rdx
mov    %r14,%rdi
mov    $0x40,%esi
mov    %rax,%rcx
call   1060 <strftime@plt>
xor    %ebx,%ebx
cmp    $0x10,%eax
cmovge %r14,%rbx
jmp    119e <asyslogd_sys_time+0x5e>
xor    %ebx,%ebx
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.tm = type { i32 }
@asyslogd_sys_time.db = internal global [64 x i8] zeroinitializer
@.str = [18 x i8] c"%Y-%m-%d %H:%M:%S\00"
define i8* @asyslogd_sys_time() {
%1 = alloca i8*
%2 = alloca i32
%3 = alloca %struct.tm*
%4 = call i32 @memset(i8* getelementptr inbounds ([64 x i8], [64 x i8]* @asyslogd_sys_time.db, i64 0, i64 0), i32 0, i32 64)
%5 = call i32 @time(i32* null)
store i32 %5, i32* %2
%6 = load i32, i32* %2
%7 = icmp slt i32 %6, 1
br i1 %7, label %8, label %9
8: ; preds = %0
store i8* null, i8** %1
br label %20
9: ; preds = %0
%10 = call %struct.tm* @localtime(i32* %2)
store %struct.tm* %10, %struct.tm** %3
%11 = load %struct.tm*, %struct.tm** %3
%12 = icmp eq %struct.tm* %11, null
br i1 %12, label %13, label %14
13: ; preds = %9
store i8* null, i8** %1
br label %20
14: ; preds = %9
%15 = load %struct.tm*, %struct.tm** %3
%16 = call i32 @strftime(i8* getelementptr inbounds ([64 x i8], [64 x i8]* @asyslogd_sys_time.db, i64 0, i64 0), i32 64, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), %struct.tm* %15)
%17 = icmp slt i32 %16, 16
br i1 %17, label %18, label %19
18: ; preds = %14
store i8* null, i8** %1
br label %20
19: ; preds = %14
store i8* getelementptr inbounds ([64 x i8], [64 x i8]* @asyslogd_sys_time.db, i64 0, i64 0), i8** %1
br label %20
20: ; preds = %19, %18, %13, %8
%21 = load i8*, i8** %1
ret i8* %21
}

LLVM IR (-O2):
%struct.tm = type { i32 }
@asyslogd_sys_time.db = internal global [64 x i8] zeroinitializer
@.str = [18 x i8] c"%Y-%m-%d %H:%M:%S\00"
define i8* @asyslogd_sys_time() {
%1 = alloca i32
%2 = tail call i32 @memset(i8* getelementptr inbounds ([64 x i8], [64 x i8]* @asyslogd_sys_time.db, i64 0, i64 0), i32 0, i32 64)
%3 = bitcast i32* %1 to i8*
%4 = tail call i32 @time(i32* null)
store i32 %4, i32* %1
%5 = icmp slt i32 %4, 1
br i1 %5, label %13, label %6
6: ; preds = %0
%7 = call %struct.tm* @localtime(i32* %1)
%8 = icmp eq %struct.tm* %7, null
br i1 %8, label %13, label %9
9: ; preds = %6
%10 = call i32 @strftime(i8* getelementptr inbounds ([64 x i8], [64 x i8]* @asyslogd_sys_time.db, i64 0, i64 0), i32 64, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), %struct.tm* %7)
%11 = icmp slt i32 %10, 16
%12 = select i1 %11, i8* null, i8* getelementptr inbounds ([64 x i8], [64 x i8]* @asyslogd_sys_time.db, i64 0, i64 0)
br label %13
13: ; preds = %6, %9, %0
%14 = phi i8* [ null, %0 ], [ null, %6 ], [ %12, %9 ]
ret i8* %14
}