#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 */
double INFINITY;
double NAN;
double fabs(double);
double funkceSQRT(double x, double presnost) {
  if (x < 0.0) {
    return NAN;
  }
  if (x == +INFINITY) {
    return +INFINITY;
  }
  double stareC, noveC;
  stareC = 1.0;
  noveC = 0.5 * (x / stareC + stareC);
  while (fabs(noveC - stareC) > presnost) {
    stareC = noveC;
    noveC = 0.5 * (x / stareC + stareC);
  }
  return noveC;
}


x86 assembly (clang, -O0):
<funkceSQRT>:
push   %rbp
mov    %rsp,%rbp
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    1131 <funkceSQRT+0x31>
mov    0x2ed5(%rip),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11e8 <funkceSQRT+0xe8>
movsd  -0x10(%rbp),%xmm0
mov    0x2ea3(%rip),%rax
ucomisd (%rax),%xmm0
jne    1162 <funkceSQRT+0x62>
jp     1162 <funkceSQRT+0x62>
mov    0x2e8c(%rip),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11e8 <funkceSQRT+0xe8>
movsd  0xe9e(%rip),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x10(%rbp),%xmm1
divsd  -0x20(%rbp),%xmm1
addsd  -0x20(%rbp),%xmm1
movsd  0xe7a(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
subsd  -0x20(%rbp),%xmm0
movaps 0xe70(%rip),%xmm1
pand   %xmm1,%xmm0
ucomisd -0x18(%rbp),%xmm0
jbe    11de <funkceSQRT+0xde>
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x10(%rbp),%xmm1
divsd  -0x20(%rbp),%xmm1
addsd  -0x20(%rbp),%xmm1
movsd  0xe30(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
jmp    118f <funkceSQRT+0x8f>
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<funkceSQRT>:
xorpd  %xmm2,%xmm2
ucomisd %xmm0,%xmm2
jbe    1116 <funkceSQRT+0x16>
mov    0x2ee7(%rip),%rax
movsd  (%rax),%xmm0
ret
mov    0x2ec3(%rip),%rax
movsd  (%rax),%xmm2
ucomisd %xmm0,%xmm2
jne    1129 <funkceSQRT+0x29>
jnp    1196 <funkceSQRT+0x96>
movsd  0xecf(%rip),%xmm3
addsd  %xmm0,%xmm3
mulsd  0xecb(%rip),%xmm3
movsd  0xecb(%rip),%xmm2
addsd  %xmm3,%xmm2
andpd  0xecf(%rip),%xmm2
ucomisd %xmm1,%xmm2
jbe    119b <funkceSQRT+0x9b>
movsd  0xea9(%rip),%xmm4
movapd 0xeb9(%rip),%xmm5
nopw   0x0(%rax,%rax,1)
movapd %xmm0,%xmm2
divsd  %xmm3,%xmm2
addsd  %xmm3,%xmm2
mulsd  %xmm4,%xmm2
movapd %xmm2,%xmm6
subsd  %xmm3,%xmm6
andpd  %xmm5,%xmm6
ucomisd %xmm1,%xmm6
movapd %xmm2,%xmm3
ja     1170 <funkceSQRT+0x70>
movapd %xmm2,%xmm0
ret
movapd %xmm3,%xmm0
ret

LLVM IR (-O0):
@NAN = global double 0.000000e+00
@INFINITY = global double 0.000000e+00
define double @funkceSQRT(double %0, double %1) {
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca double
store double %0, double* %4
store double %1, double* %5
%8 = load double, double* %4
%9 = fcmp olt double %8, 0.000000e+00
br i1 %9, label %10, label %12
10: ; preds = %2
%11 = load double, double* @NAN
store double %11, double* %3
br label %42
12: ; preds = %2
%13 = load double, double* %4
%14 = load double, double* @INFINITY
%15 = fcmp oeq double %13, %14
br i1 %15, label %16, label %18
16: ; preds = %12
%17 = load double, double* @INFINITY
store double %17, double* %3
br label %42
18: ; preds = %12
store double 1.000000e+00, double* %6
%19 = load double, double* %4
%20 = load double, double* %6
%21 = fdiv double %19, %20
%22 = load double, double* %6
%23 = fadd double %21, %22
%24 = fmul double 5.000000e-01, %23
store double %24, double* %7
br label %25
25: ; preds = %32, %18
%26 = load double, double* %7
%27 = load double, double* %6
%28 = fsub double %26, %27
%29 = call double @llvm.fabs.f64(double %28)
%30 = load double, double* %5
%31 = fcmp ogt double %29, %30
br i1 %31, label %32, label %40
32: ; preds = %25
%33 = load double, double* %7
store double %33, double* %6
%34 = load double, double* %4
%35 = load double, double* %6
%36 = fdiv double %34, %35
%37 = load double, double* %6
%38 = fadd double %36, %37
%39 = fmul double 5.000000e-01, %38
store double %39, double* %7
br label %25
40: ; preds = %25
%41 = load double, double* %7
store double %41, double* %3
br label %42
42: ; preds = %40, %16, %10
%43 = load double, double* %3
ret double %43
}

LLVM IR (-O2):
@NAN = global double 0.000000e+00
@INFINITY = global double 0.000000e+00
define double @funkceSQRT(double %0, double %1) {
%3 = fcmp olt double %0, 0.000000e+00
br i1 %3, label %4, label %6
4: ; preds = %2
%5 = load double, double* @NAN
br label %23
6: ; preds = %2
%7 = load double, double* @INFINITY
%8 = fcmp oeq double %7, %0
br i1 %8, label %23, label %9
9: ; preds = %6
%10 = fadd double %0, 1.000000e+00
%11 = fmul double %10, 5.000000e-01
%12 = fadd double %11, -1.000000e+00
%13 = tail call double @llvm.fabs.f64(double %12)
%14 = fcmp ogt double %13, %1
br i1 %14, label %15, label %23
15: ; preds = %9, %15
%16 = phi double [ %19, %15 ], [ %11, %9 ]
%17 = fdiv double %0, %16
%18 = fadd double %16, %17
%19 = fmul double %18, 5.000000e-01
%20 = fsub double %19, %16
%21 = tail call double @llvm.fabs.f64(double %20)
%22 = fcmp ogt double %21, %1
br i1 %22, label %15, label %23
23: ; preds = %15, %9, %6, %4
%24 = phi double [ %5, %4 ], [ %7, %6 ], [ %11, %9 ], [ %19, %15 ]
ret double %24
}