#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 timezone {
  scalar_t__ tv_usec;
  scalar_t__ tv_sec;
};
struct timeval {
  scalar_t__ tv_usec;
  scalar_t__ tv_sec;
};

/* Variables and functions */
int /*<<< orphan*/ gettimeofday(struct timezone *, struct timezone *);
int /*<<< orphan*/ memset(struct timezone *, int /*<<< orphan*/, int);
double get_usec(void) {
  struct timeval tv;
  struct timezone tz;
  double res;
  memset(&tv, 0, sizeof(&tv));
  memset(&tz, 0, sizeof(&tz));
  gettimeofday(&tv, &tz);
  res = (double)tv.tv_sec + (double)tv.tv_usec / 1000000;
  return res;
}


x86 assembly (clang, -O0):
<get_usec>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
lea    -0x10(%rbp),%rdi
xor    %esi,%esi
mov    $0x8,%edx
call   1040 <memset@plt>
lea    -0x20(%rbp),%rdi
xor    %esi,%esi
mov    $0x8,%edx
call   1040 <memset@plt>
lea    -0x10(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   1030 <gettimeofday@plt>
cvtsi2sdq -0x8(%rbp),%xmm0
cvtsi2sdq -0x10(%rbp),%xmm1
movsd  0xe97(%rip),%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_usec>:
push   %r14
push   %rbx
sub    $0x28,%rsp
lea    0x8(%rsp),%r14
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x8,%edx
call   1040 <memset@plt>
lea    0x18(%rsp),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x8,%edx
call   1040 <memset@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1030 <gettimeofday@plt>
cvtsi2sdq 0x10(%rsp),%xmm1
cvtsi2sdq 0x8(%rsp),%xmm0
divsd  0xe90(%rip),%xmm0
addsd  %xmm1,%xmm0
add    $0x28,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.timeval = type { i64, i64 }
%struct.timezone = type { i64, i64 }
define double @get_usec() {
%1 = alloca %struct.timeval
%2 = alloca %struct.timezone
%3 = alloca double
%4 = bitcast %struct.timeval* %1 to %struct.timezone*
%5 = call i32 @memset(%struct.timezone* %4, i32 0, i32 8)
%6 = call i32 @memset(%struct.timezone* %2, i32 0, i32 8)
%7 = bitcast %struct.timeval* %1 to %struct.timezone*
%8 = call i32 @gettimeofday(%struct.timezone* %7, %struct.timezone* %2)
%9 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i32 0, i32 1
%10 = load i64, i64* %9
%11 = sitofp i64 %10 to double
%12 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i32 0, i32 0
%13 = load i64, i64* %12
%14 = sitofp i64 %13 to double
%15 = fdiv double %14, 1.000000e+06
%16 = fadd double %11, %15
store double %16, double* %3
%17 = load double, double* %3
ret double %17
}

LLVM IR (-O2):
%struct.timeval = type { i64, i64 }
%struct.timezone = type { i64, i64 }
define double @get_usec() {
%1 = alloca %struct.timeval
%2 = alloca %struct.timezone
%3 = bitcast %struct.timeval* %1 to i8*
%4 = bitcast %struct.timezone* %2 to i8*
%5 = bitcast %struct.timeval* %1 to %struct.timezone*
%6 = call i32 @memset(%struct.timezone* %5, i32 0, i32 8)
%7 = call i32 @memset(%struct.timezone* %2, i32 0, i32 8)
%8 = call i32 @gettimeofday(%struct.timezone* %5, %struct.timezone* %2)
%9 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i64 0, i32 1
%10 = load i64, i64* %9
%11 = sitofp i64 %10 to double
%12 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i64 0, i32 0
%13 = load i64, i64* %12
%14 = sitofp i64 %13 to double
%15 = fdiv double %14, 1.000000e+06
%16 = fadd double %15, %11
ret double %16
}