#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 */
float fabs(float);
float stub1(float);
float stub2(float);
float stub3(float);
float rtbis(float (*func)(float), float x1, float x2, float xacc) {
  void nrerror(char error_text[]);
  int j;
  float dx, f, fmid, xmid, rtb;
  f = (*func)(x1);
  fmid = (*func)(x2);
  if (f * fmid >= 0.0)
    nrerror("Root must be bracketed for bisection in rtbis");
  rtb = f < 0.0 ? (dx = x2 - x1, x1) : (dx = x1 - x2, x2);
  for (j = 1; j <= 40; j++) {
    fmid = (*func)(xmid = rtb + (dx *= 0.5));
    if (fmid <= 0.0)
      rtb = xmid;
    if (fabs(dx) < xacc || fmid == 0.0)
      return rtb;
  }
  nrerror("Too many bisections in rtbis");
  return 0.0;
}


x86 assembly (clang, -O0):
<rtbis>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
movss  %xmm0,-0x14(%rbp)
movss  %xmm1,-0x18(%rbp)
movss  %xmm2,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
movss  -0x14(%rbp),%xmm0
call   *%rax
movss  %xmm0,-0x28(%rbp)
mov    -0x10(%rbp),%rax
movss  -0x18(%rbp),%xmm0
call   *%rax
movss  %xmm0,-0x2c(%rbp)
movss  -0x28(%rbp),%xmm0
mulss  -0x2c(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     1182 <rtbis+0x62>
lea    0xe8b(%rip),%rdi
call   1030 <nrerror@plt>
movss  -0x28(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
xorps  %xmm0,%xmm0
ucomisd %xmm1,%xmm0
jbe    11b6 <rtbis+0x96>
movss  -0x18(%rbp),%xmm0
subss  -0x14(%rbp),%xmm0
movss  %xmm0,-0x24(%rbp)
movss  -0x14(%rbp),%xmm0
movss  %xmm0,-0x38(%rbp)
jmp    11cf <rtbis+0xaf>
movss  -0x14(%rbp),%xmm0
subss  -0x18(%rbp),%xmm0
movss  %xmm0,-0x24(%rbp)
movss  -0x18(%rbp),%xmm0
movss  %xmm0,-0x38(%rbp)
movss  -0x38(%rbp),%xmm0
movss  %xmm0,-0x34(%rbp)
movl   $0x1,-0x20(%rbp)
cmpl   $0x28,-0x20(%rbp)
jg     129a <rtbis+0x17a>
mov    -0x10(%rbp),%rax
movss  -0x34(%rbp),%xmm0
movss  -0x24(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
movsd  0xdfc(%rip),%xmm2
mulsd  %xmm2,%xmm1
cvtsd2ss %xmm1,%xmm1
movss  %xmm1,-0x24(%rbp)
addss  %xmm1,%xmm0
movss  %xmm0,-0x30(%rbp)
call   *%rax
movss  %xmm0,-0x2c(%rbp)
movss  -0x2c(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
xorps  %xmm0,%xmm0
ucomisd %xmm1,%xmm0
jb     1241 <rtbis+0x121>
movss  -0x30(%rbp),%xmm0
movss  %xmm0,-0x34(%rbp)
movss  -0x24(%rbp),%xmm0
call   1040 <fabs@plt>
movaps %xmm0,%xmm1
movss  -0x1c(%rbp),%xmm0
ucomiss %xmm1,%xmm0
ja     1278 <rtbis+0x158>
movss  -0x2c(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    1287 <rtbis+0x167>
jp     1287 <rtbis+0x167>
movss  -0x34(%rbp),%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    12ae <rtbis+0x18e>
jmp    128c <rtbis+0x16c>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    11e0 <rtbis+0xc0>
lea    0xd95(%rip),%rdi
call   1030 <nrerror@plt>
xorps  %xmm0,%xmm0
movss  %xmm0,-0x4(%rbp)
movss  -0x4(%rbp),%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rtbis>:
push   %rbp
push   %rbx
sub    $0x48,%rsp
movss  %xmm2,0xc(%rsp)
movaps %xmm1,0x10(%rsp)
mov    %rdi,%rbx
movaps %xmm0,0x20(%rsp)
call   *%rdi
movaps %xmm0,0x30(%rsp)
movaps 0x10(%rsp),%xmm0
call   *%rbx
movaps 0x30(%rsp),%xmm3
mulss  %xmm3,%xmm0
xorps  %xmm2,%xmm2
ucomiss %xmm2,%xmm0
jb     115c <rtbis+0x4c>
lea    0xed1(%rip),%rdi
call   1030 <nrerror@plt>
xorps  %xmm2,%xmm2
movaps 0x30(%rsp),%xmm3
ucomiss %xmm3,%xmm2
ja     1174 <rtbis+0x64>
movaps 0x20(%rsp),%xmm0
movaps %xmm0,%xmm4
movaps 0x10(%rsp),%xmm1
subss  %xmm1,%xmm4
jmp    1185 <rtbis+0x75>
movaps 0x10(%rsp),%xmm1
movaps %xmm1,%xmm4
movaps 0x20(%rsp),%xmm0
subss  %xmm0,%xmm4
cmpltss %xmm2,%xmm3
andps  %xmm3,%xmm0
andnps %xmm1,%xmm3
orps   %xmm0,%xmm3
mov    $0x28,%ebp
nopl   0x0(%rax,%rax,1)
movaps %xmm3,0x30(%rsp)
mulss  0xe53(%rip),%xmm4
movaps %xmm4,0x10(%rsp)
movaps %xmm4,%xmm0
addss  %xmm3,%xmm0
movaps %xmm0,0x20(%rsp)
call   *%rbx
xorps  %xmm5,%xmm5
movaps 0x10(%rsp),%xmm4
movaps %xmm0,%xmm3
cmpnless %xmm5,%xmm3
movaps %xmm3,%xmm2
andnps 0x20(%rsp),%xmm2
andps  0x30(%rsp),%xmm3
orps   %xmm2,%xmm3
movaps %xmm4,%xmm1
andps  0xe26(%rip),%xmm1
movss  0xc(%rsp),%xmm2
ucomiss %xmm1,%xmm2
ja     1210 <rtbis+0x100>
ucomiss %xmm5,%xmm0
jne    11fc <rtbis+0xec>
jnp    1210 <rtbis+0x100>
add    $0xffffffff,%ebp
jne    11a0 <rtbis+0x90>
lea    0xe46(%rip),%rdi
call   1030 <nrerror@plt>
xorps  %xmm3,%xmm3
movaps %xmm3,%xmm0
add    $0x48,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [46 x i8] c"Root must be bracketed for bisection in rtbis\00"
@.str.1 = [29 x i8] c"Too many bisections in rtbis\00"
define float @rtbis(float (float)* %0, float %1, float %2, float %3) {
%5 = alloca float
%6 = alloca float (float)*
%7 = alloca float
%8 = alloca float
%9 = alloca float
%10 = alloca i32
%11 = alloca float
%12 = alloca float
%13 = alloca float
%14 = alloca float
%15 = alloca float
store float (float)* %0, float (float)** %6
store float %1, float* %7
store float %2, float* %8
store float %3, float* %9
%16 = load float (float)*, float (float)** %6
%17 = load float, float* %7
%18 = call float %16(float %17)
store float %18, float* %12
%19 = load float (float)*, float (float)** %6
%20 = load float, float* %8
%21 = call float %19(float %20)
store float %21, float* %13
%22 = load float, float* %12
%23 = load float, float* %13
%24 = fmul float %22, %23
%25 = fpext float %24 to double
%26 = fcmp oge double %25, 0.000000e+00
br i1 %26, label %27, label %28
27: ; preds = %4
br label %28
28: ; preds = %27, %4
%29 = load float, float* %12
%30 = fpext float %29 to double
%31 = fcmp olt double %30, 0.000000e+00
br i1 %31, label %32, label %37
32: ; preds = %28
%33 = load float, float* %8
%34 = load float, float* %7
%35 = fsub float %33, %34
store float %35, float* %11
%36 = load float, float* %7
br label %42
37: ; preds = %28
%38 = load float, float* %7
%39 = load float, float* %8
%40 = fsub float %38, %39
store float %40, float* %11
%41 = load float, float* %8
br label %42
42: ; preds = %37, %32
%43 = phi float [ %36, %32 ], [ %41, %37 ]
store float %43, float* %15
store i32 1, i32* %10
br label %44
44: ; preds = %73, %42
%45 = load i32, i32* %10
%46 = icmp sle i32 %45, 40
br i1 %46, label %47, label %76
47: ; preds = %44
%48 = load float (float)*, float (float)** %6
%49 = load float, float* %15
%50 = load float, float* %11
%51 = fpext float %50 to double
%52 = fmul double %51, 5.000000e-01
%53 = fptrunc double %52 to float
store float %53, float* %11
%54 = fadd float %49, %53
store float %54, float* %14
%55 = call float %48(float %54)
store float %55, float* %13
%56 = load float, float* %13
%57 = fpext float %56 to double
%58 = fcmp ole double %57, 0.000000e+00
br i1 %58, label %59, label %61
59: ; preds = %47
%60 = load float, float* %14
store float %60, float* %15
br label %61
61: ; preds = %59, %47
%62 = load float, float* %11
%63 = call float @fabs(float %62)
%64 = load float, float* %9
%65 = fcmp olt float %63, %64
br i1 %65, label %70, label %66
66: ; preds = %61
%67 = load float, float* %13
%68 = fpext float %67 to double
%69 = fcmp oeq double %68, 0.000000e+00
br i1 %69, label %70, label %72
70: ; preds = %66, %61
%71 = load float, float* %15
store float %71, float* %5
br label %77
72: ; preds = %66
br label %73
73: ; preds = %72
%74 = load i32, i32* %10
%75 = add nsw i32 %74, 1
store i32 %75, i32* %10
br label %44
76: ; preds = %44
store float 0.000000e+00, float* %5
br label %77
77: ; preds = %76, %70
%78 = load float, float* %5
ret float %78
}

LLVM IR (-O2):
@.str = [46 x i8] c"Root must be bracketed for bisection in rtbis\00"
@.str.1 = [29 x i8] c"Too many bisections in rtbis\00"
define float @rtbis(float (float)* nocapture %0, float %1, float %2, float %3) {
%5 = tail call float %0(float %1)
%6 = tail call float %0(float %2)
%7 = fmul float %5, %6
%8 = fcmp ult float %7, 0.000000e+00
br i1 %8, label %10, label %9
9: ; preds = %4
tail call void @nrerror(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str, i64 0, i64 0))
br label %10
10: ; preds = %9, %4
%11 = fcmp olt float %5, 0.000000e+00
%12 = fsub float %2, %1
%13 = fsub float %1, %2
%14 = select i1 %11, float %12, float %13
%15 = select i1 %11, float %1, float %2
br label %19
16: ; preds = %19
%17 = add nuw nsw i32 %21, 1
%18 = icmp eq i32 %17, 41
br i1 %18, label %32, label %19
19: ; preds = %10, %16
%20 = phi float [ %15, %10 ], [ %27, %16 ]
%21 = phi i32 [ 1, %10 ], [ %17, %16 ]
%22 = phi float [ %14, %10 ], [ %23, %16 ]
%23 = fmul float %22, 5.000000e-01
%24 = fadd float %23, %20
%25 = tail call float %0(float %24)
%26 = fcmp ugt float %25, 0.000000e+00
%27 = select i1 %26, float %20, float %24
%28 = tail call float @llvm.fabs.f32(float %23)
%29 = fcmp olt float %28, %3
%30 = fcmp oeq float %25, 0.000000e+00
%31 = select i1 %29, i1 true, i1 %30
br i1 %31, label %33, label %16
32: ; preds = %16
tail call void @nrerror(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0))
br label %33
33: ; preds = %19, %32
%34 = phi float [ 0.000000e+00, %32 ], [ %27, %19 ]
ret float %34
}