#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;
};
struct timespec {
  int tv_nsec;
  int /*<<< orphan*/ tv_sec;
};

/* Variables and functions */
int /*<<< orphan*/ __print_timestamp(char *, struct timespec *,
                                     int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ gettimeofday(struct timeval *, int /*<<< orphan*/ *);
void print_timestamp_usr(void) {
  struct timespec ts;
  struct timeval tv;
  gettimeofday(&tv, NULL);
  ts.tv_sec = tv.tv_sec;
  ts.tv_nsec = tv.tv_usec * 1000;
  __print_timestamp("  USR", &ts, 0, 0);
}


x86 assembly (clang, -O0):
<print_timestamp_usr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    -0x10(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1030 <gettimeofday@plt>
mov    -0xc(%rbp),%eax
mov    %eax,-0x4(%rbp)
imul   $0x3e8,-0x10(%rbp),%eax
mov    %eax,-0x8(%rbp)
lea    0xeb4(%rip),%rdi
lea    -0x8(%rbp),%rsi
xor    %ecx,%ecx
mov    %ecx,%edx
call   1040 <__print_timestamp@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_timestamp_usr>:
sub    $0x18,%rsp
lea    0x8(%rsp),%rdi
xor    %esi,%esi
call   1030 <gettimeofday@plt>
mov    0xc(%rsp),%eax
mov    %eax,0x14(%rsp)
imul   $0x3e8,0x8(%rsp),%eax
mov    %eax,0x10(%rsp)
lea    0xeb5(%rip),%rdi
lea    0x10(%rsp),%rsi
xor    %edx,%edx
xor    %ecx,%ecx
call   1040 <__print_timestamp@plt>
add    $0x18,%rsp
ret

LLVM IR (-O0):
%struct.timespec = type { i32, i32 }
%struct.timeval = type { i32, i32 }
@.str = [6 x i8] c" USR\00"
define void @print_timestamp_usr() {
%1 = alloca %struct.timespec
%2 = alloca %struct.timeval
%3 = call i32 @gettimeofday(%struct.timeval* %2, i32* null)
%4 = getelementptr inbounds %struct.timeval, %struct.timeval* %2, i32 0, i32 1
%5 = load i32, i32* %4
%6 = getelementptr inbounds %struct.timespec, %struct.timespec* %1, i32 0, i32 1
store i32 %5, i32* %6
%7 = getelementptr inbounds %struct.timeval, %struct.timeval* %2, i32 0, i32 0
%8 = load i32, i32* %7
%9 = mul nsw i32 %8, 1000
%10 = getelementptr inbounds %struct.timespec, %struct.timespec* %1, i32 0, i32 0
store i32 %9, i32* %10
%11 = call i32 @__print_timestamp(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), %struct.timespec* %1, i32 0, i32 0)
ret void
}

LLVM IR (-O2):
%struct.timespec = type { i32, i32 }
%struct.timeval = type { i32, i32 }
@.str = [6 x i8] c" USR\00"
define void @print_timestamp_usr() {
%1 = alloca %struct.timespec
%2 = alloca %struct.timeval
%3 = bitcast %struct.timespec* %1 to i8*
%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 1
%7 = load i32, i32* %6
%8 = getelementptr inbounds %struct.timespec, %struct.timespec* %1, i64 0, i32 1
store i32 %7, i32* %8
%9 = getelementptr inbounds %struct.timeval, %struct.timeval* %2, i64 0, i32 0
%10 = load i32, i32* %9
%11 = mul nsw i32 %10, 1000
%12 = getelementptr inbounds %struct.timespec, %struct.timespec* %1, i64 0, i32 0
store i32 %11, i32* %12
%13 = call i32 @__print_timestamp(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), %struct.timespec* %1, i32 0, i32 0)
ret void
}