#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 M_PI;
double acos(double);
int /*<<< orphan*/ printf(char *, double, double, double, double, ...);
double sin(int);
main() {
  double P, R, D, res;
  double AD, AP, area;
  double Parc, Ptri, Darc, Dtri;
  double Parea, Darea;
  P = 1;
  R = 0.8;
  D = 0.8;
  for (R = 0.05; R < 2.0; R += 0.001) {
    AD = AP = Parc = Ptri = Darc = Dtri = Parea = Darea = 0.0;
    if (R + D <= P)
      res = 1;
    else if (D - R >= P)
      res = P * P / (D * D);
    else if (R - D >= P)
      res = 0.0;
    else {
      AD = acos(0.5 * (P * P + R * R - D * D) / (P * R));
      AP = acos(0.5 * (D * D + R * R - P * P) / (D * R));
      area = M_PI * D * D;
      Ptri = P * P * 0.5 * sin(2 * AD) / area;
      Parc = P * P * AD / area;
      Dtri = D * D * 0.5 * sin(2 * AP) / area;
      Darc = D * D * AP / area;
      res = Darc - Dtri + Parc - Ptri;
    }
    if (0)
      printf("%e %e %e %e\n", R, res, AD * 180 / M_PI, AP * 180 / M_PI);
    else
      printf("%e %e %e %e %e %e\n", R, Ptri, Parc, Dtri, Darc, res);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
movsd  0xec6(%rip),%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  0xeb1(%rip),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  0xea4(%rip),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  0xe8f(%rip),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  0xe9a(%rip),%xmm0
ucomisd -0x18(%rbp),%xmm0
jbe    145f <main+0x32f>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x70(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x68(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x60(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x58(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x50(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x48(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x38(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x18(%rbp),%xmm1
addsd  -0x20(%rbp),%xmm1
movsd  -0x10(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jb     11f4 <main+0xc4>
movsd  0xe26(%rip),%xmm0
movsd  %xmm0,-0x28(%rbp)
jmp    141c <main+0x2ec>
movsd  -0x20(%rbp),%xmm0
subsd  -0x18(%rbp),%xmm0
ucomisd -0x10(%rbp),%xmm0
jb     122b <main+0xfb>
movsd  -0x10(%rbp),%xmm0
mulsd  -0x10(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
mulsd  -0x20(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
jmp    1417 <main+0x2e7>
movsd  -0x18(%rbp),%xmm0
subsd  -0x20(%rbp),%xmm0
ucomisd -0x10(%rbp),%xmm0
jb     124d <main+0x11d>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x28(%rbp)
jmp    1412 <main+0x2e2>
movsd  -0x10(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm2
movsd  -0x18(%rbp),%xmm1
mulsd  -0x18(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  -0x20(%rbp),%xmm1
movsd  -0x20(%rbp),%xmm2
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  0xd86(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  -0x10(%rbp),%xmm1
mulsd  -0x18(%rbp),%xmm1
divsd  %xmm1,%xmm0
call   1040 <acos@plt>
movsd  %xmm0,-0x30(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm2
movsd  -0x18(%rbp),%xmm1
mulsd  -0x18(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  -0x10(%rbp),%xmm1
movsd  -0x10(%rbp),%xmm2
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  0xd1d(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  -0x20(%rbp),%xmm1
mulsd  -0x18(%rbp),%xmm1
divsd  %xmm1,%xmm0
call   1040 <acos@plt>
movsd  %xmm0,-0x38(%rbp)
mov    0x2cc2(%rip),%rax
movsd  (%rax),%xmm0
mulsd  -0x20(%rbp),%xmm0
mulsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x10(%rbp),%xmm0
mulsd  -0x10(%rbp),%xmm0
movsd  0xcd5(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x80(%rbp)
movsd  0xcbc(%rip),%xmm0
mulsd  -0x30(%rbp),%xmm0
cvttsd2si %xmm0,%edi
call   1050 <sin@plt>
movaps %xmm0,%xmm1
movsd  -0x80(%rbp),%xmm0
mulsd  %xmm1,%xmm0
divsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x10(%rbp),%xmm0
mulsd  -0x10(%rbp),%xmm0
mulsd  -0x30(%rbp),%xmm0
divsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x20(%rbp),%xmm0
mulsd  -0x20(%rbp),%xmm0
movsd  0xc75(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x78(%rbp)
movsd  0xc5c(%rip),%xmm0
mulsd  -0x38(%rbp),%xmm0
cvttsd2si %xmm0,%edi
call   1050 <sin@plt>
movaps %xmm0,%xmm1
movsd  -0x78(%rbp),%xmm0
mulsd  %xmm1,%xmm0
divsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x20(%rbp),%xmm0
mulsd  -0x20(%rbp),%xmm0
mulsd  -0x38(%rbp),%xmm0
divsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x58(%rbp),%xmm0
subsd  -0x60(%rbp),%xmm0
addsd  -0x48(%rbp),%xmm0
subsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
jmp    1417 <main+0x2e7>
jmp    141c <main+0x2ec>
movsd  -0x18(%rbp),%xmm0
movsd  -0x50(%rbp),%xmm1
movsd  -0x48(%rbp),%xmm2
movsd  -0x60(%rbp),%xmm3
movsd  -0x58(%rbp),%xmm4
movsd  -0x28(%rbp),%xmm5
lea    0xbef(%rip),%rdi
mov    $0x6,%al
call   1030 <printf@plt>
movsd  0xbd8(%rip),%xmm0
addsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
jmp    1176 <main+0x46>
mov    -0x4(%rbp),%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x58,%rsp
movsd  0xec1(%rip),%xmm6
movsd  0xec9(%rip),%xmm1
mov    0x2e9a(%rip),%r14
lea    0xf1b(%rip),%rbx
jmp    12c2 <main+0x192>
movapd %xmm6,%xmm0
mulsd  %xmm6,%xmm0
movsd  %xmm0,0x10(%rsp)
addsd  %xmm1,%xmm0
addsd  0xeb4(%rip),%xmm0
movsd  0xeb4(%rip),%xmm1
mulsd  %xmm1,%xmm0
divsd  %xmm6,%xmm0
call   1040 <acos@plt>
movapd %xmm0,0x20(%rsp)
movsd  0x10(%rsp),%xmm2
addsd  0xe9b(%rip),%xmm2
addsd  0xe9b(%rip),%xmm2
mulsd  0xe83(%rip),%xmm2
movsd  0x8(%rsp),%xmm0
movsd  0xe4d(%rip),%xmm1
mulsd  %xmm1,%xmm0
divsd  %xmm0,%xmm2
movapd %xmm2,%xmm0
call   1040 <acos@plt>
movapd %xmm0,0x10(%rsp)
movsd  (%r14),%xmm0
movsd  0xe29(%rip),%xmm1
mulsd  %xmm1,%xmm0
mulsd  %xmm1,%xmm0
movapd %xmm0,0x40(%rsp)
movapd 0x20(%rsp),%xmm0
addsd  %xmm0,%xmm0
cvttsd2si %xmm0,%edi
call   1050 <sin@plt>
movapd %xmm0,0x30(%rsp)
movapd 0x10(%rsp),%xmm0
addsd  %xmm0,%xmm0
cvttsd2si %xmm0,%edi
call   1050 <sin@plt>
movapd 0x30(%rsp),%xmm4
movapd 0x20(%rsp),%xmm2
movsd  0x8(%rsp),%xmm6
mulsd  0xe15(%rip),%xmm0
unpcklpd 0x10(%rsp),%xmm4
mulpd  0xe1f(%rip),%xmm4
unpcklpd %xmm4,%xmm2
shufpd $0x1,%xmm0,%xmm4
movapd 0x40(%rsp),%xmm0
unpcklpd %xmm0,%xmm0
divpd  %xmm0,%xmm4
divpd  %xmm0,%xmm2
movapd %xmm4,%xmm0
unpckhpd %xmm4,%xmm0
movapd %xmm4,%xmm5
subsd  %xmm0,%xmm5
addsd  %xmm2,%xmm5
movapd %xmm2,%xmm0
unpckhpd %xmm2,%xmm0
subsd  %xmm0,%xmm5
nopl   0x0(%rax)
movapd %xmm2,%xmm1
unpckhpd %xmm2,%xmm1
movapd %xmm4,%xmm3
unpckhpd %xmm4,%xmm3
mov    %rbx,%rdi
movapd %xmm6,%xmm0
mov    $0x6,%al
call   1030 <printf@plt>
movsd  0xd6a(%rip),%xmm1
movsd  0x8(%rsp),%xmm6
addsd  0xd9c(%rip),%xmm6
movsd  0xd9c(%rip),%xmm0
ucomisd %xmm6,%xmm0
jbe    1333 <main+0x203>
movapd %xmm6,%xmm0
addsd  0xd3a(%rip),%xmm0
xorpd  %xmm2,%xmm2
ucomisd %xmm0,%xmm1
movapd %xmm1,%xmm5
xorpd  %xmm4,%xmm4
movsd  %xmm6,0x8(%rsp)
jae    1280 <main+0x150>
movsd  0xd1a(%rip),%xmm0
subsd  %xmm6,%xmm0
xorpd  %xmm2,%xmm2
ucomisd %xmm1,%xmm0
movsd  0xd16(%rip),%xmm5
xorpd  %xmm4,%xmm4
jae    1280 <main+0x150>
movapd %xmm6,%xmm0
addsd  0xd08(%rip),%xmm0
ucomisd %xmm1,%xmm0
jb     115a <main+0x2a>
xorpd  %xmm2,%xmm2
xorpd  %xmm5,%xmm5
xorpd  %xmm4,%xmm4
jmp    1280 <main+0x150>
xor    %eax,%eax
add    $0x58,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@M_PI = global double 0.000000e+00
@.str = [19 x i8] c"%e %e %e %e %e %e\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca double
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca double
%11 = alloca double
%12 = alloca double
%13 = alloca double
%14 = alloca double
store i32 0, i32* %1
store double 1.000000e+00, double* %2
store double 8.000000e-01, double* %3
store double 8.000000e-01, double* %4
store double 5.000000e-02, double* %3
br label %15
15: ; preds = %137, %0
%16 = load double, double* %3
%17 = fcmp olt double %16, 2.000000e+00
br i1 %17, label %18, label %140
18: ; preds = %15
store double 0.000000e+00, double* %14
store double 0.000000e+00, double* %13
store double 0.000000e+00, double* %12
store double 0.000000e+00, double* %11
store double 0.000000e+00, double* %10
store double 0.000000e+00, double* %9
store double 0.000000e+00, double* %7
store double 0.000000e+00, double* %6
%19 = load double, double* %3
%20 = load double, double* %4
%21 = fadd double %19, %20
%22 = load double, double* %2
%23 = fcmp ole double %21, %22
br i1 %23, label %24, label %25
24: ; preds = %18
store double 1.000000e+00, double* %5
br label %129
25: ; preds = %18
%26 = load double, double* %4
%27 = load double, double* %3
%28 = fsub double %26, %27
%29 = load double, double* %2
%30 = fcmp oge double %28, %29
br i1 %30, label %31, label %39
31: ; preds = %25
%32 = load double, double* %2
%33 = load double, double* %2
%34 = fmul double %32, %33
%35 = load double, double* %4
%36 = load double, double* %4
%37 = fmul double %35, %36
%38 = fdiv double %34, %37
store double %38, double* %5
br label %128
39: ; preds = %25
%40 = load double, double* %3
%41 = load double, double* %4
%42 = fsub double %40, %41
%43 = load double, double* %2
%44 = fcmp oge double %42, %43
br i1 %44, label %45, label %46
45: ; preds = %39
store double 0.000000e+00, double* %5
br label %127
46: ; preds = %39
%47 = load double, double* %2
%48 = load double, double* %2
%49 = load double, double* %3
%50 = load double, double* %3
%51 = fmul double %49, %50
%52 = call double @llvm.fmuladd.f64(double %47, double %48, double %51)
%53 = load double, double* %4
%54 = load double, double* %4
%55 = fneg double %53
%56 = call double @llvm.fmuladd.f64(double %55, double %54, double %52)
%57 = fmul double 5.000000e-01, %56
%58 = load double, double* %2
%59 = load double, double* %3
%60 = fmul double %58, %59
%61 = fdiv double %57, %60
%62 = call double @acos(double %61)
store double %62, double* %6
%63 = load double, double* %4
%64 = load double, double* %4
%65 = load double, double* %3
%66 = load double, double* %3
%67 = fmul double %65, %66
%68 = call double @llvm.fmuladd.f64(double %63, double %64, double %67)
%69 = load double, double* %2
%70 = load double, double* %2
%71 = fneg double %69
%72 = call double @llvm.fmuladd.f64(double %71, double %70, double %68)
%73 = fmul double 5.000000e-01, %72
%74 = load double, double* %4
%75 = load double, double* %3
%76 = fmul double %74, %75
%77 = fdiv double %73, %76
%78 = call double @acos(double %77)
store double %78, double* %7
%79 = load double, double* @M_PI
%80 = load double, double* %4
%81 = fmul double %79, %80
%82 = load double, double* %4
%83 = fmul double %81, %82
store double %83, double* %8
%84 = load double, double* %2
%85 = load double, double* %2
%86 = fmul double %84, %85
%87 = fmul double %86, 5.000000e-01
%88 = load double, double* %6
%89 = fmul double 2.000000e+00, %88
%90 = fptosi double %89 to i32
%91 = call double @sin(i32 %90)
%92 = fmul double %87, %91
%93 = load double, double* %8
%94 = fdiv double %92, %93
store double %94, double* %10
%95 = load double, double* %2
%96 = load double, double* %2
%97 = fmul double %95, %96
%98 = load double, double* %6
%99 = fmul double %97, %98
%100 = load double, double* %8
%101 = fdiv double %99, %100
store double %101, double* %9
%102 = load double, double* %4
%103 = load double, double* %4
%104 = fmul double %102, %103
%105 = fmul double %104, 5.000000e-01
%106 = load double, double* %7
%107 = fmul double 2.000000e+00, %106
%108 = fptosi double %107 to i32
%109 = call double @sin(i32 %108)
%110 = fmul double %105, %109
%111 = load double, double* %8
%112 = fdiv double %110, %111
store double %112, double* %12
%113 = load double, double* %4
%114 = load double, double* %4
%115 = fmul double %113, %114
%116 = load double, double* %7
%117 = fmul double %115, %116
%118 = load double, double* %8
%119 = fdiv double %117, %118
store double %119, double* %11
%120 = load double, double* %11
%121 = load double, double* %12
%122 = fsub double %120, %121
%123 = load double, double* %9
%124 = fadd double %122, %123
%125 = load double, double* %10
%126 = fsub double %124, %125
store double %126, double* %5
br label %127
127: ; preds = %46, %45
br label %128
128: ; preds = %127, %31
br label %129
129: ; preds = %128, %24
%130 = load double, double* %3
%131 = load double, double* %10
%132 = load double, double* %9
%133 = load double, double* %12
%134 = load double, double* %11
%135 = load double, double* %5
%136 = call i32 (i8*, double, double, double, double, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), double %130, double %131, double %132, double %133, double %134, double %135)
br label %137
137: ; preds = %129
%138 = load double, double* %3
%139 = fadd double %138, 1.000000e-03
store double %139, double* %3
br label %15
140: ; preds = %15
%141 = load i32, i32* %1
ret i32 %141
}

LLVM IR (-O2):
@M_PI = global double 0.000000e+00
@.str = [19 x i8] c"%e %e %e %e %e %e\0A\00"
define i32 @main() {
br label %1
1: ; preds = %0, %51
%2 = phi double [ 5.000000e-02, %0 ], [ %59, %51 ]
%3 = fadd double %2, 8.000000e-01
%4 = fcmp ugt double %3, 1.000000e+00
br i1 %4, label %5, label %51
5: ; preds = %1
%6 = fsub double 8.000000e-01, %2
%7 = fcmp ult double %6, 1.000000e+00
br i1 %7, label %8, label %51
8: ; preds = %5
%9 = fadd double %2, -8.000000e-01
%10 = fcmp ult double %9, 1.000000e+00
br i1 %10, label %11, label %51
11: ; preds = %8
%12 = fmul double %2, %2
%13 = fadd double %12, 1.000000e+00
%14 = fadd double %13, 0xBFE47AE147AE147C
%15 = fmul double %14, 5.000000e-01
%16 = fdiv double %15, %2
%17 = tail call double @acos(double %16)
%18 = fadd double %12, 0x3FE47AE147AE147C
%19 = fadd double %18, -1.000000e+00
%20 = fmul double %19, 5.000000e-01
%21 = fmul double %2, 8.000000e-01
%22 = fdiv double %20, %21
%23 = tail call double @acos(double %22)
%24 = load double, double* @M_PI
%25 = fmul double %24, 8.000000e-01
%26 = fmul double %25, 8.000000e-01
%27 = fmul double %17, 2.000000e+00
%28 = fptosi double %27 to i32
%29 = tail call double @sin(i32 %28)
%30 = fmul double %23, 2.000000e+00
%31 = fptosi double %30 to i32
%32 = tail call double @sin(i32 %31)
%33 = fmul double %32, 0x3FD47AE147AE147C
%34 = insertelement <2 x double> poison, double %29, i64 0
%35 = insertelement <2 x double> %34, double %23, i64 1
%36 = fmul <2 x double> %35, <double 5.000000e-01, double 0x3FE47AE147AE147C>
%37 = insertelement <4 x double> poison, double %17, i64 0
%38 = shufflevector <2 x double> %36, <2 x double> poison, <4 x i32> <i32 0, i32 1, i32 undef, i32 undef>
%39 = shufflevector <4 x double> %37, <4 x double> %38, <4 x i32> <i32 0, i32 4, i32 5, i32 undef>
%40 = insertelement <4 x double> %39, double %33, i64 3
%41 = insertelement <4 x double> poison, double %26, i64 0
%42 = shufflevector <4 x double> %41, <4 x double> poison, <4 x i32> zeroinitializer
%43 = fdiv <4 x double> %40, %42
%44 = extractelement <4 x double> %43, i64 2
%45 = extractelement <4 x double> %43, i64 3
%46 = fsub double %44, %45
%47 = extractelement <4 x double> %43, i64 0
%48 = fadd double %47, %46
%49 = extractelement <4 x double> %43, i64 1
%50 = fsub double %48, %49
br label %51
51: ; preds = %8, %5, %1, %11
%52 = phi double [ %50, %11 ], [ 1.000000e+00, %1 ], [ 0x3FF8FFFFFFFFFFFF, %5 ], [ 0.000000e+00, %8 ]
%53 = phi <4 x double> [ %43, %11 ], [ zeroinitializer, %1 ], [ zeroinitializer, %5 ], [ zeroinitializer, %8 ]
%54 = extractelement <4 x double> %53, i64 0
%55 = extractelement <4 x double> %53, i64 1
%56 = extractelement <4 x double> %53, i64 2
%57 = extractelement <4 x double> %53, i64 3
%58 = tail call i32 (i8*, double, double, double, double, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), double %2, double %55, double %54, double %57, double %56, double %52)
%59 = fadd double %2, 1.000000e-03
%60 = fcmp olt double %59, 2.000000e+00
br i1 %60, label %1, label %61
61: ; preds = %51
ret i32 0
}