#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 TwiceNumFreqs;

/* Variables and functions */
double cos(double);
int /*<<< orphan*/ freeMat(int, double ***);
int /*<<< orphan*/ initMat(int, int, double ***);
int /*<<< orphan*/ matrixMultiply(int, int, int, double **, double **,
                                  double **);
int /*<<< orphan*/ rref(int, int, double **);
double sin(double);
int /*<<< orphan*/ transpose(int, int, double **, double **);
double discreteFourier(int n, double *x, double *y, int numFreqs,
                       double *cosines, double *sines) {
  int i = 0;
  int j = 0;
  register int TwiceNumFreqs = 2 * numFreqs;
  register double angularFreq = 2 * 3.14159265358979323846 / (x[n - 1] - x[0]);
  double meanOfData = 0;
  double *(*bMat);
  initMat(n, TwiceNumFreqs, &bMat);
  double *(*bMatTr);
  initMat(TwiceNumFreqs, n, &bMatTr);
  double *(*leastSqr);
  initMat(TwiceNumFreqs, (TwiceNumFreqs) + 1, &leastSqr);
  double *(*tempMat);
  initMat(TwiceNumFreqs, TwiceNumFreqs, &tempMat);
  for (i = 0; i < n; i++) {
    meanOfData += y[i];
    for (j = 0; j < numFreqs; j++) {
      bMat[i][2 * j] = cos(angularFreq * (j + 1) * (x[i]));
      bMat[i][(2 * j) + 1] = sin(angularFreq * (j + 1) * (x[i]));
    }
  }
  transpose(n, TwiceNumFreqs, bMat, bMatTr);
  matrixMultiply(TwiceNumFreqs, n, TwiceNumFreqs, bMatTr, bMat, tempMat);
  for (i = 0; i < TwiceNumFreqs; i++) {
    for (j = 0; j < n; j++) {
      leastSqr[i][TwiceNumFreqs] += bMatTr[i][j] * y[j];
      if (j < TwiceNumFreqs) {
        leastSqr[i][j] = tempMat[i][j];
      }
    }
  }
  rref((TwiceNumFreqs), (TwiceNumFreqs) + 1, leastSqr);
  for (i = 0; i < numFreqs; i++) {
    cosines[i] = leastSqr[2 * i][TwiceNumFreqs];
    sines[i] = leastSqr[(2 * i) + 1][TwiceNumFreqs];
  }
  freeMat(n, &bMat);
  freeMat(TwiceNumFreqs, &bMatTr);
  freeMat(TwiceNumFreqs, &leastSqr);
  freeMat(TwiceNumFreqs, &tempMat);
  return meanOfData / n;
}


x86 assembly (clang, -O0):
<discreteFourier>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
movl   $0x0,-0x34(%rbp)
movl   $0x0,-0x38(%rbp)
mov    -0x1c(%rbp),%eax
shl    $0x1,%eax
mov    %eax,-0x3c(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x4(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm1
mov    -0x10(%rbp),%rax
subsd  (%rax),%xmm1
movsd  0xe39(%rip),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x50(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x3c(%rbp),%esi
lea    -0x58(%rbp),%rdx
call   1030 <initMat@plt>
mov    -0x3c(%rbp),%edi
mov    -0x4(%rbp),%esi
lea    -0x60(%rbp),%rdx
call   1030 <initMat@plt>
mov    -0x3c(%rbp),%edi
mov    -0x3c(%rbp),%esi
add    $0x1,%esi
lea    -0x68(%rbp),%rdx
call   1030 <initMat@plt>
mov    -0x3c(%rbp),%edi
mov    -0x3c(%rbp),%esi
lea    -0x70(%rbp),%rdx
call   1030 <initMat@plt>
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    12f6 <discreteFourier+0x186>
mov    -0x18(%rbp),%rax
movslq -0x34(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
addsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movl   $0x0,-0x38(%rbp)
mov    -0x38(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    12e3 <discreteFourier+0x173>
movsd  -0x48(%rbp),%xmm0
mov    -0x38(%rbp),%eax
add    $0x1,%eax
cvtsi2sd %eax,%xmm1
mulsd  %xmm1,%xmm0
mov    -0x10(%rbp),%rax
movslq -0x34(%rbp),%rcx
mulsd  (%rax,%rcx,8),%xmm0
call   1070 <cos@plt>
mov    -0x58(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    -0x38(%rbp),%ecx
shl    $0x1,%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
movsd  -0x48(%rbp),%xmm0
mov    -0x38(%rbp),%eax
add    $0x1,%eax
cvtsi2sd %eax,%xmm1
mulsd  %xmm1,%xmm0
mov    -0x10(%rbp),%rax
movslq -0x34(%rbp),%rcx
mulsd  (%rax,%rcx,8),%xmm0
call   1060 <sin@plt>
mov    -0x58(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    -0x38(%rbp),%ecx
shl    $0x1,%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    1248 <discreteFourier+0xd8>
jmp    12e8 <discreteFourier+0x178>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    121e <discreteFourier+0xae>
mov    -0x4(%rbp),%edi
mov    -0x3c(%rbp),%esi
mov    -0x58(%rbp),%rdx
mov    -0x60(%rbp),%rcx
call   1050 <transpose@plt>
mov    -0x3c(%rbp),%edi
mov    -0x4(%rbp),%esi
mov    -0x3c(%rbp),%edx
mov    -0x60(%rbp),%rcx
mov    -0x58(%rbp),%r8
mov    -0x70(%rbp),%r9
call   1080 <matrixMultiply@plt>
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x3c(%rbp),%eax
jge    13e9 <discreteFourier+0x279>
movl   $0x0,-0x38(%rbp)
mov    -0x38(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    13d6 <discreteFourier+0x266>
mov    -0x60(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x38(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x18(%rbp),%rax
movslq -0x38(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm2
mov    -0x68(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x3c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x38(%rbp),%eax
cmp    -0x3c(%rbp),%eax
jge    13c3 <discreteFourier+0x253>
mov    -0x70(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x38(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x68(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x38(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
jmp    13c8 <discreteFourier+0x258>
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    133d <discreteFourier+0x1cd>
jmp    13db <discreteFourier+0x26b>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    132a <discreteFourier+0x1ba>
mov    -0x3c(%rbp),%edi
mov    -0x3c(%rbp),%esi
add    $0x1,%esi
mov    -0x68(%rbp),%rdx
call   1090 <rref@plt>
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    146d <discreteFourier+0x2fd>
mov    -0x68(%rbp),%rax
mov    -0x34(%rbp),%ecx
shl    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x3c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x28(%rbp),%rax
movslq -0x34(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x68(%rbp),%rax
mov    -0x34(%rbp),%ecx
shl    $0x1,%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x3c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x30(%rbp),%rax
movslq -0x34(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1402 <discreteFourier+0x292>
mov    -0x4(%rbp),%edi
lea    -0x58(%rbp),%rsi
call   1040 <freeMat@plt>
mov    -0x3c(%rbp),%edi
lea    -0x60(%rbp),%rsi
call   1040 <freeMat@plt>
mov    -0x3c(%rbp),%edi
lea    -0x68(%rbp),%rsi
call   1040 <freeMat@plt>
mov    -0x3c(%rbp),%edi
lea    -0x70(%rbp),%rsi
call   1040 <freeMat@plt>
movsd  -0x50(%rbp),%xmm0
cvtsi2sdl -0x4(%rbp),%xmm1
divsd  %xmm1,%xmm0
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<discreteFourier>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x78,%rsp
mov    %r9,0x68(%rsp)
mov    %r8,0x60(%rsp)
mov    %ecx,%r13d
mov    %rdx,0x48(%rsp)
mov    %rsi,%r14
mov    %edi,%r15d
lea    0x0(%r13,%r13,1),%ebx
movslq %edi,%rbp
movsd  -0x8(%rsi,%rbp,8),%xmm0
subsd  (%rsi),%xmm0
movsd  %xmm0,0x30(%rsp)
lea    0x10(%rsp),%rdx
mov    %ebp,%edi
mov    %ebx,%esi
call   1030 <initMat@plt>
lea    0x28(%rsp),%rdx
mov    %ebx,%edi
mov    %ebp,%esi
call   1030 <initMat@plt>
lea    0x1(%r13,%r13,1),%esi
lea    0x8(%rsp),%rdx
mov    %ebx,%edi
mov    %esi,0x1c(%rsp)
call   1030 <initMat@plt>
lea    0x38(%rsp),%rdx
mov    %ebx,%edi
mov    %ebx,0x40(%rsp)
mov    %ebx,%esi
call   1030 <initMat@plt>
mov    %r15d,0x44(%rsp)
mov    %r15d,%r12d
mov    %r13,0x50(%rsp)
mov    %r13d,%eax
test   %ebp,%ebp
mov    %rax,0x58(%rsp)
jle    12e7 <discreteFourier+0x177>
movsd  0xdea(%rip),%xmm1
divsd  0x30(%rsp),%xmm1
mov    %rax,%rbp
shl    $0x4,%rbp
xorpd  %xmm0,%xmm0
movsd  %xmm0,0x20(%rsp)
xor    %r13d,%r13d
movsd  %xmm1,0x70(%rsp)
jmp    124d <discreteFourier+0xdd>
nopl   0x0(%rax,%rax,1)
add    $0x1,%r13
cmp    %r12,%r13
je     12f1 <discreteFourier+0x181>
movsd  0x20(%rsp),%xmm0
mov    0x48(%rsp),%rax
addsd  (%rax,%r13,8),%xmm0
movsd  %xmm0,0x20(%rsp)
cmpl   $0x0,0x50(%rsp)
jle    1240 <discreteFourier+0xd0>
mov    $0x1,%r15d
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
xorps  %xmm2,%xmm2
cvtsi2sd %r15d,%xmm2
mulsd  %xmm1,%xmm2
movsd  %xmm2,0x30(%rsp)
movsd  (%r14,%r13,8),%xmm0
mulsd  %xmm2,%xmm0
call   1070 <cos@plt>
mov    0x10(%rsp),%rax
mov    (%rax,%r13,8),%rax
movsd  %xmm0,(%rax,%rbx,1)
movsd  0x30(%rsp),%xmm0
mulsd  (%r14,%r13,8),%xmm0
call   1060 <sin@plt>
movsd  0x70(%rsp),%xmm1
mov    0x10(%rsp),%rax
mov    (%rax,%r13,8),%rax
movsd  %xmm0,0x8(%rax,%rbx,1)
add    $0x10,%rbx
add    $0x1,%r15d
cmp    %rbx,%rbp
jne    1280 <discreteFourier+0x110>
jmp    1240 <discreteFourier+0xd0>
xorpd  %xmm0,%xmm0
movsd  %xmm0,0x20(%rsp)
mov    0x10(%rsp),%rdx
mov    0x28(%rsp),%rcx
mov    0x44(%rsp),%r14d
mov    %r14d,%edi
mov    0x40(%rsp),%r15d
mov    %r15d,%esi
call   1050 <transpose@plt>
mov    0x28(%rsp),%rcx
mov    0x10(%rsp),%r8
mov    0x38(%rsp),%r9
mov    %r15d,%edi
mov    %r14d,%esi
mov    %r15d,%edx
call   1080 <matrixMultiply@plt>
mov    0x50(%rsp),%r13
test   %r13d,%r13d
jle    13ea <discreteFourier+0x27a>
mov    0x28(%rsp),%r8
mov    0x8(%rsp),%r9
movslq %r15d,%rbp
cmp    $0x2,%r15d
mov    $0x1,%r10d
cmovge %r15d,%r10d
xor    %esi,%esi
mov    0x48(%rsp),%rax
jmp    1369 <discreteFourier+0x1f9>
nop
add    $0x1,%rsi
cmp    %r10,%rsi
je     13b2 <discreteFourier+0x242>
test   %r14d,%r14d
jle    1360 <discreteFourier+0x1f0>
mov    (%r8,%rsi,8),%rdi
mov    (%r9,%rsi,8),%rbx
mov    0x38(%rsp),%r11
xor    %ecx,%ecx
jmp    1389 <discreteFourier+0x219>
nop
add    $0x1,%rcx
cmp    %rcx,%r12
je     1360 <discreteFourier+0x1f0>
movsd  (%rdi,%rcx,8),%xmm0
mulsd  (%rax,%rcx,8),%xmm0
addsd  (%rbx,%rbp,8),%xmm0
movsd  %xmm0,(%rbx,%rbp,8)
cmp    %rbp,%rcx
jge    1380 <discreteFourier+0x210>
mov    (%r11,%rsi,8),%rdx
movsd  (%rdx,%rcx,8),%xmm0
movsd  %xmm0,(%rbx,%rcx,8)
jmp    1380 <discreteFourier+0x210>
mov    0x8(%rsp),%rdx
mov    %r15d,%edi
mov    0x1c(%rsp),%esi
call   1090 <rref@plt>
test   %r13d,%r13d
mov    0x68(%rsp),%rbx
mov    0x60(%rsp),%rax
jle    1480 <discreteFourier+0x310>
mov    0x8(%rsp),%r8
cmp    $0x1,%r13d
mov    0x58(%rsp),%r9
jne    1400 <discreteFourier+0x290>
xor    %ecx,%ecx
jmp    1456 <discreteFourier+0x2e6>
mov    0x8(%rsp),%rdx
mov    %r15d,%edi
mov    0x1c(%rsp),%esi
call   1090 <rref@plt>
jmp    1480 <discreteFourier+0x310>
mov    %r9d,%edx
and    $0xfffffffe,%edx
lea    0x18(%r8),%rsi
xor    %ecx,%ecx
nopl   0x0(%rax)
mov    -0x18(%rsi),%rdi
movsd  (%rdi,%rbp,8),%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x10(%rsi),%rdi
movsd  (%rdi,%rbp,8),%xmm0
movsd  %xmm0,(%rbx,%rcx,8)
mov    -0x8(%rsi),%rdi
movsd  (%rdi,%rbp,8),%xmm0
movsd  %xmm0,0x8(%rax,%rcx,8)
mov    (%rsi),%rdi
movsd  (%rdi,%rbp,8),%xmm0
movsd  %xmm0,0x8(%rbx,%rcx,8)
add    $0x2,%rcx
add    $0x20,%rsi
cmp    %rcx,%rdx
jne    1410 <discreteFourier+0x2a0>
test   $0x1,%r9b
je     1480 <discreteFourier+0x310>
mov    %rcx,%rdx
shl    $0x4,%rdx
mov    (%r8,%rdx,1),%rsi
movsd  (%rsi,%rbp,8),%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    0x8(%r8,%rdx,1),%rax
movsd  (%rax,%rbp,8),%xmm0
movsd  %xmm0,(%rbx,%rcx,8)
lea    0x10(%rsp),%rsi
mov    %r14d,%edi
call   1040 <freeMat@plt>
lea    0x28(%rsp),%rsi
mov    %r15d,%edi
call   1040 <freeMat@plt>
lea    0x8(%rsp),%rsi
mov    %r15d,%edi
call   1040 <freeMat@plt>
lea    0x38(%rsp),%rsi
mov    %r15d,%edi
call   1040 <freeMat@plt>
xorps  %xmm1,%xmm1
cvtsi2sd %r14d,%xmm1
movsd  0x20(%rsp),%xmm0
divsd  %xmm1,%xmm0
add    $0x78,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define double @discreteFourier(i32 %0, double* %1, double* %2, i32 %3, double* %4, double* %5) {
%7 = alloca i32
%8 = alloca double*
%9 = alloca double*
%10 = alloca i32
%11 = alloca double*
%12 = alloca double*
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca double
%17 = alloca double
%18 = alloca double**
%19 = alloca double**
%20 = alloca double**
%21 = alloca double**
store i32 %0, i32* %7
store double* %1, double** %8
store double* %2, double** %9
store i32 %3, i32* %10
store double* %4, double** %11
store double* %5, double** %12
store i32 0, i32* %13
store i32 0, i32* %14
%22 = load i32, i32* %10
%23 = mul nsw i32 2, %22
store i32 %23, i32* %15
%24 = load double*, double** %8
%25 = load i32, i32* %7
%26 = sub nsw i32 %25, 1
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds double, double* %24, i64 %27
%29 = load double, double* %28
%30 = load double*, double** %8
%31 = getelementptr inbounds double, double* %30, i64 0
%32 = load double, double* %31
%33 = fsub double %29, %32
%34 = fdiv double 0x401921FB54442D18, %33
store double %34, double* %16
store double 0.000000e+00, double* %17
%35 = load i32, i32* %7
%36 = load i32, i32* %15
%37 = call i32 @initMat(i32 %35, i32 %36, double*** %18)
%38 = load i32, i32* %15
%39 = load i32, i32* %7
%40 = call i32 @initMat(i32 %38, i32 %39, double*** %19)
%41 = load i32, i32* %15
%42 = load i32, i32* %15
%43 = add nsw i32 %42, 1
%44 = call i32 @initMat(i32 %41, i32 %43, double*** %20)
%45 = load i32, i32* %15
%46 = load i32, i32* %15
%47 = call i32 @initMat(i32 %45, i32 %46, double*** %21)
store i32 0, i32* %13
br label %48
48: ; preds = %112, %6
%49 = load i32, i32* %13
%50 = load i32, i32* %7
%51 = icmp slt i32 %49, %50
br i1 %51, label %52, label %115
52: ; preds = %48
%53 = load double*, double** %9
%54 = load i32, i32* %13
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds double, double* %53, i64 %55
%57 = load double, double* %56
%58 = load double, double* %17
%59 = fadd double %58, %57
store double %59, double* %17
store i32 0, i32* %14
br label %60
60: ; preds = %108, %52
%61 = load i32, i32* %14
%62 = load i32, i32* %10
%63 = icmp slt i32 %61, %62
br i1 %63, label %64, label %111
64: ; preds = %60
%65 = load double, double* %16
%66 = load i32, i32* %14
%67 = add nsw i32 %66, 1
%68 = sitofp i32 %67 to double
%69 = fmul double %65, %68
%70 = load double*, double** %8
%71 = load i32, i32* %13
%72 = sext i32 %71 to i64
%73 = getelementptr inbounds double, double* %70, i64 %72
%74 = load double, double* %73
%75 = fmul double %69, %74
%76 = call double @cos(double %75)
%77 = load double**, double*** %18
%78 = load i32, i32* %13
%79 = sext i32 %78 to i64
%80 = getelementptr inbounds double*, double** %77, i64 %79
%81 = load double*, double** %80
%82 = load i32, i32* %14
%83 = mul nsw i32 2, %82
%84 = sext i32 %83 to i64
%85 = getelementptr inbounds double, double* %81, i64 %84
store double %76, double* %85
%86 = load double, double* %16
%87 = load i32, i32* %14
%88 = add nsw i32 %87, 1
%89 = sitofp i32 %88 to double
%90 = fmul double %86, %89
%91 = load double*, double** %8
%92 = load i32, i32* %13
%93 = sext i32 %92 to i64
%94 = getelementptr inbounds double, double* %91, i64 %93
%95 = load double, double* %94
%96 = fmul double %90, %95
%97 = call double @sin(double %96)
%98 = load double**, double*** %18
%99 = load i32, i32* %13
%100 = sext i32 %99 to i64
%101 = getelementptr inbounds double*, double** %98, i64 %100
%102 = load double*, double** %101
%103 = load i32, i32* %14
%104 = mul nsw i32 2, %103
%105 = add nsw i32 %104, 1
%106 = sext i32 %105 to i64
%107 = getelementptr inbounds double, double* %102, i64 %106
store double %97, double* %107
br label %108
108: ; preds = %64
%109 = load i32, i32* %14
%110 = add nsw i32 %109, 1
store i32 %110, i32* %14
br label %60
111: ; preds = %60
br label %112
112: ; preds = %111
%113 = load i32, i32* %13
%114 = add nsw i32 %113, 1
store i32 %114, i32* %13
br label %48
115: ; preds = %48
%116 = load i32, i32* %7
%117 = load i32, i32* %15
%118 = load double**, double*** %18
%119 = load double**, double*** %19
%120 = call i32 @transpose(i32 %116, i32 %117, double** %118, double** %119)
%121 = load i32, i32* %15
%122 = load i32, i32* %7
%123 = load i32, i32* %15
%124 = load double**, double*** %19
%125 = load double**, double*** %18
%126 = load double**, double*** %21
%127 = call i32 @matrixMultiply(i32 %121, i32 %122, i32 %123, double** %124, double** %125, double** %126)
store i32 0, i32* %13
br label %128
128: ; preds = %188, %115
%129 = load i32, i32* %13
%130 = load i32, i32* %15
%131 = icmp slt i32 %129, %130
br i1 %131, label %132, label %191
132: ; preds = %128
store i32 0, i32* %14
br label %133
133: ; preds = %184, %132
%134 = load i32, i32* %14
%135 = load i32, i32* %7
%136 = icmp slt i32 %134, %135
br i1 %136, label %137, label %187
137: ; preds = %133
%138 = load double**, double*** %19
%139 = load i32, i32* %13
%140 = sext i32 %139 to i64
%141 = getelementptr inbounds double*, double** %138, i64 %140
%142 = load double*, double** %141
%143 = load i32, i32* %14
%144 = sext i32 %143 to i64
%145 = getelementptr inbounds double, double* %142, i64 %144
%146 = load double, double* %145
%147 = load double*, double** %9
%148 = load i32, i32* %14
%149 = sext i32 %148 to i64
%150 = getelementptr inbounds double, double* %147, i64 %149
%151 = load double, double* %150
%152 = load double**, double*** %20
%153 = load i32, i32* %13
%154 = sext i32 %153 to i64
%155 = getelementptr inbounds double*, double** %152, i64 %154
%156 = load double*, double** %155
%157 = load i32, i32* %15
%158 = sext i32 %157 to i64
%159 = getelementptr inbounds double, double* %156, i64 %158
%160 = load double, double* %159
%161 = call double @llvm.fmuladd.f64(double %146, double %151, double %160)
store double %161, double* %159
%162 = load i32, i32* %14
%163 = load i32, i32* %15
%164 = icmp slt i32 %162, %163
br i1 %164, label %165, label %183
165: ; preds = %137
%166 = load double**, double*** %21
%167 = load i32, i32* %13
%168 = sext i32 %167 to i64
%169 = getelementptr inbounds double*, double** %166, i64 %168
%170 = load double*, double** %169
%171 = load i32, i32* %14
%172 = sext i32 %171 to i64
%173 = getelementptr inbounds double, double* %170, i64 %172
%174 = load double, double* %173
%175 = load double**, double*** %20
%176 = load i32, i32* %13
%177 = sext i32 %176 to i64
%178 = getelementptr inbounds double*, double** %175, i64 %177
%179 = load double*, double** %178
%180 = load i32, i32* %14
%181 = sext i32 %180 to i64
%182 = getelementptr inbounds double, double* %179, i64 %181
store double %174, double* %182
br label %183
183: ; preds = %165, %137
br label %184
184: ; preds = %183
%185 = load i32, i32* %14
%186 = add nsw i32 %185, 1
store i32 %186, i32* %14
br label %133
187: ; preds = %133
br label %188
188: ; preds = %187
%189 = load i32, i32* %13
%190 = add nsw i32 %189, 1
store i32 %190, i32* %13
br label %128
191: ; preds = %128
%192 = load i32, i32* %15
%193 = load i32, i32* %15
%194 = add nsw i32 %193, 1
%195 = load double**, double*** %20
%196 = call i32 @rref(i32 %192, i32 %194, double** %195)
store i32 0, i32* %13
br label %197
197: ; preds = %231, %191
%198 = load i32, i32* %13
%199 = load i32, i32* %10
%200 = icmp slt i32 %198, %199
br i1 %200, label %201, label %234
201: ; preds = %197
%202 = load double**, double*** %20
%203 = load i32, i32* %13
%204 = mul nsw i32 2, %203
%205 = sext i32 %204 to i64
%206 = getelementptr inbounds double*, double** %202, i64 %205
%207 = load double*, double** %206
%208 = load i32, i32* %15
%209 = sext i32 %208 to i64
%210 = getelementptr inbounds double, double* %207, i64 %209
%211 = load double, double* %210
%212 = load double*, double** %11
%213 = load i32, i32* %13
%214 = sext i32 %213 to i64
%215 = getelementptr inbounds double, double* %212, i64 %214
store double %211, double* %215
%216 = load double**, double*** %20
%217 = load i32, i32* %13
%218 = mul nsw i32 2, %217
%219 = add nsw i32 %218, 1
%220 = sext i32 %219 to i64
%221 = getelementptr inbounds double*, double** %216, i64 %220
%222 = load double*, double** %221
%223 = load i32, i32* %15
%224 = sext i32 %223 to i64
%225 = getelementptr inbounds double, double* %222, i64 %224
%226 = load double, double* %225
%227 = load double*, double** %12
%228 = load i32, i32* %13
%229 = sext i32 %228 to i64
%230 = getelementptr inbounds double, double* %227, i64 %229
store double %226, double* %230
br label %231
231: ; preds = %201
%232 = load i32, i32* %13
%233 = add nsw i32 %232, 1
store i32 %233, i32* %13
br label %197
234: ; preds = %197
%235 = load i32, i32* %7
%236 = call i32 @freeMat(i32 %235, double*** %18)
%237 = load i32, i32* %15
%238 = call i32 @freeMat(i32 %237, double*** %19)
%239 = load i32, i32* %15
%240 = call i32 @freeMat(i32 %239, double*** %20)
%241 = load i32, i32* %15
%242 = call i32 @freeMat(i32 %241, double*** %21)
%243 = load double, double* %17
%244 = load i32, i32* %7
%245 = sitofp i32 %244 to double
%246 = fdiv double %243, %245
ret double %246
}

LLVM IR (-O2):
define double @discreteFourier(i32 %0, double* nocapture %1, double* nocapture %2, i32 %3, double* nocapture writeonly %4, double* nocapture writeonly %5) {
%7 = alloca double**
%8 = alloca double**
%9 = alloca double**
%10 = alloca double**
%11 = shl nsw i32 %3, 1
%12 = add nsw i32 %0, -1
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds double, double* %1, i64 %13
%15 = load double, double* %14
%16 = load double, double* %1
%17 = fsub double %15, %16
%18 = fdiv double 0x401921FB54442D18, %17
%19 = bitcast double*** %7 to i8*
%20 = call i32 @initMat(i32 %0, i32 %11, double*** %7)
%21 = bitcast double*** %8 to i8*
%22 = call i32 @initMat(i32 %11, i32 %0, double*** %8)
%23 = bitcast double*** %9 to i8*
%24 = or i32 %11, 1
%25 = call i32 @initMat(i32 %11, i32 %24, double*** %9)
%26 = bitcast double*** %10 to i8*
%27 = call i32 @initMat(i32 %11, i32 %11, double*** %10)
%28 = icmp sgt i32 %0, 0
br i1 %28, label %29, label %67
29: ; preds = %6
%30 = icmp sgt i32 %3, 0
%31 = zext i32 %0 to i64
%32 = zext i32 %3 to i64
br label %33
33: ; preds = %29, %64
%34 = phi i64 [ 0, %29 ], [ %65, %64 ]
%35 = phi double [ 0.000000e+00, %29 ], [ %38, %64 ]
%36 = getelementptr inbounds double, double* %2, i64 %34
%37 = load double, double* %36
%38 = fadd double %35, %37
br i1 %30, label %39, label %64
39: ; preds = %33
%40 = getelementptr inbounds double, double* %1, i64 %34
br label %41
41: ; preds = %39, %41
%42 = phi i64 [ 0, %39 ], [ %43, %41 ]
%43 = add nuw nsw i64 %42, 1
%44 = trunc i64 %43 to i32
%45 = sitofp i32 %44 to double
%46 = fmul double %18, %45
%47 = load double, double* %40
%48 = fmul double %46, %47
%49 = call double @cos(double %48)
%50 = load double**, double*** %7
%51 = getelementptr inbounds double*, double** %50, i64 %34
%52 = load double*, double** %51
%53 = shl nuw nsw i64 %42, 1
%54 = getelementptr inbounds double, double* %52, i64 %53
store double %49, double* %54
%55 = load double, double* %40
%56 = fmul double %46, %55
%57 = call double @sin(double %56)
%58 = load double**, double*** %7
%59 = getelementptr inbounds double*, double** %58, i64 %34
%60 = load double*, double** %59
%61 = or i64 %53, 1
%62 = getelementptr inbounds double, double* %60, i64 %61
store double %57, double* %62
%63 = icmp eq i64 %43, %32
br i1 %63, label %64, label %41
64: ; preds = %41, %33
%65 = add nuw nsw i64 %34, 1
%66 = icmp eq i64 %65, %31
br i1 %66, label %67, label %33
67: ; preds = %64, %6
%68 = phi double [ 0.000000e+00, %6 ], [ %38, %64 ]
%69 = load double**, double*** %7
%70 = load double**, double*** %8
%71 = call i32 @transpose(i32 %0, i32 %11, double** %69, double** %70)
%72 = load double**, double*** %8
%73 = load double**, double*** %7
%74 = load double**, double*** %10
%75 = call i32 @matrixMultiply(i32 %11, i32 %0, i32 %11, double** %72, double** %73, double** %74)
%76 = icmp sgt i32 %3, 0
br i1 %76, label %80, label %77
77: ; preds = %67
%78 = load double**, double*** %9
%79 = call i32 @rref(i32 %11, i32 %24, double** %78)
br label %175
80: ; preds = %67
%81 = load double**, double*** %8
%82 = load double**, double*** %9
%83 = sext i32 %11 to i64
%84 = call i32 @llvm.smax.i32(i32 %11, i32 1)
%85 = zext i32 %84 to i64
%86 = zext i32 %0 to i64
br label %87
87: ; preds = %80, %114
%88 = phi i64 [ 0, %80 ], [ %115, %114 ]
br i1 %28, label %89, label %114
89: ; preds = %87
%90 = getelementptr inbounds double*, double** %81, i64 %88
%91 = load double*, double** %90
%92 = getelementptr inbounds double*, double** %82, i64 %88
%93 = load double*, double** %92
%94 = getelementptr inbounds double, double* %93, i64 %83
%95 = load double**, double*** %10
%96 = getelementptr inbounds double*, double** %95, i64 %88
br label %97
97: ; preds = %89, %111
%98 = phi i64 [ 0, %89 ], [ %112, %111 ]
%99 = getelementptr inbounds double, double* %91, i64 %98
%100 = load double, double* %99
%101 = getelementptr inbounds double, double* %2, i64 %98
%102 = load double, double* %101
%103 = load double, double* %94
%104 = call double @llvm.fmuladd.f64(double %100, double %102, double %103)
store double %104, double* %94
%105 = icmp slt i64 %98, %83
br i1 %105, label %106, label %111
106: ; preds = %97
%107 = load double*, double** %96
%108 = getelementptr inbounds double, double* %107, i64 %98
%109 = load double, double* %108
%110 = getelementptr inbounds double, double* %93, i64 %98
store double %109, double* %110
br label %111
111: ; preds = %97, %106
%112 = add nuw nsw i64 %98, 1
%113 = icmp eq i64 %112, %86
br i1 %113, label %114, label %97
114: ; preds = %111, %87
%115 = add nuw nsw i64 %88, 1
%116 = icmp eq i64 %115, %85
br i1 %116, label %117, label %87
117: ; preds = %114
%118 = load double**, double*** %9
%119 = call i32 @rref(i32 %11, i32 %24, double** %118)
br i1 %76, label %120, label %175
120: ; preds = %117
%121 = load double**, double*** %9
%122 = sext i32 %11 to i64
%123 = zext i32 %3 to i64
%124 = and i64 %123, 1
%125 = icmp eq i32 %3, 1
br i1 %125, label %159, label %126
126: ; preds = %120
%127 = and i64 %123, 4294967294
br label %128
128: ; preds = %128, %126
%129 = phi i64 [ 0, %126 ], [ %156, %128 ]
%130 = phi i64 [ 0, %126 ], [ %157, %128 ]
%131 = shl nuw nsw i64 %129, 1
%132 = getelementptr inbounds double*, double** %121, i64 %131
%133 = load double*, double** %132
%134 = getelementptr inbounds double, double* %133, i64 %122
%135 = load double, double* %134
%136 = getelementptr inbounds double, double* %4, i64 %129
store double %135, double* %136
%137 = or i64 %131, 1
%138 = getelementptr inbounds double*, double** %121, i64 %137
%139 = load double*, double** %138
%140 = getelementptr inbounds double, double* %139, i64 %122
%141 = load double, double* %140
%142 = getelementptr inbounds double, double* %5, i64 %129
store double %141, double* %142
%143 = or i64 %129, 1
%144 = shl nuw nsw i64 %143, 1
%145 = getelementptr inbounds double*, double** %121, i64 %144
%146 = load double*, double** %145
%147 = getelementptr inbounds double, double* %146, i64 %122
%148 = load double, double* %147
%149 = getelementptr inbounds double, double* %4, i64 %143
store double %148, double* %149
%150 = or i64 %144, 1
%151 = getelementptr inbounds double*, double** %121, i64 %150
%152 = load double*, double** %151
%153 = getelementptr inbounds double, double* %152, i64 %122
%154 = load double, double* %153
%155 = getelementptr inbounds double, double* %5, i64 %143
store double %154, double* %155
%156 = add nuw nsw i64 %129, 2
%157 = add nuw i64 %130, 2
%158 = icmp eq i64 %157, %127
br i1 %158, label %159, label %128
159: ; preds = %128, %120
%160 = phi i64 [ 0, %120 ], [ %156, %128 ]
%161 = icmp eq i64 %124, 0
br i1 %161, label %175, label %162
162: ; preds = %159
%163 = shl nuw nsw i64 %160, 1
%164 = getelementptr inbounds double*, double** %121, i64 %163
%165 = load double*, double** %164
%166 = getelementptr inbounds double, double* %165, i64 %122
%167 = load double, double* %166
%168 = getelementptr inbounds double, double* %4, i64 %160
store double %167, double* %168
%169 = or i64 %163, 1
%170 = getelementptr inbounds double*, double** %121, i64 %169
%171 = load double*, double** %170
%172 = getelementptr inbounds double, double* %171, i64 %122
%173 = load double, double* %172
%174 = getelementptr inbounds double, double* %5, i64 %160
store double %173, double* %174
br label %175
175: ; preds = %162, %159, %77, %117
%176 = call i32 @freeMat(i32 %0, double*** %7)
%177 = call i32 @freeMat(i32 %11, double*** %8)
%178 = call i32 @freeMat(i32 %11, double*** %9)
%179 = call i32 @freeMat(i32 %11, double*** %10)
%180 = sitofp i32 %0 to double
%181 = fdiv double %68, %180
ret double %181
}