#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 HodnotaFunkce(unsigned int, double *, double);
double fabs(double);
double Prusecik(unsigned int aRad, double aKoef[], double aOkraje[2],
                double aTolerance) {
  for (long counter = 0; counter < 2000; counter++) {
    double middle = (aOkraje[0] + aOkraje[1]) / 2;
    double low_f = HodnotaFunkce(aRad, aKoef, aOkraje[0]);
    double middle_f = HodnotaFunkce(aRad, aKoef, middle);
    double high_f = HodnotaFunkce(aRad, aKoef, aOkraje[1]);
    if (fabs(middle_f) < aTolerance)
      return middle;
    else if ((middle_f / low_f) > 0)
      aOkraje[0] = middle;
    else
      aOkraje[1] = middle;
  }
  return -1e-10;
}


x86 assembly (clang, -O0):
<Prusecik>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %edi,-0xc(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
movsd  %xmm0,-0x28(%rbp)
movq   $0x0,-0x30(%rbp)
cmpq   $0x7d0,-0x30(%rbp)
jge    1229 <Prusecik+0x119>
mov    -0x20(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x20(%rbp),%rax
addsd  0x8(%rax),%xmm0
movsd  0xeb1(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0xc(%rbp),%edi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rax
movsd  (%rax),%xmm0
call   1030 <HodnotaFunkce@plt>
movsd  %xmm0,-0x40(%rbp)
mov    -0xc(%rbp),%edi
mov    -0x18(%rbp),%rsi
movsd  -0x38(%rbp),%xmm0
call   1030 <HodnotaFunkce@plt>
movsd  %xmm0,-0x48(%rbp)
mov    -0xc(%rbp),%edi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rax
movsd  0x8(%rax),%xmm0
call   1030 <HodnotaFunkce@plt>
movsd  %xmm0,-0x50(%rbp)
movsd  -0x48(%rbp),%xmm1
movaps 0xe5b(%rip),%xmm0
pand   %xmm0,%xmm1
movsd  -0x28(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    11d7 <Prusecik+0xc7>
movsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1236 <Prusecik+0x126>
movsd  -0x48(%rbp),%xmm0
divsd  -0x40(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    1200 <Prusecik+0xf0>
movsd  -0x38(%rbp),%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,(%rax)
jmp    120e <Prusecik+0xfe>
movsd  -0x38(%rbp),%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,0x8(%rax)
jmp    1213 <Prusecik+0x103>
jmp    1218 <Prusecik+0x108>
mov    -0x30(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
jmp    1130 <Prusecik+0x20>
movsd  0xdcf(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Prusecik>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x38,%rsp
movsd  %xmm0,0x10(%rsp)
mov    %rdx,%rbx
mov    %rsi,%r14
mov    %edi,%r15d
mov    $0x7d0,%ebp
xchg   %ax,%ax
movsd  (%rbx),%xmm0
movsd  0x8(%rbx),%xmm1
addsd  %xmm0,%xmm1
mulsd  0xebb(%rip),%xmm1
movsd  %xmm1,0x8(%rsp)
mov    %r15d,%edi
mov    %r14,%rsi
call   1030 <HodnotaFunkce@plt>
movsd  %xmm0,0x18(%rsp)
mov    %r15d,%edi
mov    %r14,%rsi
movsd  0x8(%rsp),%xmm0
call   1030 <HodnotaFunkce@plt>
movaps %xmm0,0x20(%rsp)
movsd  0x8(%rbx),%xmm0
mov    %r15d,%edi
mov    %r14,%rsi
call   1030 <HodnotaFunkce@plt>
movapd 0x20(%rsp),%xmm2
movapd %xmm2,%xmm0
andpd  0xe8c(%rip),%xmm0
movsd  0x10(%rsp),%xmm1
ucomisd %xmm0,%xmm1
ja     11d2 <Prusecik+0xc2>
divsd  0x18(%rsp),%xmm2
xor    %eax,%eax
ucomisd 0xe60(%rip),%xmm2
setbe  %al
movsd  0x8(%rsp),%xmm0
movsd  %xmm0,(%rbx,%rax,8)
add    $0xffffffffffffffff,%rbp
jne    1130 <Prusecik+0x20>
movsd  0xe38(%rip),%xmm0
jmp    11d8 <Prusecik+0xc8>
movsd  0x8(%rsp),%xmm0
add    $0x38,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define double @Prusecik(i32 %0, double* %1, double* %2, double %3) {
%5 = alloca double
%6 = alloca i32
%7 = alloca double*
%8 = alloca double*
%9 = alloca double
%10 = alloca i64
%11 = alloca double
%12 = alloca double
%13 = alloca double
%14 = alloca double
store i32 %0, i32* %6
store double* %1, double** %7
store double* %2, double** %8
store double %3, double* %9
store i64 0, i64* %10
br label %15
15: ; preds = %64, %4
%16 = load i64, i64* %10
%17 = icmp slt i64 %16, 2000
br i1 %17, label %18, label %67
18: ; preds = %15
%19 = load double*, double** %8
%20 = getelementptr inbounds double, double* %19, i64 0
%21 = load double, double* %20
%22 = load double*, double** %8
%23 = getelementptr inbounds double, double* %22, i64 1
%24 = load double, double* %23
%25 = fadd double %21, %24
%26 = fdiv double %25, 2.000000e+00
store double %26, double* %11
%27 = load i32, i32* %6
%28 = load double*, double** %7
%29 = load double*, double** %8
%30 = getelementptr inbounds double, double* %29, i64 0
%31 = load double, double* %30
%32 = call double @HodnotaFunkce(i32 %27, double* %28, double %31)
store double %32, double* %12
%33 = load i32, i32* %6
%34 = load double*, double** %7
%35 = load double, double* %11
%36 = call double @HodnotaFunkce(i32 %33, double* %34, double %35)
store double %36, double* %13
%37 = load i32, i32* %6
%38 = load double*, double** %7
%39 = load double*, double** %8
%40 = getelementptr inbounds double, double* %39, i64 1
%41 = load double, double* %40
%42 = call double @HodnotaFunkce(i32 %37, double* %38, double %41)
store double %42, double* %14
%43 = load double, double* %13
%44 = call double @llvm.fabs.f64(double %43)
%45 = load double, double* %9
%46 = fcmp olt double %44, %45
br i1 %46, label %47, label %49
47: ; preds = %18
%48 = load double, double* %11
store double %48, double* %5
br label %68
49: ; preds = %18
%50 = load double, double* %13
%51 = load double, double* %12
%52 = fdiv double %50, %51
%53 = fcmp ogt double %52, 0.000000e+00
br i1 %53, label %54, label %58
54: ; preds = %49
%55 = load double, double* %11
%56 = load double*, double** %8
%57 = getelementptr inbounds double, double* %56, i64 0
store double %55, double* %57
br label %62
58: ; preds = %49
%59 = load double, double* %11
%60 = load double*, double** %8
%61 = getelementptr inbounds double, double* %60, i64 1
store double %59, double* %61
br label %62
62: ; preds = %58, %54
br label %63
63: ; preds = %62
br label %64
64: ; preds = %63
%65 = load i64, i64* %10
%66 = add nsw i64 %65, 1
store i64 %66, i64* %10
br label %15
67: ; preds = %15
store double -1.000000e-10, double* %5
br label %68
68: ; preds = %67, %47
%69 = load double, double* %5
ret double %69
}

LLVM IR (-O2):
define double @Prusecik(i32 %0, double* %1, double* nocapture %2, double %3) {
%5 = getelementptr inbounds double, double* %2, i64 1
br label %6
6: ; preds = %4, %18
%7 = phi i64 [ 0, %4 ], [ %22, %18 ]
%8 = load double, double* %2
%9 = load double, double* %5
%10 = fadd double %8, %9
%11 = fmul double %10, 5.000000e-01
%12 = tail call double @HodnotaFunkce(i32 %0, double* %1, double %8)
%13 = tail call double @HodnotaFunkce(i32 %0, double* %1, double %11)
%14 = load double, double* %5
%15 = tail call double @HodnotaFunkce(i32 %0, double* %1, double %14)
%16 = tail call double @llvm.fabs.f64(double %13)
%17 = fcmp olt double %16, %3
br i1 %17, label %24, label %18
18: ; preds = %6
%19 = fdiv double %13, %12
%20 = fcmp ogt double %19, 0.000000e+00
%21 = select i1 %20, double* %2, double* %5
store double %11, double* %21
%22 = add nuw nsw i64 %7, 1
%23 = icmp eq i64 %22, 2000
br i1 %23, label %24, label %6
24: ; preds = %6, %18
%25 = phi double [ %11, %6 ], [ -1.000000e-10, %18 ]
ret double %25
}