#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 cg_tol(double f, double gnorm, int StopRule, double tol) {
  if (StopRule) {
    if (gnorm <= tol)
      return (1);
  } else if (gnorm <= tol * (((double)1) + fabs(f)))
    return (1);
  return (0);
}


x86 assembly (clang, -O0):
<cg_tol>:
push   %rbp
mov    %rsp,%rbp
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
mov    %edi,-0x1c(%rbp)
movsd  %xmm2,-0x28(%rbp)
cmpl   $0x0,-0x1c(%rbp)
je     1145 <cg_tol+0x45>
movsd  -0x18(%rbp),%xmm1
movsd  -0x28(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jb     1140 <cg_tol+0x40>
movl   $0x1,-0x4(%rbp)
jmp    1191 <cg_tol+0x91>
jmp    118a <cg_tol+0x8a>
movsd  -0x18(%rbp),%xmm1
movsd  -0x28(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm3
movaps 0xeb5(%rip),%xmm2
pand   %xmm2,%xmm3
movsd  0xe99(%rip),%xmm2
addsd  %xmm3,%xmm2
mulsd  %xmm2,%xmm0
ucomisd %xmm1,%xmm0
jb     1185 <cg_tol+0x85>
movl   $0x1,-0x4(%rbp)
jmp    1191 <cg_tol+0x91>
jmp    118a <cg_tol+0x8a>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<cg_tol>:
test   %edi,%edi
je     1112 <cg_tol+0x12>
mov    $0x1,%eax
ucomisd %xmm1,%xmm2
jae    1111 <cg_tol+0x11>
xor    %eax,%eax
ret
andpd  0xee6(%rip),%xmm0
addsd  0xeee(%rip),%xmm0
mulsd  %xmm2,%xmm0
mov    $0x1,%eax
ucomisd %xmm1,%xmm0
jb     110f <cg_tol+0xf>
jmp    1111 <cg_tol+0x11>

LLVM IR (-O0):
define i32 @cg_tol(double %0, double %1, i32 %2, double %3) {
%5 = alloca i32
%6 = alloca double
%7 = alloca double
%8 = alloca i32
%9 = alloca double
store double %0, double* %6
store double %1, double* %7
store i32 %2, i32* %8
store double %3, double* %9
%10 = load i32, i32* %8
%11 = icmp ne i32 %10, 0
br i1 %11, label %12, label %18
12: ; preds = %4
%13 = load double, double* %7
%14 = load double, double* %9
%15 = fcmp ole double %13, %14
br i1 %15, label %16, label %17
16: ; preds = %12
store i32 1, i32* %5
br label %29
17: ; preds = %12
br label %28
18: ; preds = %4
%19 = load double, double* %7
%20 = load double, double* %9
%21 = load double, double* %6
%22 = call double @llvm.fabs.f64(double %21)
%23 = fadd double 1.000000e+00, %22
%24 = fmul double %20, %23
%25 = fcmp ole double %19, %24
br i1 %25, label %26, label %27
26: ; preds = %18
store i32 1, i32* %5
br label %29
27: ; preds = %18
br label %28
28: ; preds = %27, %17
store i32 0, i32* %5
br label %29
29: ; preds = %28, %26, %16
%30 = load i32, i32* %5
ret i32 %30
}

LLVM IR (-O2):
define i32 @cg_tol(double %0, double %1, i32 %2, double %3) {
%5 = icmp eq i32 %2, 0
br i1 %5, label %8, label %6
6: ; preds = %4
%7 = fcmp ugt double %1, %3
br i1 %7, label %13, label %14
8: ; preds = %4
%9 = tail call double @llvm.fabs.f64(double %0)
%10 = fadd double %9, 1.000000e+00
%11 = fmul double %10, %3
%12 = fcmp ult double %11, %1
br i1 %12, label %13, label %14
13: ; preds = %8, %6
br label %14
14: ; preds = %8, %6, %13
%15 = phi i32 [ 0, %13 ], [ 1, %6 ], [ 1, %8 ]
ret i32 %15
}