#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 double ssize_t;

/* Variables and functions */
int /*<<< orphan*/ printf(char *, double);
void print_statistics(ssize_t received, struct timespec start,
                      struct timespec end) {
  double elapsed =
      end.tv_sec - start.tv_sec + (end.tv_nsec - start.tv_nsec) * 1e-9;
  double megabytes = received / (1024.0 * 1024.0);
  printf("Data received: %f MB\n", megabytes);
  printf("Transfer time: %f seconds\n", elapsed);
  printf("Throughput achieved: %f MB/s\n", megabytes / elapsed);
}


x86 assembly (clang, -O0):
<print_statistics>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movsd  %xmm0,-0x18(%rbp)
mov    -0x10(%rbp),%eax
sub    -0x8(%rbp),%eax
cvtsi2sd %eax,%xmm1
mov    -0xc(%rbp),%eax
sub    -0x4(%rbp),%eax
cvtsi2sd %eax,%xmm0
movsd  0xec7(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  0xea5(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
lea    0xea0(%rip),%rdi
call   1030 <printf@plt>
movsd  -0x20(%rbp),%xmm0
lea    0xea5(%rip),%rdi
call   1030 <printf@plt>
movsd  -0x28(%rbp),%xmm0
divsd  -0x20(%rbp),%xmm0
lea    0xeaa(%rip),%rdi
call   1030 <printf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_statistics>:
sub    $0x18,%rsp
mov    %rsi,%rax
sub    %edi,%esi
shr    $0x20,%rdi
shr    $0x20,%rax
cvtsi2sd %esi,%xmm1
sub    %edi,%eax
cvtsi2sd %eax,%xmm2
mulsd  0xecd(%rip),%xmm2
addsd  %xmm1,%xmm2
movsd  %xmm2,0x8(%rsp)
mulsd  0xec3(%rip),%xmm0
movsd  %xmm0,0x10(%rsp)
lea    0xebe(%rip),%rdi
call   1030 <printf@plt>
lea    0xec8(%rip),%rdi
movsd  0x8(%rsp),%xmm0
call   1030 <printf@plt>
movsd  0x10(%rsp),%xmm0
divsd  0x8(%rsp),%xmm0
lea    0xec5(%rip),%rdi
add    $0x18,%rsp
jmp    1030 <printf@plt>

LLVM IR (-O0):
%struct.timespec = type { i32, i32 }
@.str = [22 x i8] c"Data received: %f MB\0A\00"
@.str.1 = [27 x i8] c"Transfer time: %f seconds\0A\00"
@.str.2 = [30 x i8] c"Throughput achieved: %f MB/s\0A\00"
define void @print_statistics(double %0, i64 %1, i64 %2) {
%4 = alloca %struct.timespec
%5 = alloca %struct.timespec
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = bitcast %struct.timespec* %4 to i64*
store i64 %1, i64* %9
%10 = bitcast %struct.timespec* %5 to i64*
store i64 %2, i64* %10
store double %0, double* %6
%11 = getelementptr inbounds %struct.timespec, %struct.timespec* %5, i32 0, i32 0
%12 = load i32, i32* %11
%13 = getelementptr inbounds %struct.timespec, %struct.timespec* %4, i32 0, i32 0
%14 = load i32, i32* %13
%15 = sub nsw i32 %12, %14
%16 = sitofp i32 %15 to double
%17 = getelementptr inbounds %struct.timespec, %struct.timespec* %5, i32 0, i32 1
%18 = load i32, i32* %17
%19 = getelementptr inbounds %struct.timespec, %struct.timespec* %4, i32 0, i32 1
%20 = load i32, i32* %19
%21 = sub nsw i32 %18, %20
%22 = sitofp i32 %21 to double
%23 = call double @llvm.fmuladd.f64(double %22, double 1.000000e-09, double %16)
store double %23, double* %7
%24 = load double, double* %6
%25 = fdiv double %24, 0x4130000000000000
store double %25, double* %8
%26 = load double, double* %8
%27 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), double %26)
%28 = load double, double* %7
%29 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), double %28)
%30 = load double, double* %8
%31 = load double, double* %7
%32 = fdiv double %30, %31
%33 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0), double %32)
ret void
}

LLVM IR (-O2):
@.str = [22 x i8] c"Data received: %f MB\0A\00"
@.str.1 = [27 x i8] c"Transfer time: %f seconds\0A\00"
@.str.2 = [30 x i8] c"Throughput achieved: %f MB/s\0A\00"
define void @print_statistics(double %0, i64 %1, i64 %2) {
%4 = trunc i64 %1 to i32
%5 = lshr i64 %1, 32
%6 = trunc i64 %5 to i32
%7 = trunc i64 %2 to i32
%8 = lshr i64 %2, 32
%9 = trunc i64 %8 to i32
%10 = sub nsw i32 %7, %4
%11 = sitofp i32 %10 to double
%12 = sub nsw i32 %9, %6
%13 = sitofp i32 %12 to double
%14 = tail call double @llvm.fmuladd.f64(double %13, double 1.000000e-09, double %11)
%15 = fmul double %0, 0x3EB0000000000000
%16 = tail call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), double %15)
%17 = tail call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), double %14)
%18 = fdiv double %15, %14
%19 = tail call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0), double %18)
ret void
}