#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 f(int, int);
int /*<<< orphan*/ fixrts(float *, int);
int /*<<< orphan*/ free_vector(float *, int, int);
int /*<<< orphan*/ memcof(float *, int, int, float *, float *);
int /*<<< orphan*/ predic(float *, int, float *, int, float *, int);
int /*<<< orphan*/ printf(char *, ...);
float *vector(int, int);
int main(void) {
  int i;
  float dum, *d, *future, *data;
  d = vector(1, 10);
  future = vector(1, 20);
  data = vector(1, 500);
  for (i = 1; i <= 500; i++)
    data[i] = f(i, 500);
  memcof(data, 500, 10, &dum, d);
  fixrts(d, 10);
  predic(data, 500, d, 10, future, 20);
  printf("%6s %11s %12s\n", "I", "Actual", "PREDIC");
  for (i = 1; i <= 20; i++)
    printf("%6d %12.6f %12.6f\n", i, f(i + 500, 500), future[i]);
  free_vector(data, 1, 500);
  free_vector(future, 1, 20);
  free_vector(d, 1, 10);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x1,%edi
mov    $0xa,%esi
call   1080 <vector@plt>
mov    %rax,-0x18(%rbp)
mov    $0x1,%edi
mov    $0x14,%esi
call   1080 <vector@plt>
mov    %rax,-0x20(%rbp)
mov    $0x1,%edi
mov    $0x1f4,%esi
call   1080 <vector@plt>
mov    %rax,-0x28(%rbp)
movl   $0x1,-0x8(%rbp)
cmpl   $0x1f4,-0x8(%rbp)
jg     11f8 <main+0x88>
mov    -0x8(%rbp),%edi
mov    $0x1f4,%esi
call   1040 <f@plt>
cvtsd2ss %xmm0,%xmm0
mov    -0x28(%rbp),%rax
movslq -0x8(%rbp),%rcx
movss  %xmm0,(%rax,%rcx,4)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11bf <main+0x4f>
mov    -0x28(%rbp),%rdi
mov    -0x18(%rbp),%r8
mov    $0x1f4,%esi
mov    $0xa,%edx
lea    -0xc(%rbp),%rcx
call   1090 <memcof@plt>
mov    -0x18(%rbp),%rdi
mov    $0xa,%esi
call   1030 <fixrts@plt>
mov    -0x28(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%r8
mov    $0x1f4,%esi
mov    $0xa,%ecx
mov    $0x14,%r9d
call   1070 <predic@plt>
lea    0xdb7(%rip),%rdi
lea    0xdbf(%rip),%rsi
lea    0xdba(%rip),%rdx
lea    0xdba(%rip),%rcx
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x1,-0x8(%rbp)
cmpl   $0x14,-0x8(%rbp)
jg     12bf <main+0x14f>
mov    -0x8(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x8(%rbp),%edi
add    $0x1f4,%edi
mov    $0x1f4,%esi
call   1040 <f@plt>
mov    -0x2c(%rbp),%esi
mov    -0x20(%rbp),%rax
movslq -0x8(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm1
cvtss2sd %xmm1,%xmm1
lea    0xd75(%rip),%rdi
mov    $0x2,%al
call   1050 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    126c <main+0xfc>
mov    -0x28(%rbp),%rdi
mov    $0x1,%esi
mov    $0x1f4,%edx
call   1060 <free_vector@plt>
mov    -0x20(%rbp),%rdi
mov    $0x1,%esi
mov    $0x14,%edx
call   1060 <free_vector@plt>
mov    -0x18(%rbp),%rdi
mov    $0x1,%esi
mov    $0xa,%edx
call   1060 <free_vector@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    $0x1,%edi
mov    $0xa,%esi
call   1080 <vector@plt>
mov    %rax,%r14
mov    $0x1,%edi
mov    $0x14,%esi
call   1080 <vector@plt>
mov    %rax,%r15
mov    $0x1,%edi
mov    $0x1f4,%esi
call   1080 <vector@plt>
mov    %rax,%r12
mov    $0x1,%ebx
nopl   0x0(%rax,%rax,1)
mov    %ebx,%edi
mov    $0x1f4,%esi
call   1040 <f@plt>
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,(%r12,%rbx,4)
add    $0x1,%rbx
cmp    $0x1f5,%rbx
jne    11c0 <main+0x50>
lea    0xc(%rsp),%rcx
mov    %r12,%rdi
mov    $0x1f4,%esi
mov    $0xa,%edx
mov    %r14,%r8
call   1090 <memcof@plt>
mov    %r14,%rdi
mov    $0xa,%esi
call   1030 <fixrts@plt>
mov    %r12,%rdi
mov    $0x1f4,%esi
mov    %r14,%rdx
mov    $0xa,%ecx
mov    %r15,%r8
mov    $0x14,%r9d
call   1070 <predic@plt>
lea    0xdd1(%rip),%rdi
lea    0xdd9(%rip),%rsi
lea    0xdd4(%rip),%rdx
lea    0xdd4(%rip),%rcx
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x1,%ebx
lea    0xdc8(%rip),%r13
nopw   0x0(%rax,%rax,1)
lea    0x1f4(%rbx),%edi
mov    $0x1f4,%esi
call   1040 <f@plt>
movss  (%r15,%rbx,4),%xmm1
cvtss2sd %xmm1,%xmm1
mov    %r13,%rdi
mov    %ebx,%esi
mov    $0x2,%al
call   1050 <printf@plt>
add    $0x1,%rbx
cmp    $0x15,%rbx
jne    1260 <main+0xf0>
mov    %r12,%rdi
mov    $0x1,%esi
mov    $0x1f4,%edx
call   1060 <free_vector@plt>
mov    %r15,%rdi
mov    $0x1,%esi
mov    $0x14,%edx
call   1060 <free_vector@plt>
mov    %r14,%rdi
mov    $0x1,%esi
mov    $0xa,%edx
call   1060 <free_vector@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [15 x i8] c"%6s %11s %12s\0A\00"
@.str.1 = [2 x i8] c"I\00"
@.str.2 = [7 x i8] c"Actual\00"
@.str.3 = [7 x i8] c"PREDIC\00"
@.str.4 = [19 x i8] c"%6d %12.6f %12.6f\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca float
%4 = alloca float*
%5 = alloca float*
%6 = alloca float*
store i32 0, i32* %1
%7 = call float* @vector(i32 1, i32 10)
store float* %7, float** %4
%8 = call float* @vector(i32 1, i32 20)
store float* %8, float** %5
%9 = call float* @vector(i32 1, i32 500)
store float* %9, float** %6
store i32 1, i32* %2
br label %10
10: ; preds = %21, %0
%11 = load i32, i32* %2
%12 = icmp sle i32 %11, 500
br i1 %12, label %13, label %24
13: ; preds = %10
%14 = load i32, i32* %2
%15 = call double @f(i32 %14, i32 500)
%16 = fptrunc double %15 to float
%17 = load float*, float** %6
%18 = load i32, i32* %2
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds float, float* %17, i64 %19
store float %16, float* %20
br label %21
21: ; preds = %13
%22 = load i32, i32* %2
%23 = add nsw i32 %22, 1
store i32 %23, i32* %2
br label %10
24: ; preds = %10
%25 = load float*, float** %6
%26 = load float*, float** %4
%27 = call i32 @memcof(float* %25, i32 500, i32 10, float* %3, float* %26)
%28 = load float*, float** %4
%29 = call i32 @fixrts(float* %28, i32 10)
%30 = load float*, float** %6
%31 = load float*, float** %4
%32 = load float*, float** %5
%33 = call i32 @predic(float* %30, i32 500, float* %31, i32 10, float* %32, i32 20)
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
store i32 1, i32* %2
br label %35
35: ; preds = %50, %24
%36 = load i32, i32* %2
%37 = icmp sle i32 %36, 20
br i1 %37, label %38, label %53
38: ; preds = %35
%39 = load i32, i32* %2
%40 = load i32, i32* %2
%41 = add nsw i32 %40, 500
%42 = call double @f(i32 %41, i32 500)
%43 = load float*, float** %5
%44 = load i32, i32* %2
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds float, float* %43, i64 %45
%47 = load float, float* %46
%48 = fpext float %47 to double
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0), i32 %39, double %42, double %48)
br label %50
50: ; preds = %38
%51 = load i32, i32* %2
%52 = add nsw i32 %51, 1
store i32 %52, i32* %2
br label %35
53: ; preds = %35
%54 = load float*, float** %6
%55 = call i32 @free_vector(float* %54, i32 1, i32 500)
%56 = load float*, float** %5
%57 = call i32 @free_vector(float* %56, i32 1, i32 20)
%58 = load float*, float** %4
%59 = call i32 @free_vector(float* %58, i32 1, i32 10)
ret i32 0
}

LLVM IR (-O2):
@.str = [15 x i8] c"%6s %11s %12s\0A\00"
@.str.1 = [2 x i8] c"I\00"
@.str.2 = [7 x i8] c"Actual\00"
@.str.3 = [7 x i8] c"PREDIC\00"
@.str.4 = [19 x i8] c"%6d %12.6f %12.6f\0A\00"
define i32 @main() {
%1 = alloca float
%2 = bitcast float* %1 to i8*
%3 = tail call float* @vector(i32 1, i32 10)
%4 = tail call float* @vector(i32 1, i32 20)
%5 = tail call float* @vector(i32 1, i32 500)
br label %6
6: ; preds = %0, %6
%7 = phi i64 [ 1, %0 ], [ %12, %6 ]
%8 = trunc i64 %7 to i32
%9 = tail call double @f(i32 %8, i32 500)
%10 = fptrunc double %9 to float
%11 = getelementptr inbounds float, float* %5, i64 %7
store float %10, float* %11
%12 = add nuw nsw i64 %7, 1
%13 = icmp eq i64 %12, 501
br i1 %13, label %14, label %6
14: ; preds = %6
%15 = call i32 @memcof(float* %5, i32 500, i32 10, float* %1, float* %3)
%16 = call i32 @fixrts(float* %3, i32 10)
%17 = call i32 @predic(float* %5, i32 500, float* %3, i32 10, float* %4, i32 20)
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
br label %19
19: ; preds = %14, %19
%20 = phi i64 [ 1, %14 ], [ %29, %19 ]
%21 = trunc i64 %20 to i32
%22 = add i32 %21, 500
%23 = call double @f(i32 %22, i32 500)
%24 = getelementptr inbounds float, float* %4, i64 %20
%25 = load float, float* %24
%26 = fpext float %25 to double
%27 = trunc i64 %20 to i32
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0), i32 %27, double %23, double %26)
%29 = add nuw nsw i64 %20, 1
%30 = icmp eq i64 %29, 21
br i1 %30, label %31, label %19
31: ; preds = %19
%32 = call i32 @free_vector(float* %5, i32 1, i32 500)
%33 = call i32 @free_vector(float* %4, i32 1, i32 20)
%34 = call i32 @free_vector(float* %3, i32 1, i32 10)
ret i32 0
}