#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*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, ...);
int main(void) {
  int n = 0;
  printf("Enter the no. of co-ordinates:");
  scanf("%d", &n);
  int i = 0, j = 0;
  double P = 0, x[n + 1], y[n + 1];
  for (i = 0; i < n; i++) {
    printf("\nEnter x(%d) ,y(%d) :", i, i);
    scanf("%lf %lf", (x + i), (y + i));
  }
  double sum = 0, num = 1, dem = 0;
  printf("\nEnter the point for interpolation:");
  scanf("%lf", &P);
  for (i = 0; i < n; i++) {
    num = 1, dem = 1;
    for (j = 0; j < n; j++)
      if (i != j) {
        num *= P - x[j];
        dem *= x[i] - x[j];
      }
    sum += (y[i] * num) / dem;
  }
  printf("\nY(%lf)=%lf", P, sum);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
lea    0xecb(%rip),%rdi
xor    %eax,%eax
mov    %al,-0x59(%rbp)
call   1030 <printf@plt>
mov    -0x59(%rbp),%al
lea    0xed6(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %rsp,%rcx
mov    %rcx,-0x20(%rbp)
lea    0xf(,%rax,8),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x58(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
lea    0xf(,%rax,8),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x50(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x30(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    121e <main+0xfe>
mov    -0xc(%rbp),%esi
mov    -0xc(%rbp),%edx
lea    0xe4d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x58(%rbp),%rsi
mov    -0x50(%rbp),%rdx
movslq -0xc(%rbp),%rax
shl    $0x3,%rax
add    %rax,%rsi
movslq -0xc(%rbp),%rax
shl    $0x3,%rax
add    %rax,%rdx
lea    0xe37(%rip),%rdi
mov    $0x0,%al
call   1040 <scanf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11c4 <main+0xa4>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  0xdd2(%rip),%xmm0
movsd  %xmm0,-0x40(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x48(%rbp)
lea    0xe06(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xdf4(%rip),%rdi
lea    -0x18(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1321 <main+0x201>
movsd  0xd8a(%rip),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  0xd7d(%rip),%xmm0
movsd  %xmm0,-0x48(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    12f2 <main+0x1d2>
mov    -0xc(%rbp),%eax
cmp    -0x10(%rbp),%eax
je     12df <main+0x1bf>
mov    -0x58(%rbp),%rax
movsd  -0x18(%rbp),%xmm0
movslq -0x10(%rbp),%rcx
subsd  (%rax,%rcx,8),%xmm0
mulsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movslq -0xc(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movslq -0x10(%rbp),%rcx
subsd  (%rax,%rcx,8),%xmm0
mulsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
jmp    12e4 <main+0x1c4>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    128f <main+0x16f>
mov    -0x50(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mulsd  -0x40(%rbp),%xmm0
divsd  -0x48(%rbp),%xmm0
addsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1262 <main+0x142>
movsd  -0x18(%rbp),%xmm0
movsd  -0x38(%rbp),%xmm1
lea    0xd3a(%rip),%rdi
mov    $0x2,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
movl   $0x0,-0x2c(%rbp)
lea    0xed1(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xee2(%rip),%rdi
lea    -0x2c(%rbp),%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
mov    %rsp,-0x48(%rbp)
movq   $0x0,-0x40(%rbp)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %rsp,%r12
lea    0xf(,%rax,8),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r12
mov    %r12,%rsp
mov    -0x2c(%rbp),%eax
lea    0x1(%rax),%ecx
mov    %rsp,%rdx
lea    0xf(,%rcx,8),%rcx
and    $0xfffffffffffffff0,%rcx
sub    %rcx,%rdx
mov    %rdx,-0x38(%rbp)
mov    %rdx,%rsp
test   %eax,%eax
jle    11f7 <main+0xd7>
lea    0xe9f(%rip),%r15
mov    %r12,%r14
mov    -0x38(%rbp),%r13
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
lea    0xe6b(%rip),%rdi
mov    %ebx,%esi
mov    %ebx,%edx
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r15,%rdi
mov    %r14,%rsi
mov    %r13,%rdx
xor    %eax,%eax
call   1040 <scanf@plt>
add    $0x1,%rbx
movslq -0x2c(%rbp),%rax
add    $0x8,%r13
add    $0x8,%r14
cmp    %rax,%rbx
jl     11c0 <main+0xa0>
lea    0xe52(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe40(%rip),%rdi
lea    -0x40(%rbp),%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
mov    -0x2c(%rbp),%eax
movsd  -0x40(%rbp),%xmm0
test   %eax,%eax
jle    1326 <main+0x206>
mov    %eax,%ecx
and    $0xfffffffe,%ecx
xorpd  %xmm1,%xmm1
xor    %edx,%edx
movapd 0xdc6(%rip),%xmm2
mov    -0x38(%rbp),%rbx
jmp    1262 <main+0x142>
movsd  (%rbx,%rdx,8),%xmm4
mulsd  %xmm3,%xmm4
unpckhpd %xmm3,%xmm3
divsd  %xmm3,%xmm4
addsd  %xmm4,%xmm1
add    $0x1,%rdx
cmp    %rax,%rdx
je     132a <main+0x20a>
cmp    $0x1,%eax
jne    1280 <main+0x160>
xor    %esi,%esi
movapd %xmm2,%xmm3
test   $0x1,%al
je     1240 <main+0x120>
jmp    12fc <main+0x1dc>
cs nopw 0x0(%rax,%rax,1)
xor    %edi,%edi
movapd %xmm2,%xmm3
jmp    1299 <main+0x179>
nopl   0x0(%rax,%rax,1)
add    $0x1,%rdi
cmp    %rcx,%rdi
je     12f0 <main+0x1d0>
mov    %rdi,%rsi
cmp    %rdi,%rdx
je     12bd <main+0x19d>
movapd %xmm0,%xmm4
movhpd (%r12,%rdx,8),%xmm4
movsd  (%r12,%rsi,8),%xmm5
unpcklpd %xmm5,%xmm5
subpd  %xmm5,%xmm4
mulpd  %xmm4,%xmm3
lea    0x1(%rsi),%rdi
cmp    %rdi,%rdx
je     1290 <main+0x170>
movapd %xmm0,%xmm4
movhpd (%r12,%rdx,8),%xmm4
movsd  0x8(%r12,%rsi,8),%xmm5
unpcklpd %xmm5,%xmm5
subpd  %xmm5,%xmm4
mulpd  %xmm4,%xmm3
jmp    1290 <main+0x170>
cs nopw 0x0(%rax,%rax,1)
nop
add    $0x2,%rsi
test   $0x1,%al
je     1240 <main+0x120>
cmp    %rsi,%rdx
je     1240 <main+0x120>
movapd %xmm0,%xmm4
movhpd (%r12,%rdx,8),%xmm4
movsd  (%r12,%rsi,8),%xmm5
unpcklpd %xmm5,%xmm5
subpd  %xmm5,%xmm4
mulpd  %xmm4,%xmm3
jmp    1240 <main+0x120>
xorpd  %xmm1,%xmm1
lea    0xd43(%rip),%rdi
mov    $0x2,%al
call   1030 <printf@plt>
mov    -0x48(%rbp),%rsp
xor    %eax,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [31 x i8] c"Enter the no. of co-ordinates:\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [22 x i8] c"\0AEnter x(%d) ,y(%d) :\00"
@.str.3 = [8 x i8] c"%lf %lf\00"
@.str.4 = [36 x i8] c"\0AEnter the point for interpolation:\00"
@.str.5 = [4 x i8] c"%lf\00"
@.str.6 = [12 x i8] c"\0AY(%lf)=%lf\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca double
%6 = alloca i8*
%7 = alloca i64
%8 = alloca i64
%9 = alloca double
%10 = alloca double
%11 = alloca double
store i32 0, i32* %1
store i32 0, i32* %2
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
%13 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
store i32 0, i32* %3
store i32 0, i32* %4
store double 0.000000e+00, double* %5
%14 = load i32, i32* %2
%15 = add nsw i32 %14, 1
%16 = zext i32 %15 to i64
%17 = call i8* @llvm.stacksave()
store i8* %17, i8** %6
%18 = alloca double, i64 %16
store i64 %16, i64* %7
%19 = load i32, i32* %2
%20 = add nsw i32 %19, 1
%21 = zext i32 %20 to i64
%22 = alloca double, i64 %21
store i64 %21, i64* %8
store i32 0, i32* %3
br label %23
23: ; preds = %38, %0
%24 = load i32, i32* %3
%25 = load i32, i32* %2
%26 = icmp slt i32 %24, %25
br i1 %26, label %27, label %41
27: ; preds = %23
%28 = load i32, i32* %3
%29 = load i32, i32* %3
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i32 %28, i32 %29)
%31 = load i32, i32* %3
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds double, double* %18, i64 %32
%34 = load i32, i32* %3
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds double, double* %22, i64 %35
%37 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), double* %33, double* %36)
br label %38
38: ; preds = %27
%39 = load i32, i32* %3
%40 = add nsw i32 %39, 1
store i32 %40, i32* %3
br label %23
41: ; preds = %23
store double 0.000000e+00, double* %9
store double 1.000000e+00, double* %10
store double 0.000000e+00, double* %11
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.4, i64 0, i64 0))
%43 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), double* %5)
store i32 0, i32* %3
br label %44
44: ; preds = %92, %41
%45 = load i32, i32* %3
%46 = load i32, i32* %2
%47 = icmp slt i32 %45, %46
br i1 %47, label %48, label %95
48: ; preds = %44
store double 1.000000e+00, double* %10
store double 1.000000e+00, double* %11
store i32 0, i32* %4
br label %49
49: ; preds = %78, %48
%50 = load i32, i32* %4
%51 = load i32, i32* %2
%52 = icmp slt i32 %50, %51
br i1 %52, label %53, label %81
53: ; preds = %49
%54 = load i32, i32* %3
%55 = load i32, i32* %4
%56 = icmp ne i32 %54, %55
br i1 %56, label %57, label %77
57: ; preds = %53
%58 = load double, double* %5
%59 = load i32, i32* %4
%60 = sext i32 %59 to i64
%61 = getelementptr inbounds double, double* %18, i64 %60
%62 = load double, double* %61
%63 = fsub double %58, %62
%64 = load double, double* %10
%65 = fmul double %64, %63
store double %65, double* %10
%66 = load i32, i32* %3
%67 = sext i32 %66 to i64
%68 = getelementptr inbounds double, double* %18, i64 %67
%69 = load double, double* %68
%70 = load i32, i32* %4
%71 = sext i32 %70 to i64
%72 = getelementptr inbounds double, double* %18, i64 %71
%73 = load double, double* %72
%74 = fsub double %69, %73
%75 = load double, double* %11
%76 = fmul double %75, %74
store double %76, double* %11
br label %77
77: ; preds = %57, %53
br label %78
78: ; preds = %77
%79 = load i32, i32* %4
%80 = add nsw i32 %79, 1
store i32 %80, i32* %4
br label %49
81: ; preds = %49
%82 = load i32, i32* %3
%83 = sext i32 %82 to i64
%84 = getelementptr inbounds double, double* %22, i64 %83
%85 = load double, double* %84
%86 = load double, double* %10
%87 = fmul double %85, %86
%88 = load double, double* %11
%89 = fdiv double %87, %88
%90 = load double, double* %9
%91 = fadd double %90, %89
store double %91, double* %9
br label %92
92: ; preds = %81
%93 = load i32, i32* %3
%94 = add nsw i32 %93, 1
store i32 %94, i32* %3
br label %44
95: ; preds = %44
%96 = load double, double* %5
%97 = load double, double* %9
%98 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.6, i64 0, i64 0), double %96, double %97)
store i32 0, i32* %1
%99 = load i8*, i8** %6
%100 = load i32, i32* %1
ret i32 %100
}

LLVM IR (-O2):
@.str = [31 x i8] c"Enter the no. of co-ordinates:\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [22 x i8] c"\0AEnter x(%d) ,y(%d) :\00"
@.str.3 = [8 x i8] c"%lf %lf\00"
@.str.4 = [36 x i8] c"\0AEnter the point for interpolation:\00"
@.str.5 = [4 x i8] c"%lf\00"
@.str.6 = [12 x i8] c"\0AY(%lf)=%lf\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca double
%3 = bitcast i32* %1 to i8*
store i32 0, i32* %1
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
%5 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%6 = bitcast double* %2 to i8*
store double 0.000000e+00, double* %2
%7 = load i32, i32* %1
%8 = add nsw i32 %7, 1
%9 = zext i32 %8 to i64
%10 = call i8* @llvm.stacksave()
%11 = alloca double, i64 %9
%12 = load i32, i32* %1
%13 = add nsw i32 %12, 1
%14 = zext i32 %13 to i64
%15 = alloca double, i64 %14
%16 = icmp sgt i32 %12, 0
br i1 %16, label %17, label %28
17: ; preds = %0, %17
%18 = phi i64 [ %24, %17 ], [ 0, %0 ]
%19 = trunc i64 %18 to i32
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i32 %19, i32 %19)
%21 = getelementptr inbounds double, double* %11, i64 %18
%22 = getelementptr inbounds double, double* %15, i64 %18
%23 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), double* %21, double* %22)
%24 = add nuw nsw i64 %18, 1
%25 = load i32, i32* %1
%26 = sext i32 %25 to i64
%27 = icmp slt i64 %24, %26
br i1 %27, label %17, label %28
28: ; preds = %17, %0
%29 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @.str.4, i64 0, i64 0))
%30 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), double* %2)
%31 = load i32, i32* %1
%32 = icmp sgt i32 %31, 0
%33 = load double, double* %2
br i1 %32, label %34, label %103
34: ; preds = %28
%35 = zext i32 %31 to i64
%36 = insertelement <2 x double> poison, double %33, i64 0
%37 = and i64 %35, 1
%38 = icmp eq i32 %31, 1
%39 = and i64 %35, 4294967294
%40 = icmp eq i64 %37, 0
br label %41
41: ; preds = %92, %34
%42 = phi i64 [ 0, %34 ], [ %101, %92 ]
%43 = phi double [ 0.000000e+00, %34 ], [ %100, %92 ]
%44 = getelementptr inbounds double, double* %11, i64 %42
br i1 %38, label %77, label %45
45: ; preds = %41, %72
%46 = phi i64 [ %74, %72 ], [ 0, %41 ]
%47 = phi <2 x double> [ %73, %72 ], [ <double 1.000000e+00, double 1.000000e+00>, %41 ]
%48 = phi i64 [ %75, %72 ], [ 0, %41 ]
%49 = icmp eq i64 %42, %46
br i1 %49, label %59, label %50
50: ; preds = %45
%51 = getelementptr inbounds double, double* %11, i64 %46
%52 = load double, double* %51
%53 = load double, double* %44
%54 = insertelement <2 x double> %36, double %53, i64 1
%55 = insertelement <2 x double> poison, double %52, i64 0
%56 = shufflevector <2 x double> %55, <2 x double> poison, <2 x i32> zeroinitializer
%57 = fsub <2 x double> %54, %56
%58 = fmul <2 x double> %47, %57
br label %59
59: ; preds = %45, %50
%60 = phi <2 x double> [ %58, %50 ], [ %47, %45 ]
%61 = or i64 %46, 1
%62 = icmp eq i64 %42, %61
br i1 %62, label %72, label %63
63: ; preds = %59
%64 = getelementptr inbounds double, double* %11, i64 %61
%65 = load double, double* %64
%66 = load double, double* %44
%67 = insertelement <2 x double> %36, double %66, i64 1
%68 = insertelement <2 x double> poison, double %65, i64 0
%69 = shufflevector <2 x double> %68, <2 x double> poison, <2 x i32> zeroinitializer
%70 = fsub <2 x double> %67, %69
%71 = fmul <2 x double> %60, %70
br label %72
72: ; preds = %63, %59
%73 = phi <2 x double> [ %71, %63 ], [ %60, %59 ]
%74 = add nuw nsw i64 %46, 2
%75 = add i64 %48, 2
%76 = icmp eq i64 %75, %39
br i1 %76, label %77, label %45
77: ; preds = %72, %41
%78 = phi <2 x double> [ undef, %41 ], [ %73, %72 ]
%79 = phi i64 [ 0, %41 ], [ %74, %72 ]
%80 = phi <2 x double> [ <double 1.000000e+00, double 1.000000e+00>, %41 ], [ %73, %72 ]
br i1 %40, label %92, label %81
81: ; preds = %77
%82 = icmp eq i64 %42, %79
br i1 %82, label %92, label %83
83: ; preds = %81
%84 = getelementptr inbounds double, double* %11, i64 %79
%85 = load double, double* %84
%86 = load double, double* %44
%87 = insertelement <2 x double> %36, double %86, i64 1
%88 = insertelement <2 x double> poison, double %85, i64 0
%89 = shufflevector <2 x double> %88, <2 x double> poison, <2 x i32> zeroinitializer
%90 = fsub <2 x double> %87, %89
%91 = fmul <2 x double> %80, %90
br label %92
92: ; preds = %81, %83, %77
%93 = phi <2 x double> [ %78, %77 ], [ %91, %83 ], [ %80, %81 ]
%94 = getelementptr inbounds double, double* %15, i64 %42
%95 = load double, double* %94
%96 = extractelement <2 x double> %93, i64 0
%97 = fmul double %96, %95
%98 = extractelement <2 x double> %93, i64 1
%99 = fdiv double %97, %98
%100 = fadd double %43, %99
%101 = add nuw nsw i64 %42, 1
%102 = icmp eq i64 %101, %35
br i1 %102, label %103, label %41
103: ; preds = %92, %28
%104 = phi double [ 0.000000e+00, %28 ], [ %100, %92 ]
%105 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.6, i64 0, i64 0), double %33, double %104)
ret i32 0
}