#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 */
long double pow(long double, double);
long double pi(void) {
  long double area, w, h, r, x;
  area = 0.0;
  r = 2.0;
  x = 0.0;
  w = r / 100000;
  for (int i = 0; i < 100000; i++) {
    x += w / 1.000001;
    h = pow(pow(r, 2) - pow(x, 2), 0.5);
    area += h * w;
  }
  return area;
}


x86 assembly (clang, -O0):
<pi>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
fldz
fld    %st(0)
fstpt  -0x10(%rbp)
flds   0xed8(%rip)
fstpt  -0x40(%rbp)
fstpt  -0x50(%rbp)
fldt   -0x40(%rbp)
flds   0xecd(%rip)
fdivrp %st,%st(1)
fstpt  -0x20(%rbp)
movl   $0x0,-0x54(%rbp)
cmpl   $0x186a0,-0x54(%rbp)
jge    11cc <pi+0xbc>
fldt   -0x20(%rbp)
fldl   0xeaf(%rip)
fdivrp %st,%st(1)
fldt   -0x50(%rbp)
faddp  %st,%st(1)
fstpt  -0x50(%rbp)
fldt   -0x40(%rbp)
mov    %rsp,%rax
fstpt  (%rax)
movsd  0xe9d(%rip),%xmm0
movsd  %xmm0,-0x68(%rbp)
call   1030 <pow@plt>
movsd  -0x68(%rbp),%xmm0
fstpt  -0x60(%rbp)
fldt   -0x50(%rbp)
mov    %rsp,%rax
fstpt  (%rax)
call   1030 <pow@plt>
fldt   -0x60(%rbp)
fsubp  %st,%st(1)
mov    %rsp,%rax
fstpt  (%rax)
movsd  0xe74(%rip),%xmm0
call   1030 <pow@plt>
fstpt  -0x30(%rbp)
fldt   -0x30(%rbp)
fldt   -0x20(%rbp)
fldt   -0x10(%rbp)
fxch   %st(2)
fmulp  %st,%st(1)
faddp  %st,%st(1)
fstpt  -0x10(%rbp)
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
jmp    1143 <pi+0x33>
fldt   -0x10(%rbp)
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pi>:
push   %rbx
sub    $0x60,%rsp
fldz
mov    $0x186a0,%ebx
fldt   0xede(%rip)
fstpt  0x54(%rsp)
flds   0xef4(%rip)
fstpt  0x48(%rsp)
fldt   0xeda(%rip)
fstpt  0x3c(%rsp)
fld    %st(0)
nopl   0x0(%rax)
fstpt  0x30(%rsp)
fldt   0x54(%rsp)
faddp  %st,%st(1)
fstpt  0x18(%rsp)
fldt   0x48(%rsp)
fstpt  (%rsp)
movsd  0xecb(%rip),%xmm0
call   1030 <pow@plt>
fstpt  0x24(%rsp)
fldt   0x18(%rsp)
fstpt  (%rsp)
movsd  0xeb3(%rip),%xmm0
call   1030 <pow@plt>
fldt   0x24(%rsp)
fsubp  %st,%st(1)
fstpt  (%rsp)
movsd  0xea5(%rip),%xmm0
call   1030 <pow@plt>
fldt   0x3c(%rsp)
fmulp  %st,%st(1)
fldt   0x30(%rsp)
faddp  %st,%st(1)
fstpt  0x30(%rsp)
fldt   0x18(%rsp)
fldt   0x54(%rsp)
faddp  %st,%st(1)
fstpt  0x18(%rsp)
fldt   0x48(%rsp)
fstpt  (%rsp)
movsd  0xe6b(%rip),%xmm0
call   1030 <pow@plt>
fstpt  0x24(%rsp)
fldt   0x18(%rsp)
fstpt  (%rsp)
movsd  0xe53(%rip),%xmm0
call   1030 <pow@plt>
fldt   0x24(%rsp)
fsubp  %st,%st(1)
fstpt  (%rsp)
movsd  0xe45(%rip),%xmm0
call   1030 <pow@plt>
fldt   0x18(%rsp)
fldt   0x3c(%rsp)
fmulp  %st,%st(2)
fldt   0x30(%rsp)
faddp  %st,%st(2)
add    $0xfffffffe,%ebx
fxch   %st(1)
jne    1140 <pi+0x30>
fstp   %st(1)
add    $0x60,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define x86_fp80 @pi() {
%1 = alloca x86_fp80
%2 = alloca x86_fp80
%3 = alloca x86_fp80
%4 = alloca x86_fp80
%5 = alloca x86_fp80
%6 = alloca i32
store x86_fp80 0xK00000000000000000000, x86_fp80* %1
store x86_fp80 0xK40008000000000000000, x86_fp80* %4
store x86_fp80 0xK00000000000000000000, x86_fp80* %5
%7 = load x86_fp80, x86_fp80* %4
%8 = fdiv x86_fp80 %7, 0xK400FC350000000000000
store x86_fp80 %8, x86_fp80* %2
store i32 0, i32* %6
br label %9
9: ; preds = %27, %0
%10 = load i32, i32* %6
%11 = icmp slt i32 %10, 100000
br i1 %11, label %12, label %30
12: ; preds = %9
%13 = load x86_fp80, x86_fp80* %2
%14 = fdiv x86_fp80 %13, 0xK3FFF800008637BD05800
%15 = load x86_fp80, x86_fp80* %5
%16 = fadd x86_fp80 %15, %14
store x86_fp80 %16, x86_fp80* %5
%17 = load x86_fp80, x86_fp80* %4
%18 = call x86_fp80 @pow(x86_fp80 %17, double 2.000000e+00)
%19 = load x86_fp80, x86_fp80* %5
%20 = call x86_fp80 @pow(x86_fp80 %19, double 2.000000e+00)
%21 = fsub x86_fp80 %18, %20
%22 = call x86_fp80 @pow(x86_fp80 %21, double 5.000000e-01)
store x86_fp80 %22, x86_fp80* %3
%23 = load x86_fp80, x86_fp80* %3
%24 = load x86_fp80, x86_fp80* %2
%25 = load x86_fp80, x86_fp80* %1
%26 = call x86_fp80 @llvm.fmuladd.f80(x86_fp80 %23, x86_fp80 %24, x86_fp80 %25)
store x86_fp80 %26, x86_fp80* %1
br label %27
27: ; preds = %12
%28 = load i32, i32* %6
%29 = add nsw i32 %28, 1
store i32 %29, i32* %6
br label %9
30: ; preds = %9
%31 = load x86_fp80, x86_fp80* %1
ret x86_fp80 %31
}

LLVM IR (-O2):
define x86_fp80 @pi() {
br label %2
1: ; preds = %2
ret x86_fp80 %17
2: ; preds = %2, %0
%3 = phi i32 [ 0, %0 ], [ %18, %2 ]
%4 = phi x86_fp80 [ 0xK00000000000000000000, %0 ], [ %12, %2 ]
%5 = phi x86_fp80 [ 0xK00000000000000000000, %0 ], [ %17, %2 ]
%6 = fadd x86_fp80 %4, 0xK3FEFA7C5A1485C0F42F1
%7 = tail call x86_fp80 @pow(x86_fp80 0xK40008000000000000000, double 2.000000e+00)
%8 = tail call x86_fp80 @pow(x86_fp80 %6, double 2.000000e+00)
%9 = fsub x86_fp80 %7, %8
%10 = tail call x86_fp80 @pow(x86_fp80 %9, double 5.000000e-01)
%11 = tail call x86_fp80 @llvm.fmuladd.f80(x86_fp80 %10, x86_fp80 0xK3FEFA7C5AC471B478423, x86_fp80 %5)
%12 = fadd x86_fp80 %6, 0xK3FEFA7C5A1485C0F42F1
%13 = tail call x86_fp80 @pow(x86_fp80 0xK40008000000000000000, double 2.000000e+00)
%14 = tail call x86_fp80 @pow(x86_fp80 %12, double 2.000000e+00)
%15 = fsub x86_fp80 %13, %14
%16 = tail call x86_fp80 @pow(x86_fp80 %15, double 5.000000e-01)
%17 = tail call x86_fp80 @llvm.fmuladd.f80(x86_fp80 %16, x86_fp80 0xK3FEFA7C5AC471B478423, x86_fp80 %11)
%18 = add nuw nsw i32 %3, 2
%19 = icmp eq i32 %18, 100000
br i1 %19, label %1, label %2
}