#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 W_of_vsq(double, double *, double *, double *);
double fabs(double);
scalar_t__ isfinite(double);
void stub1(double *, double *, double *, double **, double *, double *, int);
int /*<<< orphan*/ validate_x(double *, double *);
int general_newton_raphson(double x[], int n,
                           void (*funcd)(double[], double[], double[],
                                         double[][1], double *, double *,
                                         int)) {
  double f, df, dx[1], x_old[1], resid[1], jac[1][1];
  double errx, x_orig[1];
  int n_iter, id, jd, i_extra, doing_extra;
  double dW, dvsq, vsq_old, vsq, W, W_old, rho, p, u;
  int keep_iterating;
  errx = 1.;
  df = f = 1.;
  i_extra = doing_extra = 0;
  for (id = 0; id < n; id++)
    x_old[id] = x_orig[id] = x[id];
  vsq_old = vsq = W = W_old = 0.;
  n_iter = 0;
  keep_iterating = 1;
  while (keep_iterating) {
    (*funcd)(x, dx, resid, jac, &f, &df, n);
    errx = 0.;
    for (id = 0; id < n; id++) {
      x_old[id] = x[id];
    }
    for (id = 0; id < n; id++) {
      x[id] += dx[id];
    }
    validate_x(x, x_old);
    W_old = W;
    W = W_of_vsq(x[0], &p, &rho, &u);
    errx = (W == 0.) ? fabs(W - W_old) : fabs((W - W_old) / W);
    errx +=
        (x[0] == 0.) ? fabs(x[0] - x_old[0]) : fabs((x[0] - x_old[0]) / x[0]);
    if ((fabs(errx) <= 1.0e-10) && (doing_extra == 0) && (2 > 0)) {
      doing_extra = 1;
    }
    if (doing_extra == 1)
      i_extra++;
    if (((fabs(errx) <= 1.0e-10) && (doing_extra == 0)) || (i_extra > 2) ||
        (n_iter >= (30 - 1))) {
      keep_iterating = 0;
    }
    n_iter++;
  }
  if ((isfinite(f) == 0) || (isfinite(df) == 0)) {
    return (2);
  }
  if (fabs(errx) > 1.0e-10) {
    return (1);
  }
  if ((fabs(errx) <= 1.0e-10) && (fabs(errx) > 1.0e-10)) {
    return (0);
  }
  if (fabs(errx) <= 1.0e-10) {
    return (0);
  }
  return (0);
}


x86 assembly (clang, -O0):
<general_newton_raphson>:
push   %rbp
mov    %rsp,%rbp
sub    $0xe0,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %rdx,-0x20(%rbp)
movsd  0xeb2(%rip),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  0xea5(%rip),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  0xe98(%rip),%xmm0
movsd  %xmm0,-0x30(%rbp)
movl   $0x0,-0x74(%rbp)
movl   $0x0,-0x70(%rbp)
movl   $0x0,-0x68(%rbp)
mov    -0x68(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11bd <general_newton_raphson+0x8d>
mov    -0x10(%rbp),%rax
movslq -0x68(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movslq -0x68(%rbp),%rax
movsd  %xmm0,-0x60(%rbp,%rax,8)
movslq -0x68(%rbp),%rax
movsd  %xmm0,-0x40(%rbp,%rax,8)
mov    -0x68(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x68(%rbp)
jmp    1182 <general_newton_raphson+0x52>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0xa8(%rbp)
ff
xorps  %xmm0,%xmm0
movsd  %xmm0,-0xa0(%rbp)
ff
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x98(%rbp)
ff
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x90(%rbp)
ff
movl   $0x0,-0x64(%rbp)
movl   $0x1,-0xc4(%rbp)
cmpl   $0x0,-0xc4(%rbp)
je     1484 <general_newton_raphson+0x354>
mov    -0x20(%rbp),%rax
mov    -0x10(%rbp),%rdi
lea    -0x38(%rbp),%rsi
lea    -0x48(%rbp),%rdx
lea    -0x50(%rbp),%rcx
mov    -0x14(%rbp),%r10d
lea    -0x28(%rbp),%r8
lea    -0x30(%rbp),%r9
mov    %r10d,(%rsp)
call   *%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x58(%rbp)
movl   $0x0,-0x68(%rbp)
mov    -0x68(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    126d <general_newton_raphson+0x13d>
mov    -0x10(%rbp),%rax
movslq -0x68(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movslq -0x68(%rbp),%rax
movsd  %xmm0,-0x40(%rbp,%rax,8)
mov    -0x68(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x68(%rbp)
jmp    123c <general_newton_raphson+0x10c>
movl   $0x0,-0x68(%rbp)
mov    -0x68(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    12aa <general_newton_raphson+0x17a>
movslq -0x68(%rbp),%rax
movsd  -0x38(%rbp,%rax,8),%xmm0
mov    -0x10(%rbp),%rax
movslq -0x68(%rbp),%rcx
addsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x68(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x68(%rbp)
jmp    1274 <general_newton_raphson+0x144>
mov    -0x10(%rbp),%rdi
lea    -0x40(%rbp),%rsi
call   1040 <validate_x@plt>
movsd  -0xa0(%rbp),%xmm0
ff
movsd  %xmm0,-0xa8(%rbp)
ff
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
lea    -0xb8(%rbp),%rdi
lea    -0xb0(%rbp),%rsi
lea    -0xc0(%rbp),%rdx
call   1050 <W_of_vsq@plt>
movsd  %xmm0,-0xa0(%rbp)
ff
movsd  -0xa0(%rbp),%xmm0
ff
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    1334 <general_newton_raphson+0x204>
jp     1334 <general_newton_raphson+0x204>
movsd  -0xa0(%rbp),%xmm0
ff
subsd  -0xa8(%rbp),%xmm0
ff
movaps 0xced(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  %xmm0,-0xd0(%rbp)
ff
jmp    135f <general_newton_raphson+0x22f>
movsd  -0xa0(%rbp),%xmm0
ff
subsd  -0xa8(%rbp),%xmm0
ff
divsd  -0xa0(%rbp),%xmm0
ff
movaps 0xcbd(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  %xmm0,-0xd0(%rbp)
ff
movsd  -0xd0(%rbp),%xmm0
ff
movsd  %xmm0,-0x58(%rbp)
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    13ac <general_newton_raphson+0x27c>
jp     13ac <general_newton_raphson+0x27c>
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
subsd  -0x40(%rbp),%xmm0
movaps 0xc75(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  %xmm0,-0xd8(%rbp)
ff
jmp    13d4 <general_newton_raphson+0x2a4>
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
subsd  -0x40(%rbp),%xmm0
mov    -0x10(%rbp),%rax
divsd  (%rax),%xmm0
movaps 0xc48(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  %xmm0,-0xd8(%rbp)
ff
movsd  -0xd8(%rbp),%xmm0
ff
addsd  -0x58(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x58(%rbp),%xmm1
movaps 0xc1e(%rip),%xmm0
pand   %xmm0,%xmm1
movsd  0xc0a(%rip),%xmm0
ucomisd %xmm1,%xmm0
jb     1419 <general_newton_raphson+0x2e9>
cmpl   $0x0,-0x74(%rbp)
jne    1419 <general_newton_raphson+0x2e9>
movl   $0x1,-0x74(%rbp)
cmpl   $0x1,-0x74(%rbp)
jne    142c <general_newton_raphson+0x2fc>
mov    -0x70(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x70(%rbp)
movsd  -0x58(%rbp),%xmm1
movaps 0xbd8(%rip),%xmm0
pand   %xmm0,%xmm1
movsd  0xbc4(%rip),%xmm0
ucomisd %xmm1,%xmm0
jb     1458 <general_newton_raphson+0x328>
cmpl   $0x0,-0x74(%rbp)
je     146c <general_newton_raphson+0x33c>
cmpl   $0x2,-0x70(%rbp)
jg     146c <general_newton_raphson+0x33c>
cmpl   $0x1d,-0x64(%rbp)
jl     1476 <general_newton_raphson+0x346>
movl   $0x0,-0xc4(%rbp)
mov    -0x64(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x64(%rbp)
jmp    11fa <general_newton_raphson+0xca>
movsd  -0x28(%rbp),%xmm0
call   1030 <isfinite@plt>
cmp    $0x0,%rax
je     14ac <general_newton_raphson+0x37c>
movsd  -0x30(%rbp),%xmm0
call   1030 <isfinite@plt>
cmp    $0x0,%rax
jne    14b8 <general_newton_raphson+0x388>
movl   $0x2,-0x4(%rbp)
jmp    156b <general_newton_raphson+0x43b>
movsd  -0x58(%rbp),%xmm0
movaps 0xb4c(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  0xb38(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    14e6 <general_newton_raphson+0x3b6>
movl   $0x1,-0x4(%rbp)
jmp    156b <general_newton_raphson+0x43b>
movsd  -0x58(%rbp),%xmm1
movaps 0xb1e(%rip),%xmm0
pand   %xmm0,%xmm1
movsd  0xb0a(%rip),%xmm0
ucomisd %xmm1,%xmm0
jb     1536 <general_newton_raphson+0x406>
movsd  -0x58(%rbp),%xmm0
movaps 0xafc(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  0xae8(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    1536 <general_newton_raphson+0x406>
movl   $0x0,-0x4(%rbp)
jmp    156b <general_newton_raphson+0x43b>
movsd  -0x58(%rbp),%xmm1
movaps 0xace(%rip),%xmm0
pand   %xmm0,%xmm1
movsd  0xaba(%rip),%xmm0
ucomisd %xmm1,%xmm0
jb     1564 <general_newton_raphson+0x434>
movl   $0x0,-0x4(%rbp)
jmp    156b <general_newton_raphson+0x43b>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xe0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<general_newton_raphson>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x98,%rsp
mov    %rdx,0x60(%rsp)
mov    %esi,%r15d
mov    %rdi,%rbx
movabs $0x3ff0000000000000,%rax
mov    %rax,0x18(%rsp)
mov    %rax,0x10(%rsp)
lea    -0x1(%r15),%eax
test   %esi,%esi
jle    1173 <general_newton_raphson+0x43>
movsd  (%rbx,%rax,8),%xmm0
movsd  %xmm0,0x8(%rsp)
mov    %eax,%eax
mov    %rax,0x58(%rsp)
mov    %r15d,%r13d
mov    %r13d,%eax
and    $0xfffffffc,%eax
mov    %rax,0x50(%rsp)
add    $0xfffffffffffffffc,%rax
mov    %rax,0x48(%rsp)
mov    %rax,%rcx
shr    $0x2,%rcx
add    $0x1,%rcx
mov    %rcx,%rax
mov    %rcx,0x40(%rsp)
and    $0xfffffffffffffffe,%rcx
mov    %rcx,0x38(%rsp)
xor    %r12d,%r12d
xorpd  %xmm0,%xmm0
xor    %ebp,%ebp
xor    %r14d,%r14d
nopl   0x0(%rax)
movapd %xmm0,0x20(%rsp)
mov    %r15d,(%rsp)
mov    %rbx,%rdi
lea    0x68(%rsp),%rsi
lea    0x90(%rsp),%rdx
lea    0x88(%rsp),%rcx
lea    0x18(%rsp),%r8
lea    0x10(%rsp),%r9
call   *0x60(%rsp)
test   %r15d,%r15d
jle    12d7 <general_newton_raphson+0x1a7>
mov    0x58(%rsp),%rax
movsd  (%rbx,%rax,8),%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  0x68(%rsp),%xmm0
cmp    $0x4,%r15d
jae    1220 <general_newton_raphson+0xf0>
xor    %eax,%eax
jmp    12c0 <general_newton_raphson+0x190>
nopl   0x0(%rax)
movapd %xmm0,%xmm1
unpcklpd %xmm0,%xmm1
cmpq   $0x0,0x48(%rsp)
je     139d <general_newton_raphson+0x26d>
mov    0x38(%rsp),%rcx
xor    %eax,%eax
nopl   0x0(%rax,%rax,1)
movupd (%rbx,%rax,8),%xmm2
movupd 0x10(%rbx,%rax,8),%xmm3
movupd 0x20(%rbx,%rax,8),%xmm4
movupd 0x30(%rbx,%rax,8),%xmm5
addpd  %xmm1,%xmm2
addpd  %xmm1,%xmm3
movupd %xmm2,(%rbx,%rax,8)
movupd %xmm3,0x10(%rbx,%rax,8)
addpd  %xmm1,%xmm4
addpd  %xmm1,%xmm5
movupd %xmm4,0x20(%rbx,%rax,8)
movupd %xmm5,0x30(%rbx,%rax,8)
add    $0x8,%rax
add    $0xfffffffffffffffe,%rcx
jne    1240 <general_newton_raphson+0x110>
testb  $0x1,0x40(%rsp)
je     12ad <general_newton_raphson+0x17d>
movupd (%rbx,%rax,8),%xmm2
movupd 0x10(%rbx,%rax,8),%xmm3
addpd  %xmm1,%xmm2
addpd  %xmm1,%xmm3
movupd %xmm2,(%rbx,%rax,8)
movupd %xmm3,0x10(%rbx,%rax,8)
mov    0x50(%rsp),%rcx
mov    %rcx,%rax
cmp    %r13,%rcx
je     12d7 <general_newton_raphson+0x1a7>
nopw   0x0(%rax,%rax,1)
movsd  (%rbx,%rax,8),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,(%rbx,%rax,8)
add    $0x1,%rax
cmp    %rax,%r13
jne    12c0 <general_newton_raphson+0x190>
mov    %rbx,%rdi
lea    0x8(%rsp),%rsi
call   1040 <validate_x@plt>
movsd  (%rbx),%xmm0
lea    0x78(%rsp),%rdi
lea    0x80(%rsp),%rsi
lea    0x70(%rsp),%rdx
call   1050 <W_of_vsq@plt>
movapd %xmm0,%xmm1
movhpd (%rbx),%xmm1
movapd %xmm1,%xmm2
cmpeqpd 0xd0c(%rip),%xmm2
movapd 0x20(%rsp),%xmm4
movhpd 0x8(%rsp),%xmm4
movapd %xmm2,%xmm3
andnpd %xmm1,%xmm3
subpd  %xmm4,%xmm1
andpd  0xccc(%rip),%xmm2
orpd   %xmm3,%xmm2
divpd  %xmm2,%xmm1
andpd  0xccc(%rip),%xmm1
pshufd $0xee,%xmm1,%xmm2
test   %ebp,%ebp
mov    %ebp,%eax
mov    $0x1,%ecx
cmove  %ecx,%eax
addpd  %xmm1,%xmm2
movsd  0xccf(%rip),%xmm1
ucomisd %xmm2,%xmm1
setae  %sil
cmovae %eax,%ebp
xor    %eax,%eax
cmp    $0x1,%ebp
sete   %cl
test   %ebp,%ebp
sete   %dl
test   %dl,%sil
jne    13af <general_newton_raphson+0x27f>
mov    %cl,%al
add    %eax,%r14d
cmp    $0x2,%r14d
ja     13af <general_newton_raphson+0x27f>
lea    0x1(%r12),%eax
cmp    $0x1d,%r12d
mov    %eax,%r12d
jb     11c0 <general_newton_raphson+0x90>
jmp    13af <general_newton_raphson+0x27f>
xor    %eax,%eax
testb  $0x1,0x40(%rsp)
jne    128f <general_newton_raphson+0x15f>
jmp    12ad <general_newton_raphson+0x17d>
movapd %xmm2,0x20(%rsp)
movsd  0x18(%rsp),%xmm0
call   1030 <isfinite@plt>
mov    $0x2,%ebx
test   %rax,%rax
je     13f1 <general_newton_raphson+0x2c1>
movsd  0x10(%rsp),%xmm0
call   1030 <isfinite@plt>
test   %rax,%rax
je     13f1 <general_newton_raphson+0x2c1>
mov    $0x1,%ebx
movapd 0x20(%rsp),%xmm0
ucomisd 0xc43(%rip),%xmm0
ja     13f1 <general_newton_raphson+0x2c1>
xor    %ebx,%ebx
mov    %ebx,%eax
add    $0x98,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @general_newton_raphson(double* %0, i32 %1, void (double*, double*, double*, [1 x double]*, double*, double*, i32)* %2) {
%4 = alloca i32
%5 = alloca double*
%6 = alloca i32
%7 = alloca void (double*, double*, double*, [1 x double]*, double*, double*, i32)*
%8 = alloca double
%9 = alloca double
%10 = alloca [1 x double]
%11 = alloca [1 x double]
%12 = alloca [1 x double]
%13 = alloca [1 x [1 x double]]
%14 = alloca double
%15 = alloca [1 x double]
%16 = alloca i32
%17 = alloca i32
%18 = alloca i32
%19 = alloca i32
%20 = alloca i32
%21 = alloca double
%22 = alloca double
%23 = alloca double
%24 = alloca double
%25 = alloca double
%26 = alloca double
%27 = alloca double
%28 = alloca double
%29 = alloca double
%30 = alloca i32
store double* %0, double** %5
store i32 %1, i32* %6
store void (double*, double*, double*, [1 x double]*, double*, double*, i32)* %2, void (double*, double*, double*, [1 x double]*, double*, double*, i32)** %7
store double 1.000000e+00, double* %14
store double 1.000000e+00, double* %8
store double 1.000000e+00, double* %9
store i32 0, i32* %20
store i32 0, i32* %19
store i32 0, i32* %17
br label %31
31: ; preds = %47, %3
%32 = load i32, i32* %17
%33 = load i32, i32* %6
%34 = icmp slt i32 %32, %33
br i1 %34, label %35, label %50
35: ; preds = %31
%36 = load double*, double** %5
%37 = load i32, i32* %17
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds double, double* %36, i64 %38
%40 = load double, double* %39
%41 = load i32, i32* %17
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds [1 x double], [1 x double]* %15, i64 0, i64 %42
store double %40, double* %43
%44 = load i32, i32* %17
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds [1 x double], [1 x double]* %11, i64 0, i64 %45
store double %40, double* %46
br label %47
47: ; preds = %35
%48 = load i32, i32* %17
%49 = add nsw i32 %48, 1
store i32 %49, i32* %17
br label %31
50: ; preds = %31
store double 0.000000e+00, double* %26
store double 0.000000e+00, double* %25
store double 0.000000e+00, double* %24
store double 0.000000e+00, double* %23
store i32 0, i32* %16
store i32 1, i32* %30
br label %51
51: ; preds = %176, %50
%52 = load i32, i32* %30
%53 = icmp ne i32 %52, 0
br i1 %53, label %54, label %179
54: ; preds = %51
%55 = load void (double*, double*, double*, [1 x double]*, double*, double*, i32)*, void (double*, double*, double*, [1 x double]*, double*, double*, i32)** %7
%56 = load double*, double** %5
%57 = getelementptr inbounds [1 x double], [1 x double]* %10, i64 0, i64 0
%58 = getelementptr inbounds [1 x double], [1 x double]* %12, i64 0, i64 0
%59 = getelementptr inbounds [1 x [1 x double]], [1 x [1 x double]]* %13, i64 0, i64 0
%60 = load i32, i32* %6
store double 0.000000e+00, double* %14
store i32 0, i32* %17
br label %61
61: ; preds = %74, %54
%62 = load i32, i32* %17
%63 = load i32, i32* %6
%64 = icmp slt i32 %62, %63
br i1 %64, label %65, label %77
65: ; preds = %61
%66 = load double*, double** %5
%67 = load i32, i32* %17
%68 = sext i32 %67 to i64
%69 = getelementptr inbounds double, double* %66, i64 %68
%70 = load double, double* %69
%71 = load i32, i32* %17
%72 = sext i32 %71 to i64
%73 = getelementptr inbounds [1 x double], [1 x double]* %11, i64 0, i64 %72
store double %70, double* %73
br label %74
74: ; preds = %65
%75 = load i32, i32* %17
%76 = add nsw i32 %75, 1
store i32 %76, i32* %17
br label %61
77: ; preds = %61
store i32 0, i32* %17
br label %78
78: ; preds = %93, %77
%79 = load i32, i32* %17
%80 = load i32, i32* %6
%81 = icmp slt i32 %79, %80
br i1 %81, label %82, label %96
82: ; preds = %78
%83 = load i32, i32* %17
%84 = sext i32 %83 to i64
%85 = getelementptr inbounds [1 x double], [1 x double]* %10, i64 0, i64 %84
%86 = load double, double* %85
%87 = load double*, double** %5
%88 = load i32, i32* %17
%89 = sext i32 %88 to i64
%90 = getelementptr inbounds double, double* %87, i64 %89
%91 = load double, double* %90
%92 = fadd double %91, %86
store double %92, double* %90
br label %93
93: ; preds = %82
%94 = load i32, i32* %17
%95 = add nsw i32 %94, 1
store i32 %95, i32* %17
br label %78
96: ; preds = %78
%97 = load double*, double** %5
%98 = getelementptr inbounds [1 x double], [1 x double]* %11, i64 0, i64 0
%99 = call i32 @validate_x(double* %97, double* %98)
%100 = load double, double* %25
store double %100, double* %26
%101 = load double*, double** %5
%102 = getelementptr inbounds double, double* %101, i64 0
%103 = load double, double* %102
%104 = call double @W_of_vsq(double %103, double* %28, double* %27, double* %29)
store double %104, double* %25
%105 = load double, double* %25
%106 = fcmp oeq double %105, 0.000000e+00
br i1 %106, label %107, label %112
107: ; preds = %96
%108 = load double, double* %25
%109 = load double, double* %26
%110 = fsub double %108, %109
%111 = call double @llvm.fabs.f64(double %110)
br label %119
112: ; preds = %96
%113 = load double, double* %25
%114 = load double, double* %26
%115 = fsub double %113, %114
%116 = load double, double* %25
%117 = fdiv double %115, %116
%118 = call double @llvm.fabs.f64(double %117)
br label %119
119: ; preds = %112, %107
%120 = phi double [ %111, %107 ], [ %118, %112 ]
store double %120, double* %14
%121 = load double*, double** %5
%122 = getelementptr inbounds double, double* %121, i64 0
%123 = load double, double* %122
%124 = fcmp oeq double %123, 0.000000e+00
br i1 %124, label %125, label %133
125: ; preds = %119
%126 = load double*, double** %5
%127 = getelementptr inbounds double, double* %126, i64 0
%128 = load double, double* %127
%129 = getelementptr inbounds [1 x double], [1 x double]* %11, i64 0, i64 0
%130 = load double, double* %129
%131 = fsub double %128, %130
%132 = call double @llvm.fabs.f64(double %131)
br label %145
133: ; preds = %119
%134 = load double*, double** %5
%135 = getelementptr inbounds double, double* %134, i64 0
%136 = load double, double* %135
%137 = getelementptr inbounds [1 x double], [1 x double]* %11, i64 0, i64 0
%138 = load double, double* %137
%139 = fsub double %136, %138
%140 = load double*, double** %5
%141 = getelementptr inbounds double, double* %140, i64 0
%142 = load double, double* %141
%143 = fdiv double %139, %142
%144 = call double @llvm.fabs.f64(double %143)
br label %145
145: ; preds = %133, %125
%146 = phi double [ %132, %125 ], [ %144, %133 ]
%147 = load double, double* %14
%148 = fadd double %147, %146
store double %148, double* %14
%149 = load double, double* %14
%150 = call double @llvm.fabs.f64(double %149)
%151 = fcmp ole double %150, 1.000000e-10
br i1 %151, label %152, label %156
152: ; preds = %145
%153 = load i32, i32* %20
%154 = icmp eq i32 %153, 0
br i1 %154, label %155, label %156
155: ; preds = %152
store i32 1, i32* %20
br label %156
156: ; preds = %155, %152, %145
%157 = load i32, i32* %20
%158 = icmp eq i32 %157, 1
br i1 %158, label %159, label %162
159: ; preds = %156
%160 = load i32, i32* %19
%161 = add nsw i32 %160, 1
store i32 %161, i32* %19
br label %162
162: ; preds = %159, %156
%163 = load double, double* %14
%164 = call double @llvm.fabs.f64(double %163)
%165 = fcmp ole double %164, 1.000000e-10
br i1 %165, label %166, label %169
166: ; preds = %162
%167 = load i32, i32* %20
%168 = icmp eq i32 %167, 0
br i1 %168, label %175, label %169
169: ; preds = %166, %162
%170 = load i32, i32* %19
%171 = icmp sgt i32 %170, 2
br i1 %171, label %175, label %172
172: ; preds = %169
%173 = load i32, i32* %16
%174 = icmp sge i32 %173, 29
br i1 %174, label %175, label %176
175: ; preds = %172, %169, %166
store i32 0, i32* %30
br label %176
176: ; preds = %175, %172
%177 = load i32, i32* %16
%178 = add nsw i32 %177, 1
store i32 %178, i32* %16
br label %51
179: ; preds = %51
%180 = load double, double* %8
%181 = call i64 @isfinite(double %180)
%182 = icmp eq i64 %181, 0
br i1 %182, label %187, label %183
183: ; preds = %179
%184 = load double, double* %9
%185 = call i64 @isfinite(double %184)
%186 = icmp eq i64 %185, 0
br i1 %186, label %187, label %188
187: ; preds = %183, %179
store i32 2, i32* %4
br label %208
188: ; preds = %183
%189 = load double, double* %14
%190 = call double @llvm.fabs.f64(double %189)
%191 = fcmp ogt double %190, 1.000000e-10
br i1 %191, label %192, label %193
192: ; preds = %188
store i32 1, i32* %4
br label %208
193: ; preds = %188
%194 = load double, double* %14
%195 = call double @llvm.fabs.f64(double %194)
%196 = fcmp ole double %195, 1.000000e-10
br i1 %196, label %197, label %202
197: ; preds = %193
%198 = load double, double* %14
%199 = call double @llvm.fabs.f64(double %198)
%200 = fcmp ogt double %199, 1.000000e-10
br i1 %200, label %201, label %202
201: ; preds = %197
store i32 0, i32* %4
br label %208
202: ; preds = %197, %193
%203 = load double, double* %14
%204 = call double @llvm.fabs.f64(double %203)
%205 = fcmp ole double %204, 1.000000e-10
br i1 %205, label %206, label %207
206: ; preds = %202
store i32 0, i32* %4
br label %208
207: ; preds = %202
store i32 0, i32* %4
br label %208
208: ; preds = %207, %206, %201, %192, %187
%209 = load i32, i32* %4
ret i32 %209
}

LLVM IR (-O2):
define i32 @general_newton_raphson(double* %0, i32 %1, void (double*, double*, double*, [1 x double]*, double*, double*, i32)* nocapture %2) {
%4 = alloca double
%5 = alloca double
%6 = alloca [1 x double]
%7 = alloca [1 x double]
%8 = alloca [1 x double]
%9 = alloca [1 x [1 x double]]
%10 = alloca double
%11 = alloca double
%12 = alloca double
%13 = bitcast double* %4 to i8*
%14 = bitcast double* %5 to i8*
%15 = bitcast [1 x double]* %6 to i8*
%16 = bitcast [1 x double]* %7 to i8*
%17 = bitcast [1 x double]* %8 to i8*
%18 = bitcast [1 x [1 x double]]* %9 to i8*
%19 = bitcast double* %10 to i8*
%20 = bitcast double* %11 to i8*
%21 = bitcast double* %12 to i8*
store double 1.000000e+00, double* %4
store double 1.000000e+00, double* %5
%22 = icmp sgt i32 %1, 0
br i1 %22, label %25, label %23
23: ; preds = %3
%24 = add i32 %1, -1
br label %31
25: ; preds = %3
%26 = getelementptr inbounds [1 x double], [1 x double]* %7, i64 0, i64 0
%27 = add nsw i32 %1, -1
%28 = zext i32 %27 to i64
%29 = getelementptr inbounds double, double* %0, i64 %28
%30 = load double, double* %29
store double %30, double* %26
br label %31
31: ; preds = %23, %25
%32 = phi i32 [ %24, %23 ], [ %27, %25 ]
%33 = getelementptr inbounds [1 x double], [1 x double]* %6, i64 0, i64 0
%34 = getelementptr inbounds [1 x double], [1 x double]* %8, i64 0, i64 0
%35 = getelementptr inbounds [1 x [1 x double]], [1 x [1 x double]]* %9, i64 0, i64 0
%36 = getelementptr inbounds [1 x double], [1 x double]* %7, i64 0, i64 0
%37 = zext i32 %32 to i64
%38 = getelementptr inbounds double, double* %0, i64 %37
%39 = zext i32 %1 to i64
%40 = and i64 %39, 4294967292
%41 = add nsw i64 %40, -4
%42 = lshr exact i64 %41, 2
%43 = add nuw nsw i64 %42, 1
%44 = icmp ult i32 %1, 4
%45 = and i64 %39, 4294967292
%46 = and i64 %43, 1
%47 = icmp eq i64 %41, 0
%48 = and i64 %43, 9223372036854775806
%49 = icmp eq i64 %46, 0
%50 = icmp eq i64 %45, %39
br label %51
51: ; preds = %31, %114
%52 = phi double [ 0.000000e+00, %31 ], [ %117, %114 ]
%53 = phi i32 [ 0, %31 ], [ %145, %114 ]
%54 = phi i32 [ 0, %31 ], [ %135, %114 ]
%55 = phi i32 [ 0, %31 ], [ %138, %114 ]
br i1 %22, label %56, label %114
56: ; preds = %51
%57 = load double, double* %38
store double %57, double* %36
%58 = load double, double* %33
br i1 %44, label %105, label %59
59: ; preds = %56
%60 = insertelement <2 x double> poison, double %58, i64 0
%61 = shufflevector <2 x double> %60, <2 x double> poison, <2 x i32> zeroinitializer
%62 = insertelement <2 x double> poison, double %58, i64 0
%63 = shufflevector <2 x double> %62, <2 x double> poison, <2 x i32> zeroinitializer
br i1 %47, label %91, label %64
64: ; preds = %59, %64
%65 = phi i64 [ %88, %64 ], [ 0, %59 ]
%66 = phi i64 [ %89, %64 ], [ 0, %59 ]
%67 = getelementptr inbounds double, double* %0, i64 %65
%68 = bitcast double* %67 to <2 x double>*
%69 = load <2 x double>, <2 x double>* %68
%70 = getelementptr inbounds double, double* %67, i64 2
%71 = bitcast double* %70 to <2 x double>*
%72 = load <2 x double>, <2 x double>* %71
%73 = fadd <2 x double> %61, %69
%74 = fadd <2 x double> %63, %72
%75 = bitcast double* %67 to <2 x double>*
store <2 x double> %73, <2 x double>* %75
%76 = bitcast double* %70 to <2 x double>*
store <2 x double> %74, <2 x double>* %76
%77 = or i64 %65, 4
%78 = getelementptr inbounds double, double* %0, i64 %77
%79 = bitcast double* %78 to <2 x double>*
%80 = load <2 x double>, <2 x double>* %79
%81 = getelementptr inbounds double, double* %78, i64 2
%82 = bitcast double* %81 to <2 x double>*
%83 = load <2 x double>, <2 x double>* %82
%84 = fadd <2 x double> %61, %80
%85 = fadd <2 x double> %63, %83
%86 = bitcast double* %78 to <2 x double>*
store <2 x double> %84, <2 x double>* %86
%87 = bitcast double* %81 to <2 x double>*
store <2 x double> %85, <2 x double>* %87
%88 = add nuw i64 %65, 8
%89 = add i64 %66, 2
%90 = icmp eq i64 %89, %48
br i1 %90, label %91, label %64
91: ; preds = %64, %59
%92 = phi i64 [ 0, %59 ], [ %88, %64 ]
br i1 %49, label %104, label %93
93: ; preds = %91
%94 = getelementptr inbounds double, double* %0, i64 %92
%95 = bitcast double* %94 to <2 x double>*
%96 = load <2 x double>, <2 x double>* %95
%97 = getelementptr inbounds double, double* %94, i64 2
%98 = bitcast double* %97 to <2 x double>*
%99 = load <2 x double>, <2 x double>* %98
%100 = fadd <2 x double> %61, %96
%101 = fadd <2 x double> %63, %99
%102 = bitcast double* %94 to <2 x double>*
store <2 x double> %100, <2 x double>* %102
%103 = bitcast double* %97 to <2 x double>*
store <2 x double> %101, <2 x double>* %103
br label %104
104: ; preds = %91, %93
br i1 %50, label %114, label %105
105: ; preds = %56, %104
%106 = phi i64 [ 0, %56 ], [ %45, %104 ]
br label %107
107: ; preds = %105, %107
%108 = phi i64 [ %112, %107 ], [ %106, %105 ]
%109 = getelementptr inbounds double, double* %0, i64 %108
%110 = load double, double* %109
%111 = fadd double %58, %110
store double %111, double* %109
%112 = add nuw nsw i64 %108, 1
%113 = icmp eq i64 %112, %39
br i1 %113, label %114, label %107
114: ; preds = %107, %104, %51
%115 = call i32 @validate_x(double* %0, double* %36)
%116 = load double, double* %0
%117 = call double @W_of_vsq(double %116, double* %11, double* %10, double* %12)
%118 = load double, double* %0
%119 = insertelement <2 x double> poison, double %117, i64 0
%120 = insertelement <2 x double> %119, double %118, i64 1
%121 = fcmp oeq <2 x double> %120, zeroinitializer
%122 = load double, double* %36
%123 = insertelement <2 x double> poison, double %52, i64 0
%124 = insertelement <2 x double> %123, double %122, i64 1
%125 = fsub <2 x double> %120, %124
%126 = select <2 x i1> %121, <2 x double> <double 1.000000e+00, double 1.000000e+00>, <2 x double> %120
%127 = fdiv <2 x double> %125, %126
%128 = call <2 x double> @llvm.fabs.v2f64(<2 x double> %127)
%129 = shufflevector <2 x double> %128, <2 x double> poison, <2 x i32> <i32 1, i32 undef>
%130 = fadd <2 x double> %128, %129
%131 = extractelement <2 x double> %130, i64 0
%132 = fcmp ole double %131, 1.000000e-10
%133 = icmp eq i32 %54, 0
%134 = select i1 %132, i1 %133, i1 false
%135 = select i1 %134, i32 1, i32 %54
%136 = icmp eq i32 %135, 1
%137 = zext i1 %136 to i32
%138 = add nuw nsw i32 %55, %137
%139 = icmp eq i32 %135, 0
%140 = icmp ugt i32 %138, 2
%141 = select i1 %132, i1 %139, i1 false
%142 = select i1 %141, i1 true, i1 %140
%143 = icmp ugt i32 %53, 28
%144 = select i1 %142, i1 true, i1 %143
%145 = add nuw nsw i32 %53, 1
br i1 %144, label %146, label %51
146: ; preds = %114
%147 = extractelement <2 x double> %130, i64 0
%148 = load double, double* %4
%149 = call i64 @isfinite(double %148)
%150 = icmp eq i64 %149, 0
br i1 %150, label %158, label %151
151: ; preds = %146
%152 = load double, double* %5
%153 = call i64 @isfinite(double %152)
%154 = icmp eq i64 %153, 0
br i1 %154, label %158, label %155
155: ; preds = %151
%156 = fcmp ogt double %147, 1.000000e-10
br i1 %156, label %158, label %157
157: ; preds = %155
br label %158
158: ; preds = %157, %155, %146, %151
%159 = phi i32 [ 2, %151 ], [ 2, %146 ], [ 1, %155 ], [ 0, %157 ]
ret i32 %159
}