#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 *, ...);
double display_error(long long average, long long high, long long low,
                     long long expected, int quiet) {
  double error;
  error = (((double)average - expected) / expected) * 100.0;
  if (!quiet) {
    printf("   Expected: %lld\n", expected);
    printf("   High: %lld   Low:  %lld   Average:  %lld\n", high, low, average);
    printf("   ( note, a small value above %lld may be expected due\n",
           expected);
    printf("     to overhead and interrupt noise, among other reasons)\n");
    printf("   Average Error = %.2f%%\n", error);
  }
  return error;
}


x86 assembly (clang, -O0):
<display_error>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8d,-0x24(%rbp)
cvtsi2sdq -0x8(%rbp),%xmm0
cvtsi2sdq -0x20(%rbp),%xmm1
subsd  %xmm1,%xmm0
cvtsi2sdq -0x20(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  0xeb2(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
cmpl   $0x0,-0x24(%rbp)
jne    11c0 <display_error+0xb0>
mov    -0x20(%rbp),%rsi
lea    0xe9c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x8(%rbp),%rcx
lea    0xe95(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%rsi
lea    0xeb0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xedb(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movsd  -0x30(%rbp),%xmm0
lea    0xf04(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movsd  -0x30(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<display_error>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
cvtsi2sd %rdi,%xmm0
cvtsi2sd %rcx,%xmm1
subsd  %xmm1,%xmm0
divsd  %xmm1,%xmm0
mulsd  0xebe(%rip),%xmm0
test   %r8d,%r8d
jne    11b5 <display_error+0x95>
mov    %rdi,%r14
mov    %rcx,%rbx
mov    %rdx,%r15
mov    %rsi,%r12
lea    0xeae(%rip),%rdi
mov    %rcx,%rsi
xor    %eax,%eax
movsd  %xmm0,(%rsp)
call   1040 <printf@plt>
lea    0xeab(%rip),%rdi
mov    %r12,%rsi
mov    %r15,%rdx
mov    %r14,%rcx
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xec1(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xf04(%rip),%rdi
call   1030 <puts@plt>
lea    0xedd(%rip),%rdi
movsd  (%rsp),%xmm0
mov    $0x1,%al
call   1040 <printf@plt>
movsd  (%rsp),%xmm0
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [19 x i8] c" Expected: %lld\0A\00"
@.str.1 = [45 x i8] c" High: %lld Low: %lld Average: %lld\0A\00"
@.str.2 = [57 x i8] c" ( note, a small value above %lld may be expected due\0A\00"
@.str.3 = [60 x i8] c" to overhead and interrupt noise, among other reasons)\0A\00"
@.str.4 = [27 x i8] c" Average Error = %.2f%%\0A\00"
define double @display_error(i64 %0, i64 %1, i64 %2, i64 %3, i32 %4) {
%6 = alloca i64
%7 = alloca i64
%8 = alloca i64
%9 = alloca i64
%10 = alloca i32
%11 = alloca double
store i64 %0, i64* %6
store i64 %1, i64* %7
store i64 %2, i64* %8
store i64 %3, i64* %9
store i32 %4, i32* %10
%12 = load i64, i64* %6
%13 = sitofp i64 %12 to double
%14 = load i64, i64* %9
%15 = sitofp i64 %14 to double
%16 = fsub double %13, %15
%17 = load i64, i64* %9
%18 = sitofp i64 %17 to double
%19 = fdiv double %16, %18
%20 = fmul double %19, 1.000000e+02
store double %20, double* %11
%21 = load i32, i32* %10
%22 = icmp ne i32 %21, 0
br i1 %22, label %35, label %23
23: ; preds = %5
%24 = load i64, i64* %9
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i64 %24)
%26 = load i64, i64* %7
%27 = load i64, i64* %8
%28 = load i64, i64* %6
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.1, i64 0, i64 0), i64 %26, i64 %27, i64 %28)
%30 = load i64, i64* %9
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.2, i64 0, i64 0), i64 %30)
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str.3, i64 0, i64 0))
%33 = load double, double* %11
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.4, i64 0, i64 0), double %33)
br label %35
35: ; preds = %23, %5
%36 = load double, double* %11
ret double %36
}

LLVM IR (-O2):
@.str = [19 x i8] c" Expected: %lld\0A\00"
@.str.1 = [45 x i8] c" High: %lld Low: %lld Average: %lld\0A\00"
@.str.2 = [57 x i8] c" ( note, a small value above %lld may be expected due\0A\00"
@.str.4 = [27 x i8] c" Average Error = %.2f%%\0A\00"
@str = [59 x i8] c" to overhead and interrupt noise, among other reasons)\00"
define double @display_error(i64 %0, i64 %1, i64 %2, i64 %3, i32 %4) {
%6 = sitofp i64 %0 to double
%7 = sitofp i64 %3 to double
%8 = fsub double %6, %7
%9 = fdiv double %8, %7
%10 = fmul double %9, 1.000000e+02
%11 = icmp eq i32 %4, 0
br i1 %11, label %12, label %18
12: ; preds = %5
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i64 %3)
%14 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @.str.1, i64 0, i64 0), i64 %1, i64 %2, i64 %0)
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([57 x i8], [57 x i8]* @.str.2, i64 0, i64 0), i64 %3)
%16 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([59 x i8], [59 x i8]* @str, i64 0, i64 0))
%17 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.4, i64 0, i64 0), double %10)
br label %18
18: ; preds = %12, %5
ret double %10
}