#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*/ free(double *);
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ secant(int, double *, double *, double, int);
int arrels_legendre(int imax, double prec, int nmax) {
  double x1, x0;
  double **zeros = (double **)malloc(imax * sizeof(double *));
  int i, j, grau;
  for (j = 0; j < imax; j++) {
    zeros[j] = (double *)malloc((j + 1) * sizeof(double));
  }
  zeros[0][0] = 0;
  for (i = 1; i < imax; i++) {
    if (i == 8) {
      for (j = 0; j < imax - 1; j++) {
        printf("->%d %lf\n", j, zeros[i - 1][j]);
      }
    }
    grau = i + 1;
    x0 = -1;
    x1 = zeros[i - 1][0];
    secant(grau, &x0, &x1, prec, nmax);
    zeros[i][0] = (x0 + x1) / 2;
    for (j = 1; j <= i - 1; j++) {
      x0 = zeros[i - 1][j - 1];
      x1 = zeros[i - 1][j];
      secant(grau, &x0, &x1, prec, nmax);
      zeros[i][j] = (x0 + x1) / 2;
    }
    printf("\n");
    x0 = zeros[i - 1][i - 1];
    x1 = 1;
    secant(grau, &x0, &x1, prec, nmax);
    zeros[i][i] = (x0 + x1) / 2;
  }
  printf("Arrels del polinomi de grau %d:\n", imax);
  for (j = 0; j < imax; j++) {
    printf("%d.\t%lf\n", j + 1, zeros[imax - 1][j]);
  }
  for (j = 0; j < imax; j++) {
    free(zeros[j]);
  }
  return 0;
}


x86 assembly (clang, -O0):
<arrels_legendre>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
movsd  %xmm0,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
movslq -0x4(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,-0x30(%rbp)
movl   $0x0,-0x38(%rbp)
mov    -0x38(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11a9 <arrels_legendre+0x69>
mov    -0x38(%rbp),%eax
add    $0x1,%eax
cltq
shl    $0x3,%rax
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,%rdx
mov    -0x30(%rbp),%rax
movslq -0x38(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    116d <arrels_legendre+0x2d>
mov    -0x30(%rbp),%rax
mov    (%rax),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax)
movl   $0x1,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    13d4 <arrels_legendre+0x294>
cmpl   $0x8,-0x34(%rbp)
jne    122a <arrels_legendre+0xea>
movl   $0x0,-0x38(%rbp)
mov    -0x38(%rbp),%eax
mov    -0x4(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    1225 <arrels_legendre+0xe5>
mov    -0x38(%rbp),%esi
mov    -0x30(%rbp),%rax
mov    -0x34(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x38(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
lea    0xe08(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    11db <arrels_legendre+0x9b>
jmp    122a <arrels_legendre+0xea>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
movsd  0xdcd(%rip),%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x30(%rbp),%rax
mov    -0x34(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x3c(%rbp),%edi
movsd  -0x10(%rbp),%xmm0
mov    -0x14(%rbp),%ecx
lea    -0x28(%rbp),%rsi
lea    -0x20(%rbp),%rdx
call   1050 <secant@plt>
movsd  -0x28(%rbp),%xmm0
addsd  -0x20(%rbp),%xmm0
movsd  0xd7c(%rip),%xmm1
divsd  %xmm1,%xmm0
mov    -0x30(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movsd  %xmm0,(%rax)
movl   $0x1,-0x38(%rbp)
mov    -0x38(%rbp),%eax
mov    -0x34(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jg     1344 <arrels_legendre+0x204>
mov    -0x30(%rbp),%rax
mov    -0x34(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rax
mov    -0x38(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x30(%rbp),%rax
mov    -0x34(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x38(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x3c(%rbp),%edi
movsd  -0x10(%rbp),%xmm0
mov    -0x14(%rbp),%ecx
lea    -0x28(%rbp),%rsi
lea    -0x20(%rbp),%rdx
call   1050 <secant@plt>
movsd  -0x28(%rbp),%xmm0
addsd  -0x20(%rbp),%xmm0
movsd  0xce3(%rip),%xmm1
divsd  %xmm1,%xmm0
mov    -0x30(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x38(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    129f <arrels_legendre+0x15f>
lea    0xcf6(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x30(%rbp),%rax
mov    -0x34(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rax
mov    -0x34(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  0xc92(%rip),%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x3c(%rbp),%edi
movsd  -0x10(%rbp),%xmm0
mov    -0x14(%rbp),%ecx
lea    -0x28(%rbp),%rsi
lea    -0x20(%rbp),%rdx
call   1050 <secant@plt>
movsd  -0x28(%rbp),%xmm0
addsd  -0x20(%rbp),%xmm0
movsd  0xc53(%rip),%xmm1
divsd  %xmm1,%xmm0
mov    -0x30(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x34(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    11be <arrels_legendre+0x7e>
mov    -0x4(%rbp),%esi
lea    0xc44(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x38(%rbp)
mov    -0x38(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    1434 <arrels_legendre+0x2f4>
mov    -0x38(%rbp),%esi
add    $0x1,%esi
mov    -0x30(%rbp),%rax
mov    -0x4(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x38(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
lea    0xc24(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    13ec <arrels_legendre+0x2ac>
movl   $0x0,-0x38(%rbp)
mov    -0x38(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    1466 <arrels_legendre+0x326>
mov    -0x30(%rbp),%rax
movslq -0x38(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1030 <free@plt>
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    143b <arrels_legendre+0x2fb>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<arrels_legendre>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
mov    %esi,%r13d
movsd  %xmm0,0x10(%rsp)
mov    %edi,%r15d
lea    0x0(,%r15,8),%edi
call   1070 <malloc@plt>
mov    %rax,%r12
test   %r15d,%r15d
jle    1404 <arrels_legendre+0x2b4>
mov    %r15d,%eax
mov    %rax,0x28(%rsp)
lea    0x0(,%rax,8),%r14
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nop
lea    0x8(%rbp),%rbx
mov    %ebx,%edi
call   1070 <malloc@plt>
mov    %rax,(%r12,%rbp,1)
mov    %rbx,%rbp
cmp    %rbx,%r14
jne    11a0 <arrels_legendre+0x50>
mov    (%r12),%rax
movq   $0x0,(%rax)
mov    %r15,0x20(%rsp)
cmp    $0x2,%r15d
jl     1391 <arrels_legendre+0x241>
mov    %r13d,%ecx
mov    0x20(%rsp),%rax
lea    -0x1(%rax),%ebx
mov    $0x1,%r14d
xor    %ebp,%ebp
mov    %rsp,%r13
mov    %rbx,0x38(%rsp)
mov    %ecx,0x1c(%rsp)
jmp    127c <arrels_legendre+0x12c>
cs nopw 0x0(%rax,%rax,1)
nop
mov    $0xa,%edi
call   1040 <putchar@plt>
mov    -0x8(%r12,%r14,8),%rax
movsd  -0x8(%rax,%r14,8),%xmm0
movsd  %xmm0,(%rsp)
movabs $0x3ff0000000000000,%rax
mov    %rax,0x8(%rsp)
mov    0x30(%rsp),%r15
mov    %r15d,%edi
mov    %rsp,%rsi
mov    %r13,%rdx
movsd  0x10(%rsp),%xmm0
mov    %ebx,%ecx
call   1060 <secant@plt>
movsd  (%rsp),%xmm0
addsd  0x8(%rsp),%xmm0
mulsd  0xda8(%rip),%xmm0
mov    (%r12,%r14,8),%rax
movsd  %xmm0,(%rax,%r14,8)
add    $0x8,%rbp
mov    %r15,%r14
cmp    0x28(%rsp),%r15
mov    0x38(%rsp),%rbx
mov    %rsp,%r13
je     1391 <arrels_legendre+0x241>
mov    %rbp,0x40(%rsp)
cmp    $0x8,%r14
lea    0xd7c(%rip),%r15
jne    12af <arrels_legendre+0x15f>
xor    %ebp,%ebp
mov    0x38(%r12),%rax
movsd  (%rax,%rbp,8),%xmm0
mov    %r15,%rdi
mov    %ebp,%esi
mov    $0x1,%al
call   1050 <printf@plt>
add    $0x1,%rbp
cmp    %rbp,%rbx
jne    1290 <arrels_legendre+0x140>
lea    0x1(%r14),%rdi
movabs $0xbff0000000000000,%rax
mov    %rax,(%rsp)
mov    -0x8(%r12,%r14,8),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,0x8(%rsp)
mov    %rdi,0x30(%rsp)
mov    %r13,%rsi
lea    0x8(%rsp),%r13
mov    %r13,%rdx
movsd  0x10(%rsp),%xmm0
mov    0x1c(%rsp),%ebx
mov    %ebx,%ecx
call   1060 <secant@plt>
movsd  (%rsp),%xmm0
addsd  0x8(%rsp),%xmm0
movsd  0xcfc(%rip),%xmm1
mulsd  %xmm1,%xmm0
mov    (%r12,%r14,8),%rax
movsd  %xmm0,(%rax)
cmp    $0x2,%r14
mov    0x40(%rsp),%rbp
jb     1200 <arrels_legendre+0xb0>
xor    %r15d,%r15d
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    -0x8(%r12,%r14,8),%rax
movsd  (%rax,%r15,1),%xmm0
movsd  %xmm0,(%rsp)
movsd  0x8(%rax,%r15,1),%xmm0
movsd  %xmm0,0x8(%rsp)
mov    0x30(%rsp),%rdi
mov    %rsp,%rsi
mov    %r13,%rdx
movsd  0x10(%rsp),%xmm0
mov    %ebx,%ecx
call   1060 <secant@plt>
movsd  (%rsp),%xmm0
addsd  0x8(%rsp),%xmm0
mulsd  0xc88(%rip),%xmm0
mov    (%r12,%r14,8),%rax
movsd  %xmm0,0x8(%rax,%r15,1)
add    $0x8,%r15
cmp    %r15,%rbp
jne    1330 <arrels_legendre+0x1e0>
jmp    1200 <arrels_legendre+0xb0>
lea    0xc7a(%rip),%rdi
mov    0x20(%rsp),%r13
mov    %r13d,%esi
xor    %eax,%eax
call   1050 <printf@plt>
test   %r13d,%r13d
mov    0x28(%rsp),%rbx
jle    1420 <arrels_legendre+0x2d0>
lea    -0x1(%r13),%r15d
xor    %ebp,%ebp
lea    0xc75(%rip),%r14
xchg   %ax,%ax
mov    (%r12,%r15,8),%rax
movsd  (%rax,%rbp,8),%xmm0
add    $0x1,%rbp
mov    %r14,%rdi
mov    %ebp,%esi
mov    $0x1,%al
call   1050 <printf@plt>
cmp    %rbp,%rbx
jne    13c0 <arrels_legendre+0x270>
test   %r13d,%r13d
jle    1420 <arrels_legendre+0x2d0>
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nop
mov    (%r12,%rbp,8),%rdi
call   1030 <free@plt>
add    $0x1,%rbp
cmp    %rbp,%rbx
jne    13f0 <arrels_legendre+0x2a0>
jmp    1420 <arrels_legendre+0x2d0>
mov    (%r12),%rax
movq   $0x0,(%rax)
lea    0xbfc(%rip),%rdi
mov    %r15d,%esi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [10 x i8] c"->%d %lf\0A\00"
@.str.2 = [33 x i8] c"Arrels del polinomi de grau %d:\0A\00"
@.str.3 = [9 x i8] c"%d.\09%lf\0A\00"
define i32 @arrels_legendre(i32 %0, double %1, i32 %2) {
%4 = alloca double
%5 = alloca double
%6 = bitcast double* %4 to i8*
%7 = bitcast double* %5 to i8*
%8 = shl i32 %0, 3
%9 = tail call i64 @malloc(i32 %8)
%10 = inttoptr i64 %9 to double**
%11 = icmp sgt i32 %0, 0
br i1 %11, label %15, label %12
12: ; preds = %3
%13 = load double*, double** %10
store double 0.000000e+00, double* %13
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0), i32 %0)
br label %117
15: ; preds = %3
%16 = zext i32 %0 to i64
br label %17
17: ; preds = %15, %17
%18 = phi i64 [ 0, %15 ], [ %19, %17 ]
%19 = add nuw nsw i64 %18, 1
%20 = trunc i64 %19 to i32
%21 = shl i32 %20, 3
%22 = tail call i64 @malloc(i32 %21)
%23 = inttoptr i64 %22 to double*
%24 = getelementptr inbounds double*, double** %10, i64 %18
store double* %23, double** %24
%25 = icmp eq i64 %19, %16
br i1 %25, label %26, label %17
26: ; preds = %17
%27 = load double*, double** %10
store double 0.000000e+00, double* %27
%28 = icmp sgt i32 %0, 1
br i1 %28, label %29, label %91
29: ; preds = %26
%30 = add nsw i32 %0, -1
%31 = getelementptr inbounds double*, double** %10, i64 7
%32 = zext i32 %0 to i64
%33 = zext i32 %30 to i64
br label %34
34: ; preds = %29, %78
%35 = phi i64 [ 1, %29 ], [ %47, %78 ]
%36 = icmp eq i64 %35, 8
br i1 %36, label %37, label %46
37: ; preds = %34, %37
%38 = phi i64 [ %44, %37 ], [ 0, %34 ]
%39 = load double*, double** %31
%40 = getelementptr inbounds double, double* %39, i64 %38
%41 = load double, double* %40
%42 = trunc i64 %38 to i32
%43 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 %42, double %41)
%44 = add nuw nsw i64 %38, 1
%45 = icmp eq i64 %44, %33
br i1 %45, label %46, label %37
46: ; preds = %37, %34
%47 = add nuw nsw i64 %35, 1
store double -1.000000e+00, double* %5
%48 = add nsw i64 %35, -1
%49 = getelementptr inbounds double*, double** %10, i64 %48
%50 = load double*, double** %49
%51 = load double, double* %50
store double %51, double* %4
%52 = trunc i64 %47 to i32
%53 = call i32 @secant(i32 %52, double* %5, double* %4, double %1, i32 %2)
%54 = load double, double* %5
%55 = load double, double* %4
%56 = fadd double %54, %55
%57 = fmul double %56, 5.000000e-01
%58 = getelementptr inbounds double*, double** %10, i64 %35
%59 = load double*, double** %58
store double %57, double* %59
%60 = icmp ugt i64 %35, 1
br i1 %60, label %61, label %78
61: ; preds = %46, %61
%62 = phi i64 [ %76, %61 ], [ 1, %46 ]
%63 = load double*, double** %49
%64 = add nsw i64 %62, -1
%65 = getelementptr inbounds double, double* %63, i64 %64
%66 = load double, double* %65
store double %66, double* %5
%67 = getelementptr inbounds double, double* %63, i64 %62
%68 = load double, double* %67
store double %68, double* %4
%69 = call i32 @secant(i32 %52, double* %5, double* %4, double %1, i32 %2)
%70 = load double, double* %5
%71 = load double, double* %4
%72 = fadd double %70, %71
%73 = fmul double %72, 5.000000e-01
%74 = load double*, double** %58
%75 = getelementptr inbounds double, double* %74, i64 %62
store double %73, double* %75
%76 = add nuw nsw i64 %62, 1
%77 = icmp eq i64 %76, %35
br i1 %77, label %78, label %61
78: ; preds = %61, %46
%79 = call i32 @putchar(i32 10)
%80 = load double*, double** %49
%81 = getelementptr inbounds double, double* %80, i64 %48
%82 = load double, double* %81
store double %82, double* %5
store double 1.000000e+00, double* %4
%83 = call i32 @secant(i32 %52, double* %5, double* %4, double %1, i32 %2)
%84 = load double, double* %5
%85 = load double, double* %4
%86 = fadd double %84, %85
%87 = fmul double %86, 5.000000e-01
%88 = load double*, double** %58
%89 = getelementptr inbounds double, double* %88, i64 %35
store double %87, double* %89
%90 = icmp eq i64 %47, %32
br i1 %90, label %91, label %34
91: ; preds = %78, %26
%92 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0), i32 %0)
br i1 %11, label %93, label %117
93: ; preds = %91
%94 = add nsw i32 %0, -1
%95 = zext i32 %94 to i64
%96 = getelementptr inbounds double*, double** %10, i64 %95
%97 = zext i32 %0 to i64
br label %101
98: ; preds = %101
br i1 %11, label %99, label %117
99: ; preds = %98
%100 = zext i32 %0 to i64
br label %110
101: ; preds = %93, %101
%102 = phi i64 [ 0, %93 ], [ %103, %101 ]
%103 = add nuw nsw i64 %102, 1
%104 = load double*, double** %96
%105 = getelementptr inbounds double, double* %104, i64 %102
%106 = load double, double* %105
%107 = trunc i64 %103 to i32
%108 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i32 %107, double %106)
%109 = icmp eq i64 %103, %97
br i1 %109, label %98, label %101
110: ; preds = %99, %110
%111 = phi i64 [ 0, %99 ], [ %115, %110 ]
%112 = getelementptr inbounds double*, double** %10, i64 %111
%113 = load double*, double** %112
%114 = call i32 @free(double* %113)
%115 = add nuw nsw i64 %111, 1
%116 = icmp eq i64 %115, %100
br i1 %116, label %117, label %110
117: ; preds = %110, %91, %12, %98
ret i32 0
}