#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 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[][2], double *, double *,
                                         int)) {
  double f, df, dx[2], x_old[2];
  double resid[2], jac[2][2];
  double errx, x_orig[2];
  int n_iter, id, jd, i_extra, doing_extra;
  double dW, dvsq, vsq_old, vsq, W, W_old;
  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];
    }
    errx = (x[0] == 0.) ? fabs(dx[0]) : fabs(dx[0] / x[0]);
    if (n > 1) {
      errx += (x[1] == 0.) ? fabs(dx[1]) : fabs(dx[1] / x[1]);
    }
    validate_x(x, x_old);
    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    $0x110,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %rdx,-0x20(%rbp)
movsd  0xec2(%rip),%xmm0
movsd  %xmm0,-0x88(%rbp)
ff
movsd  0xeb2(%rip),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  0xea5(%rip),%xmm0
movsd  %xmm0,-0x30(%rbp)
movl   $0x0,-0xb4(%rbp)
movl   $0x0,-0xb0(%rbp)
movl   $0x0,-0xa8(%rbp)
mov    -0xa8(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11ce <general_newton_raphson+0xae>
mov    -0x10(%rbp),%rax
movslq -0xa8(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movslq -0xa8(%rbp),%rax
movsd  %xmm0,-0xa0(%rbp,%rax,8)
ff ff
movslq -0xa8(%rbp),%rax
movsd  %xmm0,-0x50(%rbp,%rax,8)
mov    -0xa8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xa8(%rbp)
jmp    117e <general_newton_raphson+0x5e>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0xe8(%rbp)
ff
xorps  %xmm0,%xmm0
movsd  %xmm0,-0xe0(%rbp)
ff
xorps  %xmm0,%xmm0
movsd  %xmm0,-0xd8(%rbp)
ff
xorps  %xmm0,%xmm0
movsd  %xmm0,-0xd0(%rbp)
ff
movl   $0x0,-0xa4(%rbp)
movl   $0x1,-0xec(%rbp)
cmpl   $0x0,-0xec(%rbp)
je     1498 <general_newton_raphson+0x378>
mov    -0x20(%rbp),%rax
mov    -0x10(%rbp),%rdi
lea    -0x40(%rbp),%rsi
lea    -0x60(%rbp),%rdx
lea    -0x80(%rbp),%rcx
mov    -0x14(%rbp),%r10d
lea    -0x28(%rbp),%r8
lea    -0x30(%rbp),%r9
mov    %r10d,(%rsp)
call   *%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x88(%rbp)
ff
movl   $0x0,-0xa8(%rbp)
mov    -0xa8(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1296 <general_newton_raphson+0x176>
mov    -0x10(%rbp),%rax
movslq -0xa8(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movslq -0xa8(%rbp),%rax
movsd  %xmm0,-0x50(%rbp,%rax,8)
mov    -0xa8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xa8(%rbp)
jmp    1256 <general_newton_raphson+0x136>
movl   $0x0,-0xa8(%rbp)
mov    -0xa8(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    12e5 <general_newton_raphson+0x1c5>
movslq -0xa8(%rbp),%rax
movsd  -0x40(%rbp,%rax,8),%xmm0
mov    -0x10(%rbp),%rax
movslq -0xa8(%rbp),%rcx
addsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0xa8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xa8(%rbp)
jmp    12a0 <general_newton_raphson+0x180>
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    131d <general_newton_raphson+0x1fd>
jp     131d <general_newton_raphson+0x1fd>
movsd  -0x40(%rbp),%xmm0
movaps 0xd04(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  %xmm0,-0xf8(%rbp)
ff
jmp    133d <general_newton_raphson+0x21d>
movsd  -0x40(%rbp),%xmm0
mov    -0x10(%rbp),%rax
divsd  (%rax),%xmm0
movaps 0xcdf(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  %xmm0,-0xf8(%rbp)
ff
movsd  -0xf8(%rbp),%xmm0
ff
movsd  %xmm0,-0x88(%rbp)
ff
cmpl   $0x1,-0x14(%rbp)
jle    13c9 <general_newton_raphson+0x2a9>
mov    -0x10(%rbp),%rax
movsd  0x8(%rax),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    1390 <general_newton_raphson+0x270>
jp     1390 <general_newton_raphson+0x270>
movsd  -0x38(%rbp),%xmm0
movaps 0xc91(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  %xmm0,-0x100(%rbp)
ff
jmp    13b1 <general_newton_raphson+0x291>
movsd  -0x38(%rbp),%xmm0
mov    -0x10(%rbp),%rax
divsd  0x8(%rax),%xmm0
movaps 0xc6b(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  %xmm0,-0x100(%rbp)
ff
movsd  -0x100(%rbp),%xmm0
ff
addsd  -0x88(%rbp),%xmm0
ff
movsd  %xmm0,-0x88(%rbp)
ff
mov    -0x10(%rbp),%rdi
lea    -0x50(%rbp),%rsi
call   1040 <validate_x@plt>
movsd  -0x88(%rbp),%xmm1
ff
movaps 0xc2b(%rip),%xmm0
pand   %xmm0,%xmm1
movsd  0xc17(%rip),%xmm0
ucomisd %xmm1,%xmm0
jb     1412 <general_newton_raphson+0x2f2>
cmpl   $0x0,-0xb4(%rbp)
jne    1412 <general_newton_raphson+0x2f2>
movl   $0x1,-0xb4(%rbp)
cmpl   $0x1,-0xb4(%rbp)
jne    142e <general_newton_raphson+0x30e>
mov    -0xb0(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xb0(%rbp)
movsd  -0x88(%rbp),%xmm1
ff
movaps 0xbd3(%rip),%xmm0
pand   %xmm0,%xmm1
movsd  0xbbf(%rip),%xmm0
ucomisd %xmm1,%xmm0
jb     1460 <general_newton_raphson+0x340>
cmpl   $0x0,-0xb4(%rbp)
je     147a <general_newton_raphson+0x35a>
cmpl   $0x2,-0xb0(%rbp)
jg     147a <general_newton_raphson+0x35a>
cmpl   $0x1d,-0xa4(%rbp)
jl     1484 <general_newton_raphson+0x364>
movl   $0x0,-0xec(%rbp)
mov    -0xa4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xa4(%rbp)
jmp    120e <general_newton_raphson+0xee>
movsd  -0x28(%rbp),%xmm0
call   1030 <isfinite@plt>
cmp    $0x0,%rax
je     14c0 <general_newton_raphson+0x3a0>
movsd  -0x30(%rbp),%xmm0
call   1030 <isfinite@plt>
cmp    $0x0,%rax
jne    14cc <general_newton_raphson+0x3ac>
movl   $0x2,-0x4(%rbp)
jmp    158b <general_newton_raphson+0x46b>
movsd  -0x88(%rbp),%xmm0
ff
movaps 0xb35(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  0xb21(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    14fd <general_newton_raphson+0x3dd>
movl   $0x1,-0x4(%rbp)
jmp    158b <general_newton_raphson+0x46b>
movsd  -0x88(%rbp),%xmm1
ff
movaps 0xb04(%rip),%xmm0
pand   %xmm0,%xmm1
movsd  0xaf0(%rip),%xmm0
ucomisd %xmm1,%xmm0
jb     1553 <general_newton_raphson+0x433>
movsd  -0x88(%rbp),%xmm0
ff
movaps 0xadf(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  0xacb(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    1553 <general_newton_raphson+0x433>
movl   $0x0,-0x4(%rbp)
jmp    158b <general_newton_raphson+0x46b>
movsd  -0x88(%rbp),%xmm1
ff
movaps 0xaae(%rip),%xmm0
pand   %xmm0,%xmm1
movsd  0xa9a(%rip),%xmm0
ucomisd %xmm1,%xmm0
jb     1584 <general_newton_raphson+0x464>
movl   $0x0,-0x4(%rbp)
jmp    158b <general_newton_raphson+0x46b>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x110,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<general_newton_raphson>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xb8,%rsp
mov    %rdx,0x68(%rsp)
mov    %esi,%ebp
mov    %rdi,%rbx
movabs $0x3ff0000000000000,%rax
mov    %rax,0x28(%rsp)
mov    %rax,0x20(%rsp)
mov    %esi,%r12d
lea    0x0(,%r12,8),%r14
test   %esi,%esi
jle    117e <general_newton_raphson+0x4e>
lea    0x70(%rsp),%rdi
mov    %rbx,%rsi
mov    %r14,%rdx
call   1030 <memcpy@plt>
mov    %r14,0x60(%rsp)
mov    %r12d,%eax
and    $0xfffffffc,%eax
mov    %rax,0x58(%rsp)
add    $0xfffffffffffffffc,%rax
mov    %rax,0x50(%rsp)
mov    %rax,%rcx
shr    $0x2,%rcx
add    $0x1,%rcx
mov    %rcx,%rax
mov    %rcx,0x48(%rsp)
and    $0xfffffffffffffffe,%rcx
mov    %rcx,0x40(%rsp)
xor    %r15d,%r15d
xor    %r13d,%r13d
xor    %r14d,%r14d
nopl   0x0(%rax)
mov    %ebp,(%rsp)
mov    %rbx,%rdi
lea    0x10(%rsp),%rsi
lea    0x80(%rsp),%rdx
lea    0x90(%rsp),%rcx
lea    0x28(%rsp),%r8
lea    0x20(%rsp),%r9
call   *0x68(%rsp)
test   %ebp,%ebp
jle    12d9 <general_newton_raphson+0x1a9>
lea    0x70(%rsp),%rdi
mov    %rbx,%rsi
mov    0x60(%rsp),%rdx
call   1030 <memcpy@plt>
cmp    $0x4,%ebp
jae    1210 <general_newton_raphson+0xe0>
xor    %eax,%eax
jmp    12c0 <general_newton_raphson+0x190>
nop
cmpq   $0x0,0x50(%rsp)
je     13d2 <general_newton_raphson+0x2a2>
mov    0x40(%rsp),%rcx
xor    %eax,%eax
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movupd (%rbx,%rax,8),%xmm0
movupd 0x10(%rbx,%rax,8),%xmm1
movupd 0x20(%rbx,%rax,8),%xmm2
movupd 0x30(%rbx,%rax,8),%xmm3
addpd  0x10(%rsp,%rax,8),%xmm0
addpd  0x20(%rsp,%rax,8),%xmm1
movupd %xmm0,(%rbx,%rax,8)
movupd %xmm1,0x10(%rbx,%rax,8)
addpd  0x30(%rsp,%rax,8),%xmm2
addpd  0x40(%rsp,%rax,8),%xmm3
movupd %xmm2,0x20(%rbx,%rax,8)
movupd %xmm3,0x30(%rbx,%rax,8)
add    $0x8,%rax
add    $0xfffffffffffffffe,%rcx
jne    1230 <general_newton_raphson+0x100>
testb  $0x1,0x48(%rsp)
je     12a9 <general_newton_raphson+0x179>
movupd (%rbx,%rax,8),%xmm0
movupd 0x10(%rbx,%rax,8),%xmm1
addpd  0x10(%rsp,%rax,8),%xmm0
addpd  0x20(%rsp,%rax,8),%xmm1
movupd %xmm0,(%rbx,%rax,8)
movupd %xmm1,0x10(%rbx,%rax,8)
mov    0x58(%rsp),%rcx
mov    %rcx,%rax
cmp    %r12,%rcx
je     12d9 <general_newton_raphson+0x1a9>
cs nopw 0x0(%rax,%rax,1)
movsd  0x10(%rsp,%rax,8),%xmm0
addsd  (%rbx,%rax,8),%xmm0
movsd  %xmm0,(%rbx,%rax,8)
add    $0x1,%rax
cmp    %rax,%r12
jne    12c0 <general_newton_raphson+0x190>
movsd  (%rbx),%xmm0
movsd  0x10(%rsp),%xmm6
movapd %xmm0,%xmm1
cmpeqsd 0xd20(%rip),%xmm1
movapd %xmm1,%xmm2
movsd  0xd04(%rip),%xmm3
andpd  %xmm3,%xmm2
andnpd %xmm0,%xmm1
orpd   %xmm2,%xmm1
divsd  %xmm1,%xmm6
movapd 0xd0c(%rip),%xmm5
andpd  %xmm5,%xmm6
cmp    $0x2,%ebp
jl     1359 <general_newton_raphson+0x229>
movsd  0x8(%rbx),%xmm0
movsd  0x18(%rsp),%xmm1
movapd %xmm0,%xmm2
cmpeqsd 0xcdb(%rip),%xmm2
movapd %xmm2,%xmm3
movsd  0xcbf(%rip),%xmm4
andpd  %xmm4,%xmm3
andnpd %xmm0,%xmm2
orpd   %xmm3,%xmm2
divsd  %xmm2,%xmm1
andpd  %xmm5,%xmm1
addsd  %xmm1,%xmm6
movapd %xmm6,0x30(%rsp)
mov    %rbx,%rdi
lea    0x70(%rsp),%rsi
call   1050 <validate_x@plt>
movapd 0x30(%rsp),%xmm1
movapd 0xca6(%rip),%xmm0
test   %r14d,%r14d
mov    %r14d,%eax
mov    $0x1,%ecx
cmove  %ecx,%eax
andpd  %xmm0,%xmm1
movsd  0xc74(%rip),%xmm0
ucomisd %xmm1,%xmm0
setae  %sil
cmovae %eax,%r14d
xor    %eax,%eax
cmp    $0x1,%r14d
sete   %cl
test   %r14d,%r14d
sete   %dl
test   %dl,%sil
jne    13e4 <general_newton_raphson+0x2b4>
mov    %cl,%al
add    %eax,%r13d
cmp    $0x2,%r13d
ja     13e4 <general_newton_raphson+0x2b4>
lea    0x1(%r15),%eax
cmp    $0x1d,%r15d
mov    %eax,%r15d
jb     11c0 <general_newton_raphson+0x90>
jmp    13e4 <general_newton_raphson+0x2b4>
xor    %eax,%eax
testb  $0x1,0x48(%rsp)
jne    1287 <general_newton_raphson+0x157>
jmp    12a9 <general_newton_raphson+0x179>
movapd %xmm1,0x30(%rsp)
movsd  0x28(%rsp),%xmm0
call   1040 <isfinite@plt>
mov    $0x2,%ebx
test   %rax,%rax
je     1426 <general_newton_raphson+0x2f6>
movsd  0x20(%rsp),%xmm0
call   1040 <isfinite@plt>
test   %rax,%rax
je     1426 <general_newton_raphson+0x2f6>
mov    $0x1,%ebx
movapd 0x30(%rsp),%xmm0
ucomisd 0xbe6(%rip),%xmm0
ja     1426 <general_newton_raphson+0x2f6>
xor    %ebx,%ebx
mov    %ebx,%eax
add    $0xb8,%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*, [2 x double]*, double*, double*, i32)* %2) {
%4 = alloca i32
%5 = alloca double*
%6 = alloca i32
%7 = alloca void (double*, double*, double*, [2 x double]*, double*, double*, i32)*
%8 = alloca double
%9 = alloca double
%10 = alloca [2 x double]
%11 = alloca [2 x double]
%12 = alloca [2 x double]
%13 = alloca [2 x [2 x double]]
%14 = alloca double
%15 = alloca [2 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 i32
store double* %0, double** %5
store i32 %1, i32* %6
store void (double*, double*, double*, [2 x double]*, double*, double*, i32)* %2, void (double*, double*, double*, [2 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 %28
28: ; preds = %44, %3
%29 = load i32, i32* %17
%30 = load i32, i32* %6
%31 = icmp slt i32 %29, %30
br i1 %31, label %32, label %47
32: ; preds = %28
%33 = load double*, double** %5
%34 = load i32, i32* %17
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds double, double* %33, i64 %35
%37 = load double, double* %36
%38 = load i32, i32* %17
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds [2 x double], [2 x double]* %15, i64 0, i64 %39
store double %37, double* %40
%41 = load i32, i32* %17
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds [2 x double], [2 x double]* %11, i64 0, i64 %42
store double %37, double* %43
br label %44
44: ; preds = %32
%45 = load i32, i32* %17
%46 = add nsw i32 %45, 1
store i32 %46, i32* %17
br label %28
47: ; preds = %28
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* %27
br label %48
48: ; preds = %166, %47
%49 = load i32, i32* %27
%50 = icmp ne i32 %49, 0
br i1 %50, label %51, label %169
51: ; preds = %48
%52 = load void (double*, double*, double*, [2 x double]*, double*, double*, i32)*, void (double*, double*, double*, [2 x double]*, double*, double*, i32)** %7
%53 = load double*, double** %5
%54 = getelementptr inbounds [2 x double], [2 x double]* %10, i64 0, i64 0
%55 = getelementptr inbounds [2 x double], [2 x double]* %12, i64 0, i64 0
%56 = getelementptr inbounds [2 x [2 x double]], [2 x [2 x double]]* %13, i64 0, i64 0
%57 = load i32, i32* %6
store double 0.000000e+00, double* %14
store i32 0, i32* %17
br label %58
58: ; preds = %71, %51
%59 = load i32, i32* %17
%60 = load i32, i32* %6
%61 = icmp slt i32 %59, %60
br i1 %61, label %62, label %74
62: ; preds = %58
%63 = load double*, double** %5
%64 = load i32, i32* %17
%65 = sext i32 %64 to i64
%66 = getelementptr inbounds double, double* %63, i64 %65
%67 = load double, double* %66
%68 = load i32, i32* %17
%69 = sext i32 %68 to i64
%70 = getelementptr inbounds [2 x double], [2 x double]* %11, i64 0, i64 %69
store double %67, double* %70
br label %71
71: ; preds = %62
%72 = load i32, i32* %17
%73 = add nsw i32 %72, 1
store i32 %73, i32* %17
br label %58
74: ; preds = %58
store i32 0, i32* %17
br label %75
75: ; preds = %90, %74
%76 = load i32, i32* %17
%77 = load i32, i32* %6
%78 = icmp slt i32 %76, %77
br i1 %78, label %79, label %93
79: ; preds = %75
%80 = load i32, i32* %17
%81 = sext i32 %80 to i64
%82 = getelementptr inbounds [2 x double], [2 x double]* %10, i64 0, i64 %81
%83 = load double, double* %82
%84 = load double*, double** %5
%85 = load i32, i32* %17
%86 = sext i32 %85 to i64
%87 = getelementptr inbounds double, double* %84, i64 %86
%88 = load double, double* %87
%89 = fadd double %88, %83
store double %89, double* %87
br label %90
90: ; preds = %79
%91 = load i32, i32* %17
%92 = add nsw i32 %91, 1
store i32 %92, i32* %17
br label %75
93: ; preds = %75
%94 = load double*, double** %5
%95 = getelementptr inbounds double, double* %94, i64 0
%96 = load double, double* %95
%97 = fcmp oeq double %96, 0.000000e+00
br i1 %97, label %98, label %102
98: ; preds = %93
%99 = getelementptr inbounds [2 x double], [2 x double]* %10, i64 0, i64 0
%100 = load double, double* %99
%101 = call double @llvm.fabs.f64(double %100)
br label %110
102: ; preds = %93
%103 = getelementptr inbounds [2 x double], [2 x double]* %10, i64 0, i64 0
%104 = load double, double* %103
%105 = load double*, double** %5
%106 = getelementptr inbounds double, double* %105, i64 0
%107 = load double, double* %106
%108 = fdiv double %104, %107
%109 = call double @llvm.fabs.f64(double %108)
br label %110
110: ; preds = %102, %98
%111 = phi double [ %101, %98 ], [ %109, %102 ]
store double %111, double* %14
%112 = load i32, i32* %6
%113 = icmp sgt i32 %112, 1
br i1 %113, label %114, label %135
114: ; preds = %110
%115 = load double*, double** %5
%116 = getelementptr inbounds double, double* %115, i64 1
%117 = load double, double* %116
%118 = fcmp oeq double %117, 0.000000e+00
br i1 %118, label %119, label %123
119: ; preds = %114
%120 = getelementptr inbounds [2 x double], [2 x double]* %10, i64 0, i64 1
%121 = load double, double* %120
%122 = call double @llvm.fabs.f64(double %121)
br label %131
123: ; preds = %114
%124 = getelementptr inbounds [2 x double], [2 x double]* %10, i64 0, i64 1
%125 = load double, double* %124
%126 = load double*, double** %5
%127 = getelementptr inbounds double, double* %126, i64 1
%128 = load double, double* %127
%129 = fdiv double %125, %128
%130 = call double @llvm.fabs.f64(double %129)
br label %131
131: ; preds = %123, %119
%132 = phi double [ %122, %119 ], [ %130, %123 ]
%133 = load double, double* %14
%134 = fadd double %133, %132
store double %134, double* %14
br label %135
135: ; preds = %131, %110
%136 = load double*, double** %5
%137 = getelementptr inbounds [2 x double], [2 x double]* %11, i64 0, i64 0
%138 = call i32 @validate_x(double* %136, double* %137)
%139 = load double, double* %14
%140 = call double @llvm.fabs.f64(double %139)
%141 = fcmp ole double %140, 1.000000e-10
br i1 %141, label %142, label %146
142: ; preds = %135
%143 = load i32, i32* %20
%144 = icmp eq i32 %143, 0
br i1 %144, label %145, label %146
145: ; preds = %142
store i32 1, i32* %20
br label %146
146: ; preds = %145, %142, %135
%147 = load i32, i32* %20
%148 = icmp eq i32 %147, 1
br i1 %148, label %149, label %152
149: ; preds = %146
%150 = load i32, i32* %19
%151 = add nsw i32 %150, 1
store i32 %151, i32* %19
br label %152
152: ; preds = %149, %146
%153 = load double, double* %14
%154 = call double @llvm.fabs.f64(double %153)
%155 = fcmp ole double %154, 1.000000e-10
br i1 %155, label %156, label %159
156: ; preds = %152
%157 = load i32, i32* %20
%158 = icmp eq i32 %157, 0
br i1 %158, label %165, label %159
159: ; preds = %156, %152
%160 = load i32, i32* %19
%161 = icmp sgt i32 %160, 2
br i1 %161, label %165, label %162
162: ; preds = %159
%163 = load i32, i32* %16
%164 = icmp sge i32 %163, 29
br i1 %164, label %165, label %166
165: ; preds = %162, %159, %156
store i32 0, i32* %27
br label %166
166: ; preds = %165, %162
%167 = load i32, i32* %16
%168 = add nsw i32 %167, 1
store i32 %168, i32* %16
br label %48
169: ; preds = %48
%170 = load double, double* %8
%171 = call i64 @isfinite(double %170)
%172 = icmp eq i64 %171, 0
br i1 %172, label %177, label %173
173: ; preds = %169
%174 = load double, double* %9
%175 = call i64 @isfinite(double %174)
%176 = icmp eq i64 %175, 0
br i1 %176, label %177, label %178
177: ; preds = %173, %169
store i32 2, i32* %4
br label %198
178: ; preds = %173
%179 = load double, double* %14
%180 = call double @llvm.fabs.f64(double %179)
%181 = fcmp ogt double %180, 1.000000e-10
br i1 %181, label %182, label %183
182: ; preds = %178
store i32 1, i32* %4
br label %198
183: ; preds = %178
%184 = load double, double* %14
%185 = call double @llvm.fabs.f64(double %184)
%186 = fcmp ole double %185, 1.000000e-10
br i1 %186, label %187, label %192
187: ; preds = %183
%188 = load double, double* %14
%189 = call double @llvm.fabs.f64(double %188)
%190 = fcmp ogt double %189, 1.000000e-10
br i1 %190, label %191, label %192
191: ; preds = %187
store i32 0, i32* %4
br label %198
192: ; preds = %187, %183
%193 = load double, double* %14
%194 = call double @llvm.fabs.f64(double %193)
%195 = fcmp ole double %194, 1.000000e-10
br i1 %195, label %196, label %197
196: ; preds = %192
store i32 0, i32* %4
br label %198
197: ; preds = %192
store i32 0, i32* %4
br label %198
198: ; preds = %197, %196, %191, %182, %177
%199 = load i32, i32* %4
ret i32 %199
}

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