#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 */
int acos(int);
double getR(double, double);
double solve(double b, double h) {
  double sum, r, old_h;
  sum = 0.0;
  while ((r = getR(b, h)) >= (0.000001 * 1000000)) {
    sum += 2 * acos(-1) * r;
    old_h = h;
    h -= 2 * r;
    b = b * h / old_h;
  }
  return sum;
}


x86 assembly (clang, -O0):
<solve>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
call   1030 <getR@plt>
movsd  %xmm0,-0x20(%rbp)
movsd  0xeaa(%rip),%xmm1
ucomisd %xmm1,%xmm0
jb     11c2 <solve+0xa2>
mov    $0xffffffff,%edi
call   1040 <acos@plt>
shl    $0x1,%eax
cvtsi2sd %eax,%xmm0
movsd  -0x20(%rbp),%xmm2
movsd  -0x18(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x20(%rbp),%xmm1
movsd  -0x10(%rbp),%xmm0
addsd  %xmm1,%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  -0x8(%rbp),%xmm0
mulsd  -0x10(%rbp),%xmm0
divsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    113a <solve+0x1a>
movsd  -0x18(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<solve>:
sub    $0x28,%rsp
movsd  %xmm0,0x18(%rsp)
movsd  %xmm1,0x8(%rsp)
call   1030 <getR@plt>
movapd %xmm0,%xmm1
xorpd  %xmm0,%xmm0
movsd  %xmm0,(%rsp)
ucomisd 0xeb6(%rip),%xmm1
jb     11ea <solve+0xca>
xorpd  %xmm0,%xmm0
movsd  %xmm0,(%rsp)
movsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x10(%rsp)
cs nopw 0x0(%rax,%rax,1)
nop
movsd  %xmm1,0x20(%rsp)
mov    $0xffffffff,%edi
call   1040 <acos@plt>
add    %eax,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  0x20(%rsp),%xmm2
mulsd  %xmm2,%xmm0
movsd  (%rsp),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,(%rsp)
addsd  %xmm2,%xmm2
movsd  0x10(%rsp),%xmm1
subsd  %xmm2,%xmm1
movsd  %xmm1,0x10(%rsp)
movsd  0x18(%rsp),%xmm0
mulsd  %xmm1,%xmm0
divsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x18(%rsp)
call   1030 <getR@plt>
movapd %xmm0,%xmm1
ucomisd 0xe24(%rip),%xmm0
movsd  0x10(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
jae    1170 <solve+0x50>
movsd  (%rsp),%xmm0
add    $0x28,%rsp
ret

LLVM IR (-O0):
define double @solve(double %0, double %1) {
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca double
store double %0, double* %3
store double %1, double* %4
store double 0.000000e+00, double* %5
br label %8
8: ; preds = %13, %2
%9 = load double, double* %3
%10 = load double, double* %4
%11 = call double @getR(double %9, double %10)
store double %11, double* %6
%12 = fcmp oge double %11, 1.000000e+00
br i1 %12, label %13, label %29
13: ; preds = %8
%14 = call i32 @acos(i32 -1)
%15 = mul nsw i32 2, %14
%16 = sitofp i32 %15 to double
%17 = load double, double* %6
%18 = load double, double* %5
%19 = call double @llvm.fmuladd.f64(double %16, double %17, double %18)
store double %19, double* %5
%20 = load double, double* %4
store double %20, double* %7
%21 = load double, double* %6
%22 = load double, double* %4
%23 = call double @llvm.fmuladd.f64(double -2.000000e+00, double %21, double %22)
store double %23, double* %4
%24 = load double, double* %3
%25 = load double, double* %4
%26 = fmul double %24, %25
%27 = load double, double* %7
%28 = fdiv double %26, %27
store double %28, double* %3
br label %8
29: ; preds = %8
%30 = load double, double* %5
ret double %30
}

LLVM IR (-O2):
define double @solve(double %0, double %1) {
%3 = tail call double @getR(double %0, double %1)
%4 = fcmp ult double %3, 1.000000e+00
br i1 %4, label %19, label %5
5: ; preds = %2, %5
%6 = phi double [ %17, %5 ], [ %3, %2 ]
%7 = phi double [ %16, %5 ], [ %0, %2 ]
%8 = phi double [ %14, %5 ], [ %1, %2 ]
%9 = phi double [ %13, %5 ], [ 0.000000e+00, %2 ]
%10 = tail call i32 @acos(i32 -1)
%11 = shl nsw i32 %10, 1
%12 = sitofp i32 %11 to double
%13 = tail call double @llvm.fmuladd.f64(double %12, double %6, double %9)
%14 = tail call double @llvm.fmuladd.f64(double %6, double -2.000000e+00, double %8)
%15 = fmul double %7, %14
%16 = fdiv double %15, %8
%17 = tail call double @getR(double %16, double %14)
%18 = fcmp ult double %17, 1.000000e+00
br i1 %18, label %19, label %5
19: ; preds = %5, %2
%20 = phi double [ 0.000000e+00, %2 ], [ %13, %5 ]
ret double %20
}