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

/* Variables and functions */
struct tm *localtime(int /*<<< orphan*/ *);
char *strcpy(char *, char *);
scalar_t__ strftime(char *, int, char *, struct tm *);
int /*<<< orphan*/ time(int /*<<< orphan*/);
char *ps_get_log_time(void) {
  static char log_time[128];
  time_t t;
  struct tm *tm;
  t = time(0);
  tm = localtime(&t);
  if (tm)
    if (strftime(log_time, sizeof(log_time), "%F %T", tm))
      return log_time;
  return strcpy(log_time, "get_log_time failed");
}


x86 assembly (clang, -O0):
<ps_get_log_time>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
xor    %edi,%edi
call   1050 <time@plt>
mov    %eax,-0xc(%rbp)
lea    -0xc(%rbp),%rdi
call   1030 <localtime@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     11a5 <ps_get_log_time+0x65>
mov    -0x18(%rbp),%rcx
lea    0x2edb(%rip),%rdi
mov    $0x80,%esi
lea    0xe7f(%rip),%rdx
call   1060 <strftime@plt>
cmp    $0x0,%rax
je     11a0 <ps_get_log_time+0x60>
lea    0x2eb9(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11bc <ps_get_log_time+0x7c>
jmp    11a5 <ps_get_log_time+0x65>
lea    0x2ea4(%rip),%rdi
lea    0xe53(%rip),%rsi
call   1040 <strcpy@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ps_get_log_time>:
push   %rax
xor    %edi,%edi
call   1040 <time@plt>
mov    %eax,0x4(%rsp)
lea    0x4(%rsp),%rdi
call   1030 <localtime@plt>
test   %rax,%rax
je     116b <ps_get_log_time+0x3b>
lea    0x2efe(%rip),%rdi
lea    0xea7(%rip),%rdx
mov    $0x80,%esi
mov    %rax,%rcx
call   1050 <strftime@plt>
test   %rax,%rax
jne    1183 <ps_get_log_time+0x53>
movups 0xe94(%rip),%xmm0
movaps %xmm0,0x2ed7(%rip)
movl   $0x64656c,0x2edd(%rip)
lea    0x2ec6(%rip),%rax
pop    %rcx
ret

LLVM IR (-O0):
%struct.tm = type { i32 }
@ps_get_log_time.log_time = internal global [128 x i8] zeroinitializer
@.str = [6 x i8] c"%F %T\00"
@.str.1 = [20 x i8] c"get_log_time failed\00"
define i8* @ps_get_log_time() {
%1 = alloca i8*
%2 = alloca i32
%3 = alloca %struct.tm*
%4 = call i32 @time(i32 0)
store i32 %4, i32* %2
%5 = call %struct.tm* @localtime(i32* %2)
store %struct.tm* %5, %struct.tm** %3
%6 = load %struct.tm*, %struct.tm** %3
%7 = icmp ne %struct.tm* %6, null
br i1 %7, label %8, label %14
8: ; preds = %0
%9 = load %struct.tm*, %struct.tm** %3
%10 = call i64 @strftime(i8* getelementptr inbounds ([128 x i8], [128 x i8]* @ps_get_log_time.log_time, i64 0, i64 0), i32 128, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), %struct.tm* %9)
%11 = icmp ne i64 %10, 0
br i1 %11, label %12, label %13
12: ; preds = %8
store i8* getelementptr inbounds ([128 x i8], [128 x i8]* @ps_get_log_time.log_time, i64 0, i64 0), i8** %1
br label %16
13: ; preds = %8
br label %14
14: ; preds = %13, %0
%15 = call i8* @strcpy(i8* getelementptr inbounds ([128 x i8], [128 x i8]* @ps_get_log_time.log_time, i64 0, i64 0), i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0))
store i8* %15, i8** %1
br label %16
16: ; preds = %14, %12
%17 = load i8*, i8** %1
ret i8* %17
}

LLVM IR (-O2):
%struct.tm = type { i32 }
@ps_get_log_time.log_time = internal global [128 x i8] zeroinitializer
@.str = [6 x i8] c"%F %T\00"
@.str.1 = [20 x i8] c"get_log_time failed\00"
define i8* @ps_get_log_time() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 @time(i32 0)
store i32 %3, i32* %1
%4 = call %struct.tm* @localtime(i32* %1)
%5 = icmp eq %struct.tm* %4, null
br i1 %5, label %9, label %6
6: ; preds = %0
%7 = call i64 @strftime(i8* getelementptr inbounds ([128 x i8], [128 x i8]* @ps_get_log_time.log_time, i64 0, i64 0), i32 128, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), %struct.tm* %4)
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %10
9: ; preds = %6, %0
br label %10
10: ; preds = %6, %9
ret i8* getelementptr inbounds ([128 x i8], [128 x i8]* @ps_get_log_time.log_time, i64 0, i64 0)
}