#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 timeval {
  int tv_usec;
  int /*<<< orphan*/ tv_sec;
};

/* Variables and functions */
int /*<<< orphan*/ gettimeofday(struct timeval *, int /*<<< orphan*/ *);
int /*<<< orphan*/ localtime(int /*<<< orphan*/ *);
int /*<<< orphan*/ memset(struct timeval *, int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *, char *, int);
int /*<<< orphan*/ strftime(char *, int, char *, int /*<<< orphan*/);
void print_TOD() {
  char buffer[32];
  struct timeval time;
  memset(&time, 0, sizeof(struct timeval));
  gettimeofday(&time, NULL);
  strftime(buffer, 32, "%H:%M:%S", localtime(&time.tv_sec));
  printf("%s.%03ld\n", buffer, time.tv_usec / 1000);
}


x86 assembly (clang, -O0):
<print_TOD>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
lea    -0x28(%rbp),%rdi
xor    %esi,%esi
mov    $0x8,%edx
call   1060 <memset@plt>
lea    -0x28(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1050 <gettimeofday@plt>
lea    -0x20(%rbp),%rax
mov    %rax,-0x30(%rbp)
lea    -0x28(%rbp),%rdi
add    $0x4,%rdi
call   1030 <localtime@plt>
mov    -0x30(%rbp),%rdi
mov    %eax,%ecx
mov    $0x20,%esi
lea    0xe64(%rip),%rdx
call   1070 <strftime@plt>
lea    -0x20(%rbp),%rsi
mov    -0x28(%rbp),%eax
mov    $0x3e8,%ecx
cltd
idiv   %ecx
mov    %eax,%edx
lea    0xe50(%rip),%rdi
call   1040 <printf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_TOD>:
push   %rbx
sub    $0x30,%rsp
lea    0x8(%rsp),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x8,%edx
call   1060 <memset@plt>
mov    %rbx,%rdi
xor    %esi,%esi
call   1050 <gettimeofday@plt>
lea    0xc(%rsp),%rdi
call   1030 <localtime@plt>
lea    0xe7c(%rip),%rdx
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x20,%esi
mov    %eax,%ecx
call   1070 <strftime@plt>
movslq 0x8(%rsp),%rax
imul   $0x10624dd3,%rax,%rdx
mov    %rdx,%rax
shr    $0x3f,%rax
sar    $0x26,%rdx
add    %eax,%edx
lea    0xe51(%rip),%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
add    $0x30,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.timeval = type { i32, i32 }
@.str = [9 x i8] c"%H:%M:%S\00"
@.str.1 = [10 x i8] c"%s.%03ld\0A\00"
define void @print_TOD() {
%1 = alloca [32 x i8]
%2 = alloca %struct.timeval
%3 = call i32 @memset(%struct.timeval* %2, i32 0, i32 8)
%4 = call i32 @gettimeofday(%struct.timeval* %2, i32* null)
%5 = getelementptr inbounds [32 x i8], [32 x i8]* %1, i64 0, i64 0
%6 = getelementptr inbounds %struct.timeval, %struct.timeval* %2, i32 0, i32 1
%7 = call i32 @localtime(i32* %6)
%8 = call i32 @strftime(i8* %5, i32 32, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %7)
%9 = getelementptr inbounds [32 x i8], [32 x i8]* %1, i64 0, i64 0
%10 = getelementptr inbounds %struct.timeval, %struct.timeval* %2, i32 0, i32 0
%11 = load i32, i32* %10
%12 = sdiv i32 %11, 1000
%13 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8* %9, i32 %12)
ret void
}

LLVM IR (-O2):
%struct.timeval = type { i32, i32 }
@.str = [9 x i8] c"%H:%M:%S\00"
@.str.1 = [10 x i8] c"%s.%03ld\0A\00"
define void @print_TOD() {
%1 = alloca [32 x i8]
%2 = alloca %struct.timeval
%3 = getelementptr inbounds [32 x i8], [32 x i8]* %1, i64 0, i64 0
%4 = bitcast %struct.timeval* %2 to i8*
%5 = call i32 @memset(%struct.timeval* %2, i32 0, i32 8)
%6 = call i32 @gettimeofday(%struct.timeval* %2, i32* null)
%7 = getelementptr inbounds %struct.timeval, %struct.timeval* %2, i64 0, i32 1
%8 = call i32 @localtime(i32* %7)
%9 = call i32 @strftime(i8* %3, i32 32, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %8)
%10 = getelementptr inbounds %struct.timeval, %struct.timeval* %2, i64 0, i32 0
%11 = load i32, i32* %10
%12 = sdiv i32 %11, 1000
%13 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8* %3, i32 %12)
ret void
}