#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*/ printf(char *, double, int, double);
void show_elapsed(struct timeval *start, struct timeval *end, int count) {
  double diff;
  double rate;
  if (end->tv_usec > start->tv_usec) {
    diff = (double)(end->tv_usec - start->tv_usec);
  } else {
    diff = (double)((1000000 + end->tv_usec) - start->tv_usec);
    end->tv_sec--;
  }
  diff /= 1000000.0;
  diff += (double)(end->tv_sec - start->tv_sec);
  if (diff > 0.0)
    rate = count / diff;
  else
    rate = 0.0;
  printf("Summary\n  Elapsed: %0.2lf seconds\n    Reads: %d\n     Rate: %0.2lf "
         "Hz\n\n",
         diff, count, rate);
}


x86 assembly (clang, -O0):
<show_elapsed>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    -0x8(%rbp),%rcx
cmp    (%rcx),%rax
jle    1154 <show_elapsed+0x44>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    -0x8(%rbp),%rcx
sub    (%rcx),%rax
cvtsi2sd %rax,%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    1182 <show_elapsed+0x72>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
add    $0xf4240,%rax
mov    -0x8(%rbp),%rcx
sub    (%rcx),%rax
cvtsi2sd %rax,%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rcx
add    $0xffffffffffffffff,%rcx
mov    %rcx,0x8(%rax)
movsd  -0x20(%rbp),%xmm0
movsd  0xe71(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    -0x8(%rbp),%rcx
sub    0x8(%rcx),%rax
cvtsi2sd %rax,%xmm0
addsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    11dd <show_elapsed+0xcd>
cvtsi2sdl -0x14(%rbp),%xmm0
divsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
jmp    11e5 <show_elapsed+0xd5>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x20(%rbp),%xmm0
mov    -0x14(%rbp),%esi
movsd  -0x28(%rbp),%xmm1
lea    0xe0f(%rip),%rdi
call   1030 <printf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<show_elapsed>:
mov    (%rsi),%rax
mov    (%rdi),%r8
cmp    %r8,%rax
jle    1121 <show_elapsed+0x11>
mov    0x8(%rsi),%rcx
jmp    1133 <show_elapsed+0x23>
add    $0xf4240,%rax
mov    0x8(%rsi),%rcx
add    $0xffffffffffffffff,%rcx
mov    %rcx,0x8(%rsi)
sub    %r8,%rax
cvtsi2sd %rax,%xmm1
divsd  0xebd(%rip),%xmm1
sub    0x8(%rdi),%rcx
cvtsi2sd %rcx,%xmm0
addsd  %xmm1,%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    1165 <show_elapsed+0x55>
xorps  %xmm1,%xmm1
cvtsi2sd %edx,%xmm1
divsd  %xmm0,%xmm1
lea    0xe9c(%rip),%rdi
mov    %edx,%esi
jmp    1030 <printf@plt>

LLVM IR (-O0):
%struct.timeval = type { i64, i64 }
@.str = [71 x i8] c"Summary\0A Elapsed: %0.2lf seconds\0A Reads: %d\0A Rate: %0.2lf Hz\0A\0A\00"
define void @show_elapsed(%struct.timeval* %0, %struct.timeval* %1, i32 %2) {
%4 = alloca %struct.timeval*
%5 = alloca %struct.timeval*
%6 = alloca i32
%7 = alloca double
%8 = alloca double
store %struct.timeval* %0, %struct.timeval** %4
store %struct.timeval* %1, %struct.timeval** %5
store i32 %2, i32* %6
%9 = load %struct.timeval*, %struct.timeval** %5
%10 = getelementptr inbounds %struct.timeval, %struct.timeval* %9, i32 0, i32 0
%11 = load i64, i64* %10
%12 = load %struct.timeval*, %struct.timeval** %4
%13 = getelementptr inbounds %struct.timeval, %struct.timeval* %12, i32 0, i32 0
%14 = load i64, i64* %13
%15 = icmp sgt i64 %11, %14
br i1 %15, label %16, label %25
16: ; preds = %3
%17 = load %struct.timeval*, %struct.timeval** %5
%18 = getelementptr inbounds %struct.timeval, %struct.timeval* %17, i32 0, i32 0
%19 = load i64, i64* %18
%20 = load %struct.timeval*, %struct.timeval** %4
%21 = getelementptr inbounds %struct.timeval, %struct.timeval* %20, i32 0, i32 0
%22 = load i64, i64* %21
%23 = sub nsw i64 %19, %22
%24 = sitofp i64 %23 to double
store double %24, double* %7
br label %39
25: ; preds = %3
%26 = load %struct.timeval*, %struct.timeval** %5
%27 = getelementptr inbounds %struct.timeval, %struct.timeval* %26, i32 0, i32 0
%28 = load i64, i64* %27
%29 = add nsw i64 1000000, %28
%30 = load %struct.timeval*, %struct.timeval** %4
%31 = getelementptr inbounds %struct.timeval, %struct.timeval* %30, i32 0, i32 0
%32 = load i64, i64* %31
%33 = sub nsw i64 %29, %32
%34 = sitofp i64 %33 to double
store double %34, double* %7
%35 = load %struct.timeval*, %struct.timeval** %5
%36 = getelementptr inbounds %struct.timeval, %struct.timeval* %35, i32 0, i32 1
%37 = load i64, i64* %36
%38 = add nsw i64 %37, -1
store i64 %38, i64* %36
br label %39
39: ; preds = %25, %16
%40 = load double, double* %7
%41 = fdiv double %40, 1.000000e+06
store double %41, double* %7
%42 = load %struct.timeval*, %struct.timeval** %5
%43 = getelementptr inbounds %struct.timeval, %struct.timeval* %42, i32 0, i32 1
%44 = load i64, i64* %43
%45 = load %struct.timeval*, %struct.timeval** %4
%46 = getelementptr inbounds %struct.timeval, %struct.timeval* %45, i32 0, i32 1
%47 = load i64, i64* %46
%48 = sub nsw i64 %44, %47
%49 = sitofp i64 %48 to double
%50 = load double, double* %7
%51 = fadd double %50, %49
store double %51, double* %7
%52 = load double, double* %7
%53 = fcmp ogt double %52, 0.000000e+00
br i1 %53, label %54, label %59
54: ; preds = %39
%55 = load i32, i32* %6
%56 = sitofp i32 %55 to double
%57 = load double, double* %7
%58 = fdiv double %56, %57
store double %58, double* %8
br label %60
59: ; preds = %39
store double 0.000000e+00, double* %8
br label %60
60: ; preds = %59, %54
%61 = load double, double* %7
%62 = load i32, i32* %6
%63 = load double, double* %8
%64 = call i32 @printf(i8* getelementptr inbounds ([71 x i8], [71 x i8]* @.str, i64 0, i64 0), double %61, i32 %62, double %63)
ret void
}

LLVM IR (-O2):
%struct.timeval = type { i64, i64 }
@.str = [71 x i8] c"Summary\0A Elapsed: %0.2lf seconds\0A Reads: %d\0A Rate: %0.2lf Hz\0A\0A\00"
define void @show_elapsed(%struct.timeval* nocapture %0, %struct.timeval* nocapture %1, i32 %2) {
%4 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i64 0, i32 0
%5 = load i64, i64* %4
%6 = getelementptr inbounds %struct.timeval, %struct.timeval* %0, i64 0, i32 0
%7 = load i64, i64* %6
%8 = icmp sgt i64 %5, %7
br i1 %8, label %9, label %12
9: ; preds = %3
%10 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i64 0, i32 1
%11 = load i64, i64* %10
br label %17
12: ; preds = %3
%13 = add nsw i64 %5, 1000000
%14 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i64 0, i32 1
%15 = load i64, i64* %14
%16 = add nsw i64 %15, -1
store i64 %16, i64* %14
br label %17
17: ; preds = %9, %12
%18 = phi i64 [ %16, %12 ], [ %11, %9 ]
%19 = phi i64 [ %13, %12 ], [ %5, %9 ]
%20 = sub nsw i64 %19, %7
%21 = sitofp i64 %20 to double
%22 = fdiv double %21, 1.000000e+06
%23 = getelementptr inbounds %struct.timeval, %struct.timeval* %0, i64 0, i32 1
%24 = load i64, i64* %23
%25 = sub nsw i64 %18, %24
%26 = sitofp i64 %25 to double
%27 = fadd double %22, %26
%28 = fcmp ogt double %27, 0.000000e+00
br i1 %28, label %29, label %32
29: ; preds = %17
%30 = sitofp i32 %2 to double
%31 = fdiv double %30, %27
br label %32
32: ; preds = %17, %29
%33 = phi double [ %31, %29 ], [ 0.000000e+00, %17 ]
%34 = tail call i32 @printf(i8* getelementptr inbounds ([71 x i8], [71 x i8]* @.str, i64 0, i64 0), double %27, i32 %2, double %33)
ret void
}