#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 {
  int dummy;
};
struct timeval {
  int tv_sec;
  double tv_usec;
};

/* Variables and functions */
int /*<<< orphan*/ gettimeofday(struct timeval *, struct timezone *);
double wtime(struct timeval *t1) {
  struct timeval t2;
  double time;
  gettimeofday(&t2, (struct timezone *)0);
  time =
      ((t2.tv_sec - t1->tv_sec) * 1000000 + t2.tv_usec - t1->tv_usec) * 1.0e-6;
  return time;
}


x86 assembly (clang, -O0):
<wtime>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
lea    -0x18(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1030 <gettimeofday@plt>
mov    -0x18(%rbp),%eax
mov    -0x8(%rbp),%rcx
sub    (%rcx),%eax
imul   $0xf4240,%eax,%eax
cvtsi2sd %eax,%xmm0
addsd  -0x10(%rbp),%xmm0
mov    -0x8(%rbp),%rax
subsd  0x8(%rax),%xmm0
movsd  0xeae(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<wtime>:
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
mov    %rsp,%rdi
xor    %esi,%esi
call   1030 <gettimeofday@plt>
mov    (%rsp),%eax
sub    (%rbx),%eax
imul   $0xf4240,%eax,%eax
cvtsi2sd %eax,%xmm0
addsd  0x8(%rsp),%xmm0
subsd  0x8(%rbx),%xmm0
mulsd  0xebc(%rip),%xmm0
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.timeval = type { i32, double }
%struct.timezone = type { i32 }
define double @wtime(%struct.timeval* %0) {
%2 = alloca %struct.timeval*
%3 = alloca %struct.timeval
%4 = alloca double
store %struct.timeval* %0, %struct.timeval** %2
%5 = call i32 @gettimeofday(%struct.timeval* %3, %struct.timezone* null)
%6 = getelementptr inbounds %struct.timeval, %struct.timeval* %3, i32 0, i32 0
%7 = load i32, i32* %6
%8 = load %struct.timeval*, %struct.timeval** %2
%9 = getelementptr inbounds %struct.timeval, %struct.timeval* %8, i32 0, i32 0
%10 = load i32, i32* %9
%11 = sub nsw i32 %7, %10
%12 = mul nsw i32 %11, 1000000
%13 = sitofp i32 %12 to double
%14 = getelementptr inbounds %struct.timeval, %struct.timeval* %3, i32 0, i32 1
%15 = load double, double* %14
%16 = fadd double %13, %15
%17 = load %struct.timeval*, %struct.timeval** %2
%18 = getelementptr inbounds %struct.timeval, %struct.timeval* %17, i32 0, i32 1
%19 = load double, double* %18
%20 = fsub double %16, %19
%21 = fmul double %20, 0x3EB0C6F7A0B5ED8D
store double %21, double* %4
%22 = load double, double* %4
ret double %22
}

LLVM IR (-O2):
%struct.timeval = type { i32, double }
%struct.timezone = type { i32 }
define double @wtime(%struct.timeval* nocapture %0) {
%2 = alloca %struct.timeval
%3 = bitcast %struct.timeval* %2 to i8*
%4 = call i32 @gettimeofday(%struct.timeval* %2, %struct.timezone* null)
%5 = getelementptr inbounds %struct.timeval, %struct.timeval* %2, i64 0, i32 0
%6 = load i32, i32* %5
%7 = getelementptr inbounds %struct.timeval, %struct.timeval* %0, i64 0, i32 0
%8 = load i32, i32* %7
%9 = sub nsw i32 %6, %8
%10 = mul nsw i32 %9, 1000000
%11 = sitofp i32 %10 to double
%12 = getelementptr inbounds %struct.timeval, %struct.timeval* %2, i64 0, i32 1
%13 = load double, double* %12
%14 = fadd double %13, %11
%15 = getelementptr inbounds %struct.timeval, %struct.timeval* %0, i64 0, i32 1
%16 = load double, double* %15
%17 = fsub double %14, %16
%18 = fmul double %17, 0x3EB0C6F7A0B5ED8D
ret double %18
}