#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 fabs(double);
double find_new_radius(double a, double b, double c, double d, double r) {
  double f, df, dx, sigma, rold, rzero;
  int i;
  rzero = r;
  for (i = 0; i < 1000; i++) {
    f = a * r + b * r * r + c * r * r * r + d * r * r * r * r - rzero;
    df = a + 2.0 * b * r + 3.0 * c * r * r + 4 * d * r * r * r;
    dx = f / df;
    rold = r;
    r -= dx;
    if ((3000000 - r) * (r - -3000000) < 0.0) {
      return (r);
    }
    if (fabs((r - rold) / rold) < 1e-12) {
      return (r);
    }
  }
  return (r);
}


x86 assembly (clang, -O0):
<find_new_radius>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  %xmm2,-0x20(%rbp)
movsd  %xmm3,-0x28(%rbp)
movsd  %xmm4,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x60(%rbp)
movl   $0x0,-0x64(%rbp)
cmpl   $0x3e8,-0x64(%rbp)
jge    12d4 <find_new_radius+0x1c4>
movsd  -0x10(%rbp),%xmm0
movsd  -0x30(%rbp),%xmm2
movsd  -0x18(%rbp),%xmm1
mulsd  -0x30(%rbp),%xmm1
mulsd  -0x30(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  -0x20(%rbp),%xmm1
mulsd  -0x30(%rbp),%xmm1
mulsd  -0x30(%rbp),%xmm1
movsd  -0x30(%rbp),%xmm2
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  -0x28(%rbp),%xmm0
mulsd  -0x30(%rbp),%xmm0
mulsd  -0x30(%rbp),%xmm0
mulsd  -0x30(%rbp),%xmm0
movsd  -0x30(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
subsd  -0x60(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x10(%rbp),%xmm1
movsd  0xe5c(%rip),%xmm0
mulsd  -0x18(%rbp),%xmm0
movsd  -0x30(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  0xe3a(%rip),%xmm1
mulsd  -0x20(%rbp),%xmm1
mulsd  -0x30(%rbp),%xmm1
movsd  -0x30(%rbp),%xmm2
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  0xe13(%rip),%xmm0
mulsd  -0x28(%rbp),%xmm0
mulsd  -0x30(%rbp),%xmm0
mulsd  -0x30(%rbp),%xmm0
movsd  -0x30(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x38(%rbp),%xmm0
divsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x48(%rbp),%xmm1
movsd  -0x30(%rbp),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  0xdb6(%rip),%xmm1
subsd  -0x30(%rbp),%xmm1
movsd  -0x30(%rbp),%xmm0
movsd  0xd9c(%rip),%xmm2
subsd  %xmm2,%xmm0
mulsd  %xmm0,%xmm1
xorps  %xmm0,%xmm0
ucomisd %xmm1,%xmm0
jbe    1288 <find_new_radius+0x178>
movsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    12de <find_new_radius+0x1ce>
movsd  -0x30(%rbp),%xmm0
subsd  -0x58(%rbp),%xmm0
divsd  -0x58(%rbp),%xmm0
call   1030 <fabs@plt>
cvtsi2sd %eax,%xmm1
movsd  0xd80(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    12c1 <find_new_radius+0x1b1>
movsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    12de <find_new_radius+0x1ce>
jmp    12c6 <find_new_radius+0x1b6>
mov    -0x64(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x64(%rbp)
jmp    1142 <find_new_radius+0x32>
movsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<find_new_radius>:
push   %rbx
sub    $0x50,%rsp
movsd  %xmm0,0x20(%rsp)
movsd  %xmm1,0x28(%rsp)
addsd  %xmm1,%xmm1
movsd  %xmm1,0x18(%rsp)
movsd  0xecd(%rip),%xmm0
movsd  %xmm2,0x30(%rsp)
mulsd  %xmm2,%xmm0
movsd  %xmm0,0x10(%rsp)
movsd  0xebd(%rip),%xmm0
movsd  %xmm3,0x38(%rsp)
mulsd  %xmm3,%xmm0
movsd  %xmm0,0x8(%rsp)
mov    $0x3e7,%ebx
movsd  %xmm4,0x40(%rsp)
movapd %xmm4,%xmm1
movapd %xmm4,%xmm5
xchg   %ax,%ax
movapd %xmm1,%xmm0
mulsd  0x28(%rsp),%xmm0
mulsd  %xmm1,%xmm0
movsd  0x20(%rsp),%xmm4
movapd %xmm4,%xmm2
mulsd  %xmm1,%xmm2
addsd  %xmm0,%xmm2
movapd %xmm1,%xmm3
mulsd  0x30(%rsp),%xmm3
mulsd  %xmm1,%xmm3
mulsd  %xmm1,%xmm3
addsd  %xmm2,%xmm3
movapd %xmm1,%xmm0
mulsd  0x38(%rsp),%xmm0
mulsd  %xmm1,%xmm0
mulsd  %xmm1,%xmm0
mulsd  %xmm1,%xmm0
addsd  %xmm3,%xmm0
subsd  0x40(%rsp),%xmm0
movsd  0x18(%rsp),%xmm2
mulsd  %xmm1,%xmm2
addsd  %xmm4,%xmm2
movsd  0x10(%rsp),%xmm3
mulsd  %xmm1,%xmm3
mulsd  %xmm1,%xmm3
addsd  %xmm2,%xmm3
movsd  0x8(%rsp),%xmm2
mulsd  %xmm1,%xmm2
mulsd  %xmm1,%xmm2
mulsd  %xmm1,%xmm2
addsd  %xmm3,%xmm2
divsd  %xmm2,%xmm0
subsd  %xmm0,%xmm5
movsd  0xe04(%rip),%xmm3
movapd %xmm3,%xmm0
subsd  %xmm5,%xmm0
movapd %xmm5,%xmm2
addsd  %xmm3,%xmm2
mulsd  %xmm0,%xmm2
xorpd  %xmm0,%xmm0
ucomisd %xmm2,%xmm0
ja     125d <find_new_radius+0x14d>
movapd %xmm5,%xmm0
subsd  %xmm1,%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm5,0x48(%rsp)
call   1030 <fabs@plt>
movsd  0x48(%rsp),%xmm5
sub    $0x1,%ebx
setb   %cl
test   %eax,%eax
jle    125d <find_new_radius+0x14d>
movapd %xmm5,%xmm1
test   %cl,%cl
je     1170 <find_new_radius+0x60>
movapd %xmm5,%xmm0
add    $0x50,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define double @find_new_radius(double %0, double %1, double %2, double %3, double %4) {
%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
%15 = alloca double
%16 = alloca double
%17 = alloca double
%18 = alloca i32
store double %0, double* %7
store double %1, double* %8
store double %2, double* %9
store double %3, double* %10
store double %4, double* %11
%19 = load double, double* %11
store double %19, double* %17
store i32 0, i32* %18
br label %20
20: ; preds = %96, %5
%21 = load i32, i32* %18
%22 = icmp slt i32 %21, 1000
br i1 %22, label %23, label %99
23: ; preds = %20
%24 = load double, double* %7
%25 = load double, double* %11
%26 = load double, double* %8
%27 = load double, double* %11
%28 = fmul double %26, %27
%29 = load double, double* %11
%30 = fmul double %28, %29
%31 = call double @llvm.fmuladd.f64(double %24, double %25, double %30)
%32 = load double, double* %9
%33 = load double, double* %11
%34 = fmul double %32, %33
%35 = load double, double* %11
%36 = fmul double %34, %35
%37 = load double, double* %11
%38 = call double @llvm.fmuladd.f64(double %36, double %37, double %31)
%39 = load double, double* %10
%40 = load double, double* %11
%41 = fmul double %39, %40
%42 = load double, double* %11
%43 = fmul double %41, %42
%44 = load double, double* %11
%45 = fmul double %43, %44
%46 = load double, double* %11
%47 = call double @llvm.fmuladd.f64(double %45, double %46, double %38)
%48 = load double, double* %17
%49 = fsub double %47, %48
store double %49, double* %12
%50 = load double, double* %7
%51 = load double, double* %8
%52 = fmul double 2.000000e+00, %51
%53 = load double, double* %11
%54 = call double @llvm.fmuladd.f64(double %52, double %53, double %50)
%55 = load double, double* %9
%56 = fmul double 3.000000e+00, %55
%57 = load double, double* %11
%58 = fmul double %56, %57
%59 = load double, double* %11
%60 = call double @llvm.fmuladd.f64(double %58, double %59, double %54)
%61 = load double, double* %10
%62 = fmul double 4.000000e+00, %61
%63 = load double, double* %11
%64 = fmul double %62, %63
%65 = load double, double* %11
%66 = fmul double %64, %65
%67 = load double, double* %11
%68 = call double @llvm.fmuladd.f64(double %66, double %67, double %60)
store double %68, double* %13
%69 = load double, double* %12
%70 = load double, double* %13
%71 = fdiv double %69, %70
store double %71, double* %14
%72 = load double, double* %11
store double %72, double* %16
%73 = load double, double* %14
%74 = load double, double* %11
%75 = fsub double %74, %73
store double %75, double* %11
%76 = load double, double* %11
%77 = fsub double 3.000000e+06, %76
%78 = load double, double* %11
%79 = fsub double %78, -3.000000e+06
%80 = fmul double %77, %79
%81 = fcmp olt double %80, 0.000000e+00
br i1 %81, label %82, label %84
82: ; preds = %23
%83 = load double, double* %11
store double %83, double* %6
br label %101
84: ; preds = %23
%85 = load double, double* %11
%86 = load double, double* %16
%87 = fsub double %85, %86
%88 = load double, double* %16
%89 = fdiv double %87, %88
%90 = call i32 @fabs(double %89)
%91 = sitofp i32 %90 to double
%92 = fcmp olt double %91, 0x3D719799812DEA11
br i1 %92, label %93, label %95
93: ; preds = %84
%94 = load double, double* %11
store double %94, double* %6
br label %101
95: ; preds = %84
br label %96
96: ; preds = %95
%97 = load i32, i32* %18
%98 = add nsw i32 %97, 1
store i32 %98, i32* %18
br label %20
99: ; preds = %20
%100 = load double, double* %11
store double %100, double* %6
br label %101
101: ; preds = %99, %93, %82
%102 = load double, double* %6
ret double %102
}

LLVM IR (-O2):
define double @find_new_radius(double %0, double %1, double %2, double %3, double %4) {
%6 = fmul double %1, 2.000000e+00
%7 = fmul double %2, 3.000000e+00
%8 = fmul double %3, 4.000000e+00
br label %9
9: ; preds = %35, %5
%10 = phi i32 [ 0, %5 ], [ %40, %35 ]
%11 = phi double [ %4, %5 ], [ %30, %35 ]
%12 = fmul double %11, %1
%13 = fmul double %11, %12
%14 = tail call double @llvm.fmuladd.f64(double %0, double %11, double %13)
%15 = fmul double %11, %2
%16 = fmul double %11, %15
%17 = tail call double @llvm.fmuladd.f64(double %16, double %11, double %14)
%18 = fmul double %11, %3
%19 = fmul double %11, %18
%20 = fmul double %11, %19
%21 = tail call double @llvm.fmuladd.f64(double %20, double %11, double %17)
%22 = fsub double %21, %4
%23 = tail call double @llvm.fmuladd.f64(double %6, double %11, double %0)
%24 = fmul double %7, %11
%25 = tail call double @llvm.fmuladd.f64(double %24, double %11, double %23)
%26 = fmul double %8, %11
%27 = fmul double %11, %26
%28 = tail call double @llvm.fmuladd.f64(double %27, double %11, double %25)
%29 = fdiv double %22, %28
%30 = fsub double %11, %29
%31 = fsub double 3.000000e+06, %30
%32 = fadd double %30, 3.000000e+06
%33 = fmul double %31, %32
%34 = fcmp olt double %33, 0.000000e+00
br i1 %34, label %43, label %35
35: ; preds = %9
%36 = fsub double %30, %11
%37 = fdiv double %36, %11
%38 = tail call i32 @fabs(double %37)
%39 = icmp slt i32 %38, 1
%40 = add nuw nsw i32 %10, 1
%41 = icmp eq i32 %40, 1000
%42 = select i1 %39, i1 true, i1 %41
br i1 %42, label %43, label %9
43: ; preds = %35, %9
ret double %30
}