#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*/ szTime;
struct tm {
  int tm_year;
  int tm_mon;
  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,
                           char const *, int const);
int /*<<< orphan*/ strncpy(char *, char *, size_t);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int currentTime(const char *file, const int line, char *currTime, size_t size) {
  struct tm *ptm = NULL;
  time_t t;
  char szTime[256];
  t = time(NULL);
  ptm = localtime(&t);
  memset(szTime, 0, sizeof(szTime));
  sprintf(szTime, "[%d-%02d-%02d %02d:%02d:%02d][%s:%03d] ",
          (ptm->tm_year + 1900), ptm->tm_mon + 1, ptm->tm_mday, ptm->tm_hour,
          ptm->tm_min, ptm->tm_sec, file, line);
  strncpy(currTime, szTime, size);
  return 0;
}


x86 assembly (clang, -O0):
<currentTime>:
push   %rbp
mov    %rsp,%rbp
push   %rbx
sub    $0x158,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
movq   $0x0,-0x30(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1060 <time@plt>
mov    %eax,-0x34(%rbp)
lea    -0x34(%rbp),%rdi
call   1030 <localtime@plt>
mov    %rax,-0x30(%rbp)
lea    -0x140(%rbp),%rdi
xor    %esi,%esi
mov    $0x100,%edx
call   1050 <memset@plt>
lea    -0x140(%rbp),%rdi
mov    -0x30(%rbp),%rax
mov    (%rax),%edx
add    $0x76c,%edx
mov    -0x30(%rbp),%rax
mov    0x4(%rax),%ecx
add    $0x1,%ecx
mov    -0x30(%rbp),%rax
mov    0x8(%rax),%r8d
mov    -0x30(%rbp),%rax
mov    0xc(%rax),%r9d
mov    -0x30(%rbp),%rax
mov    0x10(%rax),%ebx
mov    -0x30(%rbp),%rax
mov    0x14(%rax),%r11d
mov    -0x10(%rbp),%r10
mov    -0x14(%rbp),%eax
lea    0xe17(%rip),%rsi
mov    %ebx,(%rsp)
mov    %r11d,0x8(%rsp)
mov    %r10,0x10(%rsp)
mov    %eax,0x18(%rsp)
call   1070 <sprintf@plt>
mov    -0x20(%rbp),%rdi
lea    -0x140(%rbp),%rsi
mov    -0x28(%rbp),%rdx
call   1040 <strncpy@plt>
xor    %eax,%eax
add    $0x158,%rsp
pop    %rbx
pop    %rbp
ret

x86 assembly (clang, -O2):
<currentTime>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x118,%rsp
mov    %rcx,%r14
mov    %rdx,%r15
mov    %esi,%r13d
mov    %rdi,%r12
xor    %edi,%edi
call   1060 <time@plt>
mov    %eax,0xc(%rsp)
lea    0xc(%rsp),%rdi
call   1030 <localtime@plt>
mov    %rax,%rbp
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x100,%edx
call   1050 <memset@plt>
mov    $0x76c,%edx
add    0x0(%rbp),%edx
mov    0x4(%rbp),%ecx
mov    0x8(%rbp),%r8d
add    $0x1,%ecx
mov    0xc(%rbp),%r9d
mov    0x10(%rbp),%eax
mov    0x14(%rbp),%ebp
lea    0xe44(%rip),%rsi
mov    %rbx,%rdi
push   %r13
push   %r12
push   %rbp
push   %rax
call   1070 <sprintf@plt>
add    $0x20,%rsp
mov    %r15,%rdi
mov    %rbx,%rsi
mov    %r14,%rdx
call   1040 <strncpy@plt>
xor    %eax,%eax
add    $0x118,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
%struct.tm = type { i32, i32, i32, i32, i32, i32 }
@.str = [40 x i8] c"[%d-%02d-%02d %02d:%02d:%02d][%s:%03d] \00"
define i32 @currentTime(i8* %0, i32 %1, i8* %2, i64 %3) {
%5 = alloca i32
%6 = alloca [256 x i8]
%7 = bitcast i32* %5 to i8*
%8 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%9 = tail call i32 @time(i32* null)
store i32 %9, i32* %5
%10 = call %struct.tm* @localtime(i32* %5)
%11 = call i32 @memset(i8* %8, i32 0, i32 256)
%12 = getelementptr inbounds %struct.tm, %struct.tm* %10, i64 0, i32 0
%13 = load i32, i32* %12
%14 = add nsw i32 %13, 1900
%15 = getelementptr inbounds %struct.tm, %struct.tm* %10, i64 0, i32 1
%16 = load i32, i32* %15
%17 = add nsw i32 %16, 1
%18 = getelementptr inbounds %struct.tm, %struct.tm* %10, i64 0, i32 2
%19 = load i32, i32* %18
%20 = getelementptr inbounds %struct.tm, %struct.tm* %10, i64 0, i32 3
%21 = load i32, i32* %20
%22 = getelementptr inbounds %struct.tm, %struct.tm* %10, i64 0, i32 4
%23 = load i32, i32* %22
%24 = getelementptr inbounds %struct.tm, %struct.tm* %10, i64 0, i32 5
%25 = load i32, i32* %24
%26 = call i32 @sprintf(i8* %8, i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0), i32 %14, i32 %17, i32 %19, i32 %21, i32 %23, i32 %25, i8* %0, i32 %1)
%27 = call i32 @strncpy(i8* %2, i8* %8, i64 %3)
ret i32 0
}