#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*/ correl(float *, float *, int, float *);
int /*<<< orphan*/ free_vector(float *, int, int);
int /*<<< orphan*/ printf(char *, ...);
float *vector(int, int);
int main(void) {
  unsigned long i, j;
  float cmp, *data1, *data2, *ans;
  data1 = vector(1, 64);
  data2 = vector(1, 64);
  ans = vector(1, (2 * 64));
  for (i = 1; i <= 64; i++) {
    if ((i > 64 / 2 - 64 / 8) && (i < 64 / 2 + 64 / 8))
      data1[i] = 1.0;
    else
      data1[i] = 0.0;
    data2[i] = data1[i];
  }
  correl(data1, data2, 64, ans);
  printf("%3s %14s %18s\n", "n", "CORREL", "direct calc.");
  for (i = 0; i <= 16; i++) {
    cmp = 0.0;
    for (j = 1; j <= 64; j++)
      cmp += data1[((i + j - 1) % 64) + 1] * data2[j];
    printf("%3ld %15.6f %15.6f\n", i, ans[i + 1], cmp);
  }
  free_vector(ans, 1, (2 * 64));
  free_vector(data2, 1, 64);
  free_vector(data1, 1, 64);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x1,%edi
mov    $0x40,%esi
call   1050 <vector@plt>
mov    %rax,-0x28(%rbp)
mov    $0x1,%edi
mov    $0x40,%esi
call   1050 <vector@plt>
mov    %rax,-0x30(%rbp)
mov    $0x1,%edi
mov    $0x80,%esi
call   1050 <vector@plt>
mov    %rax,-0x38(%rbp)
movq   $0x1,-0x10(%rbp)
cmpq   $0x40,-0x10(%rbp)
ja     1206 <main+0xc6>
cmpq   $0x18,-0x10(%rbp)
jbe    11cb <main+0x8b>
cmpq   $0x28,-0x10(%rbp)
jae    11cb <main+0x8b>
mov    -0x28(%rbp),%rax
mov    -0x10(%rbp),%rcx
movss  0xe3f(%rip),%xmm0
movss  %xmm0,(%rax,%rcx,4)
jmp    11db <main+0x9b>
mov    -0x28(%rbp),%rax
mov    -0x10(%rbp),%rcx
xorps  %xmm0,%xmm0
movss  %xmm0,(%rax,%rcx,4)
mov    -0x28(%rbp),%rax
mov    -0x10(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm0
mov    -0x30(%rbp),%rax
mov    -0x10(%rbp),%rcx
movss  %xmm0,(%rax,%rcx,4)
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1190 <main+0x50>
mov    -0x28(%rbp),%rdi
mov    -0x30(%rbp),%rsi
mov    -0x38(%rbp),%rcx
mov    $0x40,%edx
call   1060 <correl@plt>
lea    0xde1(%rip),%rdi
lea    0xde9(%rip),%rsi
lea    0xde4(%rip),%rdx
lea    0xde4(%rip),%rcx
mov    $0x0,%al
call   1030 <printf@plt>
movq   $0x0,-0x10(%rbp)
cmpq   $0x10,-0x10(%rbp)
ja     12f5 <main+0x1b5>
xorps  %xmm0,%xmm0
movss  %xmm0,-0x1c(%rbp)
movq   $0x1,-0x18(%rbp)
cmpq   $0x40,-0x18(%rbp)
ja     12b7 <main+0x177>
mov    -0x28(%rbp),%rax
mov    -0x10(%rbp),%rcx
add    -0x18(%rbp),%rcx
sub    $0x1,%rcx
and    $0x3f,%rcx
movss  0x4(%rax,%rcx,4),%xmm0
mov    -0x30(%rbp),%rax
mov    -0x18(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm2
movss  -0x1c(%rbp),%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x1c(%rbp)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1262 <main+0x122>
mov    -0x10(%rbp),%rsi
mov    -0x38(%rbp),%rax
mov    -0x10(%rbp),%rcx
movss  0x4(%rax,%rcx,4),%xmm0
cvtss2sd %xmm0,%xmm0
movss  -0x1c(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
lea    0xd4c(%rip),%rdi
mov    $0x2,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1247 <main+0x107>
mov    -0x38(%rbp),%rdi
mov    $0x1,%esi
mov    $0x80,%edx
call   1040 <free_vector@plt>
mov    -0x30(%rbp),%rdi
mov    $0x1,%esi
mov    $0x40,%edx
call   1040 <free_vector@plt>
mov    -0x28(%rbp),%rdi
mov    $0x1,%esi
mov    $0x40,%edx
call   1040 <free_vector@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    $0x1,%edi
mov    $0x40,%esi
call   1050 <vector@plt>
mov    %rax,%r14
mov    $0x1,%edi
mov    $0x40,%esi
call   1050 <vector@plt>
mov    %rax,%rbx
mov    $0x1,%edi
mov    $0x80,%esi
call   1050 <vector@plt>
mov    %rax,%r15
mov    $0xffffffffffffffe8,%rax
movss  0xe70(%rip),%xmm0
jmp    11b7 <main+0x77>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movss  %xmm1,0x68(%r14,%rax,4)
movss  %xmm1,0x68(%rbx,%rax,4)
add    $0x2,%rax
cmp    $0x28,%rax
je     11e2 <main+0xa2>
movaps %xmm0,%xmm1
cmp    $0xf,%rax
jb     11c3 <main+0x83>
xorps  %xmm1,%xmm1
movss  %xmm1,0x64(%r14,%rax,4)
movss  %xmm1,0x64(%rbx,%rax,4)
lea    0x1(%rax),%rcx
movaps %xmm0,%xmm1
cmp    $0xf,%rcx
jb     11a0 <main+0x60>
xorps  %xmm1,%xmm1
jmp    11a0 <main+0x60>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    $0x40,%edx
mov    %r15,%rcx
call   1060 <correl@plt>
lea    0xe08(%rip),%rdi
lea    0xe10(%rip),%rsi
lea    0xe0b(%rip),%rdx
lea    0xe0b(%rip),%rcx
xor    %r13d,%r13d
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0x41,%ebp
xorps  %xmm1,%xmm1
mov    $0x8,%eax
mov    %rbp,%rcx
nopl   0x0(%rax,%rax,1)
lea    -0x1(%rcx),%edx
and    $0x3f,%edx
movss  0x4(%r14,%rdx,4),%xmm0
mulss  -0x4(%rbx,%rax,1),%xmm0
addss  %xmm1,%xmm0
mov    %ecx,%edx
and    $0x3f,%edx
movss  0x4(%r14,%rdx,4),%xmm1
mulss  (%rbx,%rax,1),%xmm1
addss  %xmm0,%xmm1
add    $0x8,%rax
add    $0x2,%rcx
cmp    $0x108,%rax
jne    1230 <main+0xf0>
lea    0x1(%r13),%r12
movss  0x4(%r15,%r13,4),%xmm0
cvtss2sd %xmm0,%xmm0
cvtss2sd %xmm1,%xmm1
lea    0xda3(%rip),%rdi
mov    %r13,%rsi
mov    $0x2,%al
call   1030 <printf@plt>
add    $0x1,%rbp
mov    %r12,%r13
cmp    $0x11,%r12
jne    1220 <main+0xe0>
mov    %r15,%rdi
mov    $0x1,%esi
mov    $0x80,%edx
call   1040 <free_vector@plt>
mov    %rbx,%rdi
mov    $0x1,%esi
mov    $0x40,%edx
call   1040 <free_vector@plt>
mov    %r14,%rdi
mov    $0x1,%esi
mov    $0x40,%edx
call   1040 <free_vector@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [15 x i8] c"%3s %14s %18s\0A\00"
@.str.1 = [2 x i8] c"n\00"
@.str.2 = [7 x i8] c"CORREL\00"
@.str.3 = [13 x i8] c"direct calc.\00"
@.str.4 = [20 x i8] c"%3ld %15.6f %15.6f\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i64
%3 = alloca i64
%4 = alloca float
%5 = alloca float*
%6 = alloca float*
%7 = alloca float*
store i32 0, i32* %1
%8 = call float* @vector(i32 1, i32 64)
store float* %8, float** %5
%9 = call float* @vector(i32 1, i32 64)
store float* %9, float** %6
%10 = call float* @vector(i32 1, i32 128)
store float* %10, float** %7
store i64 1, i64* %2
br label %11
11: ; preds = %36, %0
%12 = load i64, i64* %2
%13 = icmp ule i64 %12, 64
br i1 %13, label %14, label %39
14: ; preds = %11
%15 = load i64, i64* %2
%16 = icmp ugt i64 %15, 24
br i1 %16, label %17, label %24
17: ; preds = %14
%18 = load i64, i64* %2
%19 = icmp ult i64 %18, 40
br i1 %19, label %20, label %24
20: ; preds = %17
%21 = load float*, float** %5
%22 = load i64, i64* %2
%23 = getelementptr inbounds float, float* %21, i64 %22
store float 1.000000e+00, float* %23
br label %28
24: ; preds = %17, %14
%25 = load float*, float** %5
%26 = load i64, i64* %2
%27 = getelementptr inbounds float, float* %25, i64 %26
store float 0.000000e+00, float* %27
br label %28
28: ; preds = %24, %20
%29 = load float*, float** %5
%30 = load i64, i64* %2
%31 = getelementptr inbounds float, float* %29, i64 %30
%32 = load float, float* %31
%33 = load float*, float** %6
%34 = load i64, i64* %2
%35 = getelementptr inbounds float, float* %33, i64 %34
store float %32, float* %35
br label %36
36: ; preds = %28
%37 = load i64, i64* %2
%38 = add i64 %37, 1
store i64 %38, i64* %2
br label %11
39: ; preds = %11
%40 = load float*, float** %5
%41 = load float*, float** %6
%42 = load float*, float** %7
%43 = call i32 @correl(float* %40, float* %41, i32 64, float* %42)
%44 = 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 ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0))
store i64 0, i64* %2
br label %45
45: ; preds = %82, %39
%46 = load i64, i64* %2
%47 = icmp ule i64 %46, 16
br i1 %47, label %48, label %85
48: ; preds = %45
store float 0.000000e+00, float* %4
store i64 1, i64* %3
br label %49
49: ; preds = %68, %48
%50 = load i64, i64* %3
%51 = icmp ule i64 %50, 64
br i1 %51, label %52, label %71
52: ; preds = %49
%53 = load float*, float** %5
%54 = load i64, i64* %2
%55 = load i64, i64* %3
%56 = add i64 %54, %55
%57 = sub i64 %56, 1
%58 = urem i64 %57, 64
%59 = add i64 %58, 1
%60 = getelementptr inbounds float, float* %53, i64 %59
%61 = load float, float* %60
%62 = load float*, float** %6
%63 = load i64, i64* %3
%64 = getelementptr inbounds float, float* %62, i64 %63
%65 = load float, float* %64
%66 = load float, float* %4
%67 = call float @llvm.fmuladd.f32(float %61, float %65, float %66)
store float %67, float* %4
br label %68
68: ; preds = %52
%69 = load i64, i64* %3
%70 = add i64 %69, 1
store i64 %70, i64* %3
br label %49
71: ; preds = %49
%72 = load i64, i64* %2
%73 = load float*, float** %7
%74 = load i64, i64* %2
%75 = add i64 %74, 1
%76 = getelementptr inbounds float, float* %73, i64 %75
%77 = load float, float* %76
%78 = fpext float %77 to double
%79 = load float, float* %4
%80 = fpext float %79 to double
%81 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0), i64 %72, double %78, double %80)
br label %82
82: ; preds = %71
%83 = load i64, i64* %2
%84 = add i64 %83, 1
store i64 %84, i64* %2
br label %45
85: ; preds = %45
%86 = load float*, float** %7
%87 = call i32 @free_vector(float* %86, i32 1, i32 128)
%88 = load float*, float** %6
%89 = call i32 @free_vector(float* %88, i32 1, i32 64)
%90 = load float*, float** %5
%91 = call i32 @free_vector(float* %90, i32 1, i32 64)
ret i32 0
}

LLVM IR (-O2):
@.str = [15 x i8] c"%3s %14s %18s\0A\00"
@.str.1 = [2 x i8] c"n\00"
@.str.2 = [7 x i8] c"CORREL\00"
@.str.3 = [13 x i8] c"direct calc.\00"
@.str.4 = [20 x i8] c"%3ld %15.6f %15.6f\0A\00"
define i32 @main() {
%1 = tail call float* @vector(i32 1, i32 64)
%2 = tail call float* @vector(i32 1, i32 64)
%3 = tail call float* @vector(i32 1, i32 128)
br label %4
4: ; preds = %4, %0
%5 = phi i64 [ 1, %0 ], [ %17, %4 ]
%6 = add nsw i64 %5, -25
%7 = icmp ult i64 %6, 15
%8 = select i1 %7, float 1.000000e+00, float 0.000000e+00
%9 = getelementptr inbounds float, float* %1, i64 %5
store float %8, float* %9
%10 = getelementptr inbounds float, float* %2, i64 %5
store float %8, float* %10
%11 = add nuw nsw i64 %5, 1
%12 = add nsw i64 %5, -24
%13 = icmp ult i64 %12, 15
%14 = select i1 %13, float 1.000000e+00, float 0.000000e+00
%15 = getelementptr inbounds float, float* %1, i64 %11
store float %14, float* %15
%16 = getelementptr inbounds float, float* %2, i64 %11
store float %14, float* %16
%17 = add nuw nsw i64 %5, 2
%18 = icmp eq i64 %17, 65
br i1 %18, label %19, label %4
19: ; preds = %4
%20 = tail call i32 @correl(float* %1, float* %2, i32 64, float* %3)
%21 = tail 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 ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0))
br label %22
22: ; preds = %19, %47
%23 = phi i64 [ 0, %19 ], [ %48, %47 ]
%24 = add nuw nsw i64 %23, 63
br label %25
25: ; preds = %25, %22
%26 = phi i64 [ 1, %22 ], [ %45, %25 ]
%27 = phi float [ 0.000000e+00, %22 ], [ %44, %25 ]
%28 = add nuw nsw i64 %24, %26
%29 = and i64 %28, 63
%30 = add nuw nsw i64 %29, 1
%31 = getelementptr inbounds float, float* %1, i64 %30
%32 = load float, float* %31
%33 = getelementptr inbounds float, float* %2, i64 %26
%34 = load float, float* %33
%35 = tail call float @llvm.fmuladd.f32(float %32, float %34, float %27)
%36 = add nuw nsw i64 %26, 1
%37 = add nuw nsw i64 %24, %36
%38 = and i64 %37, 63
%39 = add nuw nsw i64 %38, 1
%40 = getelementptr inbounds float, float* %1, i64 %39
%41 = load float, float* %40
%42 = getelementptr inbounds float, float* %2, i64 %36
%43 = load float, float* %42
%44 = tail call float @llvm.fmuladd.f32(float %41, float %43, float %35)
%45 = add nuw nsw i64 %26, 2
%46 = icmp eq i64 %45, 65
br i1 %46, label %47, label %25
47: ; preds = %25
%48 = add nuw nsw i64 %23, 1
%49 = getelementptr inbounds float, float* %3, i64 %48
%50 = load float, float* %49
%51 = fpext float %50 to double
%52 = fpext float %44 to double
%53 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0), i64 %23, double %51, double %52)
%54 = icmp eq i64 %48, 17
br i1 %54, label %55, label %22
55: ; preds = %47
%56 = tail call i32 @free_vector(float* %3, i32 1, i32 128)
%57 = tail call i32 @free_vector(float* %2, i32 1, i32 64)
%58 = tail call i32 @free_vector(float* %1, i32 1, i32 64)
ret i32 0
}