#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);
void stub1(float, float *, float *);
float rtnewt(void (*funcd)(float, float *, float *), float x1, float x2,
             float xacc) {
  void nrerror(char error_text[]);
  int j;
  float df, dx, f, rtn;
  rtn = 0.5 * (x1 + x2);
  for (j = 1; j <= 20; j++) {
    (*funcd)(rtn, &f, &df);
    dx = f / df;
    rtn -= dx;
    if ((x1 - rtn) * (rtn - x2) < 0.0)
      nrerror("Jumped out of brackets in rtnewt");
    if (fabs(dx) < xacc)
      return rtn;
  }
  nrerror("Maximum number of iterations exceeded in rtnewt");
  return 0.0;
}


x86 assembly (clang, -O0):
<rtnewt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
movss  %xmm0,-0x14(%rbp)
movss  %xmm1,-0x18(%rbp)
movss  %xmm2,-0x1c(%rbp)
movss  -0x14(%rbp),%xmm0
addss  -0x18(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0xeaf(%rip),%xmm0
mulsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x30(%rbp)
movl   $0x1,-0x20(%rbp)
cmpl   $0x14,-0x20(%rbp)
jg     1216 <rtnewt+0xf6>
mov    -0x10(%rbp),%rax
movss  -0x30(%rbp),%xmm0
lea    -0x2c(%rbp),%rdi
lea    -0x24(%rbp),%rsi
call   *%rax
movss  -0x2c(%rbp),%xmm0
divss  -0x24(%rbp),%xmm0
movss  %xmm0,-0x28(%rbp)
movss  -0x28(%rbp),%xmm1
movss  -0x30(%rbp),%xmm0
subss  %xmm1,%xmm0
movss  %xmm0,-0x30(%rbp)
movss  -0x14(%rbp),%xmm0
subss  -0x30(%rbp),%xmm0
movss  -0x30(%rbp),%xmm1
subss  -0x18(%rbp),%xmm1
mulss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm1
xorps  %xmm0,%xmm0
ucomisd %xmm1,%xmm0
jbe    11d9 <rtnewt+0xb9>
lea    0xe34(%rip),%rdi
call   1030 <nrerror@plt>
movss  -0x28(%rbp),%xmm0
call   1040 <fabs@plt>
movaps %xmm0,%xmm1
movss  -0x1c(%rbp),%xmm0
ucomiss %xmm1,%xmm0
jbe    1203 <rtnewt+0xe3>
movss  -0x30(%rbp),%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    122a <rtnewt+0x10a>
jmp    1208 <rtnewt+0xe8>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1165 <rtnewt+0x45>
lea    0xe0c(%rip),%rdi
call   1030 <nrerror@plt>
xorps  %xmm0,%xmm0
movss  %xmm0,-0x4(%rbp)
movss  -0x4(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rtnewt>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x30,%rsp
movss  %xmm2,0x14(%rsp)
mov    %rdi,%rbx
movss  %xmm0,0xc(%rsp)
movss  %xmm1,0x10(%rsp)
addss  %xmm1,%xmm0
mulss  0xec3(%rip),%xmm0
mov    $0x14,%ebp
lea    0x18(%rsp),%r14
lea    0x1c(%rsp),%r15
lea    0xecd(%rip),%r12
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movss  %xmm0,0x8(%rsp)
mov    %r14,%rdi
mov    %r15,%rsi
call   *%rbx
movss  0x18(%rsp),%xmm2
divss  0x1c(%rsp),%xmm2
movss  0x8(%rsp),%xmm1
subss  %xmm2,%xmm1
movss  0xc(%rsp),%xmm0
subss  %xmm1,%xmm0
movss  %xmm1,0x8(%rsp)
subss  0x10(%rsp),%xmm1
mulss  %xmm0,%xmm1
xorps  %xmm0,%xmm0
ucomiss %xmm1,%xmm0
jbe    11b8 <rtnewt+0xa8>
mov    %r12,%rdi
movaps %xmm2,0x20(%rsp)
call   1030 <nrerror@plt>
movaps 0x20(%rsp),%xmm2
andps  0xe51(%rip),%xmm2
movss  0x14(%rsp),%xmm0
ucomiss %xmm2,%xmm0
ja     11e6 <rtnewt+0xd6>
add    $0xffffffff,%ebp
movss  0x8(%rsp),%xmm0
jne    1160 <rtnewt+0x50>
lea    0xe65(%rip),%rdi
call   1030 <nrerror@plt>
xorps  %xmm0,%xmm0
jmp    11ec <rtnewt+0xdc>
movss  0x8(%rsp),%xmm0
add    $0x30,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [33 x i8] c"Jumped out of brackets in rtnewt\00"
@.str.1 = [48 x i8] c"Maximum number of iterations exceeded in rtnewt\00"
define float @rtnewt(void (float, float*, float*)* %0, float %1, float %2, float %3) {
%5 = alloca float
%6 = alloca void (float, 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
store void (float, float*, float*)* %0, void (float, float*, float*)** %6
store float %1, float* %7
store float %2, float* %8
store float %3, float* %9
%15 = load float, float* %7
%16 = load float, float* %8
%17 = fadd float %15, %16
%18 = fpext float %17 to double
%19 = fmul double 5.000000e-01, %18
%20 = fptrunc double %19 to float
store float %20, float* %14
store i32 1, i32* %10
br label %21
21: ; preds = %51, %4
%22 = load i32, i32* %10
%23 = icmp sle i32 %22, 20
br i1 %23, label %24, label %54
24: ; preds = %21
%25 = load void (float, float*, float*)*, void (float, float*, float*)** %6
%26 = load float, float* %14
%27 = load float, float* %13
%28 = load float, float* %11
%29 = fdiv float %27, %28
store float %29, float* %12
%30 = load float, float* %12
%31 = load float, float* %14
%32 = fsub float %31, %30
store float %32, float* %14
%33 = load float, float* %7
%34 = load float, float* %14
%35 = fsub float %33, %34
%36 = load float, float* %14
%37 = load float, float* %8
%38 = fsub float %36, %37
%39 = fmul float %35, %38
%40 = fpext float %39 to double
%41 = fcmp olt double %40, 0.000000e+00
br i1 %41, label %42, label %43
42: ; preds = %24
br label %43
43: ; preds = %42, %24
%44 = load float, float* %12
%45 = call float @fabs(float %44)
%46 = load float, float* %9
%47 = fcmp olt float %45, %46
br i1 %47, label %48, label %50
48: ; preds = %43
%49 = load float, float* %14
store float %49, float* %5
br label %55
50: ; preds = %43
br label %51
51: ; preds = %50
%52 = load i32, i32* %10
%53 = add nsw i32 %52, 1
store i32 %53, i32* %10
br label %21
54: ; preds = %21
store float 0.000000e+00, float* %5
br label %55
55: ; preds = %54, %48
%56 = load float, float* %5
ret float %56
}

LLVM IR (-O2):
@.str = [33 x i8] c"Jumped out of brackets in rtnewt\00"
@.str.1 = [48 x i8] c"Maximum number of iterations exceeded in rtnewt\00"
define float @rtnewt(void (float, float*, float*)* nocapture %0, float %1, float %2, float %3) {
%5 = alloca float
%6 = alloca float
%7 = bitcast float* %5 to i8*
%8 = bitcast float* %6 to i8*
%9 = fadd float %1, %2
%10 = fmul float %9, 5.000000e-01
br label %14
11: ; preds = %26
%12 = add nuw nsw i32 %16, 1
%13 = icmp eq i32 %12, 21
br i1 %13, label %29, label %14
14: ; preds = %4, %11
%15 = phi float [ %10, %4 ], [ %20, %11 ]
%16 = phi i32 [ 1, %4 ], [ %12, %11 ]
%17 = load float, float* %6
%18 = load float, float* %5
%19 = fdiv float %17, %18
%20 = fsub float %15, %19
%21 = fsub float %1, %20
%22 = fsub float %20, %2
%23 = fmul float %21, %22
%24 = fcmp olt float %23, 0.000000e+00
br i1 %24, label %25, label %26
25: ; preds = %14
br label %26
26: ; preds = %25, %14
%27 = call float @llvm.fabs.f32(float %19)
%28 = fcmp olt float %27, %3
br i1 %28, label %30, label %11
29: ; preds = %11
br label %30
30: ; preds = %26, %29
%31 = phi float [ 0.000000e+00, %29 ], [ %20, %26 ]
ret float %31
}