#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 scalar_t__ time_t;
struct tm {
  size_t tm_hour;
  int /*<<< orphan*/ tm_sec;
  int /*<<< orphan*/ tm_min;
};
struct timeval {
  scalar_t__ tv_sec;
  int tv_usec;
};

/* Variables and functions */
int /*<<< orphan*/ d59(char *, int /*<<< orphan*/);
int /*<<< orphan*/ d999(char *, int);
int /*<<< orphan*/ gettimeofday(struct timeval *, int /*<<< orphan*/ *);
int /*<<< orphan*/ localtime_r(scalar_t__ *, struct tm *);
int /*<<< orphan*/ memcpy(char *, char *, int);
void ts_9(char *to) {
  static time_t sec = 0;
  static char sbuf[8] = {48, 48, 48, 48, 48, 46, 0, 0};
  struct timeval tv;
  gettimeofday(&tv, NULL);
  time_t sec2 = tv.tv_sec;
  if (sec2 != sec) {
    sec = sec2;
    struct tm loct;
    localtime_r(&sec, &loct);
    sbuf[0] = "0123456789ten123456789TE"[loct.tm_hour];
    d59(sbuf + 1, loct.tm_min);
    d59(sbuf + 3, loct.tm_sec);
  }
  memcpy(to, sbuf, 6);
  d999(to + 6, tv.tv_usec / 1000);
}


x86 assembly (clang, -O0):
<ts_9>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
lea    -0x18(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1050 <gettimeofday@plt>
mov    -0x18(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmp    0x2edc(%rip),%rax
je     11d7 <ts_9+0x87>
mov    -0x20(%rbp),%rax
mov    %rax,0x2ecb(%rip)
lea    0x2ec4(%rip),%rdi
lea    -0x30(%rbp),%rsi
call   1030 <localtime_r@plt>
mov    -0x30(%rbp),%rcx
lea    0xe58(%rip),%rax
mov    (%rax,%rcx,1),%al
mov    %al,0x2e97(%rip)
mov    -0x24(%rbp),%esi
lea    0x2e8d(%rip),%rdi
add    $0x1,%rdi
call   1040 <d59@plt>
mov    -0x28(%rbp),%esi
lea    0x2e7a(%rip),%rdi
add    $0x3,%rdi
call   1040 <d59@plt>
mov    -0x8(%rbp),%rdi
lea    0x2e66(%rip),%rsi
mov    $0x6,%edx
call   1060 <memcpy@plt>
mov    -0x8(%rbp),%rdi
add    $0x6,%rdi
mov    -0x10(%rbp),%eax
mov    $0x3e8,%ecx
cltd
idiv   %ecx
mov    %eax,%esi
call   1070 <d999@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ts_9>:
push   %rbx
sub    $0x20,%rsp
mov    %rdi,%rbx
lea    0x10(%rsp),%rdi
xor    %esi,%esi
call   1050 <gettimeofday@plt>
mov    0x10(%rsp),%rax
cmp    0x2ee8(%rip),%rax
je     11bc <ts_9+0x6c>
mov    %rax,0x2edf(%rip)
lea    0x2ed8(%rip),%rdi
mov    %rsp,%rsi
call   1030 <localtime_r@plt>
mov    (%rsp),%rax
lea    0xe6d(%rip),%rcx
mov    (%rax,%rcx,1),%al
mov    %al,0x2eac(%rip)
mov    0xc(%rsp),%esi
lea    0x2ea2(%rip),%rdi
call   1040 <d59@plt>
mov    0x8(%rsp),%esi
lea    0x2e94(%rip),%rdi
call   1040 <d59@plt>
lea    0x2e85(%rip),%rsi
mov    %rbx,%rdi
mov    $0x6,%edx
call   1060 <memcpy@plt>
add    $0x6,%rbx
movslq 0x18(%rsp),%rax
imul   $0x10624dd3,%rax,%rsi
mov    %rsi,%rax
shr    $0x3f,%rax
sar    $0x26,%rsi
add    %eax,%esi
mov    %rbx,%rdi
call   1070 <d999@plt>
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.timeval = type { i64, i32 }
%struct.tm = type { i64, i32, i32 }
@ts_9.sec = internal global i64 0
@ts_9.sbuf = internal global [8 x i8] c"00000.\00\00"
@.str = [25 x i8] c"0123456789ten123456789TE\00"
define void @ts_9(i8* %0) {
%2 = alloca i8*
%3 = alloca %struct.timeval
%4 = alloca i64
%5 = alloca %struct.tm
store i8* %0, i8** %2
%6 = call i32 @gettimeofday(%struct.timeval* %3, i32* null)
%7 = getelementptr inbounds %struct.timeval, %struct.timeval* %3, i32 0, i32 0
%8 = load i64, i64* %7
store i64 %8, i64* %4
%9 = load i64, i64* %4
%10 = load i64, i64* @ts_9.sec
%11 = icmp ne i64 %9, %10
br i1 %11, label %12, label %25
12: ; preds = %1
%13 = load i64, i64* %4
store i64 %13, i64* @ts_9.sec
%14 = call i32 @localtime_r(i64* @ts_9.sec, %struct.tm* %5)
%15 = getelementptr inbounds %struct.tm, %struct.tm* %5, i32 0, i32 0
%16 = load i64, i64* %15
%17 = getelementptr inbounds [25 x i8], [25 x i8]* @.str, i64 0, i64 %16
%18 = load i8, i8* %17
store i8 %18, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @ts_9.sbuf, i64 0, i64 0)
%19 = getelementptr inbounds %struct.tm, %struct.tm* %5, i32 0, i32 2
%20 = load i32, i32* %19
%21 = call i32 @d59(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @ts_9.sbuf, i64 0, i64 1), i32 %20)
%22 = getelementptr inbounds %struct.tm, %struct.tm* %5, i32 0, i32 1
%23 = load i32, i32* %22
%24 = call i32 @d59(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @ts_9.sbuf, i64 0, i64 3), i32 %23)
br label %25
25: ; preds = %12, %1
%26 = load i8*, i8** %2
%27 = call i32 @memcpy(i8* %26, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @ts_9.sbuf, i64 0, i64 0), i32 6)
%28 = load i8*, i8** %2
%29 = getelementptr inbounds i8, i8* %28, i64 6
%30 = getelementptr inbounds %struct.timeval, %struct.timeval* %3, i32 0, i32 1
%31 = load i32, i32* %30
%32 = sdiv i32 %31, 1000
%33 = call i32 @d999(i8* %29, i32 %32)
ret void
}

LLVM IR (-O2):
%struct.timeval = type { i64, i32 }
%struct.tm = type { i64, i32, i32 }
@ts_9.sec = internal global i64 0
@ts_9.sbuf = internal global [8 x i8] c"00000.\00\00"
@.str = [25 x i8] c"0123456789ten123456789TE\00"
define void @ts_9(i8* %0) {
%2 = alloca %struct.timeval
%3 = alloca %struct.tm
%4 = bitcast %struct.timeval* %2 to i8*
%5 = call i32 @gettimeofday(%struct.timeval* %2, i32* null)
%6 = getelementptr inbounds %struct.timeval, %struct.timeval* %2, i64 0, i32 0
%7 = load i64, i64* %6
%8 = load i64, i64* @ts_9.sec
%9 = icmp eq i64 %7, %8
br i1 %9, label %23, label %10
10: ; preds = %1
store i64 %7, i64* @ts_9.sec
%11 = bitcast %struct.tm* %3 to i8*
%12 = call i32 @localtime_r(i64* @ts_9.sec, %struct.tm* %3)
%13 = getelementptr inbounds %struct.tm, %struct.tm* %3, i64 0, i32 0
%14 = load i64, i64* %13
%15 = getelementptr inbounds [25 x i8], [25 x i8]* @.str, i64 0, i64 %14
%16 = load i8, i8* %15
store i8 %16, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @ts_9.sbuf, i64 0, i64 0)
%17 = getelementptr inbounds %struct.tm, %struct.tm* %3, i64 0, i32 2
%18 = load i32, i32* %17
%19 = call i32 @d59(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @ts_9.sbuf, i64 0, i64 1), i32 %18)
%20 = getelementptr inbounds %struct.tm, %struct.tm* %3, i64 0, i32 1
%21 = load i32, i32* %20
%22 = call i32 @d59(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @ts_9.sbuf, i64 0, i64 3), i32 %21)
br label %23
23: ; preds = %10, %1
%24 = call i32 @memcpy(i8* %0, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @ts_9.sbuf, i64 0, i64 0), i32 6)
%25 = getelementptr inbounds i8, i8* %0, i64 6
%26 = getelementptr inbounds %struct.timeval, %struct.timeval* %2, i64 0, i32 1
%27 = load i32, i32* %26
%28 = sdiv i32 %27, 1000
%29 = call i32 @d999(i8* %25, i32 %28)
ret void
}