#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 sin(double);
double sqrt(double);
double areacirclesection2(double r, double ang0, double ang1) {
  double alpha, halfchord;
  if (ang0 > ang1)
    ang1 += 6.283185307179586476925286766559;
  alpha = (ang1 - ang0) / 2.0;
  if (alpha > 1.5707963267948966192313216916398) {
    alpha = 3.1415926535897932384626433832795 - alpha;
    halfchord = r * sin(alpha);
    return (3.1415926535897932384626433832795 - alpha) * r * r +
           sqrt(r * r - halfchord * halfchord) * halfchord;
  } else {
    halfchord = r * sin(alpha);
    return alpha * r * r - sqrt(r * r - halfchord * halfchord) * halfchord;
  }
}


x86 assembly (clang, -O0):
<areacirclesection2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  %xmm2,-0x20(%rbp)
movsd  -0x18(%rbp),%xmm0
ucomisd -0x20(%rbp),%xmm0
jbe    1159 <areacirclesection2+0x39>
movsd  0xeb1(%rip),%xmm0
addsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
subsd  -0x18(%rbp),%xmm0
movsd  0xea5(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  0xe87(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    123f <areacirclesection2+0x11f>
movsd  0xe85(%rip),%xmm0
subsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x28(%rbp),%xmm0
call   1030 <sin@plt>
movaps %xmm0,%xmm1
movsd  -0x48(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  0xe4e(%rip),%xmm0
subsd  -0x28(%rbp),%xmm0
mulsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm2
movsd  -0x30(%rbp),%xmm1
mulsd  -0x30(%rbp),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
call   1040 <sqrt@plt>
movsd  -0x40(%rbp),%xmm2
movaps %xmm0,%xmm1
movsd  -0x38(%rbp),%xmm0
mulsd  -0x30(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    12eb <areacirclesection2+0x1cb>
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x28(%rbp),%xmm0
call   1030 <sin@plt>
movaps %xmm0,%xmm1
movsd  -0x60(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x28(%rbp),%xmm0
mulsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm2
movsd  -0x30(%rbp),%xmm1
mulsd  -0x30(%rbp),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
call   1040 <sqrt@plt>
movsd  -0x58(%rbp),%xmm2
movaps %xmm0,%xmm1
movsd  -0x50(%rbp),%xmm0
mulsd  -0x30(%rbp),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<areacirclesection2>:
sub    $0x28,%rsp
movsd  0xed4(%rip),%xmm3
addsd  %xmm2,%xmm3
movapd %xmm2,%xmm4
cmpltsd %xmm1,%xmm4
andpd  %xmm4,%xmm3
andnpd %xmm2,%xmm4
orpd   %xmm3,%xmm4
subsd  %xmm1,%xmm4
mulsd  0xeb7(%rip),%xmm4
movsd  %xmm0,0x8(%rsp)
ucomisd 0xeb1(%rip),%xmm4
jbe    11c6 <areacirclesection2+0xa6>
movsd  0xeaf(%rip),%xmm0
subsd  %xmm4,%xmm0
movsd  %xmm0,0x10(%rsp)
call   1030 <sin@plt>
movapd %xmm0,%xmm3
movsd  0x8(%rsp),%xmm2
mulsd  %xmm2,%xmm3
movsd  0xe8a(%rip),%xmm0
subsd  0x10(%rsp),%xmm0
mulsd  %xmm2,%xmm0
movsd  %xmm0,0x10(%rsp)
movapd %xmm3,%xmm1
mulsd  %xmm3,%xmm1
movapd %xmm2,%xmm0
mulsd  %xmm2,%xmm0
subsd  %xmm1,%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     1215 <areacirclesection2+0xf5>
movapd %xmm2,%xmm1
sqrtsd %xmm0,%xmm0
jmp    122c <areacirclesection2+0x10c>
movapd %xmm4,%xmm0
movapd %xmm4,0x10(%rsp)
call   1030 <sin@plt>
movapd 0x10(%rsp),%xmm2
movapd %xmm0,%xmm4
movsd  0x8(%rsp),%xmm3
mulsd  %xmm3,%xmm4
mulsd  %xmm3,%xmm2
movapd %xmm4,%xmm1
mulsd  %xmm4,%xmm1
movapd %xmm3,%xmm0
mulsd  %xmm3,%xmm0
subsd  %xmm1,%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     1240 <areacirclesection2+0x120>
movapd %xmm3,%xmm1
sqrtsd %xmm0,%xmm0
jmp    1263 <areacirclesection2+0x143>
movsd  %xmm3,0x20(%rsp)
call   1040 <sqrt@plt>
movsd  0x20(%rsp),%xmm3
movsd  0x8(%rsp),%xmm1
mulsd  %xmm3,%xmm0
movsd  0x10(%rsp),%xmm2
mulsd  %xmm1,%xmm2
addsd  %xmm0,%xmm2
jmp    126f <areacirclesection2+0x14f>
movapd %xmm2,0x10(%rsp)
movsd  %xmm4,0x20(%rsp)
call   1040 <sqrt@plt>
movsd  0x20(%rsp),%xmm4
movapd 0x10(%rsp),%xmm2
movsd  0x8(%rsp),%xmm1
mulsd  %xmm0,%xmm4
mulsd  %xmm1,%xmm2
subsd  %xmm4,%xmm2
movapd %xmm2,%xmm0
add    $0x28,%rsp
ret

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

LLVM IR (-O2):
define double @areacirclesection2(double %0, double %1, double %2) {
%4 = fcmp ogt double %1, %2
%5 = fadd double %2, 0x401921FB54442D18
%6 = select i1 %4, double %5, double %2
%7 = fsub double %6, %1
%8 = fmul double %7, 5.000000e-01
%9 = fcmp ogt double %8, 0x3FF921FB54442D18
br i1 %9, label %10, label %22
10: ; preds = %3
%11 = fsub double 0x400921FB54442D18, %8
%12 = tail call double @sin(double %11)
%13 = fmul double %12, %0
%14 = fsub double 0x400921FB54442D18, %11
%15 = fmul double %14, %0
%16 = fneg double %13
%17 = fmul double %13, %16
%18 = tail call double @llvm.fmuladd.f64(double %0, double %0, double %17)
%19 = tail call double @sqrt(double %18)
%20 = fmul double %19, %13
%21 = tail call double @llvm.fmuladd.f64(double %15, double %0, double %20)
br label %33
22: ; preds = %3
%23 = tail call double @sin(double %8)
%24 = fmul double %23, %0
%25 = fmul double %8, %0
%26 = fneg double %24
%27 = fmul double %24, %26
%28 = tail call double @llvm.fmuladd.f64(double %0, double %0, double %27)
%29 = tail call double @sqrt(double %28)
%30 = fneg double %29
%31 = fmul double %24, %30
%32 = tail call double @llvm.fmuladd.f64(double %25, double %0, double %31)
br label %33
33: ; preds = %22, %10
%34 = phi double [ %21, %10 ], [ %32, %22 ]
ret double %34
}