#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 */
double fLagrange(float, int, float *, float *);
int /*<<< orphan*/ free(float *);
float *malloc(int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, ...);
int main() {
  printf("Lagrange-Interpolation fuer Polynom n-ten Gerades\n"
         "n = ");
  int n;
  scanf("%d", &n);
  float *fX = malloc((n + 1) * sizeof(float));
  float *fY = malloc((n + 1) * sizeof(float));
  printf("Geben Sie %d Punkte (x,y) ein.\n", n + 1);
  for (int i = 0; i <= n; i++) {
    printf("x%d = ", i);
    scanf("%f", &(fX[i]));
    printf("y%d = ", i);
    scanf("%f", &(fY[i]));
  }
  for (float f = -3.0; f <= 3.0; f += 0.5) {
    printf("%f\t%f\n", f, fLagrange(f, n + 1, fX, fY));
  }
  free(fX);
  free(fY);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeb2(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xedb(%rip),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x0,%al
call   1070 <scanf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
cltq
shl    $0x2,%rax
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
cltq
shl    $0x2,%rax
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%esi
add    $0x1,%esi
lea    0xe98(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x8(%rbp),%eax
jg     123e <main+0xee>
mov    -0x1c(%rbp),%esi
lea    0xe94(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%rsi
movslq -0x1c(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe7e(%rip),%rdi
mov    $0x0,%al
call   1070 <scanf@plt>
mov    -0x1c(%rbp),%esi
lea    0xe70(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%rsi
movslq -0x1c(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe50(%rip),%rdi
mov    $0x0,%al
call   1070 <scanf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11c8 <main+0x78>
movss  0xdba(%rip),%xmm0
movss  %xmm0,-0x20(%rbp)
movss  -0x20(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0xdac(%rip),%xmm0
ucomisd %xmm1,%xmm0
jb     12c5 <main+0x175>
movss  -0x20(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,-0x28(%rbp)
movss  -0x20(%rbp),%xmm0
mov    -0x8(%rbp),%edi
add    $0x1,%edi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1050 <fLagrange@plt>
movaps %xmm0,%xmm1
movsd  -0x28(%rbp),%xmm0
lea    0xde8(%rip),%rdi
mov    $0x2,%al
call   1040 <printf@plt>
movss  -0x20(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xd5d(%rip),%xmm1
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x20(%rbp)
jmp    124b <main+0xfb>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0xf2b(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xf54(%rip),%rdi
lea    0x4(%rsp),%rsi
xor    %eax,%eax
call   1070 <scanf@plt>
mov    0x4(%rsp),%ebx
lea    0x4(,%rbx,4),%ebp
mov    %ebp,%edi
call   1060 <malloc@plt>
mov    %rax,%r14
mov    %ebp,%edi
call   1060 <malloc@plt>
mov    %rax,%r12
add    $0x1,%ebx
lea    0xf22(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x4(%rsp),%edi
test   %edi,%edi
js     1232 <main+0xe2>
mov    $0xffffffffffffffff,%rbx
lea    0xf23(%rip),%r15
lea    0xf23(%rip),%r13
lea    0xf1f(%rip),%rbp
mov    %r14,0x10(%rsp)
mov    %r12,0x8(%rsp)
nop
add    $0x1,%rbx
mov    %r15,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r13,%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1070 <scanf@plt>
mov    %rbp,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r13,%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1070 <scanf@plt>
movslq 0x4(%rsp),%rdi
add    $0x4,%r12
add    $0x4,%r14
cmp    %rdi,%rbx
jl     11e0 <main+0x90>
mov    0x10(%rsp),%r14
mov    0x8(%rsp),%r12
add    $0x1,%edi
movss  0xdc3(%rip),%xmm0
mov    %r14,%rsi
mov    %r12,%rdx
call   1050 <fLagrange@plt>
movaps %xmm0,%xmm1
lea    0xea9(%rip),%r15
movsd  0xdd6(%rip),%xmm0
mov    %r15,%rdi
mov    $0x2,%al
call   1040 <printf@plt>
mov    0x4(%rsp),%edi
add    $0x1,%edi
movss  0xd91(%rip),%xmm0
mov    %r14,%rsi
mov    %r12,%rdx
call   1050 <fLagrange@plt>
movaps %xmm0,%xmm1
movsd  0xdaf(%rip),%xmm0
mov    %r15,%rdi
mov    $0x2,%al
call   1040 <printf@plt>
mov    0x4(%rsp),%edi
add    $0x1,%edi
movss  0xd66(%rip),%xmm0
mov    %r14,%rsi
mov    %r12,%rdx
call   1050 <fLagrange@plt>
movaps %xmm0,%xmm1
movsd  0xd88(%rip),%xmm0
mov    %r15,%rdi
mov    $0x2,%al
call   1040 <printf@plt>
mov    0x4(%rsp),%edi
add    $0x1,%edi
movss  0xd3b(%rip),%xmm0
mov    %r14,%rsi
mov    %r12,%rdx
call   1050 <fLagrange@plt>
movaps %xmm0,%xmm1
movsd  0xd61(%rip),%xmm0
mov    %r15,%rdi
mov    $0x2,%al
call   1040 <printf@plt>
mov    0x4(%rsp),%edi
add    $0x1,%edi
movss  0xd10(%rip),%xmm0
mov    %r14,%rsi
mov    %r12,%rdx
call   1050 <fLagrange@plt>
movaps %xmm0,%xmm1
movsd  0xd3a(%rip),%xmm0
mov    %r15,%rdi
mov    $0x2,%al
call   1040 <printf@plt>
mov    0x4(%rsp),%edi
add    $0x1,%edi
movss  0xce5(%rip),%xmm0
mov    %r14,%rsi
mov    %r12,%rdx
call   1050 <fLagrange@plt>
movaps %xmm0,%xmm1
movsd  0xd13(%rip),%xmm0
mov    %r15,%rdi
mov    $0x2,%al
call   1040 <printf@plt>
mov    0x4(%rsp),%edi
add    $0x1,%edi
xorps  %xmm0,%xmm0
mov    %r14,%rsi
mov    %r12,%rdx
call   1050 <fLagrange@plt>
movaps %xmm0,%xmm1
xorps  %xmm0,%xmm0
mov    %r15,%rdi
mov    $0x2,%al
call   1040 <printf@plt>
mov    0x4(%rsp),%edi
add    $0x1,%edi
movss  0xc95(%rip),%xmm0
mov    %r14,%rsi
mov    %r12,%rdx
call   1050 <fLagrange@plt>
movaps %xmm0,%xmm1
movsd  0xcc7(%rip),%xmm0
mov    %r15,%rdi
mov    $0x2,%al
call   1040 <printf@plt>
mov    0x4(%rsp),%edi
add    $0x1,%edi
movss  0xc6a(%rip),%xmm0
mov    %r14,%rsi
mov    %r12,%rdx
call   1050 <fLagrange@plt>
movaps %xmm0,%xmm1
movsd  0xca0(%rip),%xmm0
mov    %r15,%rdi
mov    $0x2,%al
call   1040 <printf@plt>
mov    0x4(%rsp),%edi
add    $0x1,%edi
movss  0xc3f(%rip),%xmm0
mov    %r14,%rsi
mov    %r12,%rdx
call   1050 <fLagrange@plt>
movaps %xmm0,%xmm1
movsd  0xc79(%rip),%xmm0
mov    %r15,%rdi
mov    $0x2,%al
call   1040 <printf@plt>
mov    0x4(%rsp),%edi
add    $0x1,%edi
movss  0xc14(%rip),%xmm0
mov    %r14,%rsi
mov    %r12,%rdx
call   1050 <fLagrange@plt>
movaps %xmm0,%xmm1
movsd  0xc52(%rip),%xmm0
mov    %r15,%rdi
mov    $0x2,%al
call   1040 <printf@plt>
mov    0x4(%rsp),%edi
add    $0x1,%edi
movss  0xbe9(%rip),%xmm0
mov    %r14,%rsi
mov    %r12,%rdx
call   1050 <fLagrange@plt>
movaps %xmm0,%xmm1
movsd  0xc2b(%rip),%xmm0
mov    %r15,%rdi
mov    $0x2,%al
call   1040 <printf@plt>
mov    0x4(%rsp),%edi
add    $0x1,%edi
movss  0xbbe(%rip),%xmm0
mov    %r14,%rsi
mov    %r12,%rdx
call   1050 <fLagrange@plt>
movaps %xmm0,%xmm1
movsd  0xc04(%rip),%xmm0
mov    %r15,%rdi
mov    $0x2,%al
call   1040 <printf@plt>
mov    %r14,%rdi
call   1030 <free@plt>
mov    %r12,%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 = [55 x i8] c"Lagrange-Interpolation fuer Polynom n-ten Gerades\0An = \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [32 x i8] c"Geben Sie %d Punkte (x,y) ein.\0A\00"
@.str.3 = [7 x i8] c"x%d = \00"
@.str.4 = [3 x i8] c"%f\00"
@.str.5 = [7 x i8] c"y%d = \00"
@.str.6 = [7 x i8] c"%f\09%f\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca float*
%4 = alloca float*
%5 = alloca i32
%6 = alloca float
store i32 0, i32* %1
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str, i64 0, i64 0))
%8 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%9 = load i32, i32* %2
%10 = add nsw i32 %9, 1
%11 = sext i32 %10 to i64
%12 = mul i64 %11, 4
%13 = trunc i64 %12 to i32
%14 = call float* @malloc(i32 %13)
store float* %14, float** %3
%15 = load i32, i32* %2
%16 = add nsw i32 %15, 1
%17 = sext i32 %16 to i64
%18 = mul i64 %17, 4
%19 = trunc i64 %18 to i32
%20 = call float* @malloc(i32 %19)
store float* %20, float** %4
%21 = load i32, i32* %2
%22 = add nsw i32 %21, 1
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0), i32 %22)
store i32 0, i32* %5
br label %24
24: ; preds = %43, %0
%25 = load i32, i32* %5
%26 = load i32, i32* %2
%27 = icmp sle i32 %25, %26
br i1 %27, label %28, label %46
28: ; preds = %24
%29 = load i32, i32* %5
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i32 %29)
%31 = load float*, float** %3
%32 = load i32, i32* %5
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds float, float* %31, i64 %33
%35 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), float* %34)
%36 = load i32, i32* %5
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0), i32 %36)
%38 = load float*, float** %4
%39 = load i32, i32* %5
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds float, float* %38, i64 %40
%42 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), float* %41)
br label %43
43: ; preds = %28
%44 = load i32, i32* %5
%45 = add nsw i32 %44, 1
store i32 %45, i32* %5
br label %24
46: ; preds = %24
store float -3.000000e+00, float* %6
br label %47
47: ; preds = %61, %46
%48 = load float, float* %6
%49 = fpext float %48 to double
%50 = fcmp ole double %49, 3.000000e+00
br i1 %50, label %51, label %66
51: ; preds = %47
%52 = load float, float* %6
%53 = fpext float %52 to double
%54 = load float, float* %6
%55 = load i32, i32* %2
%56 = add nsw i32 %55, 1
%57 = load float*, float** %3
%58 = load float*, float** %4
%59 = call double @fLagrange(float %54, i32 %56, float* %57, float* %58)
%60 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0), double %53, double %59)
br label %61
61: ; preds = %51
%62 = load float, float* %6
%63 = fpext float %62 to double
%64 = fadd double %63, 5.000000e-01
%65 = fptrunc double %64 to float
store float %65, float* %6
br label %47
66: ; preds = %47
%67 = load float*, float** %3
%68 = call i32 @free(float* %67)
%69 = load float*, float** %4
%70 = call i32 @free(float* %69)
ret i32 0
}

LLVM IR (-O2):
@.str = [55 x i8] c"Lagrange-Interpolation fuer Polynom n-ten Gerades\0An = \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [32 x i8] c"Geben Sie %d Punkte (x,y) ein.\0A\00"
@.str.3 = [7 x i8] c"x%d = \00"
@.str.4 = [3 x i8] c"%f\00"
@.str.5 = [7 x i8] c"y%d = \00"
@.str.6 = [7 x i8] c"%f\09%f\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([55 x i8], [55 x i8]* @.str, i64 0, i64 0))
%3 = bitcast i32* %1 to i8*
%4 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%5 = load i32, i32* %1
%6 = shl i32 %5, 2
%7 = add i32 %6, 4
%8 = call float* @malloc(i32 %7)
%9 = call float* @malloc(i32 %7)
%10 = add nsw i32 %5, 1
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0), i32 %10)
%12 = load i32, i32* %1
%13 = icmp slt i32 %12, 0
br i1 %13, label %14, label %69
14: ; preds = %69, %0
%15 = phi i32 [ %12, %0 ], [ %79, %69 ]
%16 = add nsw i32 %15, 1
%17 = call double @fLagrange(float -3.000000e+00, i32 %16, float* %8, float* %9)
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0), double -3.000000e+00, double %17)
%19 = load i32, i32* %1
%20 = add nsw i32 %19, 1
%21 = call double @fLagrange(float -2.500000e+00, i32 %20, float* %8, float* %9)
%22 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0), double -2.500000e+00, double %21)
%23 = load i32, i32* %1
%24 = add nsw i32 %23, 1
%25 = call double @fLagrange(float -2.000000e+00, i32 %24, float* %8, float* %9)
%26 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0), double -2.000000e+00, double %25)
%27 = load i32, i32* %1
%28 = add nsw i32 %27, 1
%29 = call double @fLagrange(float -1.500000e+00, i32 %28, float* %8, float* %9)
%30 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0), double -1.500000e+00, double %29)
%31 = load i32, i32* %1
%32 = add nsw i32 %31, 1
%33 = call double @fLagrange(float -1.000000e+00, i32 %32, float* %8, float* %9)
%34 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0), double -1.000000e+00, double %33)
%35 = load i32, i32* %1
%36 = add nsw i32 %35, 1
%37 = call double @fLagrange(float -5.000000e-01, i32 %36, float* %8, float* %9)
%38 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0), double -5.000000e-01, double %37)
%39 = load i32, i32* %1
%40 = add nsw i32 %39, 1
%41 = call double @fLagrange(float 0.000000e+00, i32 %40, float* %8, float* %9)
%42 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0), double 0.000000e+00, double %41)
%43 = load i32, i32* %1
%44 = add nsw i32 %43, 1
%45 = call double @fLagrange(float 5.000000e-01, i32 %44, float* %8, float* %9)
%46 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0), double 5.000000e-01, double %45)
%47 = load i32, i32* %1
%48 = add nsw i32 %47, 1
%49 = call double @fLagrange(float 1.000000e+00, i32 %48, float* %8, float* %9)
%50 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0), double 1.000000e+00, double %49)
%51 = load i32, i32* %1
%52 = add nsw i32 %51, 1
%53 = call double @fLagrange(float 1.500000e+00, i32 %52, float* %8, float* %9)
%54 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0), double 1.500000e+00, double %53)
%55 = load i32, i32* %1
%56 = add nsw i32 %55, 1
%57 = call double @fLagrange(float 2.000000e+00, i32 %56, float* %8, float* %9)
%58 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0), double 2.000000e+00, double %57)
%59 = load i32, i32* %1
%60 = add nsw i32 %59, 1
%61 = call double @fLagrange(float 2.500000e+00, i32 %60, float* %8, float* %9)
%62 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0), double 2.500000e+00, double %61)
%63 = load i32, i32* %1
%64 = add nsw i32 %63, 1
%65 = call double @fLagrange(float 3.000000e+00, i32 %64, float* %8, float* %9)
%66 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0), double 3.000000e+00, double %65)
%67 = call i32 @free(float* %8)
%68 = call i32 @free(float* %9)
ret i32 0
69: ; preds = %0, %69
%70 = phi i64 [ %78, %69 ], [ 0, %0 ]
%71 = trunc i64 %70 to i32
%72 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i32 %71)
%73 = getelementptr inbounds float, float* %8, i64 %70
%74 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), float* %73)
%75 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0), i32 %71)
%76 = getelementptr inbounds float, float* %9, i64 %70
%77 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), float* %76)
%78 = add nuw nsw i64 %70, 1
%79 = load i32, i32* %1
%80 = sext i32 %79 to i64
%81 = icmp slt i64 %70, %80
br i1 %81, label %69, label %14
}