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

/* Variables and functions */
int /*<<< orphan*/ fflush(int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, int, float, int);
void display_rate(struct timeval start, struct timeval end, int num) {
  int d_s, d_us;
  float sec;
  d_s = end.tv_sec - start.tv_sec;
  d_us = end.tv_usec - start.tv_usec;
  sec = d_s + d_us / 1000000.0;
  printf("%d tiles in %.2f seconds (%.2f tiles/s)\n", num, sec, num / sec);
  fflush(NULL);
}


x86 assembly (clang, -O0):
<display_rate>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x10(%rbp),%eax
sub    -0x8(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0xc(%rbp),%eax
sub    -0x4(%rbp),%eax
mov    %eax,-0x1c(%rbp)
cvtsi2sdl -0x18(%rbp),%xmm0
cvtsi2sdl -0x1c(%rbp),%xmm1
movsd  0xea9(%rip),%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x20(%rbp)
mov    -0x14(%rbp),%esi
movss  -0x20(%rbp),%xmm0
cvtsi2ssl -0x14(%rbp),%xmm1
divss  -0x20(%rbp),%xmm1
cvttss2si %xmm1,%edx
lea    0xe83(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
mov    %eax,%edi
call   1040 <fflush@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<display_rate>:
push   %rax
mov    %rsi,%rax
sub    %edi,%esi
shr    $0x20,%rdi
shr    $0x20,%rax
sub    %edi,%eax
cvtsi2sd %esi,%xmm0
cvtsi2sd %eax,%xmm1
divsd  0xec0(%rip),%xmm1
addsd  %xmm0,%xmm1
xorps  %xmm0,%xmm0
cvtsd2ss %xmm1,%xmm0
xorps  %xmm1,%xmm1
cvtsi2ss %edx,%xmm1
divss  %xmm0,%xmm1
cvttss2si %xmm1,%eax
lea    0xea7(%rip),%rdi
mov    %edx,%esi
mov    %eax,%edx
call   1030 <printf@plt>
xor    %edi,%edi
pop    %rax
jmp    1040 <fflush@plt>

LLVM IR (-O0):
%struct.timeval = type { i32, i32 }
@.str = [41 x i8] c"%d tiles in %.2f seconds (%.2f tiles/s)\0A\00"
define void @display_rate(i64 %0, i64 %1, i32 %2) {
%4 = alloca %struct.timeval
%5 = alloca %struct.timeval
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca float
%10 = bitcast %struct.timeval* %4 to i64*
store i64 %0, i64* %10
%11 = bitcast %struct.timeval* %5 to i64*
store i64 %1, i64* %11
store i32 %2, i32* %6
%12 = getelementptr inbounds %struct.timeval, %struct.timeval* %5, i32 0, i32 0
%13 = load i32, i32* %12
%14 = getelementptr inbounds %struct.timeval, %struct.timeval* %4, i32 0, i32 0
%15 = load i32, i32* %14
%16 = sub nsw i32 %13, %15
store i32 %16, i32* %7
%17 = getelementptr inbounds %struct.timeval, %struct.timeval* %5, i32 0, i32 1
%18 = load i32, i32* %17
%19 = getelementptr inbounds %struct.timeval, %struct.timeval* %4, i32 0, i32 1
%20 = load i32, i32* %19
%21 = sub nsw i32 %18, %20
store i32 %21, i32* %8
%22 = load i32, i32* %7
%23 = sitofp i32 %22 to double
%24 = load i32, i32* %8
%25 = sitofp i32 %24 to double
%26 = fdiv double %25, 1.000000e+06
%27 = fadd double %23, %26
%28 = fptrunc double %27 to float
store float %28, float* %9
%29 = load i32, i32* %6
%30 = load float, float* %9
%31 = load i32, i32* %6
%32 = sitofp i32 %31 to float
%33 = load float, float* %9
%34 = fdiv float %32, %33
%35 = fptosi float %34 to i32
%36 = call i32 @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0), i32 %29, float %30, i32 %35)
%37 = call i32 @fflush(i32* null)
ret void
}

LLVM IR (-O2):
@.str = [41 x i8] c"%d tiles in %.2f seconds (%.2f tiles/s)\0A\00"
define void @display_rate(i64 %0, i64 %1, i32 %2) {
%4 = trunc i64 %0 to i32
%5 = lshr i64 %0, 32
%6 = trunc i64 %5 to i32
%7 = trunc i64 %1 to i32
%8 = lshr i64 %1, 32
%9 = trunc i64 %8 to i32
%10 = sub nsw i32 %7, %4
%11 = sub nsw i32 %9, %6
%12 = sitofp i32 %10 to double
%13 = sitofp i32 %11 to double
%14 = fdiv double %13, 1.000000e+06
%15 = fadd double %14, %12
%16 = fptrunc double %15 to float
%17 = sitofp i32 %2 to float
%18 = fdiv float %17, %16
%19 = fptosi float %18 to i32
%20 = tail call i32 @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0), i32 %2, float %16, i32 %19)
%21 = tail call i32 @fflush(i32* null)
ret void
}