#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 pow(double, int);
double wspol(double *tab, int n, double x) {
  if (n == 0) {
    return 0;
  } else {
    return tab[n - 1] * pow(x, n - 1) + wspol(tab, n - 1, x);
  }
}


x86 assembly (clang, -O0):
<wspol>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
movsd  %xmm0,-0x20(%rbp)
cmpl   $0x0,-0x14(%rbp)
jne    114b <wspol+0x2b>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11a5 <wspol+0x85>
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x20(%rbp),%xmm0
mov    -0x14(%rbp),%edi
sub    $0x1,%edi
call   1040 <pow@plt>
movsd  %xmm0,-0x30(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
sub    $0x1,%esi
movsd  -0x20(%rbp),%xmm0
call   1030 <wspol@plt>
movsd  -0x30(%rbp),%xmm2
movaps %xmm0,%xmm1
movsd  -0x28(%rbp),%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<wspol>:
test   %esi,%esi
je     117b <wspol+0x5b>
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %esi,%ebx
mov    %rdi,%r14
movslq %esi,%rax
add    $0xffffffff,%ebx
movsd  -0x8(%rdi,%rax,8),%xmm1
movsd  %xmm1,0x10(%rsp)
movsd  %xmm0,(%rsp)
mov    %ebx,%edi
call   1040 <pow@plt>
movsd  %xmm0,0x8(%rsp)
mov    %r14,%rdi
mov    %ebx,%esi
movsd  (%rsp),%xmm0
call   1030 <wspol@plt>
movsd  0x8(%rsp),%xmm1
mulsd  0x10(%rsp),%xmm1
addsd  %xmm1,%xmm0
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret
xorps  %xmm0,%xmm0
ret

LLVM IR (-O0):
define double @wspol(double* %0, i32 %1, double %2) {
%4 = alloca double
%5 = alloca double*
%6 = alloca i32
%7 = alloca double
store double* %0, double** %5
store i32 %1, i32* %6
store double %2, double* %7
%8 = load i32, i32* %6
%9 = icmp eq i32 %8, 0
br i1 %9, label %10, label %11
10: ; preds = %3
store double 0.000000e+00, double* %4
br label %28
11: ; preds = %3
%12 = load double*, double** %5
%13 = load i32, i32* %6
%14 = sub nsw i32 %13, 1
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds double, double* %12, i64 %15
%17 = load double, double* %16
%18 = load double, double* %7
%19 = load i32, i32* %6
%20 = sub nsw i32 %19, 1
%21 = call double @pow(double %18, i32 %20)
%22 = load double*, double** %5
%23 = load i32, i32* %6
%24 = sub nsw i32 %23, 1
%25 = load double, double* %7
%26 = call double @wspol(double* %22, i32 %24, double %25)
%27 = call double @llvm.fmuladd.f64(double %17, double %21, double %26)
store double %27, double* %4
br label %28
28: ; preds = %11, %10
%29 = load double, double* %4
ret double %29
}

LLVM IR (-O2):
define double @wspol(double* nocapture %0, i32 %1, double %2) {
%4 = icmp eq i32 %1, 0
br i1 %4, label %5, label %7
5: ; preds = %3, %7
%6 = phi double [ %14, %7 ], [ 0.000000e+00, %3 ]
ret double %6
7: ; preds = %3
%8 = add nsw i32 %1, -1
%9 = sext i32 %8 to i64
%10 = getelementptr inbounds double, double* %0, i64 %9
%11 = load double, double* %10
%12 = tail call double @pow(double %2, i32 %8)
%13 = tail call double @wspol(double* %0, i32 %8, double %2)
%14 = tail call double @llvm.fmuladd.f64(double %11, double %12, double %13)
br label %5
}