#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 */

/* Variables and functions */
int /*<<< orphan*/ printf(char *, char *, double, double);
void printspeed(char *caption, unsigned long bytes, double time) {
  if (bytes / 1073741824UL > 0) {
    printf("%s %.4f sec (%.3f GBps)\n", caption, time,
           (double)bytes / 1073741824UL / time);
  } else if (bytes / 1048576 > 0) {
    printf("%s %.4f (%.3f MBps)\n", caption, time,
           (double)bytes / 1048576 / time);
  } else if (bytes / 1024 > 0) {
    printf("%s %.4f (%.3f KBps)\n", caption, time, (double)bytes / 1024 / time);
  } else {
    printf("%s %.4f (%f Bps)\n", caption, time, (double)bytes / time);
  }
}


x86 assembly (clang, -O0):
<printspeed>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movsd  %xmm0,-0x18(%rbp)
mov    -0x10(%rbp),%rax
shr    $0x1e,%rax
cmp    $0x0,%rax
jbe    1189 <printspeed+0x79>
mov    -0x8(%rbp),%rsi
movsd  -0x18(%rbp),%xmm0
movaps 0xeb9(%rip),%xmm2
movq   -0x10(%rbp),%xmm1
punpckldq %xmm2,%xmm1
movapd 0xeb8(%rip),%xmm2
subpd  %xmm2,%xmm1
movaps %xmm1,%xmm2
unpckhpd %xmm1,%xmm1
addsd  %xmm2,%xmm1
movsd  0xec1(%rip),%xmm2
divsd  %xmm2,%xmm1
divsd  -0x18(%rbp),%xmm1
lea    0xeb9(%rip),%rdi
call   1030 <printf@plt>
jmp    129c <printspeed+0x18c>
mov    -0x10(%rbp),%rax
shr    $0x14,%rax
cmp    $0x0,%rax
jbe    11ed <printspeed+0xdd>
mov    -0x8(%rbp),%rsi
movsd  -0x18(%rbp),%xmm0
movaps 0xe55(%rip),%xmm2
movq   -0x10(%rbp),%xmm1
punpckldq %xmm2,%xmm1
movapd 0xe54(%rip),%xmm2
subpd  %xmm2,%xmm1
movaps %xmm1,%xmm2
unpckhpd %xmm1,%xmm1
addsd  %xmm2,%xmm1
movsd  0xe55(%rip),%xmm2
divsd  %xmm2,%xmm1
divsd  -0x18(%rbp),%xmm1
lea    0xe6e(%rip),%rdi
call   1030 <printf@plt>
jmp    1297 <printspeed+0x187>
mov    -0x10(%rbp),%rax
shr    $0xa,%rax
cmp    $0x0,%rax
jbe    1251 <printspeed+0x141>
mov    -0x8(%rbp),%rsi
movsd  -0x18(%rbp),%xmm0
movaps 0xdf1(%rip),%xmm2
movq   -0x10(%rbp),%xmm1
punpckldq %xmm2,%xmm1
movapd 0xdf0(%rip),%xmm2
subpd  %xmm2,%xmm1
movaps %xmm1,%xmm2
unpckhpd %xmm1,%xmm1
addsd  %xmm2,%xmm1
movsd  0xde9(%rip),%xmm2
divsd  %xmm2,%xmm1
divsd  -0x18(%rbp),%xmm1
lea    0xe1f(%rip),%rdi
call   1030 <printf@plt>
jmp    1292 <printspeed+0x182>
mov    -0x8(%rbp),%rsi
movsd  -0x18(%rbp),%xmm0
movaps 0xd9f(%rip),%xmm2
movq   -0x10(%rbp),%xmm1
punpckldq %xmm2,%xmm1
movapd 0xd9e(%rip),%xmm2
subpd  %xmm2,%xmm1
movaps %xmm1,%xmm2
unpckhpd %xmm1,%xmm1
addsd  %xmm2,%xmm1
divsd  -0x18(%rbp),%xmm1
lea    0xdee(%rip),%rdi
call   1030 <printf@plt>
jmp    1297 <printspeed+0x187>
jmp    129c <printspeed+0x18c>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printspeed>:
mov    %rdi,%rax
cmp    $0x40000000,%rsi
jae    1158 <printspeed+0x48>
cmp    $0x100000,%rsi
jae    118a <printspeed+0x7a>
movq   %rsi,%xmm2
punpckldq 0xece(%rip),%xmm2
subpd  0xed6(%rip),%xmm2
movapd %xmm2,%xmm1
unpckhpd %xmm2,%xmm1
addsd  %xmm2,%xmm1
cmp    $0x400,%rsi
jae    11bc <printspeed+0xac>
lea    0xf25(%rip),%rdi
jmp    11cb <printspeed+0xbb>
movq   %rsi,%xmm2
punpckldq 0xe9b(%rip),%xmm2
subpd  0xea3(%rip),%xmm2
movapd %xmm2,%xmm1
unpckhpd %xmm2,%xmm1
addsd  %xmm2,%xmm1
mulsd  0xe9f(%rip),%xmm1
lea    0xeb0(%rip),%rdi
jmp    11cb <printspeed+0xbb>
movq   %rsi,%xmm2
punpckldq 0xe69(%rip),%xmm2
subpd  0xe71(%rip),%xmm2
movapd %xmm2,%xmm1
unpckhpd %xmm2,%xmm1
addsd  %xmm2,%xmm1
mulsd  0xe75(%rip),%xmm1
lea    0xe97(%rip),%rdi
jmp    11cb <printspeed+0xbb>
mulsd  0xe6c(%rip),%xmm1
lea    0xe9b(%rip),%rdi
divsd  %xmm0,%xmm1
mov    %rax,%rsi
jmp    1030 <printf@plt>

LLVM IR (-O0):
@.str = [25 x i8] c"%s %.4f sec (%.3f GBps)\0A\00"
@.str.1 = [21 x i8] c"%s %.4f (%.3f MBps)\0A\00"
@.str.2 = [21 x i8] c"%s %.4f (%.3f KBps)\0A\00"
@.str.3 = [18 x i8] c"%s %.4f (%f Bps)\0A\00"
define void @printspeed(i8* %0, i64 %1, double %2) {
%4 = alloca i8*
%5 = alloca i64
%6 = alloca double
store i8* %0, i8** %4
store i64 %1, i64* %5
store double %2, double* %6
%7 = load i64, i64* %5
%8 = udiv i64 %7, 1073741824
%9 = icmp ugt i64 %8, 0
br i1 %9, label %10, label %19
10: ; preds = %3
%11 = load i8*, i8** %4
%12 = load double, double* %6
%13 = load i64, i64* %5
%14 = uitofp i64 %13 to double
%15 = fdiv double %14, 0x41D0000000000000
%16 = load double, double* %6
%17 = fdiv double %15, %16
%18 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i8* %11, double %12, double %17)
br label %55
19: ; preds = %3
%20 = load i64, i64* %5
%21 = udiv i64 %20, 1048576
%22 = icmp ugt i64 %21, 0
br i1 %22, label %23, label %32
23: ; preds = %19
%24 = load i8*, i8** %4
%25 = load double, double* %6
%26 = load i64, i64* %5
%27 = uitofp i64 %26 to double
%28 = fdiv double %27, 0x4130000000000000
%29 = load double, double* %6
%30 = fdiv double %28, %29
%31 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i8* %24, double %25, double %30)
br label %54
32: ; preds = %19
%33 = load i64, i64* %5
%34 = udiv i64 %33, 1024
%35 = icmp ugt i64 %34, 0
br i1 %35, label %36, label %45
36: ; preds = %32
%37 = load i8*, i8** %4
%38 = load double, double* %6
%39 = load i64, i64* %5
%40 = uitofp i64 %39 to double
%41 = fdiv double %40, 1.024000e+03
%42 = load double, double* %6
%43 = fdiv double %41, %42
%44 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i8* %37, double %38, double %43)
br label %53
45: ; preds = %32
%46 = load i8*, i8** %4
%47 = load double, double* %6
%48 = load i64, i64* %5
%49 = uitofp i64 %48 to double
%50 = load double, double* %6
%51 = fdiv double %49, %50
%52 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0), i8* %46, double %47, double %51)
br label %53
53: ; preds = %45, %36
br label %54
54: ; preds = %53, %23
br label %55
55: ; preds = %54, %10
ret void
}

LLVM IR (-O2):
@.str = [25 x i8] c"%s %.4f sec (%.3f GBps)\0A\00"
@.str.1 = [21 x i8] c"%s %.4f (%.3f MBps)\0A\00"
@.str.2 = [21 x i8] c"%s %.4f (%.3f KBps)\0A\00"
@.str.3 = [18 x i8] c"%s %.4f (%f Bps)\0A\00"
define void @printspeed(i8* %0, i64 %1, double %2) {
%4 = icmp ult i64 %1, 1073741824
br i1 %4, label %8, label %5
5: ; preds = %3
%6 = uitofp i64 %1 to double
%7 = fmul double %6, 0x3E10000000000000
br label %18
8: ; preds = %3
%9 = icmp ult i64 %1, 1048576
br i1 %9, label %13, label %10
10: ; preds = %8
%11 = uitofp i64 %1 to double
%12 = fmul double %11, 0x3EB0000000000000
br label %18
13: ; preds = %8
%14 = icmp ult i64 %1, 1024
%15 = uitofp i64 %1 to double
br i1 %14, label %18, label %16
16: ; preds = %13
%17 = fmul double %15, 0x3F50000000000000
br label %18
18: ; preds = %13, %10, %16, %5
%19 = phi double [ %12, %10 ], [ %17, %16 ], [ %7, %5 ], [ %15, %13 ]
%20 = phi i8* [ getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), %10 ], [ getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), %16 ], [ getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), %5 ], [ getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0), %13 ]
%21 = fdiv double %19, %2
%22 = tail call i32 @printf(i8* %20, i8* %0, double %2, double %21)
ret void
}