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

/* Variables and functions */
struct tm *localtime(int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, int, int, int, int, int, int, int);
void z_ms_print(struct timeval *t) {
  struct tm *ti;
  ti = localtime(&t->tv_sec);
  printf("%04d-%02d-%02d %02d:%02d:%02d.%03d", 1900 + (int)ti->tm_year,
         1 + (int)ti->tm_mon, (int)ti->tm_mday, (int)ti->tm_hour,
         (int)ti->tm_min, (int)ti->tm_sec, (int)(t->tv_usec / 1000));
}


x86 assembly (clang, -O0):
<z_ms_print>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
add    $0x4,%rdi
call   1030 <localtime@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    0x28(%rax),%rax
mov    %eax,%esi
add    $0x76c,%esi
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rax
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    %eax,%r8d
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %eax,%r9d
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %eax,%r10d
mov    -0x8(%rbp),%rax
mov    (%rax),%eax
mov    $0x3e8,%edi
cltd
idiv   %edi
mov    -0x14(%rbp),%edx
lea    0xe63(%rip),%rdi
mov    %r10d,(%rsp)
mov    %eax,0x8(%rsp)
call   1040 <printf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<z_ms_print>:
push   %rbx
mov    %rdi,%rbx
add    $0x4,%rdi
call   1030 <localtime@plt>
mov    $0x76c,%esi
add    0x28(%rax),%esi
mov    0x20(%rax),%edx
add    $0x1,%edx
mov    0x18(%rax),%ecx
mov    0x10(%rax),%r8d
mov    (%rax),%r10d
mov    0x8(%rax),%r9d
movslq (%rbx),%rax
imul   $0x10624dd3,%rax,%rax
mov    %rax,%rdi
shr    $0x3f,%rdi
sar    $0x26,%rax
add    %edi,%eax
lea    0xe99(%rip),%rdi
push   %rax
push   %r10
call   1040 <printf@plt>
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.timeval = type { i32, i32 }
%struct.tm = type { i64, i64, i64, i64, i64, i64 }
@.str = [35 x i8] c"%04d-%02d-%02d %02d:%02d:%02d.%03d\00"
define void @z_ms_print(%struct.timeval* %0) {
%2 = alloca %struct.timeval*
%3 = alloca %struct.tm*
store %struct.timeval* %0, %struct.timeval** %2
%4 = load %struct.timeval*, %struct.timeval** %2
%5 = getelementptr inbounds %struct.timeval, %struct.timeval* %4, i32 0, i32 1
%6 = call %struct.tm* @localtime(i32* %5)
store %struct.tm* %6, %struct.tm** %3
%7 = load %struct.tm*, %struct.tm** %3
%8 = getelementptr inbounds %struct.tm, %struct.tm* %7, i32 0, i32 5
%9 = load i64, i64* %8
%10 = trunc i64 %9 to i32
%11 = add nsw i32 1900, %10
%12 = load %struct.tm*, %struct.tm** %3
%13 = getelementptr inbounds %struct.tm, %struct.tm* %12, i32 0, i32 4
%14 = load i64, i64* %13
%15 = trunc i64 %14 to i32
%16 = add nsw i32 1, %15
%17 = load %struct.tm*, %struct.tm** %3
%18 = getelementptr inbounds %struct.tm, %struct.tm* %17, i32 0, i32 3
%19 = load i64, i64* %18
%20 = trunc i64 %19 to i32
%21 = load %struct.tm*, %struct.tm** %3
%22 = getelementptr inbounds %struct.tm, %struct.tm* %21, i32 0, i32 2
%23 = load i64, i64* %22
%24 = trunc i64 %23 to i32
%25 = load %struct.tm*, %struct.tm** %3
%26 = getelementptr inbounds %struct.tm, %struct.tm* %25, i32 0, i32 1
%27 = load i64, i64* %26
%28 = trunc i64 %27 to i32
%29 = load %struct.tm*, %struct.tm** %3
%30 = getelementptr inbounds %struct.tm, %struct.tm* %29, i32 0, i32 0
%31 = load i64, i64* %30
%32 = trunc i64 %31 to i32
%33 = load %struct.timeval*, %struct.timeval** %2
%34 = getelementptr inbounds %struct.timeval, %struct.timeval* %33, i32 0, i32 0
%35 = load i32, i32* %34
%36 = sdiv i32 %35, 1000
%37 = call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), i32 %11, i32 %16, i32 %20, i32 %24, i32 %28, i32 %32, i32 %36)
ret void
}

LLVM IR (-O2):
%struct.timeval = type { i32, i32 }
%struct.tm = type { i64, i64, i64, i64, i64, i64 }
@.str = [35 x i8] c"%04d-%02d-%02d %02d:%02d:%02d.%03d\00"
define void @z_ms_print(%struct.timeval* %0) {
%2 = getelementptr inbounds %struct.timeval, %struct.timeval* %0, i64 0, i32 1
%3 = tail call %struct.tm* @localtime(i32* %2)
%4 = getelementptr inbounds %struct.tm, %struct.tm* %3, i64 0, i32 5
%5 = load i64, i64* %4
%6 = trunc i64 %5 to i32
%7 = add nsw i32 %6, 1900
%8 = getelementptr inbounds %struct.tm, %struct.tm* %3, i64 0, i32 4
%9 = load i64, i64* %8
%10 = trunc i64 %9 to i32
%11 = add nsw i32 %10, 1
%12 = getelementptr inbounds %struct.tm, %struct.tm* %3, i64 0, i32 3
%13 = load i64, i64* %12
%14 = trunc i64 %13 to i32
%15 = getelementptr inbounds %struct.tm, %struct.tm* %3, i64 0, i32 2
%16 = load i64, i64* %15
%17 = trunc i64 %16 to i32
%18 = getelementptr inbounds %struct.tm, %struct.tm* %3, i64 0, i32 1
%19 = load i64, i64* %18
%20 = trunc i64 %19 to i32
%21 = getelementptr inbounds %struct.tm, %struct.tm* %3, i64 0, i32 0
%22 = load i64, i64* %21
%23 = trunc i64 %22 to i32
%24 = getelementptr inbounds %struct.timeval, %struct.timeval* %0, i64 0, i32 0
%25 = load i32, i32* %24
%26 = sdiv i32 %25, 1000
%27 = tail call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), i32 %7, i32 %11, i32 %14, i32 %17, i32 %20, i32 %23, i32 %26)
ret void
}