#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;
typedef int /*<<< orphan*/ dest;

/* Variables and functions */
int /*<<< orphan*/ localtime(int /*<<< orphan*/ *);
int /*<<< orphan*/ strftime(char *, int, char *, int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/);
void Sys_GetTime(char *fmt, char *dest) {
  time_t timer;
  char buf[30];
  if (!dest)
    return;
  timer = time(0);
  strftime(dest, sizeof(dest), (!fmt[0]) ? "%Y-%m-%d %H:%M:%S" : fmt,
           localtime(&timer));
}


x86 assembly (clang, -O0):
<Sys_GetTime>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1150 <Sys_GetTime+0x20>
jmp    11ac <Sys_GetTime+0x7c>
xor    %edi,%edi
call   1040 <time@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x8(%rbp),%rax
cmpb   $0x0,(%rax)
jne    117f <Sys_GetTime+0x4f>
lea    0xe8a(%rip),%rax
mov    %rax,-0x50(%rbp)
jmp    1187 <Sys_GetTime+0x57>
mov    -0x8(%rbp),%rax
mov    %rax,-0x50(%rbp)
mov    -0x50(%rbp),%rax
mov    %rax,-0x58(%rbp)
lea    -0x14(%rbp),%rdi
call   1030 <localtime@plt>
mov    -0x48(%rbp),%rdi
mov    -0x58(%rbp),%rdx
mov    %eax,%ecx
mov    $0x8,%esi
call   1050 <strftime@plt>
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Sys_GetTime>:
test   %rsi,%rsi
je     1183 <Sys_GetTime+0x53>
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%r14
mov    %rdi,%r15
xor    %edi,%edi
call   1040 <time@plt>
mov    %eax,0xc(%rsp)
cmpb   $0x0,(%r15)
lea    0xea6(%rip),%rbx
cmovne %r15,%rbx
lea    0xc(%rsp),%rdi
call   1030 <localtime@plt>
mov    %r14,%rdi
mov    $0x8,%esi
mov    %rbx,%rdx
mov    %eax,%ecx
call   1050 <strftime@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [18 x i8] c"%Y-%m-%d %H:%M:%S\00"
define void @Sys_GetTime(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
%6 = alloca [30 x i8]
store i8* %0, i8** %3
store i8* %1, i8** %4
%7 = load i8*, i8** %4
%8 = icmp ne i8* %7, null
br i1 %8, label %10, label %9
9: ; preds = %2
br label %24
10: ; preds = %2
%11 = call i32 @time(i32 0)
store i32 %11, i32* %5
%12 = load i8*, i8** %4
%13 = load i8*, i8** %3
%14 = getelementptr inbounds i8, i8* %13, i64 0
%15 = load i8, i8* %14
%16 = icmp ne i8 %15, 0
br i1 %16, label %18, label %17
17: ; preds = %10
br label %20
18: ; preds = %10
%19 = load i8*, i8** %3
br label %20
20: ; preds = %18, %17
%21 = phi i8* [ getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), %17 ], [ %19, %18 ]
%22 = call i32 @localtime(i32* %5)
%23 = call i32 @strftime(i8* %12, i32 8, i8* %21, i32 %22)
br label %24
24: ; preds = %20, %9
ret void
}

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