#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 continuous_fraction_root(int, double const, int);
double const pow_i(int, int);
double secondroot(const double radicand) {
  if (radicand <= 0)
    return 0;
  double end_value;
  int c = 1;
  while (pow_i(c, 2) <= radicand)
    ++c;
  c = c - 1;
  end_value = c + continuous_fraction_root(c, radicand, 50);
  return end_value;
}


x86 assembly (clang, -O0):
<secondroot>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movsd  %xmm0,-0x10(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x10(%rbp),%xmm0
jb     1148 <secondroot+0x28>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11b7 <secondroot+0x97>
movl   $0x1,-0x1c(%rbp)
mov    -0x1c(%rbp),%edi
mov    $0x2,%esi
call   1030 <pow_i@plt>
movaps %xmm0,%xmm1
movsd  -0x10(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jb     117c <secondroot+0x5c>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    114f <secondroot+0x2f>
mov    -0x1c(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x1c(%rbp),%edi
movsd  -0x10(%rbp),%xmm0
mov    $0x32,%esi
call   1040 <continuous_fraction_root@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%eax
add    %ecx,%eax
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<secondroot>:
movapd %xmm0,%xmm1
xorpd  %xmm0,%xmm0
ucomisd %xmm1,%xmm0
jae    117a <secondroot+0x5a>
push   %rbx
sub    $0x10,%rsp
mov    $0xffffffff,%ebx
movsd  %xmm1,0x8(%rsp)
xchg   %ax,%ax
lea    0x2(%rbx),%edi
mov    $0x2,%esi
call   1030 <pow_i@plt>
movsd  0x8(%rsp),%xmm1
add    $0x1,%ebx
ucomisd %xmm0,%xmm1
jae    1140 <secondroot+0x20>
mov    %ebx,%edi
movapd %xmm1,%xmm0
mov    $0x32,%esi
call   1040 <continuous_fraction_root@plt>
add    %ebx,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define double @secondroot(double %0) {
%2 = alloca double
%3 = alloca double
%4 = alloca double
%5 = alloca i32
store double %0, double* %3
%6 = load double, double* %3
%7 = fcmp ole double %6, 0.000000e+00
br i1 %7, label %8, label %9
8: ; preds = %1
store double 0.000000e+00, double* %2
br label %28
9: ; preds = %1
store i32 1, i32* %5
br label %10
10: ; preds = %15, %9
%11 = load i32, i32* %5
%12 = call double @pow_i(i32 %11, i32 2)
%13 = load double, double* %3
%14 = fcmp ole double %12, %13
br i1 %14, label %15, label %18
15: ; preds = %10
%16 = load i32, i32* %5
%17 = add nsw i32 %16, 1
store i32 %17, i32* %5
br label %10
18: ; preds = %10
%19 = load i32, i32* %5
%20 = sub nsw i32 %19, 1
store i32 %20, i32* %5
%21 = load i32, i32* %5
%22 = load i32, i32* %5
%23 = load double, double* %3
%24 = call i32 @continuous_fraction_root(i32 %22, double %23, i32 50)
%25 = add nsw i32 %21, %24
%26 = sitofp i32 %25 to double
store double %26, double* %4
%27 = load double, double* %4
store double %27, double* %2
br label %28
28: ; preds = %18, %8
%29 = load double, double* %2
ret double %29
}

LLVM IR (-O2):
define double @secondroot(double %0) {
%2 = fcmp ugt double %0, 0.000000e+00
br i1 %2, label %3, label %13
3: ; preds = %1, %3
%4 = phi i32 [ %7, %3 ], [ 1, %1 ]
%5 = tail call double @pow_i(i32 %4, i32 2)
%6 = fcmp ugt double %5, %0
%7 = add nuw nsw i32 %4, 1
br i1 %6, label %8, label %3
8: ; preds = %3
%9 = add nsw i32 %4, -1
%10 = tail call i32 @continuous_fraction_root(i32 %9, double %0, i32 50)
%11 = add nsw i32 %10, %9
%12 = sitofp i32 %11 to double
br label %13
13: ; preds = %1, %8
%14 = phi double [ %12, %8 ], [ 0.000000e+00, %1 ]
ret double %14
}