#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 DBL_EPSILON;
double _max_d(double, double);
double fabs(double);
scalar_t__ isfinite(double);
double _scale_tolerance_up(double d1, double d2, double tolerance) {
  double abs1, abs2, abs_max;
  if (isfinite(tolerance)) {
    tolerance = fabs(tolerance);
  } else {
    tolerance = DBL_EPSILON;
  }
  abs1 = fabs(d1);
  abs2 = fabs(d2);
  abs_max = _max_d(abs1, abs2);
  if (abs_max > 1.0) {
    return tolerance * abs_max;
  }
  return tolerance;
}


x86 assembly (clang, -O0):
<_scale_tolerance_up>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  %xmm2,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
call   1040 <isfinite@plt>
cmp    $0x0,%rax
je     1165 <_scale_tolerance_up+0x45>
movsd  -0x20(%rbp),%xmm0
movaps 0xea9(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    1175 <_scale_tolerance_up+0x55>
mov    0x2e7c(%rip),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x10(%rbp),%xmm0
movaps 0xe7f(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x18(%rbp),%xmm0
movaps 0xe6a(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  -0x30(%rbp),%xmm1
call   1030 <_max_d@plt>
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  0xe50(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    11de <_scale_tolerance_up+0xbe>
movsd  -0x20(%rbp),%xmm0
mulsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11e8 <_scale_tolerance_up+0xc8>
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_scale_tolerance_up>:
sub    $0x38,%rsp
movaps %xmm1,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movaps %xmm2,(%rsp)
movaps %xmm2,%xmm0
call   1040 <isfinite@plt>
movapd 0xebe(%rip),%xmm2
test   %rax,%rax
je     1152 <_scale_tolerance_up+0x32>
movapd (%rsp),%xmm1
andpd  %xmm2,%xmm1
jmp    115d <_scale_tolerance_up+0x3d>
mov    0x2e8f(%rip),%rax
movsd  (%rax),%xmm1
movapd %xmm1,(%rsp)
movapd 0x10(%rsp),%xmm0
andpd  %xmm2,%xmm0
movapd 0x20(%rsp),%xmm1
andpd  %xmm2,%xmm1
call   1030 <_max_d@plt>
maxsd  0xe8d(%rip),%xmm0
mulsd  (%rsp),%xmm0
add    $0x38,%rsp
ret

LLVM IR (-O0):
@DBL_EPSILON = global double 0.000000e+00
define double @_scale_tolerance_up(double %0, double %1, double %2) {
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca double
store double %0, double* %5
store double %1, double* %6
store double %2, double* %7
%11 = load double, double* %7
%12 = call i64 @isfinite(double %11)
%13 = icmp ne i64 %12, 0
br i1 %13, label %14, label %17
14: ; preds = %3
%15 = load double, double* %7
%16 = call double @llvm.fabs.f64(double %15)
store double %16, double* %7
br label %19
17: ; preds = %3
%18 = load double, double* @DBL_EPSILON
store double %18, double* %7
br label %19
19: ; preds = %17, %14
%20 = load double, double* %5
%21 = call double @llvm.fabs.f64(double %20)
store double %21, double* %8
%22 = load double, double* %6
%23 = call double @llvm.fabs.f64(double %22)
store double %23, double* %9
%24 = load double, double* %8
%25 = load double, double* %9
%26 = call double @_max_d(double %24, double %25)
store double %26, double* %10
%27 = load double, double* %10
%28 = fcmp ogt double %27, 1.000000e+00
br i1 %28, label %29, label %33
29: ; preds = %19
%30 = load double, double* %7
%31 = load double, double* %10
%32 = fmul double %30, %31
store double %32, double* %4
br label %35
33: ; preds = %19
%34 = load double, double* %7
store double %34, double* %4
br label %35
35: ; preds = %33, %29
%36 = load double, double* %4
ret double %36
}

LLVM IR (-O2):
@DBL_EPSILON = global double 0.000000e+00
define double @_scale_tolerance_up(double %0, double %1, double %2) {
%4 = tail call i64 @isfinite(double %2)
%5 = icmp eq i64 %4, 0
%6 = tail call double @llvm.fabs.f64(double %2)
%7 = load double, double* @DBL_EPSILON
%8 = select i1 %5, double %7, double %6
%9 = tail call double @llvm.fabs.f64(double %0)
%10 = tail call double @llvm.fabs.f64(double %1)
%11 = tail call double @_max_d(double %9, double %10)
%12 = fcmp ogt double %11, 1.000000e+00
%13 = select i1 %12, double %11, double 1.000000e+00
%14 = fmul double %8, %13
ret double %14
}