#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 Stopping_Rule(double x[], double tolerance) {
  double xmid = 0.5 * fabs(x[3] + x[1]);
  double eta = (xmid <= 1.0) ? 1.0 : fabs(xmid);
  return ((x[3] - x[1]) <= tolerance * eta) ? 1 : 0;
}


x86 assembly (clang, -O0):
<Stopping_Rule>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
movsd  %xmm0,-0x10(%rbp)
mov    -0x8(%rbp),%rax
movsd  0x18(%rax),%xmm1
mov    -0x8(%rbp),%rax
addsd  0x8(%rax),%xmm1
movaps 0xeea(%rip),%xmm0
pand   %xmm0,%xmm1
movsd  0xed6(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  0xebd(%rip),%xmm0
ucomisd -0x18(%rbp),%xmm0
jb     1160 <Stopping_Rule+0x60>
movsd  0xeaa(%rip),%xmm0
movsd  %xmm0,-0x28(%rbp)
jmp    1175 <Stopping_Rule+0x75>
movsd  -0x18(%rbp),%xmm0
movaps 0xea4(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x8(%rbp),%rax
movsd  0x18(%rax),%xmm1
mov    -0x8(%rbp),%rax
subsd  0x8(%rax),%xmm1
movsd  -0x10(%rbp),%xmm0
mulsd  -0x20(%rbp),%xmm0
xor    %eax,%eax
mov    $0x1,%ecx
ucomisd %xmm1,%xmm0
cmovae %ecx,%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<Stopping_Rule>:
movsd  0x8(%rdi),%xmm1
movsd  0x18(%rdi),%xmm2
movapd %xmm2,%xmm3
addsd  %xmm1,%xmm3
andpd  0xee6(%rip),%xmm3
mulsd  0xeee(%rip),%xmm3
movsd  0xeee(%rip),%xmm4
maxsd  %xmm3,%xmm4
subsd  %xmm1,%xmm2
mulsd  %xmm0,%xmm4
xor    %eax,%eax
ucomisd %xmm2,%xmm4
setae  %al
ret

LLVM IR (-O0):
define i32 @Stopping_Rule(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
%7 = load double*, double** %3
%8 = getelementptr inbounds double, double* %7, i64 3
%9 = load double, double* %8
%10 = load double*, double** %3
%11 = getelementptr inbounds double, double* %10, i64 1
%12 = load double, double* %11
%13 = fadd double %9, %12
%14 = call double @llvm.fabs.f64(double %13)
%15 = fmul double 5.000000e-01, %14
store double %15, double* %5
%16 = load double, double* %5
%17 = fcmp ole double %16, 1.000000e+00
br i1 %17, label %18, label %19
18: ; preds = %2
br label %22
19: ; preds = %2
%20 = load double, double* %5
%21 = call double @llvm.fabs.f64(double %20)
br label %22
22: ; preds = %19, %18
%23 = phi double [ 1.000000e+00, %18 ], [ %21, %19 ]
store double %23, double* %6
%24 = load double*, double** %3
%25 = getelementptr inbounds double, double* %24, i64 3
%26 = load double, double* %25
%27 = load double*, double** %3
%28 = getelementptr inbounds double, double* %27, i64 1
%29 = load double, double* %28
%30 = fsub double %26, %29
%31 = load double, double* %4
%32 = load double, double* %6
%33 = fmul double %31, %32
%34 = fcmp ole double %30, %33
%35 = zext i1 %34 to i64
%36 = select i1 %34, i32 1, i32 0
ret i32 %36
}

LLVM IR (-O2):
define i32 @Stopping_Rule(double* nocapture %0, double %1) {
%3 = getelementptr inbounds double, double* %0, i64 3
%4 = load double, double* %3
%5 = getelementptr inbounds double, double* %0, i64 1
%6 = load double, double* %5
%7 = fadd double %4, %6
%8 = tail call double @llvm.fabs.f64(double %7)
%9 = fmul double %8, 5.000000e-01
%10 = fcmp ole double %9, 1.000000e+00
%11 = select i1 %10, double 1.000000e+00, double %9
%12 = fsub double %4, %6
%13 = fmul double %11, %1
%14 = fcmp ole double %12, %13
%15 = zext i1 %14 to i32
ret i32 %15
}