#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*/ buff;

/* Variables and functions */
struct tm *localtime(int /*<<< orphan*/ *);
int /*<<< orphan*/ strftime(char *, int, char *, struct tm *);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
extern char const *format_time(void) {
  static char buff[64];
  time_t rawtime;
  struct tm *timeinfo;
  time(&rawtime);
  timeinfo = localtime(&rawtime);
  if (NULL == timeinfo)
    return NULL;
  strftime(buff, sizeof(buff), "%Y-%m-%d %H:%M:%S", timeinfo);
  return buff;
}


x86 assembly (clang, -O0):
<format_time>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
lea    -0xc(%rbp),%rdi
call   1040 <time@plt>
lea    -0xc(%rbp),%rdi
call   1030 <localtime@plt>
mov    %rax,-0x18(%rbp)
xor    %eax,%eax
cmp    -0x18(%rbp),%rax
jne    1167 <format_time+0x37>
movq   $0x0,-0x8(%rbp)
jmp    118e <format_time+0x5e>
mov    -0x18(%rbp),%rcx
lea    0x2ede(%rip),%rdi
mov    $0x40,%esi
lea    0xe82(%rip),%rdx
call   1050 <strftime@plt>
lea    0x2ec6(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<format_time>:
push   %rbx
sub    $0x10,%rsp
lea    0xc(%rsp),%rbx
mov    %rbx,%rdi
call   1040 <time@plt>
mov    %rbx,%rdi
call   1030 <localtime@plt>
test   %rax,%rax
je     116f <format_time+0x3f>
lea    0x2efa(%rip),%rbx
lea    0xea3(%rip),%rdx
mov    %rbx,%rdi
mov    $0x40,%esi
mov    %rax,%rcx
call   1050 <strftime@plt>
jmp    1171 <format_time+0x41>
xor    %ebx,%ebx
mov    %rbx,%rax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.tm = type { i32 }
@format_time.buff = internal global [64 x i8] zeroinitializer
@.str = [18 x i8] c"%Y-%m-%d %H:%M:%S\00"
define i8* @format_time() {
%1 = alloca i8*
%2 = alloca i32
%3 = alloca %struct.tm*
%4 = call i32 @time(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 eq %struct.tm* null, %6
br i1 %7, label %8, label %9
8: ; preds = %0
store i8* null, i8** %1
br label %12
9: ; preds = %0
%10 = load %struct.tm*, %struct.tm** %3
%11 = call i32 @strftime(i8* getelementptr inbounds ([64 x i8], [64 x i8]* @format_time.buff, i64 0, i64 0), i32 64, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), %struct.tm* %10)
store i8* getelementptr inbounds ([64 x i8], [64 x i8]* @format_time.buff, i64 0, i64 0), i8** %1
br label %12
12: ; preds = %9, %8
%13 = load i8*, i8** %1
ret i8* %13
}

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