#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 areacirclesection(double r, double dang) {
  double alpha, halfchord;
  alpha = dang / 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):
<areacirclesection>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  0xec9(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  0xeab(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    1213 <areacirclesection+0xf3>
movsd  0xea9(%rip),%xmm0
subsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x20(%rbp),%xmm0
call   1030 <sin@plt>
movaps %xmm0,%xmm1
movsd  -0x40(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  0xe72(%rip),%xmm0
subsd  -0x20(%rbp),%xmm0
mulsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm2
movsd  -0x28(%rbp),%xmm1
mulsd  -0x28(%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  -0x38(%rbp),%xmm2
movaps %xmm0,%xmm1
movsd  -0x30(%rbp),%xmm0
mulsd  -0x28(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    12bf <areacirclesection+0x19f>
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x20(%rbp),%xmm0
call   1030 <sin@plt>
movaps %xmm0,%xmm1
movsd  -0x58(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x20(%rbp),%xmm0
mulsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm2
movsd  -0x28(%rbp),%xmm1
mulsd  -0x28(%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  -0x50(%rbp),%xmm2
movaps %xmm0,%xmm1
movsd  -0x48(%rbp),%xmm0
mulsd  -0x28(%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):
<areacirclesection>:
sub    $0x18,%rsp
mulsd  0xed4(%rip),%xmm1
movsd  %xmm0,0x8(%rsp)
ucomisd 0xece(%rip),%xmm1
jbe    119e <areacirclesection+0x7e>
movsd  0xecc(%rip),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,(%rsp)
call   1030 <sin@plt>
movapd %xmm0,%xmm3
movsd  0x8(%rsp),%xmm2
mulsd  %xmm2,%xmm3
movsd  0xea8(%rip),%xmm0
subsd  (%rsp),%xmm0
mulsd  %xmm2,%xmm0
movsd  %xmm0,(%rsp)
movapd %xmm3,%xmm1
mulsd  %xmm3,%xmm1
movapd %xmm2,%xmm0
mulsd  %xmm2,%xmm0
subsd  %xmm1,%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     11f0 <areacirclesection+0xd0>
movapd %xmm2,%xmm1
sqrtsd %xmm0,%xmm0
jmp    1207 <areacirclesection+0xe7>
movapd %xmm1,%xmm0
movsd  %xmm1,(%rsp)
call   1030 <sin@plt>
movapd %xmm0,%xmm3
movsd  0x8(%rsp),%xmm2
mulsd  %xmm2,%xmm3
movsd  (%rsp),%xmm0
mulsd  %xmm2,%xmm0
movsd  %xmm0,(%rsp)
movapd %xmm3,%xmm1
mulsd  %xmm3,%xmm1
movapd %xmm2,%xmm0
mulsd  %xmm2,%xmm0
subsd  %xmm1,%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     1221 <areacirclesection+0x101>
movapd %xmm2,%xmm1
sqrtsd %xmm0,%xmm0
jmp    1238 <areacirclesection+0x118>
movsd  %xmm3,0x10(%rsp)
call   1040 <sqrt@plt>
movsd  0x10(%rsp),%xmm3
movsd  0x8(%rsp),%xmm1
mulsd  %xmm3,%xmm0
movsd  (%rsp),%xmm2
mulsd  %xmm1,%xmm2
addsd  %xmm0,%xmm2
movapd %xmm2,%xmm0
add    $0x18,%rsp
ret
movsd  %xmm3,0x10(%rsp)
call   1040 <sqrt@plt>
movsd  0x10(%rsp),%xmm3
movsd  0x8(%rsp),%xmm1
mulsd  %xmm0,%xmm3
movsd  (%rsp),%xmm0
mulsd  %xmm1,%xmm0
subsd  %xmm3,%xmm0
add    $0x18,%rsp
ret

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

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