#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*/ assert(int);
double fabs(double);
double going(int);
int /*<<< orphan*/ printf(char *, double, double);
void dotest(int n, double expr) {
  double merr = 1.0E-6;
  double act = going(n);
  int inrange =
      (expr == 0) ? (fabs(act) <= merr) : (fabs(act - expr) / expr <= merr);
  if (!inrange)
    printf("Expected %.6f, got %.6f\n", expr, act);
  assert(inrange);
}


x86 assembly (clang, -O0):
<dotest>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
movsd  %xmm0,-0x10(%rbp)
movsd  0xeb8(%rip),%xmm0
movsd  %xmm0,-0x18(%rbp)
mov    -0x4(%rbp),%edi
call   1050 <going@plt>
movsd  %xmm0,-0x20(%rbp)
movsd  -0x10(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    119b <dotest+0x6b>
jp     119b <dotest+0x6b>
movsd  -0x20(%rbp),%xmm1
movaps 0xe92(%rip),%xmm0
pand   %xmm0,%xmm1
movsd  -0x18(%rbp),%xmm0
ucomisd %xmm1,%xmm0
setae  %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x28(%rbp)
jmp    11c9 <dotest+0x99>
movsd  -0x20(%rbp),%xmm1
subsd  -0x10(%rbp),%xmm1
movaps 0xe64(%rip),%xmm0
pand   %xmm0,%xmm1
divsd  -0x10(%rbp),%xmm1
movsd  -0x18(%rbp),%xmm0
ucomisd %xmm1,%xmm0
setae  %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x28(%rbp)
mov    -0x28(%rbp),%eax
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
jne    11ef <dotest+0xbf>
movsd  -0x10(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
lea    0xe36(%rip),%rdi
call   1030 <printf@plt>
mov    -0x24(%rbp),%edi
call   1040 <assert@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dotest>:
sub    $0x18,%rsp
movsd  %xmm0,(%rsp)
call   1050 <going@plt>
movapd %xmm0,%xmm1
xorpd  %xmm0,%xmm0
movsd  (%rsp),%xmm2
ucomisd %xmm0,%xmm2
movapd %xmm2,%xmm0
jne    1165 <dotest+0x35>
jp     1165 <dotest+0x35>
movapd 0xea1(%rip),%xmm2
andpd  %xmm1,%xmm2
jmp    1179 <dotest+0x49>
movapd %xmm1,%xmm2
subsd  %xmm0,%xmm2
andpd  0xe8b(%rip),%xmm2
divsd  %xmm0,%xmm2
movsd  0xe8f(%rip),%xmm3
ucomisd %xmm2,%xmm3
jae    11a5 <dotest+0x75>
lea    0xe8a(%rip),%rdi
movapd %xmm2,(%rsp)
call   1030 <printf@plt>
movsd  0xe70(%rip),%xmm3
movapd (%rsp),%xmm2
xor    %edi,%edi
ucomisd %xmm2,%xmm3
setae  %dil
add    $0x18,%rsp
jmp    1040 <assert@plt>

LLVM IR (-O0):
@.str = [25 x i8] c"Expected %.6f, got %.6f\0A\00"
define void @dotest(i32 %0, double %1) {
%3 = alloca i32
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca i32
store i32 %0, i32* %3
store double %1, double* %4
store double 0x3EB0C6F7A0B5ED8D, double* %5
%8 = load i32, i32* %3
%9 = call double @going(i32 %8)
store double %9, double* %6
%10 = load double, double* %4
%11 = fcmp oeq double %10, 0.000000e+00
br i1 %11, label %12, label %18
12: ; preds = %2
%13 = load double, double* %6
%14 = call double @llvm.fabs.f64(double %13)
%15 = load double, double* %5
%16 = fcmp ole double %14, %15
%17 = zext i1 %16 to i32
br label %28
18: ; preds = %2
%19 = load double, double* %6
%20 = load double, double* %4
%21 = fsub double %19, %20
%22 = call double @llvm.fabs.f64(double %21)
%23 = load double, double* %4
%24 = fdiv double %22, %23
%25 = load double, double* %5
%26 = fcmp ole double %24, %25
%27 = zext i1 %26 to i32
br label %28
28: ; preds = %18, %12
%29 = phi i32 [ %17, %12 ], [ %27, %18 ]
store i32 %29, i32* %7
%30 = load i32, i32* %7
%31 = icmp ne i32 %30, 0
br i1 %31, label %36, label %32
32: ; preds = %28
%33 = load double, double* %4
%34 = load double, double* %6
%35 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), double %33, double %34)
br label %36
36: ; preds = %32, %28
%37 = load i32, i32* %7
%38 = call i32 @assert(i32 %37)
ret void
}

LLVM IR (-O2):
@.str = [25 x i8] c"Expected %.6f, got %.6f\0A\00"
define void @dotest(i32 %0, double %1) {
%3 = tail call double @going(i32 %0)
%4 = fcmp oeq double %1, 0.000000e+00
br i1 %4, label %5, label %7
5: ; preds = %2
%6 = tail call double @llvm.fabs.f64(double %3)
br label %11
7: ; preds = %2
%8 = fsub double %3, %1
%9 = tail call double @llvm.fabs.f64(double %8)
%10 = fdiv double %9, %1
br label %11
11: ; preds = %7, %5
%12 = phi double [ %6, %5 ], [ %10, %7 ]
%13 = fcmp ole double %12, 0x3EB0C6F7A0B5ED8D
br i1 %13, label %16, label %14
14: ; preds = %11
%15 = tail call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), double %1, double %3)
br label %16
16: ; preds = %14, %11
%17 = zext i1 %13 to i32
%18 = tail call i32 @assert(i32 %17)
ret void
}