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

/* Variables and functions */
int /*<<< orphan*/ gettimeofday(struct timeval *, int /*<<< orphan*/ *);
double piece_seconds(struct timeval then) {
  struct timeval curr;
  gettimeofday(&curr, NULL);
  return (curr.tv_sec + ((double)curr.tv_usec / 1000000.0)) -
         (then.tv_sec + ((double)then.tv_usec / 1000000.0));
}


x86 assembly (clang, -O0):
<piece_seconds>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movsd  %xmm0,-0x10(%rbp)
mov    %rdi,-0x8(%rbp)
lea    -0x20(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1030 <gettimeofday@plt>
movsd  -0x20(%rbp),%xmm0
cvtsi2sdq -0x18(%rbp),%xmm1
movsd  0xebf(%rip),%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
movsd  -0x10(%rbp),%xmm1
cvtsi2sdq -0x8(%rbp),%xmm2
movsd  0xea4(%rip),%xmm3
divsd  %xmm3,%xmm2
addsd  %xmm2,%xmm1
subsd  %xmm1,%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<piece_seconds>:
push   %rbx
sub    $0x20,%rsp
mov    %rdi,%rbx
movaps %xmm0,0x10(%rsp)
mov    %rsp,%rdi
xor    %esi,%esi
call   1030 <gettimeofday@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rbx,%xmm0
cvtsi2sdq 0x8(%rsp),%xmm1
unpcklpd %xmm0,%xmm1
divpd  0xebe(%rip),%xmm1
movsd  (%rsp),%xmm0
unpcklpd 0x10(%rsp),%xmm0
addpd  %xmm1,%xmm0
movapd %xmm0,%xmm1
unpckhpd %xmm0,%xmm1
subsd  %xmm1,%xmm0
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.timeval = type { double, i64 }
define double @piece_seconds(double %0, i64 %1) {
%3 = alloca %struct.timeval
%4 = alloca %struct.timeval
%5 = bitcast %struct.timeval* %3 to { double, i64 }*
%6 = getelementptr inbounds { double, i64 }, { double, i64 }* %5, i32 0, i32 0
store double %0, double* %6
%7 = getelementptr inbounds { double, i64 }, { double, 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 0
%10 = load double, double* %9
%11 = getelementptr inbounds %struct.timeval, %struct.timeval* %4, i32 0, i32 1
%12 = load i64, i64* %11
%13 = sitofp i64 %12 to double
%14 = fdiv double %13, 1.000000e+06
%15 = fadd double %10, %14
%16 = getelementptr inbounds %struct.timeval, %struct.timeval* %3, i32 0, i32 0
%17 = load double, double* %16
%18 = getelementptr inbounds %struct.timeval, %struct.timeval* %3, i32 0, i32 1
%19 = load i64, i64* %18
%20 = sitofp i64 %19 to double
%21 = fdiv double %20, 1.000000e+06
%22 = fadd double %17, %21
%23 = fsub double %15, %22
ret double %23
}

LLVM IR (-O2):
%struct.timeval = type { double, i64 }
define double @piece_seconds(double %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 0
%7 = load double, double* %6
%8 = getelementptr inbounds %struct.timeval, %struct.timeval* %3, i64 0, i32 1
%9 = load i64, i64* %8
%10 = insertelement <2 x i64> poison, i64 %1, i64 1
%11 = insertelement <2 x i64> %10, i64 %9, i64 0
%12 = sitofp <2 x i64> %11 to <2 x double>
%13 = fdiv <2 x double> %12, <double 1.000000e+06, double 1.000000e+06>
%14 = insertelement <2 x double> poison, double %0, i64 1
%15 = insertelement <2 x double> %14, double %7, i64 0
%16 = fadd <2 x double> %15, %13
%17 = shufflevector <2 x double> %16, <2 x double> poison, <2 x i32> <i32 1, i32 undef>
%18 = fsub <2 x double> %16, %17
%19 = extractelement <2 x double> %18, i64 0
ret double %19
}