#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 timespec {
  long long tv_sec;
  long long tv_nsec;
};

/* Variables and functions */
int /*<<< orphan*/ CLOCK_REALTIME;
int /*<<< orphan*/ clock_gettime(int /*<<< orphan*/, struct timespec *);
int /*<<< orphan*/ printf(char *, long long, char const *);
print_time(const char *mess) {
  struct timespec tm;
  long long date;
  clock_gettime(CLOCK_REALTIME, &tm);
  date = tm.tv_sec * 1000000LL + tm.tv_nsec / 1000LL;
  printf("%16Ld us : %s\n", date, mess);
}


x86 assembly (clang, -O0):
<print_time>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    0x2ead(%rip),%rax
mov    (%rax),%edi
lea    -0x20(%rbp),%rsi
call   1030 <clock_gettime@plt>
imul   $0xf4240,-0x20(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%rax
mov    $0x3e8,%ecx
cqto
idiv   %rcx
mov    %rax,%rcx
mov    -0x30(%rbp),%rax
add    %rcx,%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rsi
mov    -0x10(%rbp),%rdx
lea    0xe8b(%rip),%rdi
call   1040 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_time>:
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
mov    0x2eb1(%rip),%rax
mov    (%rax),%edi
mov    %rsp,%rsi
call   1030 <clock_gettime@plt>
imul   $0xf4240,(%rsp),%rcx
movabs $0x20c49ba5e353f7cf,%rax
9b c4 20
imulq  0x8(%rsp)
mov    %rdx,%rsi
shr    $0x3f,%rsi
sar    $0x7,%rdx
add    %rdx,%rsi
add    %rcx,%rsi
lea    0xe98(%rip),%rdi
mov    %rbx,%rdx
call   1040 <printf@plt>
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.timespec = type { i64, i64 }
@CLOCK_REALTIME = global i32 0
@.str = [15 x i8] c"%16Ld us : %s\0A\00"
define i32 @print_time(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca %struct.timespec
%5 = alloca i64
store i8* %0, i8** %3
%6 = load i32, i32* @CLOCK_REALTIME
%7 = call i32 @clock_gettime(i32 %6, %struct.timespec* %4)
%8 = getelementptr inbounds %struct.timespec, %struct.timespec* %4, i32 0, i32 0
%9 = load i64, i64* %8
%10 = mul nsw i64 %9, 1000000
%11 = getelementptr inbounds %struct.timespec, %struct.timespec* %4, i32 0, i32 1
%12 = load i64, i64* %11
%13 = sdiv i64 %12, 1000
%14 = add nsw i64 %10, %13
store i64 %14, i64* %5
%15 = load i64, i64* %5
%16 = load i8*, i8** %3
%17 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i64 %15, i8* %16)
%18 = load i32, i32* %2
ret i32 %18
}

LLVM IR (-O2):
%struct.timespec = type { i64, i64 }
@CLOCK_REALTIME = global i32 0
@.str = [15 x i8] c"%16Ld us : %s\0A\00"
define i32 @print_time(i8* %0) {
%2 = alloca %struct.timespec
%3 = bitcast %struct.timespec* %2 to i8*
%4 = load i32, i32* @CLOCK_REALTIME
%5 = call i32 @clock_gettime(i32 %4, %struct.timespec* %2)
%6 = getelementptr inbounds %struct.timespec, %struct.timespec* %2, i64 0, i32 0
%7 = load i64, i64* %6
%8 = mul nsw i64 %7, 1000000
%9 = getelementptr inbounds %struct.timespec, %struct.timespec* %2, i64 0, i32 1
%10 = load i64, i64* %9
%11 = sdiv i64 %10, 1000
%12 = add nsw i64 %11, %8
%13 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i64 %12, i8* %0)
ret i32 undef
}