#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 */
int /*<<< orphan*/ DividedDifferences(double const *, double const *, int,
                                      double *);
int /*<<< orphan*/ NewtonPolynomialInterpolation(double const *, double *, int,
                                                 double const *, double *, int);
int /*<<< orphan*/ assert(int);
int /*<<< orphan*/ free(double *);
double *malloc(int);
int SimpleNewtonPolynomialInterpolation(const double *x, const double *fx,
                                        int n, const double *z, double *pz,
                                        int m) {
  double *slopes = NULL;
  assert(n > 0);
  slopes = malloc(n * sizeof(double));
  if (slopes == NULL)
    return 1;
  DividedDifferences(x, fx, n, slopes);
  NewtonPolynomialInterpolation(x, slopes, n, z, pz, m);
  free(slopes);
  return 0;
}


x86 assembly (clang, -O0):
<SimpleNewtonPolynomialInterpolation>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8,-0x30(%rbp)
mov    %r9d,-0x34(%rbp)
movq   $0x0,-0x40(%rbp)
cmpl   $0x0,-0x1c(%rbp)
setg   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
movslq -0x1c(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1070 <malloc@plt>
mov    %rax,-0x40(%rbp)
cmpq   $0x0,-0x40(%rbp)
jne    11b2 <SimpleNewtonPolynomialInterpolation+0x62>
movl   $0x1,-0x4(%rbp)
jmp    11f2 <SimpleNewtonPolynomialInterpolation+0xa2>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x1c(%rbp),%edx
mov    -0x40(%rbp),%rcx
call   1050 <DividedDifferences@plt>
mov    -0x10(%rbp),%rdi
mov    -0x40(%rbp),%rsi
mov    -0x1c(%rbp),%edx
mov    -0x28(%rbp),%rcx
mov    -0x30(%rbp),%r8
mov    -0x34(%rbp),%r9d
call   1040 <NewtonPolynomialInterpolation@plt>
mov    -0x40(%rbp),%rdi
call   1030 <free@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<SimpleNewtonPolynomialInterpolation>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r9d,0x4(%rsp)
mov    %r8,%r15
mov    %rcx,%r12
mov    %edx,%ebx
mov    %rsi,%r13
mov    %rdi,%rbp
xor    %edi,%edi
test   %edx,%edx
setg   %dil
call   1060 <assert@plt>
lea    0x0(,%rbx,8),%edi
call   1070 <malloc@plt>
test   %rax,%rax
je     11c3 <SimpleNewtonPolynomialInterpolation+0x73>
mov    %rax,%r14
mov    %rbp,%rdi
mov    %r13,%rsi
mov    %ebx,%edx
mov    %rax,%rcx
call   1050 <DividedDifferences@plt>
mov    %rbp,%rdi
mov    %r14,%rsi
mov    %ebx,%edx
mov    %r12,%rcx
mov    %r15,%r8
mov    0x4(%rsp),%r9d
call   1040 <NewtonPolynomialInterpolation@plt>
mov    %r14,%rdi
call   1030 <free@plt>
xor    %eax,%eax
jmp    11c8 <SimpleNewtonPolynomialInterpolation+0x78>
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @SimpleNewtonPolynomialInterpolation(double* %0, double* %1, i32 %2, double* %3, double* %4, i32 %5) {
%7 = alloca i32
%8 = alloca double*
%9 = alloca double*
%10 = alloca i32
%11 = alloca double*
%12 = alloca double*
%13 = alloca i32
%14 = alloca double*
store double* %0, double** %8
store double* %1, double** %9
store i32 %2, i32* %10
store double* %3, double** %11
store double* %4, double** %12
store i32 %5, i32* %13
store double* null, double** %14
%15 = load i32, i32* %10
%16 = icmp sgt i32 %15, 0
%17 = zext i1 %16 to i32
%18 = call i32 @assert(i32 %17)
%19 = load i32, i32* %10
%20 = sext i32 %19 to i64
%21 = mul i64 %20, 8
%22 = trunc i64 %21 to i32
%23 = call double* @malloc(i32 %22)
store double* %23, double** %14
%24 = load double*, double** %14
%25 = icmp eq double* %24, null
br i1 %25, label %26, label %27
26: ; preds = %6
store i32 1, i32* %7
br label %42
27: ; preds = %6
%28 = load double*, double** %8
%29 = load double*, double** %9
%30 = load i32, i32* %10
%31 = load double*, double** %14
%32 = call i32 @DividedDifferences(double* %28, double* %29, i32 %30, double* %31)
%33 = load double*, double** %8
%34 = load double*, double** %14
%35 = load i32, i32* %10
%36 = load double*, double** %11
%37 = load double*, double** %12
%38 = load i32, i32* %13
%39 = call i32 @NewtonPolynomialInterpolation(double* %33, double* %34, i32 %35, double* %36, double* %37, i32 %38)
%40 = load double*, double** %14
%41 = call i32 @free(double* %40)
store i32 0, i32* %7
br label %42
42: ; preds = %27, %26
%43 = load i32, i32* %7
ret i32 %43
}

LLVM IR (-O2):
define i32 @SimpleNewtonPolynomialInterpolation(double* %0, double* %1, i32 %2, double* %3, double* %4, i32 %5) {
%7 = icmp sgt i32 %2, 0
%8 = zext i1 %7 to i32
%9 = tail call i32 @assert(i32 %8)
%10 = shl i32 %2, 3
%11 = tail call double* @malloc(i32 %10)
%12 = icmp eq double* %11, null
br i1 %12, label %17, label %13
13: ; preds = %6
%14 = tail call i32 @DividedDifferences(double* %0, double* %1, i32 %2, double* %11)
%15 = tail call i32 @NewtonPolynomialInterpolation(double* %0, double* %11, i32 %2, double* %3, double* %4, i32 %5)
%16 = tail call i32 @free(double* %11)
br label %17
17: ; preds = %6, %13
%18 = phi i32 [ 0, %13 ], [ 1, %6 ]
ret i32 %18
}