#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 PrusecikRek(unsigned int aRad, double aKoef[], double aOkraje[2],
                   double aTolerance) {
  static long counter = 0;
  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;
  if (counter > 2000)
    return -1e-10;
  return PrusecikRek(aRad, aKoef, aOkraje, aTolerance);
}


x86 assembly (clang, -O0):
<PrusecikRek>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %edi,-0xc(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
movsd  %xmm0,-0x28(%rbp)
mov    0x2ef9(%rip),%rax
add    $0x1,%rax
mov    %rax,0x2eee(%rip)
mov    -0x20(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x20(%rbp),%rax
addsd  0x8(%rax),%xmm0
movsd  0xead(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0xc(%rbp),%edi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rax
movsd  (%rax),%xmm0
call   1030 <HodnotaFunkce@plt>
movsd  %xmm0,-0x38(%rbp)
mov    -0xc(%rbp),%edi
mov    -0x18(%rbp),%rsi
movsd  -0x30(%rbp),%xmm0
call   1030 <HodnotaFunkce@plt>
movsd  %xmm0,-0x40(%rbp)
mov    -0xc(%rbp),%edi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rax
movsd  0x8(%rax),%xmm0
call   1030 <HodnotaFunkce@plt>
movsd  %xmm0,-0x48(%rbp)
movsd  -0x40(%rbp),%xmm1
movaps 0xe3f(%rip),%xmm0
pand   %xmm0,%xmm1
movsd  -0x28(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    11e3 <PrusecikRek+0xc3>
movsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    125c <PrusecikRek+0x13c>
movsd  -0x40(%rbp),%xmm0
divsd  -0x38(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    120c <PrusecikRek+0xec>
movsd  -0x30(%rbp),%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,(%rax)
jmp    121a <PrusecikRek+0xfa>
movsd  -0x30(%rbp),%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,0x8(%rax)
jmp    121f <PrusecikRek+0xff>
cmpq   $0x7d0,0x2e0e(%rip)
jle    1242 <PrusecikRek+0x122>
movsd  0xde0(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    125c <PrusecikRek+0x13c>
mov    -0xc(%rbp),%edi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
movsd  -0x28(%rbp),%xmm0
call   1040 <PrusecikRek@plt>
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<PrusecikRek>:
push   %rbp
push   %r14
push   %rbx
sub    $0x30,%rsp
movsd  %xmm0,0x10(%rsp)
mov    %rdx,%rbx
mov    %rsi,%r14
mov    %edi,%ebp
mov    0x2f03(%rip),%rax
nopl   (%rax)
add    $0x1,%rax
mov    %rax,0x2ef5(%rip)
movsd  (%rbx),%xmm0
movsd  0x8(%rbx),%xmm1
addsd  %xmm0,%xmm1
mulsd  0xeb0(%rip),%xmm1
movsd  %xmm1,0x8(%rsp)
mov    %ebp,%edi
mov    %r14,%rsi
call   1030 <HodnotaFunkce@plt>
movsd  %xmm0,0x18(%rsp)
mov    %ebp,%edi
mov    %r14,%rsi
movsd  0x8(%rsp),%xmm0
call   1030 <HodnotaFunkce@plt>
movaps %xmm0,0x20(%rsp)
movsd  0x8(%rbx),%xmm0
mov    %ebp,%edi
mov    %r14,%rsi
call   1030 <HodnotaFunkce@plt>
movapd 0x20(%rsp),%xmm2
movapd %xmm2,%xmm0
andpd  0xe84(%rip),%xmm0
movsd  0x10(%rsp),%xmm1
ucomisd %xmm0,%xmm1
ja     11e3 <PrusecikRek+0xd3>
divsd  0x18(%rsp),%xmm2
xor    %eax,%eax
ucomisd 0xe58(%rip),%xmm2
setbe  %al
movsd  0x8(%rsp),%xmm0
movsd  %xmm0,(%rbx,%rax,8)
mov    0x2e63(%rip),%rax
cmp    $0x7d1,%rax
jl     1130 <PrusecikRek+0x20>
movsd  0xe27(%rip),%xmm0
jmp    11e9 <PrusecikRek+0xd9>
movsd  0x8(%rsp),%xmm0
add    $0x30,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

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

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