#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 */
double fabs(double);
int /*<<< orphan*/ my_log_info(char *, double, double, ...);
void validate_stats(double actualAvg, double expectedAvg) {
  double pctErrorAvg = 0.001;
  double expectedAvgDelta = expectedAvg * pctErrorAvg;
  my_log_info("expectedAverage=%lf +/- %lf\n", expectedAvg, expectedAvgDelta);
  if (fabs(expectedAvg - actualAvg) <= expectedAvgDelta)
    my_log_info("OK. average %lf inside range [%lf, %lf]\n", actualAvg,
                expectedAvg - expectedAvgDelta, expectedAvg + expectedAvgDelta);
  else
    my_log_info("ERROR. average %lf out of range [%lf, %lf]\n", actualAvg,
                expectedAvg - expectedAvgDelta, expectedAvg + expectedAvgDelta);
}


x86 assembly (clang, -O0):
<validate_stats>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  0xee6(%rip),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x10(%rbp),%xmm0
mulsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
lea    0xec9(%rip),%rdi
mov    $0x2,%al
call   1030 <my_log_info@plt>
movsd  -0x10(%rbp),%xmm1
subsd  -0x8(%rbp),%xmm1
movaps 0xe99(%rip),%xmm0
pand   %xmm0,%xmm1
movsd  -0x20(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jb     11a6 <validate_stats+0x96>
movsd  -0x8(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
subsd  -0x20(%rbp),%xmm1
movsd  -0x10(%rbp),%xmm2
addsd  -0x20(%rbp),%xmm2
lea    0xe9b(%rip),%rdi
mov    $0x3,%al
call   1030 <my_log_info@plt>
jmp    11cd <validate_stats+0xbd>
movsd  -0x8(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
subsd  -0x20(%rbp),%xmm1
movsd  -0x10(%rbp),%xmm2
addsd  -0x20(%rbp),%xmm2
lea    0xe98(%rip),%rdi
mov    $0x3,%al
call   1030 <my_log_info@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<validate_stats>:
sub    $0x18,%rsp
movapd %xmm1,%xmm2
movsd  %xmm1,(%rsp)
movsd  %xmm0,0x10(%rsp)
movsd  0xed5(%rip),%xmm1
mulsd  %xmm2,%xmm1
movsd  %xmm1,0x8(%rsp)
lea    0xee4(%rip),%rdi
movapd %xmm2,%xmm0
mov    $0x2,%al
call   1030 <my_log_info@plt>
movsd  (%rsp),%xmm3
movapd %xmm3,%xmm1
movsd  0x10(%rsp),%xmm0
subsd  %xmm0,%xmm1
andpd  0xeae(%rip),%xmm1
movsd  0x8(%rsp),%xmm2
ucomisd %xmm1,%xmm2
movapd %xmm3,%xmm1
subsd  %xmm2,%xmm1
addsd  %xmm3,%xmm2
lea    0xee7(%rip),%rax
lea    0xeb7(%rip),%rdi
cmovb  %rax,%rdi
mov    $0x3,%al
add    $0x18,%rsp
jmp    1030 <my_log_info@plt>

LLVM IR (-O0):
@.str = [29 x i8] c"expectedAverage=%lf +/- %lf\0A\00"
@.str.1 = [41 x i8] c"OK. average %lf inside range [%lf, %lf]\0A\00"
@.str.2 = [44 x i8] c"ERROR. average %lf out of range [%lf, %lf]\0A\00"
define void @validate_stats(double %0, double %1) {
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca double
store double %0, double* %3
store double %1, double* %4
store double 1.000000e-03, double* %5
%7 = load double, double* %4
%8 = load double, double* %5
%9 = fmul double %7, %8
store double %9, double* %6
%10 = load double, double* %4
%11 = load double, double* %6
%12 = call i32 (i8*, double, double, ...) @my_log_info(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), double %10, double %11)
%13 = load double, double* %4
%14 = load double, double* %3
%15 = fsub double %13, %14
%16 = call double @llvm.fabs.f64(double %15)
%17 = load double, double* %6
%18 = fcmp ole double %16, %17
br i1 %18, label %19, label %28
19: ; preds = %2
%20 = load double, double* %3
%21 = load double, double* %4
%22 = load double, double* %6
%23 = fsub double %21, %22
%24 = load double, double* %4
%25 = load double, double* %6
%26 = fadd double %24, %25
%27 = call i32 (i8*, double, double, ...) @my_log_info(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.1, i64 0, i64 0), double %20, double %23, double %26)
br label %37
28: ; preds = %2
%29 = load double, double* %3
%30 = load double, double* %4
%31 = load double, double* %6
%32 = fsub double %30, %31
%33 = load double, double* %4
%34 = load double, double* %6
%35 = fadd double %33, %34
%36 = call i32 (i8*, double, double, ...) @my_log_info(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.2, i64 0, i64 0), double %29, double %32, double %35)
br label %37
37: ; preds = %28, %19
ret void
}

LLVM IR (-O2):
@.str = [29 x i8] c"expectedAverage=%lf +/- %lf\0A\00"
@.str.1 = [41 x i8] c"OK. average %lf inside range [%lf, %lf]\0A\00"
@.str.2 = [44 x i8] c"ERROR. average %lf out of range [%lf, %lf]\0A\00"
define void @validate_stats(double %0, double %1) {
%3 = fmul double %1, 1.000000e-03
%4 = tail call i32 (i8*, double, double, ...) @my_log_info(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), double %1, double %3)
%5 = fsub double %1, %0
%6 = tail call double @llvm.fabs.f64(double %5)
%7 = fcmp ugt double %6, %3
%8 = fsub double %1, %3
%9 = fadd double %3, %1
%10 = select i1 %7, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.1, i64 0, i64 0)
%11 = tail call i32 (i8*, double, double, ...) @my_log_info(i8* %10, double %0, double %8, double %9)
ret void
}