#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 CalcAnglesQuality(double grad_low, double grad_high) {
  double ratio;
  if (fabs(grad_low) + fabs(grad_high) < 1.0e-20)
    return (10);
  ratio = 2.0 * grad_low * grad_high /
          (grad_low * grad_low + grad_high * grad_high);
  return (ratio > 0.0 ? (int)(10.01 * ratio) : 0);
}


x86 assembly (clang, -O0):
<CalcAnglesQuality>:
push   %rbp
mov    %rsp,%rbp
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  -0x10(%rbp),%xmm1
movaps 0xf06(%rip),%xmm0
pand   %xmm0,%xmm1
movsd  -0x18(%rbp),%xmm0
movaps 0xef6(%rip),%xmm2
pand   %xmm2,%xmm0
addsd  %xmm0,%xmm1
movsd  0xec6(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    1150 <CalcAnglesQuality+0x50>
movl   $0xa,-0x4(%rbp)
jmp    11c2 <CalcAnglesQuality+0xc2>
movsd  0xeb0(%rip),%xmm0
mulsd  -0x10(%rbp),%xmm0
mulsd  -0x18(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
movsd  -0x10(%rbp),%xmm3
movsd  -0x18(%rbp),%xmm2
mulsd  -0x18(%rbp),%xmm2
mulsd  %xmm3,%xmm1
addsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    11b2 <CalcAnglesQuality+0xb2>
movsd  0xe6f(%rip),%xmm0
mulsd  -0x20(%rbp),%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0x24(%rbp)
jmp    11bc <CalcAnglesQuality+0xbc>
xor    %eax,%eax
mov    %eax,-0x24(%rbp)
jmp    11bc <CalcAnglesQuality+0xbc>
mov    -0x24(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<CalcAnglesQuality>:
movapd 0xef8(%rip),%xmm2
movapd %xmm0,%xmm3
andpd  %xmm2,%xmm3
andpd  %xmm1,%xmm2
addsd  %xmm3,%xmm2
mov    $0xa,%eax
movsd  0xeeb(%rip),%xmm3
ucomisd %xmm2,%xmm3
ja     1160 <CalcAnglesQuality+0x60>
movapd %xmm0,%xmm2
addsd  %xmm0,%xmm2
mulsd  %xmm1,%xmm2
mulsd  %xmm1,%xmm1
mulsd  %xmm0,%xmm0
addsd  %xmm1,%xmm0
divsd  %xmm0,%xmm2
xor    %ecx,%ecx
xorpd  %xmm0,%xmm0
ucomisd %xmm0,%xmm2
mulsd  0xebf(%rip),%xmm2
cvttsd2si %xmm2,%eax
cmovbe %ecx,%eax
ret

LLVM IR (-O0):
define i32 @CalcAnglesQuality(double %0, double %1) {
%3 = alloca i32
%4 = alloca double
%5 = alloca double
%6 = alloca double
store double %0, double* %4
store double %1, double* %5
%7 = load double, double* %4
%8 = call double @llvm.fabs.f64(double %7)
%9 = load double, double* %5
%10 = call double @llvm.fabs.f64(double %9)
%11 = fadd double %8, %10
%12 = fcmp olt double %11, 0x3BC79CA10C924223
br i1 %12, label %13, label %14
13: ; preds = %2
store i32 10, i32* %3
br label %35
14: ; preds = %2
%15 = load double, double* %4
%16 = fmul double 2.000000e+00, %15
%17 = load double, double* %5
%18 = fmul double %16, %17
%19 = load double, double* %4
%20 = load double, double* %4
%21 = load double, double* %5
%22 = load double, double* %5
%23 = fmul double %21, %22
%24 = call double @llvm.fmuladd.f64(double %19, double %20, double %23)
%25 = fdiv double %18, %24
store double %25, double* %6
%26 = load double, double* %6
%27 = fcmp ogt double %26, 0.000000e+00
br i1 %27, label %28, label %32
28: ; preds = %14
%29 = load double, double* %6
%30 = fmul double 1.001000e+01, %29
%31 = fptosi double %30 to i32
br label %33
32: ; preds = %14
br label %33
33: ; preds = %32, %28
%34 = phi i32 [ %31, %28 ], [ 0, %32 ]
store i32 %34, i32* %3
br label %35
35: ; preds = %33, %13
%36 = load i32, i32* %3
ret i32 %36
}

LLVM IR (-O2):
define i32 @CalcAnglesQuality(double %0, double %1) {
%3 = tail call double @llvm.fabs.f64(double %0)
%4 = tail call double @llvm.fabs.f64(double %1)
%5 = fadd double %3, %4
%6 = fcmp olt double %5, 0x3BC79CA10C924223
br i1 %6, label %17, label %7
7: ; preds = %2
%8 = fmul double %0, 2.000000e+00
%9 = fmul double %8, %1
%10 = fmul double %1, %1
%11 = tail call double @llvm.fmuladd.f64(double %0, double %0, double %10)
%12 = fdiv double %9, %11
%13 = fcmp ogt double %12, 0.000000e+00
%14 = fmul double %12, 1.001000e+01
%15 = fptosi double %14 to i32
%16 = select i1 %13, i32 %15, i32 0
br label %17
17: ; preds = %2, %7
%18 = phi i32 [ %16, %7 ], [ 10, %2 ]
ret i32 %18
}