#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 */
typedef int /*<<< orphan*/ coeff;

/* Variables and functions */
double horner_r(double, int, double *);
int /*<<< orphan*/ printf(char *, double, double);
int main(void) {
  double coeff[] = {36, -13, 1};
  int n_coeff = sizeof(coeff) / sizeof(coeff[0]);
  int grade = n_coeff - 1;
  int i;
  for (i = 0; i < 15; i++) {
    double x = i;
    double y = horner_r(x, grade, coeff);
    printf("x = %lf | y = %lf\n", x, y);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xeca(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xec7(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0xec4(%rip),%rax
mov    %rax,-0x10(%rbp)
movl   $0x3,-0x24(%rbp)
mov    -0x24(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
cmpl   $0xf,-0x2c(%rbp)
jge    11b5 <main+0x95>
cvtsi2sdl -0x2c(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm0
mov    -0x28(%rbp),%edi
lea    -0x20(%rbp),%rsi
call   1040 <horner_r@plt>
movsd  %xmm0,-0x40(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  -0x40(%rbp),%xmm1
lea    0xe76(%rip),%rdi
call   1030 <printf@plt>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1167 <main+0x47>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x30,%rsp
mov    0xef1(%rip),%rax
mov    %rax,0x20(%rsp)
movapd 0xed4(%rip),%xmm0
movapd %xmm0,0x10(%rsp)
xorpd  %xmm0,%xmm0
mov    $0xf,%ebp
lea    0x10(%rsp),%r14
lea    0xed1(%rip),%rbx
nopw   0x0(%rax,%rax,1)
movsd  %xmm0,0x8(%rsp)
movsd  0x8(%rsp),%xmm0
mov    $0x2,%edi
mov    %r14,%rsi
call   1040 <horner_r@plt>
movaps %xmm0,%xmm1
mov    %rbx,%rdi
movsd  0x8(%rsp),%xmm0
call   1030 <printf@plt>
movsd  0x8(%rsp),%xmm0
addsd  0xe68(%rip),%xmm0
add    $0xffffffff,%ebp
jne    1160 <main+0x40>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@__const.main.coeff = [3 x double] [double 3.600000e+01, double -1.300000e+01, double 1.000000e+00]
@.str = [19 x i8] c"x = %lf | y = %lf\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [3 x double]
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca double
%7 = alloca double
store i32 0, i32* %1
%8 = bitcast [3 x double]* %2 to i8*
store i32 3, i32* %3
%9 = load i32, i32* %3
%10 = sub nsw i32 %9, 1
store i32 %10, i32* %4
store i32 0, i32* %5
br label %11
11: ; preds = %24, %0
%12 = load i32, i32* %5
%13 = icmp slt i32 %12, 15
br i1 %13, label %14, label %27
14: ; preds = %11
%15 = load i32, i32* %5
%16 = sitofp i32 %15 to double
store double %16, double* %6
%17 = load double, double* %6
%18 = load i32, i32* %4
%19 = getelementptr inbounds [3 x double], [3 x double]* %2, i64 0, i64 0
%20 = call double @horner_r(double %17, i32 %18, double* %19)
store double %20, double* %7
%21 = load double, double* %6
%22 = load double, double* %7
%23 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), double %21, double %22)
br label %24
24: ; preds = %14
%25 = load i32, i32* %5
%26 = add nsw i32 %25, 1
store i32 %26, i32* %5
br label %11
27: ; preds = %11
ret i32 0
}

LLVM IR (-O2):
@__const.main.coeff = [3 x double] [double 3.600000e+01, double -1.300000e+01, double 1.000000e+00]
@.str = [19 x i8] c"x = %lf | y = %lf\0A\00"
define i32 @main() {
%1 = alloca [3 x double]
%2 = bitcast [3 x double]* %1 to i8*
%3 = getelementptr inbounds [3 x double], [3 x double]* %1, i64 0, i64 0
br label %4
4: ; preds = %0, %4
%5 = phi i32 [ 0, %0 ], [ %9, %4 ]
%6 = sitofp i32 %5 to double
%7 = call double @horner_r(double %6, i32 2, double* %3)
%8 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), double %6, double %7)
%9 = add nuw nsw i32 %5, 1
%10 = icmp eq i32 %9, 15
br i1 %10, label %11, label %4
11: ; preds = %4
ret i32 0
}