#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*/ derivatePol(int, double *, double *, double *, double *);
int /*<<< orphan*/ free(double *);
double getNextNewton(double, int, double *, double *, double *, double *);
double *malloc(int);
double getMin(int size, double *coef, double *exp) {
  double *dCoef, *dExp;
  dCoef = malloc(sizeof(double) * size);
  dExp = malloc(sizeof(double) * size);
  derivatePol(size, coef, exp, dCoef, dExp);
  double x = 3.1415;
  double oldX = x + 1;
  while (x != oldX) {
    oldX = x;
    x = getNextNewton(x, size, coef, exp, dCoef, dExp);
  }
  free(dCoef);
  free(dExp);
  return x;
}


x86 assembly (clang, -O0):
<getMin>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movslq -0x4(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,-0x20(%rbp)
movslq -0x4(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,-0x28(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
mov    -0x28(%rbp),%r8
call   1050 <derivatePol@plt>
movsd  0xe6f(%rip),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  0xe5a(%rip),%xmm0
addsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x30(%rbp),%xmm0
ucomisd -0x38(%rbp),%xmm0
jne    11cb <getMin+0x8b>
jp     11cb <getMin+0x8b>
jmp    11fc <getMin+0xbc>
movsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x30(%rbp),%xmm0
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
mov    -0x28(%rbp),%r8
call   1040 <getNextNewton@plt>
movsd  %xmm0,-0x30(%rbp)
jmp    11b0 <getMin+0x70>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
movsd  -0x30(%rbp),%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getMin>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %rdx,%r14
mov    %rsi,%r15
mov    %edi,%r12d
lea    0x0(,%r12,8),%ebx
mov    %ebx,%edi
call   1060 <malloc@plt>
mov    %rax,%r13
mov    %ebx,%edi
call   1060 <malloc@plt>
mov    %rax,%rbx
mov    %r12d,%edi
mov    %r15,%rsi
mov    %r14,%rdx
mov    %r13,%rcx
mov    %rax,%r8
call   1050 <derivatePol@plt>
movsd  0xe72(%rip),%xmm0
xchg   %ax,%ax
movsd  %xmm0,0x8(%rsp)
mov    %r12d,%edi
mov    %r15,%rsi
mov    %r14,%rdx
mov    %r13,%rcx
mov    %rbx,%r8
call   1040 <getNextNewton@plt>
ucomisd 0x8(%rsp),%xmm0
jne    1190 <getMin+0x50>
jp     1190 <getMin+0x50>
mov    %r13,%rdi
movsd  %xmm0,0x8(%rsp)
call   1030 <free@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
movsd  0x8(%rsp),%xmm0
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define double @getMin(i32 %0, double* %1, double* %2) {
%4 = alloca i32
%5 = alloca double*
%6 = alloca double*
%7 = alloca double*
%8 = alloca double*
%9 = alloca double
%10 = alloca double
store i32 %0, i32* %4
store double* %1, double** %5
store double* %2, double** %6
%11 = load i32, i32* %4
%12 = sext i32 %11 to i64
%13 = mul i64 8, %12
%14 = trunc i64 %13 to i32
%15 = call double* @malloc(i32 %14)
store double* %15, double** %7
%16 = load i32, i32* %4
%17 = sext i32 %16 to i64
%18 = mul i64 8, %17
%19 = trunc i64 %18 to i32
%20 = call double* @malloc(i32 %19)
store double* %20, double** %8
%21 = load i32, i32* %4
%22 = load double*, double** %5
%23 = load double*, double** %6
%24 = load double*, double** %7
%25 = load double*, double** %8
%26 = call i32 @derivatePol(i32 %21, double* %22, double* %23, double* %24, double* %25)
store double 3.141500e+00, double* %9
%27 = load double, double* %9
%28 = fadd double %27, 1.000000e+00
store double %28, double* %10
br label %29
29: ; preds = %33, %3
%30 = load double, double* %9
%31 = load double, double* %10
%32 = fcmp une double %30, %31
br i1 %32, label %33, label %42
33: ; preds = %29
%34 = load double, double* %9
store double %34, double* %10
%35 = load double, double* %9
%36 = load i32, i32* %4
%37 = load double*, double** %5
%38 = load double*, double** %6
%39 = load double*, double** %7
%40 = load double*, double** %8
%41 = call double @getNextNewton(double %35, i32 %36, double* %37, double* %38, double* %39, double* %40)
store double %41, double* %9
br label %29
42: ; preds = %29
%43 = load double*, double** %7
%44 = call i32 @free(double* %43)
%45 = load double*, double** %8
%46 = call i32 @free(double* %45)
%47 = load double, double* %9
ret double %47
}

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