#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_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*/ sprintf(char *, char *, int, int, int, int, int, int);
int strlen(char *);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int writeLogFileTimeStamp(char *buf) {
  time_t timer;
  struct tm *tblock;
  timer = time(NULL);
  tblock = localtime(&timer);
  sprintf(buf, " [%d-%d-%d %d:%d:%d] ", (tblock->tm_year % 100),
          (tblock->tm_mon), (tblock->tm_mday), (tblock->tm_hour),
          (tblock->tm_min), (tblock->tm_sec));
  return strlen(buf);
}


x86 assembly (clang, -O0):
<writeLogFileTimeStamp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1050 <time@plt>
mov    %eax,-0xc(%rbp)
lea    -0xc(%rbp),%rdi
call   1030 <localtime@plt>
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rax
mov    (%rax),%eax
mov    $0x64,%ecx
cltd
idiv   %ecx
mov    -0x18(%rbp),%rax
mov    0x4(%rax),%ecx
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%r8d
mov    -0x18(%rbp),%rax
mov    0xc(%rax),%r9d
mov    -0x18(%rbp),%rax
mov    0x10(%rax),%r10d
mov    -0x18(%rbp),%rax
mov    0x14(%rax),%eax
lea    0xe5c(%rip),%rsi
mov    %r10d,(%rsp)
mov    %eax,0x8(%rsp)
call   1060 <sprintf@plt>
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<writeLogFileTimeStamp>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
xor    %edi,%edi
call   1050 <time@plt>
mov    %eax,0x4(%rsp)
lea    0x4(%rsp),%rdi
call   1030 <localtime@plt>
movslq (%rax),%rdx
imul   $0x51eb851f,%rdx,%rcx
mov    %rcx,%rsi
shr    $0x3f,%rsi
sar    $0x25,%rcx
add    %esi,%ecx
imul   $0x64,%ecx,%ecx
sub    %ecx,%edx
mov    0x4(%rax),%ecx
mov    0x8(%rax),%r8d
mov    0xc(%rax),%r9d
mov    0x10(%rax),%ebx
mov    0x14(%rax),%eax
lea    0xe70(%rip),%rsi
mov    %r14,%rdi
push   %rax
push   %rbx
call   1060 <sprintf@plt>
add    $0x10,%rsp
mov    %r14,%rdi
call   1040 <strlen@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.tm = type { i32, i32, i32, i32, i32, i32 }
@.str = [22 x i8] c" [%d-%d-%d %d:%d:%d] \00"
define i32 @writeLogFileTimeStamp(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca %struct.tm*
store i8* %0, i8** %2
%5 = call i32 @time(i32* null)
store i32 %5, i32* %3
%6 = call %struct.tm* @localtime(i32* %3)
store %struct.tm* %6, %struct.tm** %4
%7 = load i8*, i8** %2
%8 = load %struct.tm*, %struct.tm** %4
%9 = getelementptr inbounds %struct.tm, %struct.tm* %8, i32 0, i32 0
%10 = load i32, i32* %9
%11 = srem i32 %10, 100
%12 = load %struct.tm*, %struct.tm** %4
%13 = getelementptr inbounds %struct.tm, %struct.tm* %12, i32 0, i32 1
%14 = load i32, i32* %13
%15 = load %struct.tm*, %struct.tm** %4
%16 = getelementptr inbounds %struct.tm, %struct.tm* %15, i32 0, i32 2
%17 = load i32, i32* %16
%18 = load %struct.tm*, %struct.tm** %4
%19 = getelementptr inbounds %struct.tm, %struct.tm* %18, i32 0, i32 3
%20 = load i32, i32* %19
%21 = load %struct.tm*, %struct.tm** %4
%22 = getelementptr inbounds %struct.tm, %struct.tm* %21, i32 0, i32 4
%23 = load i32, i32* %22
%24 = load %struct.tm*, %struct.tm** %4
%25 = getelementptr inbounds %struct.tm, %struct.tm* %24, i32 0, i32 5
%26 = load i32, i32* %25
%27 = call i32 @sprintf(i8* %7, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 %11, i32 %14, i32 %17, i32 %20, i32 %23, i32 %26)
%28 = load i8*, i8** %2
%29 = call i32 @strlen(i8* %28)
ret i32 %29
}

LLVM IR (-O2):
%struct.tm = type { i32, i32, i32, i32, i32, i32 }
@.str = [22 x i8] c" [%d-%d-%d %d:%d:%d] \00"
define i32 @writeLogFileTimeStamp(i8* %0) {
%2 = alloca i32
%3 = bitcast i32* %2 to i8*
%4 = tail call i32 @time(i32* null)
store i32 %4, i32* %2
%5 = call %struct.tm* @localtime(i32* %2)
%6 = getelementptr inbounds %struct.tm, %struct.tm* %5, i64 0, i32 0
%7 = load i32, i32* %6
%8 = srem i32 %7, 100
%9 = getelementptr inbounds %struct.tm, %struct.tm* %5, i64 0, i32 1
%10 = load i32, i32* %9
%11 = getelementptr inbounds %struct.tm, %struct.tm* %5, i64 0, i32 2
%12 = load i32, i32* %11
%13 = getelementptr inbounds %struct.tm, %struct.tm* %5, i64 0, i32 3
%14 = load i32, i32* %13
%15 = getelementptr inbounds %struct.tm, %struct.tm* %5, i64 0, i32 4
%16 = load i32, i32* %15
%17 = getelementptr inbounds %struct.tm, %struct.tm* %5, i64 0, i32 5
%18 = load i32, i32* %17
%19 = call i32 @sprintf(i8* dereferenceable(1) %0, i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 %8, i32 %10, i32 %12, i32 %14, i32 %16, i32 %18)
%20 = call i32 @strlen(i8* %0)
ret i32 %20
}