#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 */
struct tm {
  int dummy;
};
struct timeb {
  int millitm;
  int /*<<< orphan*/ time;
};

/* Variables and functions */
int /*<<< orphan*/ ftime(struct timeb *);
struct tm *localtime(int /*<<< orphan*/ *);
int /*<<< orphan*/ sprintf(char *, char *, int);
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strftime(char *, int, char *, struct tm *);
const char *logTime() {
  static char buf[128], buf2[10];
  static struct timeb tstruct;
  struct tm *tm1;
  ftime(&(tstruct));
  tm1 = localtime(&((tstruct).time));
  strftime(buf, 127, "%Y/%m/%d %H:%M:%S", tm1);
  sprintf(buf2, ".%.3d", tstruct.millitm);
  strcat(buf, buf2);
  return buf;
}


x86 assembly (clang, -O0):
<logTime>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0x2f8d(%rip),%rdi
call   1070 <ftime@plt>
lea    0x2f81(%rip),%rdi
add    $0x4,%rdi
call   1030 <localtime@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rcx
lea    0x2edd(%rip),%rdi
mov    $0x7f,%esi
lea    0xe71(%rip),%rdx
call   1040 <strftime@plt>
mov    0x2f52(%rip),%edx
lea    0x2f3f(%rip),%rdi
lea    0xe6a(%rip),%rsi
call   1060 <sprintf@plt>
lea    0x2eac(%rip),%rdi
lea    0x2f25(%rip),%rsi
call   1050 <strcat@plt>
lea    0x2e99(%rip),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<logTime>:
push   %r14
push   %rbx
push   %rax
lea    0x2f91(%rip),%rdi
call   1070 <ftime@plt>
lea    0x2f89(%rip),%rdi
call   1030 <localtime@plt>
lea    0x2eed(%rip),%r14
lea    0xe86(%rip),%rdx
mov    %r14,%rdi
mov    $0x7f,%esi
mov    %rax,%rcx
call   1040 <strftime@plt>
mov    0x2f5c(%rip),%edx
lea    0x2f49(%rip),%rbx
lea    0xe74(%rip),%rsi
mov    %rbx,%rdi
call   1060 <sprintf@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1050 <strcat@plt>
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.timeb = type { i32, i32 }
%struct.tm = type { i32 }
@logTime.buf = internal global [128 x i8] zeroinitializer
@logTime.buf2 = internal global [10 x i8] zeroinitializer
@logTime.tstruct = internal global %struct.timeb zeroinitializer
@.str = [18 x i8] c"%Y/%m/%d %H:%M:%S\00"
@.str.1 = [6 x i8] c".%.3d\00"
define i8* @logTime() {
%1 = alloca %struct.tm*
%2 = call i32 @ftime(%struct.timeb* @logTime.tstruct)
%3 = call %struct.tm* @localtime(i32* getelementptr inbounds (%struct.timeb, %struct.timeb* @logTime.tstruct, i32 0, i32 1))
store %struct.tm* %3, %struct.tm** %1
%4 = load %struct.tm*, %struct.tm** %1
%5 = call i32 @strftime(i8* getelementptr inbounds ([128 x i8], [128 x i8]* @logTime.buf, i64 0, i64 0), i32 127, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), %struct.tm* %4)
%6 = load i32, i32* getelementptr inbounds (%struct.timeb, %struct.timeb* @logTime.tstruct, i32 0, i32 0)
%7 = call i32 @sprintf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @logTime.buf2, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %6)
%8 = call i32 @strcat(i8* getelementptr inbounds ([128 x i8], [128 x i8]* @logTime.buf, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @logTime.buf2, i64 0, i64 0))
ret i8* getelementptr inbounds ([128 x i8], [128 x i8]* @logTime.buf, i64 0, i64 0)
}

LLVM IR (-O2):
%struct.timeb = type { i32, i32 }
%struct.tm = type { i32 }
@logTime.buf = internal global [128 x i8] zeroinitializer
@logTime.buf2 = internal global [10 x i8] zeroinitializer
@logTime.tstruct = internal global %struct.timeb zeroinitializer
@.str = [18 x i8] c"%Y/%m/%d %H:%M:%S\00"
@.str.1 = [6 x i8] c".%.3d\00"
define i8* @logTime() {
%1 = tail call i32 @ftime(%struct.timeb* @logTime.tstruct)
%2 = tail call %struct.tm* @localtime(i32* getelementptr inbounds (%struct.timeb, %struct.timeb* @logTime.tstruct, i64 0, i32 1))
%3 = tail call i32 @strftime(i8* getelementptr inbounds ([128 x i8], [128 x i8]* @logTime.buf, i64 0, i64 0), i32 127, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), %struct.tm* %2)
%4 = load i32, i32* getelementptr inbounds (%struct.timeb, %struct.timeb* @logTime.tstruct, i64 0, i32 0)
%5 = tail call i32 @sprintf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @logTime.buf2, i64 0, i64 0), i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %4)
%6 = tail call i32 @strcat(i8* getelementptr inbounds ([128 x i8], [128 x i8]* @logTime.buf, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @logTime.buf2, i64 0, i64 0))
ret i8* getelementptr inbounds ([128 x i8], [128 x i8]* @logTime.buf, i64 0, i64 0)
}