#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 /*<<< orphan*/ accept(double, double, double);
double square_root(double number, double precision) {
  if (number < 0.0)
    return -1;
  double result = number / 2;
  while (!accept(number, result * result, precision)) {
    result = (result + number / result) / 2;
  }
  return result;
}


x86 assembly (clang, -O0):
<square_root>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    1142 <square_root+0x32>
movsd  0xed0(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11b9 <square_root+0xa9>
movsd  -0x10(%rbp),%xmm0
movsd  0xeb1(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
mulsd  -0x20(%rbp),%xmm1
movsd  -0x18(%rbp),%xmm2
call   1030 <accept@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    1186 <square_root+0x76>
jmp    11af <square_root+0x9f>
movsd  -0x20(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
divsd  -0x20(%rbp),%xmm1
addsd  %xmm1,%xmm0
movsd  0xe5f(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    1158 <square_root+0x48>
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<square_root>:
sub    $0x18,%rsp
movapd %xmm1,%xmm2
xorpd  %xmm1,%xmm1
ucomisd %xmm0,%xmm1
jbe    112f <square_root+0x1f>
movsd  0xed6(%rip),%xmm0
add    $0x18,%rsp
ret
movsd  0xed1(%rip),%xmm1
mulsd  %xmm0,%xmm1
movsd  %xmm1,(%rsp)
mulsd  %xmm1,%xmm1
movsd  %xmm2,0x10(%rsp)
movsd  %xmm0,0x8(%rsp)
call   1030 <accept@plt>
test   %eax,%eax
je     1163 <square_root+0x53>
movsd  (%rsp),%xmm0
add    $0x18,%rsp
ret
movsd  (%rsp),%xmm1
nopl   0x0(%rax,%rax,1)
movsd  0x8(%rsp),%xmm0
movapd %xmm0,%xmm2
divsd  %xmm1,%xmm2
addsd  %xmm1,%xmm2
mulsd  0xe7e(%rip),%xmm2
movsd  %xmm2,(%rsp)
movapd %xmm2,%xmm1
mulsd  %xmm2,%xmm1
movsd  0x10(%rsp),%xmm2
call   1030 <accept@plt>
movsd  (%rsp),%xmm0
movapd %xmm0,%xmm1
test   %eax,%eax
je     1170 <square_root+0x60>
add    $0x18,%rsp
ret

LLVM IR (-O0):
define double @square_root(double %0, double %1) {
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca double
store double %0, double* %4
store double %1, double* %5
%7 = load double, double* %4
%8 = fcmp olt double %7, 0.000000e+00
br i1 %8, label %9, label %10
9: ; preds = %2
store double -1.000000e+00, double* %3
br label %31
10: ; preds = %2
%11 = load double, double* %4
%12 = fdiv double %11, 2.000000e+00
store double %12, double* %6
br label %13
13: ; preds = %22, %10
%14 = load double, double* %4
%15 = load double, double* %6
%16 = load double, double* %6
%17 = fmul double %15, %16
%18 = load double, double* %5
%19 = call i32 @accept(double %14, double %17, double %18)
%20 = icmp ne i32 %19, 0
%21 = xor i1 %20, true
br i1 %21, label %22, label %29
22: ; preds = %13
%23 = load double, double* %6
%24 = load double, double* %4
%25 = load double, double* %6
%26 = fdiv double %24, %25
%27 = fadd double %23, %26
%28 = fdiv double %27, 2.000000e+00
store double %28, double* %6
br label %13
29: ; preds = %13
%30 = load double, double* %6
store double %30, double* %3
br label %31
31: ; preds = %29, %9
%32 = load double, double* %3
ret double %32
}

LLVM IR (-O2):
define double @square_root(double %0, double %1) {
%3 = fcmp olt double %0, 0.000000e+00
br i1 %3, label %17, label %4
4: ; preds = %2
%5 = fmul double %0, 5.000000e-01
%6 = fmul double %5, %5
%7 = tail call i32 @accept(double %0, double %6, double %1)
%8 = icmp eq i32 %7, 0
br i1 %8, label %9, label %17
9: ; preds = %4, %9
%10 = phi double [ %13, %9 ], [ %5, %4 ]
%11 = fdiv double %0, %10
%12 = fadd double %10, %11
%13 = fmul double %12, 5.000000e-01
%14 = fmul double %13, %13
%15 = tail call i32 @accept(double %0, double %14, double %1)
%16 = icmp eq i32 %15, 0
br i1 %16, label %9, label %17
17: ; preds = %9, %4, %2
%18 = phi double [ -1.000000e+00, %2 ], [ %5, %4 ], [ %13, %9 ]
ret double %18
}