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

/* Variables and functions */
int /*<<< orphan*/ printf(char *, long);
void pri_times(clock_t real, struct timespec *tpstart, struct timespec *tpend) {
  long timediff = 0;
  timediff = (tpend->tv_sec - tpstart->tv_sec) * 1000000000 +
             (tpend->tv_nsec - tpstart->tv_nsec);
  printf("elapsed time:%fs\n", timediff / (double)1000000000);
}


x86 assembly (clang, -O0):
<pri_times>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%eax
mov    -0x10(%rbp),%rcx
sub    (%rcx),%eax
imul   $0x3b9aca00,%eax,%eax
mov    -0x18(%rbp),%rcx
mov    0x4(%rcx),%ecx
mov    -0x10(%rbp),%rdx
sub    0x4(%rdx),%ecx
add    %ecx,%eax
cltq
mov    %rax,-0x20(%rbp)
cvtsi2sdq -0x20(%rbp),%xmm0
movsd  0xe9f(%rip),%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%rsi
lea    0xe97(%rip),%rdi
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pri_times>:
mov    (%rdx),%eax
mov    0x4(%rdx),%ecx
sub    (%rsi),%eax
imul   $0x3b9aca00,%eax,%eax
sub    0x4(%rsi),%ecx
add    %eax,%ecx
cvtsi2sd %ecx,%xmm0
divsd  0xed2(%rip),%xmm0
cvttsd2si %xmm0,%rsi
lea    0xece(%rip),%rdi
jmp    1030 <printf@plt>

LLVM IR (-O0):
%struct.timespec = type { i32, i32 }
@.str = [18 x i8] c"elapsed time:%fs\0A\00"
define void @pri_times(i32 %0, %struct.timespec* %1, %struct.timespec* %2) {
%4 = alloca i32
%5 = alloca %struct.timespec*
%6 = alloca %struct.timespec*
%7 = alloca i64
store i32 %0, i32* %4
store %struct.timespec* %1, %struct.timespec** %5
store %struct.timespec* %2, %struct.timespec** %6
store i64 0, i64* %7
%8 = load %struct.timespec*, %struct.timespec** %6
%9 = getelementptr inbounds %struct.timespec, %struct.timespec* %8, i32 0, i32 0
%10 = load i32, i32* %9
%11 = load %struct.timespec*, %struct.timespec** %5
%12 = getelementptr inbounds %struct.timespec, %struct.timespec* %11, i32 0, i32 0
%13 = load i32, i32* %12
%14 = sub nsw i32 %10, %13
%15 = mul nsw i32 %14, 1000000000
%16 = load %struct.timespec*, %struct.timespec** %6
%17 = getelementptr inbounds %struct.timespec, %struct.timespec* %16, i32 0, i32 1
%18 = load i32, i32* %17
%19 = load %struct.timespec*, %struct.timespec** %5
%20 = getelementptr inbounds %struct.timespec, %struct.timespec* %19, i32 0, i32 1
%21 = load i32, i32* %20
%22 = sub nsw i32 %18, %21
%23 = add nsw i32 %15, %22
%24 = sext i32 %23 to i64
store i64 %24, i64* %7
%25 = load i64, i64* %7
%26 = sitofp i64 %25 to double
%27 = fdiv double %26, 1.000000e+09
%28 = fptosi double %27 to i64
%29 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i64 %28)
ret void
}

LLVM IR (-O2):
%struct.timespec = type { i32, i32 }
@.str = [18 x i8] c"elapsed time:%fs\0A\00"
define void @pri_times(i32 %0, %struct.timespec* nocapture %1, %struct.timespec* nocapture %2) {
%4 = getelementptr inbounds %struct.timespec, %struct.timespec* %2, i64 0, i32 0
%5 = load i32, i32* %4
%6 = getelementptr inbounds %struct.timespec, %struct.timespec* %1, i64 0, i32 0
%7 = load i32, i32* %6
%8 = sub nsw i32 %5, %7
%9 = mul nsw i32 %8, 1000000000
%10 = getelementptr inbounds %struct.timespec, %struct.timespec* %2, i64 0, i32 1
%11 = load i32, i32* %10
%12 = getelementptr inbounds %struct.timespec, %struct.timespec* %1, i64 0, i32 1
%13 = load i32, i32* %12
%14 = sub i32 %11, %13
%15 = add nsw i32 %14, %9
%16 = sitofp i32 %15 to double
%17 = fdiv double %16, 1.000000e+09
%18 = fptosi double %17 to i64
%19 = tail call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i64 %18)
ret void
}