int HorizLineToArc(x1, x2, y, rx, ry, start, extent)
double x1, x2;
double y;
double rx, ry;
double start, extent;
{
  double tmp;
  double tx, ty;
  double x;
  ty = y / ry;
  tmp = 1 - ty * ty;
  if (tmp < 0) {
    return 0;
  }
  tx = sqrt(tmp);
  x = tx * rx;
  if ((x >= x1) && (x <= x2) && AngleInRange(tx, ty, start, extent)) {
    return 1;
  }
  if ((-x >= x1) && (-x <= x2) && AngleInRange(-tx, ty, start, extent)) {
    return 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<HorizLineToArc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  %xmm2,-0x20(%rbp)
movsd  %xmm3,-0x28(%rbp)
movsd  %xmm4,-0x30(%rbp)
movsd  %xmm5,-0x38(%rbp)
movsd  %xmm6,-0x40(%rbp)
movsd  -0x20(%rbp),%xmm0
divsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x58(%rbp),%xmm0
movsd  -0x58(%rbp),%xmm1
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm1,%xmm0
movsd  0xe79(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x48(%rbp),%xmm0
jbe    11aa <HorizLineToArc+0x8a>
movl   $0x0,-0x4(%rbp)
jmp    12bc <HorizLineToArc+0x19c>
movsd  -0x48(%rbp),%xmm0
call   1040 <sqrt@plt>
movsd  %xmm0,-0x50(%rbp)
movsd  -0x50(%rbp),%xmm0
mulsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x60(%rbp),%xmm0
ucomisd -0x10(%rbp),%xmm0
jb     121c <HorizLineToArc+0xfc>
movsd  -0x60(%rbp),%xmm1
movsd  -0x18(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jb     121c <HorizLineToArc+0xfc>
movsd  -0x50(%rbp),%xmm0
movsd  -0x58(%rbp),%xmm1
movsd  -0x38(%rbp),%xmm2
movsd  -0x40(%rbp),%xmm3
mov    $0x4,%al
call   1030 <AngleInRange@plt>
cmp    $0x0,%eax
je     121c <HorizLineToArc+0xfc>
movl   $0x1,-0x4(%rbp)
jmp    12bc <HorizLineToArc+0x19c>
movsd  -0x60(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
ucomisd -0x10(%rbp),%xmm0
jb     12b5 <HorizLineToArc+0x195>
movsd  -0x60(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
movsd  -0x18(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jb     12b5 <HorizLineToArc+0x195>
movsd  -0x50(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  -0x58(%rbp),%xmm1
movsd  -0x38(%rbp),%xmm2
movsd  -0x40(%rbp),%xmm3
mov    $0x4,%al
call   1030 <AngleInRange@plt>
cmp    $0x0,%eax
je     12b5 <HorizLineToArc+0x195>
movl   $0x1,-0x4(%rbp)
jmp    12bc <HorizLineToArc+0x19c>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<HorizLineToArc>:
sub    $0x58,%rsp
movapd %xmm1,%xmm8
movapd %xmm0,%xmm7
divsd  %xmm4,%xmm2
movapd %xmm2,%xmm1
mulsd  %xmm2,%xmm1
movsd  0xebf(%rip),%xmm0
subsd  %xmm1,%xmm0
xor    %eax,%eax
xorpd  %xmm1,%xmm1
ucomisd %xmm0,%xmm1
ja     121a <HorizLineToArc+0xfa>
ucomisd %xmm1,%xmm0
movsd  %xmm6,0x28(%rsp)
movsd  %xmm5,0x20(%rsp)
movsd  %xmm2,0x18(%rsp)
movsd  %xmm8,0x10(%rsp)
movsd  %xmm7,0x8(%rsp)
jb     1180 <HorizLineToArc+0x60>
sqrtsd %xmm0,%xmm0
jmp    11af <HorizLineToArc+0x8f>
movaps %xmm3,0x30(%rsp)
call   1040 <sqrt@plt>
movsd  0x8(%rsp),%xmm7
movsd  0x10(%rsp),%xmm8
movapd 0x30(%rsp),%xmm3
movsd  0x18(%rsp),%xmm2
movsd  0x20(%rsp),%xmm5
movsd  0x28(%rsp),%xmm6
mulsd  %xmm0,%xmm3
ucomisd %xmm7,%xmm3
jb     121f <HorizLineToArc+0xff>
ucomisd %xmm3,%xmm8
jb     121f <HorizLineToArc+0xff>
movapd %xmm0,0x40(%rsp)
movaps 0x40(%rsp),%xmm0
movapd %xmm2,%xmm1
movapd %xmm5,%xmm2
movapd %xmm3,0x30(%rsp)
movapd %xmm6,%xmm3
mov    $0x4,%al
call   1030 <AngleInRange@plt>
movapd 0x40(%rsp),%xmm0
movsd  0x8(%rsp),%xmm7
movsd  0x10(%rsp),%xmm8
movapd 0x30(%rsp),%xmm3
movsd  0x18(%rsp),%xmm2
movsd  0x20(%rsp),%xmm5
movsd  0x28(%rsp),%xmm6
mov    %eax,%ecx
mov    $0x1,%eax
test   %ecx,%ecx
je     121f <HorizLineToArc+0xff>
add    $0x58,%rsp
ret
xorpd  0xde9(%rip),%xmm3
ucomisd %xmm7,%xmm3
jb     125a <HorizLineToArc+0x13a>
ucomisd %xmm3,%xmm8
jb     125a <HorizLineToArc+0x13a>
xorpd  0xdd4(%rip),%xmm0
movapd %xmm2,%xmm1
movapd %xmm5,%xmm2
movapd %xmm6,%xmm3
mov    $0x4,%al
call   1030 <AngleInRange@plt>
mov    %eax,%ecx
mov    $0x1,%eax
test   %ecx,%ecx
jne    121a <HorizLineToArc+0xfa>
xor    %eax,%eax
add    $0x58,%rsp
ret

LLVM IR (-O0):
define i32 @HorizLineToArc(double %0, double %1, double %2, double %3, double %4, double %5, double %6) {
%8 = alloca i32
%9 = alloca double
%10 = alloca double
%11 = alloca double
%12 = alloca double
%13 = alloca double
%14 = alloca double
%15 = alloca double
%16 = alloca double
%17 = alloca double
%18 = alloca double
%19 = alloca double
store double %0, double* %9
store double %1, double* %10
store double %2, double* %11
store double %3, double* %12
store double %4, double* %13
store double %5, double* %14
store double %6, double* %15
%20 = load double, double* %11
%21 = load double, double* %13
%22 = fdiv double %20, %21
store double %22, double* %18
%23 = load double, double* %18
%24 = load double, double* %18
%25 = fneg double %23
%26 = call double @llvm.fmuladd.f64(double %25, double %24, double 1.000000e+00)
store double %26, double* %16
%27 = load double, double* %16
%28 = fcmp olt double %27, 0.000000e+00
br i1 %28, label %29, label %30
29: ; preds = %7
store i32 0, i32* %8
br label %71
30: ; preds = %7
%31 = load double, double* %16
%32 = call double @sqrt(double %31)
store double %32, double* %17
%33 = load double, double* %17
%34 = load double, double* %12
%35 = fmul double %33, %34
store double %35, double* %19
%36 = load double, double* %19
%37 = load double, double* %9
%38 = fcmp oge double %36, %37
br i1 %38, label %39, label %51
39: ; preds = %30
%40 = load double, double* %19
%41 = load double, double* %10
%42 = fcmp ole double %40, %41
br i1 %42, label %43, label %51
43: ; preds = %39
%44 = load double, double* %17
%45 = load double, double* %18
%46 = load double, double* %14
%47 = load double, double* %15
%48 = call i32 (double, double, double, double, ...) bitcast (i32 (...)* @AngleInRange to i32 (double, double, double, double, ...)*)(double %44, double %45, double %46, double %47)
%49 = icmp ne i32 %48, 0
br i1 %49, label %50, label %51
50: ; preds = %43
store i32 1, i32* %8
br label %71
51: ; preds = %43, %39, %30
%52 = load double, double* %19
%53 = fneg double %52
%54 = load double, double* %9
%55 = fcmp oge double %53, %54
br i1 %55, label %56, label %70
56: ; preds = %51
%57 = load double, double* %19
%58 = fneg double %57
%59 = load double, double* %10
%60 = fcmp ole double %58, %59
br i1 %60, label %61, label %70
61: ; preds = %56
%62 = load double, double* %17
%63 = fneg double %62
%64 = load double, double* %18
%65 = load double, double* %14
%66 = load double, double* %15
%67 = call i32 (double, double, double, double, ...) bitcast (i32 (...)* @AngleInRange to i32 (double, double, double, double, ...)*)(double %63, double %64, double %65, double %66)
%68 = icmp ne i32 %67, 0
br i1 %68, label %69, label %70
69: ; preds = %61
store i32 1, i32* %8
br label %71
70: ; preds = %61, %56, %51
store i32 0, i32* %8
br label %71
71: ; preds = %70, %69, %50, %29
%72 = load i32, i32* %8
ret i32 %72
}

LLVM IR (-O2):
define i32 @HorizLineToArc(double %0, double %1, double %2, double %3, double %4, double %5, double %6) {
%8 = fdiv double %2, %4
%9 = fneg double %8
%10 = tail call double @llvm.fmuladd.f64(double %9, double %8, double 1.000000e+00)
%11 = fcmp olt double %10, 0.000000e+00
br i1 %11, label %31, label %12
12: ; preds = %7
%13 = tail call double @sqrt(double %10)
%14 = fmul double %13, %3
%15 = fcmp ult double %14, %0
%16 = fcmp ugt double %14, %1
%17 = or i1 %15, %16
br i1 %17, label %21, label %18
18: ; preds = %12
%19 = tail call i32 (double, double, double, double, ...) bitcast (i32 (...)* @AngleInRange to i32 (double, double, double, double, ...)*)(double %13, double %8, double %5, double %6)
%20 = icmp eq i32 %19, 0
br i1 %20, label %21, label %31
21: ; preds = %18, %12
%22 = fneg double %14
%23 = fcmp ult double %22, %0
%24 = fcmp ugt double %22, %1
%25 = or i1 %23, %24
br i1 %25, label %30, label %26
26: ; preds = %21
%27 = fneg double %13
%28 = tail call i32 (double, double, double, double, ...) bitcast (i32 (...)* @AngleInRange to i32 (double, double, double, double, ...)*)(double %27, double %8, double %5, double %6)
%29 = icmp eq i32 %28, 0
br i1 %29, label %30, label %31
30: ; preds = %26, %21
br label %31
31: ; preds = %26, %18, %7, %30
%32 = phi i32 [ 0, %30 ], [ 0, %7 ], [ 1, %18 ], [ 1, %26 ]
ret i32 %32
}