#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;
};

/* Variables and functions */
char *asctime(struct tm *);
struct tm *localtime(int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *);
int strlen(char *);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
void TOOLS_GetTime(char **ppTimeStr) {
  time_t rawTime;
  static struct tm *pTimeInfo;
  if (ppTimeStr == NULL) {
    printf("ERROR: Input time string is NULL!");
    return;
  }
  time(&rawTime);
  pTimeInfo = localtime(&rawTime);
  *ppTimeStr = (asctime(pTimeInfo) + strlen("Www Mmm dd "));
  *(*ppTimeStr + strlen("hh:mm:ss")) = '\0';
  return;
}


x86 assembly (clang, -O0):
<TOOLS_GetTime>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
jne    1178 <TOOLS_GetTime+0x28>
lea    0xe92(%rip),%rdi
call   1060 <printf@plt>
jmp    11e1 <TOOLS_GetTime+0x91>
lea    -0xc(%rbp),%rdi
call   1070 <time@plt>
lea    -0xc(%rbp),%rdi
call   1030 <localtime@plt>
mov    %rax,0x2ebf(%rip)
mov    0x2eb8(%rip),%rdi
call   1050 <asctime@plt>
mov    %rax,-0x20(%rbp)
lea    0xe7a(%rip),%rdi
call   1040 <strlen@plt>
mov    -0x20(%rbp),%rcx
cltq
add    %rax,%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x18(%rbp)
lea    0xe5f(%rip),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<TOOLS_GetTime>:
test   %rdi,%rdi
je     11b9 <TOOLS_GetTime+0x69>
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%r15
lea    0xc(%rsp),%r14
mov    %r14,%rdi
call   1070 <time@plt>
mov    %r14,%rdi
call   1030 <localtime@plt>
mov    %rax,0x2ed3(%rip)
mov    %rax,%rdi
call   1050 <asctime@plt>
mov    %rax,%r14
lea    0xe93(%rip),%rdi
call   1040 <strlen@plt>
movslq %eax,%rbx
add    %r14,%rbx
mov    %rbx,(%r15)
lea    0xe8a(%rip),%rdi
call   1040 <strlen@plt>
cltq
movb   $0x0,(%rax,%rbx,1)
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret
lea    0xe40(%rip),%rdi
jmp    1060 <printf@plt>

LLVM IR (-O0):
%struct.tm = type { i32 }
@TOOLS_GetTime.pTimeInfo = internal global %struct.tm* null
@.str = [34 x i8] c"ERROR: Input time string is NULL!\00"
@.str.1 = [12 x i8] c"Www Mmm dd \00"
@.str.2 = [9 x i8] c"hh:mm:ss\00"
define void @TOOLS_GetTime(i8** %0) {
%2 = alloca i8**
%3 = alloca i32
store i8** %0, i8*** %2
%4 = load i8**, i8*** %2
%5 = icmp eq i8** %4, null
br i1 %5, label %6, label %8
6: ; preds = %1
%7 = call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
br label %22
8: ; preds = %1
%9 = call i32 @time(i32* %3)
%10 = call %struct.tm* @localtime(i32* %3)
store %struct.tm* %10, %struct.tm** @TOOLS_GetTime.pTimeInfo
%11 = load %struct.tm*, %struct.tm** @TOOLS_GetTime.pTimeInfo
%12 = call i8* @asctime(%struct.tm* %11)
%13 = call i32 @strlen(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds i8, i8* %12, i64 %14
%16 = load i8**, i8*** %2
store i8* %15, i8** %16
%17 = load i8**, i8*** %2
%18 = load i8*, i8** %17
%19 = call i32 @strlen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds i8, i8* %18, i64 %20
store i8 0, i8* %21
br label %22
22: ; preds = %8, %6
ret void
}

LLVM IR (-O2):
%struct.tm = type { i32 }
@TOOLS_GetTime.pTimeInfo = internal unnamed_addr global %struct.tm* null
@.str = [34 x i8] c"ERROR: Input time string is NULL!\00"
@.str.1 = [12 x i8] c"Www Mmm dd \00"
@.str.2 = [9 x i8] c"hh:mm:ss\00"
define void @TOOLS_GetTime(i8** writeonly %0) {
%2 = alloca i32
%3 = bitcast i32* %2 to i8*
%4 = icmp eq i8** %0, null
br i1 %4, label %5, label %7
5: ; preds = %1
%6 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
br label %17
7: ; preds = %1
%8 = call i32 @time(i32* %2)
%9 = call %struct.tm* @localtime(i32* %2)
store %struct.tm* %9, %struct.tm** @TOOLS_GetTime.pTimeInfo
%10 = call i8* @asctime(%struct.tm* %9)
%11 = call i32 @strlen(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds i8, i8* %10, i64 %12
store i8* %13, i8** %0
%14 = call i32 @strlen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds i8, i8* %13, i64 %15
store i8 0, i8* %16
br label %17
17: ; preds = %7, %5
ret void
}