#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 solvePol(double, int, double *, double *);
double getNextNewton(double x, int size, double *coef, double *exp,
                     double *dCoef, double *dExp) {
  double f, dF;
  f = solvePol(x, size, coef, exp);
  dF = solvePol(x, size, dCoef, dExp);
  if (dF != 0)
    return x - f / dF;
  return x;
}


x86 assembly (clang, -O0):
<getNextNewton>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movsd  %xmm0,-0x10(%rbp)
mov    %edi,-0x14(%rbp)
mov    %rsi,-0x20(%rbp)
mov    %rdx,-0x28(%rbp)
mov    %rcx,-0x30(%rbp)
mov    %r8,-0x38(%rbp)
movsd  -0x10(%rbp),%xmm0
mov    -0x14(%rbp),%edi
mov    -0x20(%rbp),%rsi
mov    -0x28(%rbp),%rdx
call   1030 <solvePol@plt>
movsd  %xmm0,-0x40(%rbp)
movsd  -0x10(%rbp),%xmm0
mov    -0x14(%rbp),%edi
mov    -0x30(%rbp),%rsi
mov    -0x38(%rbp),%rdx
call   1030 <solvePol@plt>
movsd  %xmm0,-0x48(%rbp)
movsd  -0x48(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    1181 <getNextNewton+0x71>
jp     1181 <getNextNewton+0x71>
jmp    119e <getNextNewton+0x8e>
movsd  -0x10(%rbp),%xmm0
movsd  -0x40(%rbp),%xmm1
divsd  -0x48(%rbp),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11a8 <getNextNewton+0x98>
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getNextNewton>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %r8,%r14
mov    %rcx,%rbx
mov    %edi,%ebp
movsd  %xmm0,(%rsp)
call   1030 <solvePol@plt>
movsd  %xmm0,0x8(%rsp)
movsd  (%rsp),%xmm0
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r14,%rdx
call   1030 <solvePol@plt>
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    114e <getNextNewton+0x3e>
jnp    1163 <getNextNewton+0x53>
movsd  0x8(%rsp),%xmm1
divsd  %xmm0,%xmm1
movsd  (%rsp),%xmm0
subsd  %xmm1,%xmm0
jmp    1168 <getNextNewton+0x58>
movsd  (%rsp),%xmm0
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define double @getNextNewton(double %0, i32 %1, double* %2, double* %3, double* %4, double* %5) {
%7 = alloca double
%8 = alloca double
%9 = alloca i32
%10 = alloca double*
%11 = alloca double*
%12 = alloca double*
%13 = alloca double*
%14 = alloca double
%15 = alloca double
store double %0, double* %8
store i32 %1, i32* %9
store double* %2, double** %10
store double* %3, double** %11
store double* %4, double** %12
store double* %5, double** %13
%16 = load double, double* %8
%17 = load i32, i32* %9
%18 = load double*, double** %10
%19 = load double*, double** %11
%20 = call double @solvePol(double %16, i32 %17, double* %18, double* %19)
store double %20, double* %14
%21 = load double, double* %8
%22 = load i32, i32* %9
%23 = load double*, double** %12
%24 = load double*, double** %13
%25 = call double @solvePol(double %21, i32 %22, double* %23, double* %24)
store double %25, double* %15
%26 = load double, double* %15
%27 = fcmp une double %26, 0.000000e+00
br i1 %27, label %28, label %34
28: ; preds = %6
%29 = load double, double* %8
%30 = load double, double* %14
%31 = load double, double* %15
%32 = fdiv double %30, %31
%33 = fsub double %29, %32
store double %33, double* %7
br label %36
34: ; preds = %6
%35 = load double, double* %8
store double %35, double* %7
br label %36
36: ; preds = %34, %28
%37 = load double, double* %7
ret double %37
}

LLVM IR (-O2):
define double @getNextNewton(double %0, i32 %1, double* %2, double* %3, double* %4, double* %5) {
%7 = tail call double @solvePol(double %0, i32 %1, double* %2, double* %3)
%8 = tail call double @solvePol(double %0, i32 %1, double* %4, double* %5)
%9 = fcmp une double %8, 0.000000e+00
br i1 %9, label %10, label %13
10: ; preds = %6
%11 = fdiv double %7, %8
%12 = fsub double %0, %11
br label %13
13: ; preds = %6, %10
%14 = phi double [ %12, %10 ], [ %0, %6 ]
ret double %14
}