#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 tm_mon;
  int tm_year;
  int tm_mday;
  int tm_hour;
  int tm_min;
  int tm_sec;
};

/* Variables and functions */
struct tm *localtime(int /*<<< orphan*/ *);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ sprintf(char *, char *, int, int, int, int, int, int);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
void getTimeStamp(char *pOutputTime) {
  if (pOutputTime != NULL) {
    struct tm *pLocalTime = NULL;
    time_t rawtime;
    memset(pOutputTime, 0, sizeof(char) * 20);
    time(&rawtime);
    pLocalTime = localtime(&rawtime);
    if (pLocalTime != NULL) {
      pLocalTime->tm_mon += 1;
      pLocalTime->tm_year += 1900;
      sprintf(pOutputTime, "%.2i/%.2i/%.4i %.2i:%.2i:%.2i", pLocalTime->tm_mday,
              pLocalTime->tm_mon, pLocalTime->tm_year, pLocalTime->tm_hour,
              pLocalTime->tm_min, pLocalTime->tm_sec);
    }
  }
}


x86 assembly (clang, -O0):
<getTimeStamp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     11f4 <getTimeStamp+0xb4>
movq   $0x0,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
xor    %esi,%esi
mov    $0x14,%edx
call   1040 <memset@plt>
lea    -0x14(%rbp),%rdi
call   1050 <time@plt>
lea    -0x14(%rbp),%rdi
call   1030 <localtime@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     11ef <getTimeStamp+0xaf>
mov    -0x10(%rbp),%rax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    %ecx,(%rax)
mov    -0x10(%rbp),%rax
mov    0x4(%rax),%ecx
add    $0x76c,%ecx
mov    %ecx,0x4(%rax)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%edx
mov    -0x10(%rbp),%rax
mov    (%rax),%ecx
mov    -0x10(%rbp),%rax
mov    0x4(%rax),%r8d
mov    -0x10(%rbp),%rax
mov    0xc(%rax),%r9d
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%r10d
mov    -0x10(%rbp),%rax
mov    0x14(%rax),%eax
lea    0xe1e(%rip),%rsi
mov    %r10d,(%rsp)
mov    %eax,0x8(%rsp)
call   1060 <sprintf@plt>
jmp    11f4 <getTimeStamp+0xb4>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getTimeStamp>:
test   %rdi,%rdi
je     11b2 <getTimeStamp+0x72>
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
xor    %esi,%esi
mov    $0x14,%edx
call   1040 <memset@plt>
lea    0x4(%rsp),%r14
mov    %r14,%rdi
call   1050 <time@plt>
mov    %r14,%rdi
call   1030 <localtime@plt>
test   %rax,%rax
je     11ab <getTimeStamp+0x6b>
mov    (%rax),%ecx
mov    0x8(%rax),%edx
add    $0x1,%ecx
mov    %ecx,(%rax)
mov    $0x76c,%r8d
add    0x4(%rax),%r8d
mov    %r8d,0x4(%rax)
mov    0xc(%rax),%r9d
mov    0x10(%rax),%r10d
mov    0x14(%rax),%eax
lea    0xe64(%rip),%rsi
mov    %rbx,%rdi
push   %rax
push   %r10
call   1060 <sprintf@plt>
add    $0x10,%rsp
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.tm = type { i32, i32, i32, i32, i32, i32 }
@.str = [30 x i8] c"%.2i/%.2i/%.4i %.2i:%.2i:%.2i\00"
define void @getTimeStamp(i8* %0) {
%2 = alloca i8*
%3 = alloca %struct.tm*
%4 = alloca i32
store i8* %0, i8** %2
%5 = load i8*, i8** %2
%6 = icmp ne i8* %5, null
br i1 %6, label %7, label %44
7: ; preds = %1
store %struct.tm* null, %struct.tm** %3
%8 = load i8*, i8** %2
%9 = call i32 @memset(i8* %8, i32 0, i32 20)
%10 = call i32 @time(i32* %4)
%11 = call %struct.tm* @localtime(i32* %4)
store %struct.tm* %11, %struct.tm** %3
%12 = load %struct.tm*, %struct.tm** %3
%13 = icmp ne %struct.tm* %12, null
br i1 %13, label %14, label %43
14: ; preds = %7
%15 = load %struct.tm*, %struct.tm** %3
%16 = getelementptr inbounds %struct.tm, %struct.tm* %15, i32 0, i32 0
%17 = load i32, i32* %16
%18 = add nsw i32 %17, 1
store i32 %18, i32* %16
%19 = load %struct.tm*, %struct.tm** %3
%20 = getelementptr inbounds %struct.tm, %struct.tm* %19, i32 0, i32 1
%21 = load i32, i32* %20
%22 = add nsw i32 %21, 1900
store i32 %22, i32* %20
%23 = load i8*, i8** %2
%24 = load %struct.tm*, %struct.tm** %3
%25 = getelementptr inbounds %struct.tm, %struct.tm* %24, i32 0, i32 2
%26 = load i32, i32* %25
%27 = load %struct.tm*, %struct.tm** %3
%28 = getelementptr inbounds %struct.tm, %struct.tm* %27, i32 0, i32 0
%29 = load i32, i32* %28
%30 = load %struct.tm*, %struct.tm** %3
%31 = getelementptr inbounds %struct.tm, %struct.tm* %30, i32 0, i32 1
%32 = load i32, i32* %31
%33 = load %struct.tm*, %struct.tm** %3
%34 = getelementptr inbounds %struct.tm, %struct.tm* %33, i32 0, i32 3
%35 = load i32, i32* %34
%36 = load %struct.tm*, %struct.tm** %3
%37 = getelementptr inbounds %struct.tm, %struct.tm* %36, i32 0, i32 4
%38 = load i32, i32* %37
%39 = load %struct.tm*, %struct.tm** %3
%40 = getelementptr inbounds %struct.tm, %struct.tm* %39, i32 0, i32 5
%41 = load i32, i32* %40
%42 = call i32 @sprintf(i8* %23, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i32 %26, i32 %29, i32 %32, i32 %35, i32 %38, i32 %41)
br label %43
43: ; preds = %14, %7
br label %44
44: ; preds = %43, %1
ret void
}

LLVM IR (-O2):
%struct.tm = type { i32, i32, i32, i32, i32, i32 }
@.str = [30 x i8] c"%.2i/%.2i/%.4i %.2i:%.2i:%.2i\00"
define void @getTimeStamp(i8* %0) {
%2 = alloca i32
%3 = icmp eq i8* %0, null
br i1 %3, label %27, label %4
4: ; preds = %1
%5 = bitcast i32* %2 to i8*
%6 = tail call i32 @memset(i8* %0, i32 0, i32 20)
%7 = call i32 @time(i32* %2)
%8 = call %struct.tm* @localtime(i32* %2)
%9 = icmp eq %struct.tm* %8, null
br i1 %9, label %26, label %10
10: ; preds = %4
%11 = getelementptr inbounds %struct.tm, %struct.tm* %8, i64 0, i32 0
%12 = load i32, i32* %11
%13 = add nsw i32 %12, 1
store i32 %13, i32* %11
%14 = getelementptr inbounds %struct.tm, %struct.tm* %8, i64 0, i32 1
%15 = load i32, i32* %14
%16 = add nsw i32 %15, 1900
store i32 %16, i32* %14
%17 = getelementptr inbounds %struct.tm, %struct.tm* %8, i64 0, i32 2
%18 = load i32, i32* %17
%19 = getelementptr inbounds %struct.tm, %struct.tm* %8, i64 0, i32 3
%20 = load i32, i32* %19
%21 = getelementptr inbounds %struct.tm, %struct.tm* %8, i64 0, i32 4
%22 = load i32, i32* %21
%23 = getelementptr inbounds %struct.tm, %struct.tm* %8, i64 0, i32 5
%24 = load i32, i32* %23
%25 = call i32 @sprintf(i8* %0, i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i32 %18, i32 %13, i32 %16, i32 %20, i32 %22, i32 %24)
br label %26
26: ; preds = %10, %4
br label %27
27: ; preds = %26, %1
ret void
}