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

/* Variables and functions */
int /*<<< orphan*/ gettimeofday(struct timeval *, int /*<<< orphan*/ *);
double mp_time_delta(struct timeval time_start) {
  struct timeval time_end;
  gettimeofday(&time_end, NULL);
  return ((double)(time_end.tv_sec - time_start.tv_sec) +
          (double)(time_end.tv_usec - time_start.tv_usec) / (double)1000000);
}


x86 assembly (clang, -O0):
<mp_time_delta>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x8(%rbp)
lea    -0x20(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1030 <gettimeofday@plt>
mov    -0x18(%rbp),%rax
sub    -0x8(%rbp),%rax
cvtsi2sd %rax,%xmm0
mov    -0x20(%rbp),%rax
sub    -0x10(%rbp),%rax
cvtsi2sd %rax,%xmm1
movsd  0xeb1(%rip),%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mp_time_delta>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%rbx
mov    %rdi,%r14
lea    0x8(%rsp),%rdi
xor    %esi,%esi
call   1030 <gettimeofday@plt>
mov    0x10(%rsp),%rax
sub    %rbx,%rax
cvtsi2sd %rax,%xmm1
mov    0x8(%rsp),%rax
sub    %r14,%rax
cvtsi2sd %rax,%xmm0
divsd  0xeb5(%rip),%xmm0
addsd  %xmm1,%xmm0
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

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

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