#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*/ difdiv(int, double *, double *);
int /*<<< orphan*/ free(double *);
double *funcio_trigonometrica(int, double *);
int /*<<< orphan*/ hornerd(int, double, double *, double *, double *);
double *nodes_equiespaiats(int, double, double);
double *nodes_txebitxev(int, double, double);
int /*<<< orphan*/ printf(char *, ...);
int read_degree();
double read_number();
int /*<<< orphan*/ swap(double *, double *);
int main() {
  int n = 0;
  int i = 0;
  double a = 0;
  double b = 0;
  double *x;
  double *f;
  double p[] = {0, 0};
  n = read_degree();
  printf("a = ");
  a = read_number();
  printf("b = ");
  b = read_number();
  if (b < a) {
    swap(&a, &b);
  }
  x = nodes_equiespaiats(n, a, b);
  f = funcio_trigonometrica(n, x);
  difdiv(n, x, f);
  printf("\nAdirisses equidistants\n");
  for (i = 0; i < n; i++) {
    hornerd(n, x[i], x, f, p);
    printf("%.5e %.5e %.5e\n", x[i], p[0], p[1]);
  }
  x = nodes_txebitxev(n, a, b);
  f = funcio_trigonometrica(n, x);
  difdiv(n, x, f);
  printf("\nAdirisses Txebitxev\n");
  for (i = 0; i < n; i++) {
    hornerd(n, x[i], x, f, p);
    printf("%.5e %.5e %.5e\n", x[i], p[0], p[1]);
  }
  free(x);
  free(f);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x18(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
lea    -0x40(%rbp),%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   1070 <memset@plt>
mov    $0x0,%al
call   1090 <read_degree@plt>
mov    %eax,-0x8(%rbp)
lea    0xe02(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x0,%al
call   10a0 <read_number@plt>
movsd  %xmm0,-0x18(%rbp)
lea    0xded(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x0,%al
call   10a0 <read_number@plt>
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm1
movsd  -0x18(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    124c <main+0x9c>
lea    -0x18(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   10c0 <swap@plt>
mov    -0x8(%rbp),%edi
movsd  -0x18(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
call   1080 <nodes_equiespaiats@plt>
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x28(%rbp),%rsi
call   1060 <funcio_trigonometrica@plt>
mov    %rax,-0x30(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x28(%rbp),%rsi
mov    -0x30(%rbp),%rdx
call   10b0 <difdiv@plt>
lea    0xd81(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    12f7 <main+0x147>
mov    -0x8(%rbp),%edi
mov    -0x28(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x28(%rbp),%rsi
mov    -0x30(%rbp),%rdx
lea    -0x40(%rbp),%rcx
call   1040 <hornerd@plt>
mov    -0x28(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  -0x40(%rbp),%xmm1
movsd  -0x38(%rbp),%xmm2
lea    0xd41(%rip),%rdi
mov    $0x3,%al
call   1050 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1297 <main+0xe7>
mov    -0x8(%rbp),%edi
movsd  -0x18(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
call   10d0 <nodes_txebitxev@plt>
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x28(%rbp),%rsi
call   1060 <funcio_trigonometrica@plt>
mov    %rax,-0x30(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x28(%rbp),%rsi
mov    -0x30(%rbp),%rdx
call   10b0 <difdiv@plt>
lea    0xcff(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    13a2 <main+0x1f2>
mov    -0x8(%rbp),%edi
mov    -0x28(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x28(%rbp),%rsi
mov    -0x30(%rbp),%rdx
lea    -0x40(%rbp),%rcx
call   1040 <hornerd@plt>
mov    -0x28(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  -0x40(%rbp),%xmm1
movsd  -0x38(%rbp),%xmm2
lea    0xc96(%rip),%rdi
mov    $0x3,%al
call   1050 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1342 <main+0x192>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
xorpd  %xmm0,%xmm0
movapd %xmm0,0x10(%rsp)
xor    %eax,%eax
call   1090 <read_degree@plt>
mov    %eax,%r14d
lea    0xe27(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
xor    %eax,%eax
call   10a0 <read_number@plt>
movsd  %xmm0,0x20(%rsp)
movsd  %xmm0,0x8(%rsp)
lea    0xe0b(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
xor    %eax,%eax
call   10a0 <read_number@plt>
movapd %xmm0,%xmm1
movsd  0x20(%rsp),%xmm0
movsd  %xmm1,(%rsp)
ucomisd %xmm1,%xmm0
jbe    1235 <main+0x85>
lea    0x8(%rsp),%rdi
mov    %rsp,%rsi
call   10c0 <swap@plt>
movsd  0x8(%rsp),%xmm0
movsd  (%rsp),%xmm1
mov    %r14d,%edi
call   1080 <nodes_equiespaiats@plt>
mov    %rax,%rbx
mov    %r14d,%edi
mov    %rax,%rsi
call   1070 <funcio_trigonometrica@plt>
mov    %rax,%r13
mov    %r14d,%edi
mov    %rbx,%rsi
mov    %rax,%rdx
call   10b0 <difdiv@plt>
lea    0xdb7(%rip),%rdi
call   1040 <puts@plt>
mov    %r14d,%ebp
test   %r14d,%r14d
jle    12be <main+0x10e>
xor    %r15d,%r15d
lea    0xd90(%rip),%r12
nopw   0x0(%rax,%rax,1)
movsd  (%rbx,%r15,8),%xmm0
mov    %r14d,%edi
mov    %rbx,%rsi
mov    %r13,%rdx
lea    0x10(%rsp),%rcx
call   1050 <hornerd@plt>
movsd  (%rbx,%r15,8),%xmm0
movsd  0x10(%rsp),%xmm1
movsd  0x18(%rsp),%xmm2
mov    %r12,%rdi
mov    $0x3,%al
call   1060 <printf@plt>
add    $0x1,%r15
cmp    %r15,%rbp
jne    1280 <main+0xd0>
movsd  0x8(%rsp),%xmm0
movsd  (%rsp),%xmm1
mov    %r14d,%edi
call   10d0 <nodes_txebitxev@plt>
mov    %rax,%rbx
mov    %r14d,%edi
mov    %rax,%rsi
call   1070 <funcio_trigonometrica@plt>
mov    %rax,%r13
mov    %r14d,%edi
mov    %rbx,%rsi
mov    %rax,%rdx
call   10b0 <difdiv@plt>
lea    0xd3b(%rip),%rdi
call   1040 <puts@plt>
test   %r14d,%r14d
jle    134e <main+0x19e>
xor    %r15d,%r15d
lea    0xcff(%rip),%r12
nopl   0x0(%rax,%rax,1)
movsd  (%rbx,%r15,8),%xmm0
mov    %r14d,%edi
mov    %rbx,%rsi
mov    %r13,%rdx
lea    0x10(%rsp),%rcx
call   1050 <hornerd@plt>
movsd  (%rbx,%r15,8),%xmm0
movsd  0x10(%rsp),%xmm1
movsd  0x18(%rsp),%xmm2
mov    %r12,%rdi
mov    $0x3,%al
call   1060 <printf@plt>
add    $0x1,%r15
cmp    %r15,%rbp
jne    1310 <main+0x160>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %r13,%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [5 x i8] c"a = \00"
@.str.1 = [5 x i8] c"b = \00"
@.str.2 = [25 x i8] c"\0AAdirisses equidistants\0A\00"
@.str.3 = [16 x i8] c"%.5e %.5e %.5e\0A\00"
@.str.4 = [22 x i8] c"\0AAdirisses Txebitxev\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca double
%5 = alloca double
%6 = alloca double*
%7 = alloca double*
%8 = alloca [2 x double]
store i32 0, i32* %1
store i32 0, i32* %2
store i32 0, i32* %3
store double 0.000000e+00, double* %4
store double 0.000000e+00, double* %5
%9 = bitcast [2 x double]* %8 to i8*
%10 = call i32 (...) @read_degree()
store i32 %10, i32* %2
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%12 = call double (...) @read_number()
store double %12, double* %4
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%14 = call double (...) @read_number()
store double %14, double* %5
%15 = load double, double* %5
%16 = load double, double* %4
%17 = fcmp olt double %15, %16
br i1 %17, label %18, label %20
18: ; preds = %0
%19 = call i32 @swap(double* %4, double* %5)
br label %20
20: ; preds = %18, %0
%21 = load i32, i32* %2
%22 = load double, double* %4
%23 = load double, double* %5
%24 = call double* @nodes_equiespaiats(i32 %21, double %22, double %23)
store double* %24, double** %6
%25 = load i32, i32* %2
%26 = load double*, double** %6
%27 = call double* @funcio_trigonometrica(i32 %25, double* %26)
store double* %27, double** %7
%28 = load i32, i32* %2
%29 = load double*, double** %6
%30 = load double*, double** %7
%31 = call i32 @difdiv(i32 %28, double* %29, double* %30)
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %3
br label %33
33: ; preds = %58, %20
%34 = load i32, i32* %3
%35 = load i32, i32* %2
%36 = icmp slt i32 %34, %35
br i1 %36, label %37, label %61
37: ; preds = %33
%38 = load i32, i32* %2
%39 = load double*, double** %6
%40 = load i32, i32* %3
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds double, double* %39, i64 %41
%43 = load double, double* %42
%44 = load double*, double** %6
%45 = load double*, double** %7
%46 = getelementptr inbounds [2 x double], [2 x double]* %8, i64 0, i64 0
%47 = call i32 @hornerd(i32 %38, double %43, double* %44, double* %45, double* %46)
%48 = load double*, double** %6
%49 = load i32, i32* %3
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds double, double* %48, i64 %50
%52 = load double, double* %51
%53 = getelementptr inbounds [2 x double], [2 x double]* %8, i64 0, i64 0
%54 = load double, double* %53
%55 = getelementptr inbounds [2 x double], [2 x double]* %8, i64 0, i64 1
%56 = load double, double* %55
%57 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), double %52, double %54, double %56)
br label %58
58: ; preds = %37
%59 = load i32, i32* %3
%60 = add nsw i32 %59, 1
store i32 %60, i32* %3
br label %33
61: ; preds = %33
%62 = load i32, i32* %2
%63 = load double, double* %4
%64 = load double, double* %5
%65 = call double* @nodes_txebitxev(i32 %62, double %63, double %64)
store double* %65, double** %6
%66 = load i32, i32* %2
%67 = load double*, double** %6
%68 = call double* @funcio_trigonometrica(i32 %66, double* %67)
store double* %68, double** %7
%69 = load i32, i32* %2
%70 = load double*, double** %6
%71 = load double*, double** %7
%72 = call i32 @difdiv(i32 %69, double* %70, double* %71)
%73 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0))
store i32 0, i32* %3
br label %74
74: ; preds = %99, %61
%75 = load i32, i32* %3
%76 = load i32, i32* %2
%77 = icmp slt i32 %75, %76
br i1 %77, label %78, label %102
78: ; preds = %74
%79 = load i32, i32* %2
%80 = load double*, double** %6
%81 = load i32, i32* %3
%82 = sext i32 %81 to i64
%83 = getelementptr inbounds double, double* %80, i64 %82
%84 = load double, double* %83
%85 = load double*, double** %6
%86 = load double*, double** %7
%87 = getelementptr inbounds [2 x double], [2 x double]* %8, i64 0, i64 0
%88 = call i32 @hornerd(i32 %79, double %84, double* %85, double* %86, double* %87)
%89 = load double*, double** %6
%90 = load i32, i32* %3
%91 = sext i32 %90 to i64
%92 = getelementptr inbounds double, double* %89, i64 %91
%93 = load double, double* %92
%94 = getelementptr inbounds [2 x double], [2 x double]* %8, i64 0, i64 0
%95 = load double, double* %94
%96 = getelementptr inbounds [2 x double], [2 x double]* %8, i64 0, i64 1
%97 = load double, double* %96
%98 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), double %93, double %95, double %97)
br label %99
99: ; preds = %78
%100 = load i32, i32* %3
%101 = add nsw i32 %100, 1
store i32 %101, i32* %3
br label %74
102: ; preds = %74
%103 = load double*, double** %6
%104 = call i32 @free(double* %103)
%105 = load double*, double** %7
%106 = call i32 @free(double* %105)
ret i32 0
}

LLVM IR (-O2):
@.str = [5 x i8] c"a = \00"
@.str.1 = [5 x i8] c"b = \00"
@.str.3 = [16 x i8] c"%.5e %.5e %.5e\0A\00"
@str = [24 x i8] c"\0AAdirisses equidistants\00"
@str.5 = [21 x i8] c"\0AAdirisses Txebitxev\00"
define i32 @main() {
%1 = alloca double
%2 = alloca double
%3 = alloca [2 x double]
%4 = bitcast double* %1 to i8*
%5 = bitcast double* %2 to i8*
%6 = bitcast [2 x double]* %3 to i8*
%7 = tail call i32 (...) @read_degree()
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%9 = tail call double (...) @read_number()
store double %9, double* %1
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%11 = tail call double (...) @read_number()
store double %11, double* %2
%12 = fcmp olt double %11, %9
br i1 %12, label %13, label %17
13: ; preds = %0
%14 = call i32 @swap(double* %1, double* %2)
%15 = load double, double* %1
%16 = load double, double* %2
br label %17
17: ; preds = %13, %0
%18 = phi double [ %16, %13 ], [ %11, %0 ]
%19 = phi double [ %15, %13 ], [ %9, %0 ]
%20 = call double* @nodes_equiespaiats(i32 %7, double %19, double %18)
%21 = call double* @funcio_trigonometrica(i32 %7, double* %20)
%22 = call i32 @difdiv(i32 %7, double* %20, double* %21)
%23 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str, i64 0, i64 0))
%24 = icmp sgt i32 %7, 0
br i1 %24, label %25, label %40
25: ; preds = %17
%26 = getelementptr inbounds [2 x double], [2 x double]* %3, i64 0, i64 0
%27 = getelementptr inbounds [2 x double], [2 x double]* %3, i64 0, i64 1
%28 = zext i32 %7 to i64
br label %29
29: ; preds = %25, %29
%30 = phi i64 [ 0, %25 ], [ %38, %29 ]
%31 = getelementptr inbounds double, double* %20, i64 %30
%32 = load double, double* %31
%33 = call i32 @hornerd(i32 %7, double %32, double* %20, double* %21, double* %26)
%34 = load double, double* %31
%35 = load double, double* %26
%36 = load double, double* %27
%37 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), double %34, double %35, double %36)
%38 = add nuw nsw i64 %30, 1
%39 = icmp eq i64 %38, %28
br i1 %39, label %40, label %29
40: ; preds = %29, %17
%41 = load double, double* %1
%42 = load double, double* %2
%43 = call double* @nodes_txebitxev(i32 %7, double %41, double %42)
%44 = call double* @funcio_trigonometrica(i32 %7, double* %43)
%45 = call i32 @difdiv(i32 %7, double* %43, double* %44)
%46 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str.5, i64 0, i64 0))
br i1 %24, label %47, label %62
47: ; preds = %40
%48 = getelementptr inbounds [2 x double], [2 x double]* %3, i64 0, i64 0
%49 = getelementptr inbounds [2 x double], [2 x double]* %3, i64 0, i64 1
%50 = zext i32 %7 to i64
br label %51
51: ; preds = %47, %51
%52 = phi i64 [ 0, %47 ], [ %60, %51 ]
%53 = getelementptr inbounds double, double* %43, i64 %52
%54 = load double, double* %53
%55 = call i32 @hornerd(i32 %7, double %54, double* %43, double* %44, double* %48)
%56 = load double, double* %53
%57 = load double, double* %48
%58 = load double, double* %49
%59 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), double %56, double %57, double %58)
%60 = add nuw nsw i64 %52, 1
%61 = icmp eq i64 %60, %50
br i1 %61, label %62, label %51
62: ; preds = %51, %40
%63 = call i32 @free(double* %43)
%64 = call i32 @free(double* %44)
ret i32 0
}