#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*/ fpoly(float, float *, int);
int /*<<< orphan*/ free_vector(float *, int, int);
int /*<<< orphan*/ printf(char *, ...);
float *vector(int, int);
int main(void) {
  int i, j;
  float x, *afunc;
  afunc = vector(1, 5);
  printf("\n%38s\n", "powers of x");
  printf("%8s %10s %9s %9s %9s %9s\n", "x", "x**0", "x**1", "x**2", "x**3",
         "x**4");
  for (i = 1; i <= 15; i++) {
    x = i * 0.1;
    fpoly(x, afunc, 5);
    printf("%10.4f", x);
    for (j = 1; j <= 5; j++)
      printf("%10.4f", afunc[j]);
    printf("\n");
  }
  free_vector(afunc, 1, 5);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x1,%edi
mov    $0x5,%esi
call   1060 <vector@plt>
mov    %rax,-0x18(%rbp)
lea    0xe9f(%rip),%rdi
lea    0xe9f(%rip),%rsi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe9d(%rip),%rdi
lea    0xe94(%rip),%rsi
lea    0xea9(%rip),%rdx
lea    0xea7(%rip),%rcx
lea    0xea5(%rip),%r8
lea    0xea3(%rip),%r9
lea    0xea1(%rip),%rax
mov    %rax,(%rsp)
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x8(%rbp)
cmpl   $0xf,-0x8(%rbp)
jg     1262 <main+0x122>
cvtsi2sdl -0x8(%rbp),%xmm0
movsd  0xe2f(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x10(%rbp)
movss  -0x10(%rbp),%xmm0
mov    -0x18(%rbp),%rdi
mov    $0x5,%esi
call   1030 <fpoly@plt>
movss  -0x10(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe4d(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
movl   $0x1,-0xc(%rbp)
cmpl   $0x5,-0xc(%rbp)
jg     1246 <main+0x106>
mov    -0x18(%rbp),%rax
movslq -0xc(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe1d(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    120f <main+0xcf>
lea    0xdc0(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11ba <main+0x7a>
mov    -0x18(%rbp),%rdi
mov    $0x1,%esi
mov    $0x5,%edx
call   1050 <free_vector@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x20,%rsp
mov    $0x1,%edi
mov    $0x5,%esi
call   1070 <vector@plt>
mov    %rax,%rbx
lea    0xe9f(%rip),%rdi
lea    0xe9f(%rip),%rsi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xecb(%rip),%rax
mov    %rax,(%rsp)
lea    0xe92(%rip),%rdi
lea    0xe89(%rip),%rsi
lea    0xe9e(%rip),%rdx
lea    0xe9c(%rip),%rcx
lea    0xe9a(%rip),%r8
lea    0xe98(%rip),%r9
xor    %eax,%eax
call   1050 <printf@plt>
movsd  0xe3d(%rip),%xmm0
mov    $0xf,%ebp
lea    0xe87(%rip),%r14
nop
movsd  %xmm0,0x18(%rsp)
movsd  0x18(%rsp),%xmm0
mulsd  0xe24(%rip),%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,0x14(%rsp)
mov    %rbx,%rdi
mov    $0x5,%esi
call   1040 <fpoly@plt>
movss  0x14(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
mov    %r14,%rdi
mov    $0x1,%al
call   1050 <printf@plt>
movss  0x4(%rbx),%xmm0
cvtss2sd %xmm0,%xmm0
mov    %r14,%rdi
mov    $0x1,%al
call   1050 <printf@plt>
movss  0x8(%rbx),%xmm0
cvtss2sd %xmm0,%xmm0
mov    %r14,%rdi
mov    $0x1,%al
call   1050 <printf@plt>
movss  0xc(%rbx),%xmm0
cvtss2sd %xmm0,%xmm0
mov    %r14,%rdi
mov    $0x1,%al
call   1050 <printf@plt>
movss  0x10(%rbx),%xmm0
cvtss2sd %xmm0,%xmm0
mov    %r14,%rdi
mov    $0x1,%al
call   1050 <printf@plt>
movss  0x14(%rbx),%xmm0
cvtss2sd %xmm0,%xmm0
mov    %r14,%rdi
mov    $0x1,%al
call   1050 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
movsd  0x18(%rsp),%xmm0
addsd  0xd7a(%rip),%xmm0
add    $0xffffffff,%ebp
jne    11d0 <main+0x80>
mov    %rbx,%rdi
mov    $0x1,%esi
mov    $0x5,%edx
call   1060 <free_vector@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [7 x i8] c"\0A%38s\0A\00"
@.str.1 = [12 x i8] c"powers of x\00"
@.str.2 = [26 x i8] c"%8s %10s %9s %9s %9s %9s\0A\00"
@.str.3 = [2 x i8] c"x\00"
@.str.4 = [5 x i8] c"x**0\00"
@.str.5 = [5 x i8] c"x**1\00"
@.str.6 = [5 x i8] c"x**2\00"
@.str.7 = [5 x i8] c"x**3\00"
@.str.8 = [5 x i8] c"x**4\00"
@.str.9 = [7 x i8] c"%10.4f\00"
@.str.10 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca float
%5 = alloca float*
store i32 0, i32* %1
%6 = call float* @vector(i32 1, i32 5)
store float* %6, float** %5
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0))
store i32 1, i32* %2
br label %9
9: ; preds = %39, %0
%10 = load i32, i32* %2
%11 = icmp sle i32 %10, 15
br i1 %11, label %12, label %42
12: ; preds = %9
%13 = load i32, i32* %2
%14 = sitofp i32 %13 to double
%15 = fmul double %14, 1.000000e-01
%16 = fptrunc double %15 to float
store float %16, float* %4
%17 = load float, float* %4
%18 = load float*, float** %5
%19 = call i32 @fpoly(float %17, float* %18, i32 5)
%20 = load float, float* %4
%21 = fpext float %20 to double
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.9, i64 0, i64 0), double %21)
store i32 1, i32* %3
br label %23
23: ; preds = %34, %12
%24 = load i32, i32* %3
%25 = icmp sle i32 %24, 5
br i1 %25, label %26, label %37
26: ; preds = %23
%27 = load float*, float** %5
%28 = load i32, i32* %3
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds float, float* %27, i64 %29
%31 = load float, float* %30
%32 = fpext float %31 to double
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.9, i64 0, i64 0), double %32)
br label %34
34: ; preds = %26
%35 = load i32, i32* %3
%36 = add nsw i32 %35, 1
store i32 %36, i32* %3
br label %23
37: ; preds = %23
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.10, i64 0, i64 0))
br label %39
39: ; preds = %37
%40 = load i32, i32* %2
%41 = add nsw i32 %40, 1
store i32 %41, i32* %2
br label %9
42: ; preds = %9
%43 = load float*, float** %5
%44 = call i32 @free_vector(float* %43, i32 1, i32 5)
ret i32 0
}

LLVM IR (-O2):
@.str = [7 x i8] c"\0A%38s\0A\00"
@.str.1 = [12 x i8] c"powers of x\00"
@.str.2 = [26 x i8] c"%8s %10s %9s %9s %9s %9s\0A\00"
@.str.3 = [2 x i8] c"x\00"
@.str.4 = [5 x i8] c"x**0\00"
@.str.5 = [5 x i8] c"x**1\00"
@.str.6 = [5 x i8] c"x**2\00"
@.str.7 = [5 x i8] c"x**3\00"
@.str.8 = [5 x i8] c"x**4\00"
@.str.9 = [7 x i8] c"%10.4f\00"
define i32 @main() {
%1 = tail call float* @vector(i32 1, i32 5)
%2 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0))
%4 = getelementptr inbounds float, float* %1, i64 1
%5 = getelementptr inbounds float, float* %1, i64 2
%6 = getelementptr inbounds float, float* %1, i64 3
%7 = getelementptr inbounds float, float* %1, i64 4
%8 = getelementptr inbounds float, float* %1, i64 5
br label %9
9: ; preds = %0, %9
%10 = phi i32 [ 1, %0 ], [ %33, %9 ]
%11 = sitofp i32 %10 to double
%12 = fmul double %11, 1.000000e-01
%13 = fptrunc double %12 to float
%14 = tail call i32 @fpoly(float %13, float* %1, i32 5)
%15 = fpext float %13 to double
%16 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.9, i64 0, i64 0), double %15)
%17 = load float, float* %4
%18 = fpext float %17 to double
%19 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.9, i64 0, i64 0), double %18)
%20 = load float, float* %5
%21 = fpext float %20 to double
%22 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.9, i64 0, i64 0), double %21)
%23 = load float, float* %6
%24 = fpext float %23 to double
%25 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.9, i64 0, i64 0), double %24)
%26 = load float, float* %7
%27 = fpext float %26 to double
%28 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.9, i64 0, i64 0), double %27)
%29 = load float, float* %8
%30 = fpext float %29 to double
%31 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.9, i64 0, i64 0), double %30)
%32 = tail call i32 @putchar(i32 10)
%33 = add nuw nsw i32 %10, 1
%34 = icmp eq i32 %33, 16
br i1 %34, label %35, label %9
35: ; preds = %9
%36 = tail call i32 @free_vector(float* %1, i32 1, i32 5)
ret i32 0
}