#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 horner(int, double *, double *, double);
double *malloc(int);
int /*<<< orphan*/ print_vector(double *, int);
int /*<<< orphan*/ printf(char *, ...);
int read_degree();
double read_number();
int main() {
  int n = read_degree();
  int m = n + 1;
  int i = 0;
  int h = 150;
  double *x = malloc(sizeof(double) * m);
  double *f = malloc(sizeof(double) * m);
  double delta = 0;
  double p_z = 0;
  for (i = 0; i < m; i++) {
    printf("x%d = ", i);
    x[i] = read_number();
  }
  printf("\n");
  for (i = 0; i < m; i++) {
    printf("f%d = ", i);
    f[i] = read_number();
  }
  difdiv(m, x, f);
  print_vector(f, m);
  printf("\n\n");
  printf("x        p(x)\n");
  delta = (x[n] - x[0]) / h;
  for (i = 0; i <= h; i++) {
    p_z = horner(m, f, x, x[0] + i * delta);
    printf("%8lf %8lf\n", x[0] + i * delta, p_z);
  }
  free(x);
  free(f);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1070 <read_degree@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x96,-0x14(%rbp)
movslq -0xc(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0x20(%rbp)
movslq -0xc(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0x28(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x30(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x38(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    122c <main+0xac>
mov    -0x10(%rbp),%esi
lea    0xdfd(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1080 <read_number@plt>
mov    -0x20(%rbp),%rax
movslq -0x10(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    11ed <main+0x6d>
lea    0xddc(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1280 <main+0x100>
mov    -0x10(%rbp),%esi
lea    0xdb0(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1080 <read_number@plt>
mov    -0x28(%rbp),%rax
movslq -0x10(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1241 <main+0xc1>
mov    -0xc(%rbp),%edi
mov    -0x20(%rbp),%rsi
mov    -0x28(%rbp),%rdx
call   1090 <difdiv@plt>
mov    -0x28(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1060 <print_vector@plt>
lea    0xd6b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xd60(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x20(%rbp),%rax
movslq -0x8(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x20(%rbp),%rax
subsd  (%rax),%xmm0
cvtsi2sdl -0x14(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x14(%rbp),%eax
jg     1358 <main+0x1d8>
mov    -0xc(%rbp),%edi
mov    -0x28(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    -0x20(%rbp),%rax
movsd  (%rax),%xmm1
cvtsi2sdl -0x10(%rbp),%xmm0
movsd  -0x30(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
call   10a0 <horner@plt>
movsd  %xmm0,-0x38(%rbp)
mov    -0x20(%rbp),%rax
movsd  (%rax),%xmm1
cvtsi2sdl -0x10(%rbp),%xmm0
movsd  -0x30(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  -0x38(%rbp),%xmm1
lea    0xcdd(%rip),%rdi
mov    $0x2,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    12e2 <main+0x162>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
mov    -0x28(%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    $0x18,%rsp
xor    %eax,%eax
call   1090 <read_degree@plt>
mov    %eax,%ebp
lea    0x1(%rbp),%r14d
lea    0x8(,%rbp,8),%r15d
mov    %r15d,%edi
call   1070 <malloc@plt>
mov    %rax,%rbx
mov    %r15d,%edi
call   1070 <malloc@plt>
mov    %rax,%r13
mov    %rbp,(%rsp)
test   %ebp,%ebp
js     1255 <main+0xb5>
mov    %r14d,%r15d
lea    0xe25(%rip),%r12
xor    %ebp,%ebp
nopl   (%rax)
mov    %r12,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1060 <printf@plt>
xor    %eax,%eax
call   10a0 <read_number@plt>
movsd  %xmm0,(%rbx,%rbp,8)
add    $0x1,%rbp
cmp    %rbp,%r15
jne    11f0 <main+0x50>
mov    $0xa,%edi
call   1040 <putchar@plt>
cmpl   $0x0,(%rsp)
js     125f <main+0xbf>
lea    0xdef(%rip),%r12
xor    %ebp,%ebp
nopw   0x0(%rax,%rax,1)
mov    %r12,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1060 <printf@plt>
xor    %eax,%eax
call   10a0 <read_number@plt>
movsd  %xmm0,0x0(%r13,%rbp,8)
add    $0x1,%rbp
cmp    %rbp,%r15
jne    1230 <main+0x90>
jmp    125f <main+0xbf>
mov    $0xa,%edi
call   1040 <putchar@plt>
mov    %r14d,%edi
mov    %rbx,%rsi
mov    %r13,%rdx
call   10b0 <difdiv@plt>
mov    %r13,%rdi
mov    %r14d,%esi
call   1080 <print_vector@plt>
lea    0xda8(%rip),%rdi
call   1050 <puts@plt>
lea    0xd9e(%rip),%rdi
call   1050 <puts@plt>
movslq (%rsp),%rax
movsd  (%rbx,%rax,8),%xmm1
movsd  (%rbx),%xmm0
subsd  %xmm0,%xmm1
divsd  0xd57(%rip),%xmm1
xorpd  %xmm2,%xmm2
movsd  %xmm1,0x8(%rsp)
mulsd  %xmm1,%xmm2
movsd  %xmm2,(%rsp)
addsd  %xmm2,%xmm0
mov    %r14d,%edi
mov    %r13,%rsi
mov    %rbx,%rdx
call   10c0 <horner@plt>
movapd %xmm0,%xmm1
movsd  (%rsp),%xmm0
addsd  (%rbx),%xmm0
lea    0xd3c(%rip),%r15
mov    %r15,%rdi
mov    $0x2,%al
call   1060 <printf@plt>
movsd  0xd14(%rip),%xmm0
mov    $0x96,%ebp
nopl   0x0(%rax)
movsd  %xmm0,(%rsp)
movapd %xmm0,%xmm1
mulsd  0x8(%rsp),%xmm1
movsd  %xmm1,0x10(%rsp)
movsd  (%rbx),%xmm0
addsd  %xmm1,%xmm0
mov    %r14d,%edi
mov    %r13,%rsi
mov    %rbx,%rdx
call   10c0 <horner@plt>
movapd %xmm0,%xmm1
movsd  0x10(%rsp),%xmm0
addsd  (%rbx),%xmm0
mov    %r15,%rdi
mov    $0x2,%al
call   1060 <printf@plt>
movsd  (%rsp),%xmm0
addsd  0xcb8(%rip),%xmm0
add    $0xffffffff,%ebp
jne    1300 <main+0x160>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %r13,%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [7 x i8] c"x%d = \00"
@.str.2 = [7 x i8] c"f%d = \00"
@.str.5 = [11 x i8] c"%8lf %8lf\0A\00"
@str = [2 x i8] c"\0A\00"
@str.6 = [14 x i8] c"x p(x)\00"
define i32 @main() {
%1 = tail call i32 (...) @read_degree()
%2 = add i32 %1, 1
%3 = shl i32 %2, 3
%4 = tail call double* @malloc(i32 %3)
%5 = tail call double* @malloc(i32 %3)
%6 = icmp slt i32 %1, 0
br i1 %6, label %7, label %9
7: ; preds = %0
%8 = tail call i32 @putchar(i32 10)
br label %31
9: ; preds = %0
%10 = zext i32 %2 to i64
br label %11
11: ; preds = %9, %11
%12 = phi i64 [ 0, %9 ], [ %17, %11 ]
%13 = trunc i64 %12 to i32
%14 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 %13)
%15 = tail call double (...) @read_number()
%16 = getelementptr inbounds double, double* %4, i64 %12
store double %15, double* %16
%17 = add nuw nsw i64 %12, 1
%18 = icmp eq i64 %17, %10
br i1 %18, label %19, label %11
19: ; preds = %11
%20 = tail call i32 @putchar(i32 10)
br i1 %6, label %31, label %21
21: ; preds = %19
%22 = zext i32 %2 to i64
br label %23
23: ; preds = %21, %23
%24 = phi i64 [ 0, %21 ], [ %29, %23 ]
%25 = trunc i64 %24 to i32
%26 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i32 %25)
%27 = tail call double (...) @read_number()
%28 = getelementptr inbounds double, double* %5, i64 %24
store double %27, double* %28
%29 = add nuw nsw i64 %24, 1
%30 = icmp eq i64 %29, %22
br i1 %30, label %31, label %23
31: ; preds = %23, %7, %19
%32 = tail call i32 @difdiv(i32 %2, double* %4, double* %5)
%33 = tail call i32 @print_vector(double* %5, i32 %2)
%34 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str, i64 0, i64 0))
%35 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str.6, i64 0, i64 0))
%36 = sext i32 %1 to i64
%37 = getelementptr inbounds double, double* %4, i64 %36
%38 = load double, double* %37
%39 = load double, double* %4
%40 = fsub double %38, %39
%41 = fdiv double %40, 1.500000e+02
%42 = tail call double @llvm.fmuladd.f64(double %41, double 0.000000e+00, double %39)
%43 = tail call double @horner(i32 %2, double* %5, double* %4, double %42)
%44 = load double, double* %4
%45 = tail call double @llvm.fmuladd.f64(double %41, double 0.000000e+00, double %44)
%46 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0), double %45, double %43)
br label %47
47: ; preds = %31, %47
%48 = phi i32 [ 1, %31 ], [ %56, %47 ]
%49 = load double, double* %4
%50 = sitofp i32 %48 to double
%51 = tail call double @llvm.fmuladd.f64(double %50, double %41, double %49)
%52 = tail call double @horner(i32 %2, double* %5, double* %4, double %51)
%53 = load double, double* %4
%54 = tail call double @llvm.fmuladd.f64(double %50, double %41, double %53)
%55 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0), double %54, double %52)
%56 = add nuw nsw i32 %48, 1
%57 = icmp eq i32 %56, 151
br i1 %57, label %58, label %47
58: ; preds = %47
%59 = tail call i32 @free(double* %4)
%60 = tail call i32 @free(double* %5)
ret i32 0
}