#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 *, ...);
void ReportRate(double measuredRate, double expectedRate) {
  double error;
  error = (measuredRate - expectedRate) / expectedRate;
  error = (error < 0) ? -error : error;
  printf("Measured rate = %6.1f, expected rate = %6.1f\n", measuredRate,
         expectedRate);
  if (error > 0.1) {
    printf("ERROR: unexpected rate! ---------------------   ERROR!\n");
  } else {
    printf("SUCCESS: rate within tolerance!\n");
  }
}


x86 assembly (clang, -O0):
<ReportRate>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  -0x8(%rbp),%xmm0
subsd  -0x10(%rbp),%xmm0
divsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x18(%rbp),%xmm0
jbe    116a <ReportRate+0x5a>
movsd  -0x18(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    1174 <ReportRate+0x64>
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
lea    0xe79(%rip),%rdi
mov    $0x2,%al
call   1030 <printf@plt>
movsd  -0x18(%rbp),%xmm0
movsd  0xe5d(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    11c0 <ReportRate+0xb0>
lea    0xe82(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11ce <ReportRate+0xbe>
lea    0xea7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ReportRate>:
sub    $0x18,%rsp
movapd %xmm0,%xmm2
subsd  %xmm1,%xmm2
divsd  %xmm1,%xmm2
movapd 0xec8(%rip),%xmm3
xorpd  %xmm2,%xmm3
xorpd  %xmm4,%xmm4
movapd %xmm2,%xmm5
cmpltsd %xmm4,%xmm5
andpd  %xmm5,%xmm3
andnpd %xmm2,%xmm5
orpd   %xmm3,%xmm5
movapd %xmm5,(%rsp)
lea    0xeb7(%rip),%rdi
mov    $0x2,%al
call   1040 <printf@plt>
movapd (%rsp),%xmm0
ucomisd 0xe9b(%rip),%xmm0
lea    0xeea(%rip),%rax
lea    0xec3(%rip),%rdi
cmova  %rax,%rdi
add    $0x18,%rsp
jmp    1030 <puts@plt>

LLVM IR (-O0):
@.str = [46 x i8] c"Measured rate = %6.1f, expected rate = %6.1f\0A\00"
@.str.1 = [56 x i8] c"ERROR: unexpected rate! --------------------- ERROR!\0A\00"
@.str.2 = [33 x i8] c"SUCCESS: rate within tolerance!\0A\00"
define void @ReportRate(double %0, double %1) {
%3 = alloca double
%4 = alloca double
%5 = alloca double
store double %0, double* %3
store double %1, double* %4
%6 = load double, double* %3
%7 = load double, double* %4
%8 = fsub double %6, %7
%9 = load double, double* %4
%10 = fdiv double %8, %9
store double %10, double* %5
%11 = load double, double* %5
%12 = fcmp olt double %11, 0.000000e+00
br i1 %12, label %13, label %16
13: ; preds = %2
%14 = load double, double* %5
%15 = fneg double %14
br label %18
16: ; preds = %2
%17 = load double, double* %5
br label %18
18: ; preds = %16, %13
%19 = phi double [ %15, %13 ], [ %17, %16 ]
store double %19, double* %5
%20 = load double, double* %3
%21 = load double, double* %4
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str, i64 0, i64 0), double %20, double %21)
%23 = load double, double* %5
%24 = fcmp ogt double %23, 1.000000e-01
br i1 %24, label %25, label %27
25: ; preds = %18
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.1, i64 0, i64 0))
br label %29
27: ; preds = %18
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0))
br label %29
29: ; preds = %27, %25
ret void
}

LLVM IR (-O2):
@.str = [46 x i8] c"Measured rate = %6.1f, expected rate = %6.1f\0A\00"
@str = [32 x i8] c"SUCCESS: rate within tolerance!\00"
@str.3 = [55 x i8] c"ERROR: unexpected rate! --------------------- ERROR!\00"
define void @ReportRate(double %0, double %1) {
%3 = fsub double %0, %1
%4 = fdiv double %3, %1
%5 = fcmp olt double %4, 0.000000e+00
%6 = fneg double %4
%7 = select i1 %5, double %6, double %4
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @.str, i64 0, i64 0), double %0, double %1)
%9 = fcmp ogt double %7, 1.000000e-01
%10 = select i1 %9, i8* getelementptr inbounds ([55 x i8], [55 x i8]* @str.3, i64 0, i64 0), i8* getelementptr inbounds ([32 x i8], [32 x i8]* @str, i64 0, i64 0)
%11 = tail call i32 @puts(i8* dereferenceable(1) %10)
ret void
}