#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 cos(double);
double *dvector(int, int);
int /*<<< orphan*/ free_dvector(double *, int, int);
double sin(double);
void dft2d(int n, int m, int inverse, double *gRe, double *gIm, double *GRe,
           double *GIm) {
  double pi = 3.1415926535897932384626433832795;
  int nns, w, x, y;
  double *Gr2, *Gi2;
  double a, ca, sa;
  double fm, fn;
  nns = n * m;
  Gr2 = dvector(1, nns);
  Gi2 = dvector(1, nns);
  for (x = 0; x < n; x++) {
    for (w = 0; w < m; w++) {
      Gr2[m * x + w + 1] = Gi2[m * x + w + 1] = 0;
      for (y = 0; y < m; y++) {
        fm = m;
        a = 2 * pi * w * y / fm;
        if (inverse)
          a = -a;
        ca = cos(a);
        sa = sin(a);
        Gr2[m * x + w + 1] += gRe[m * x + y + 1] * ca - gIm[m * x + y + 1] * sa;
        Gi2[m * x + w + 1] += gRe[m * x + y + 1] * sa + gIm[m * x + y + 1] * ca;
      }
    }
  }
  for (y = 0; y < m; y++) {
    for (w = 0; w < n; w++) {
      GRe[m * w + y + 1] = GIm[m * w + y + 1] = 0;
      for (x = 0; x < n; x++) {
        fn = n;
        a = 2 * pi * w * x / fn;
        if (inverse)
          a = -a;
        ca = cos(a);
        sa = sin(a);
        GRe[m * w + y + 1] += Gr2[m * x + y + 1] * ca - Gi2[m * x + y + 1] * sa;
        GIm[m * w + y + 1] += Gr2[m * x + y + 1] * sa + Gi2[m * x + y + 1] * ca;
      }
      if (inverse) {
        GRe[m * w + y + 1] /= n;
        GIm[m * w + y + 1] /= n;
      } else {
        GRe[m * w + y + 1] /= m;
        GIm[m * w + y + 1] /= m;
      }
    }
  }
  free_dvector(Gr2, 1, nns);
  free_dvector(Gi2, 1, nns);
}


x86 assembly (clang, -O0):
<dft2d>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    0x10(%rbp),%rax
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %rcx,-0x18(%rbp)
mov    %r8,-0x20(%rbp)
mov    %r9,-0x28(%rbp)
movsd  0xe94(%rip),%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0x4(%rbp),%eax
imul   -0x8(%rbp),%eax
mov    %eax,-0x34(%rbp)
mov    -0x34(%rbp),%esi
mov    $0x1,%edi
call   1040 <dvector@plt>
mov    %rax,-0x48(%rbp)
mov    -0x34(%rbp),%esi
mov    $0x1,%edi
call   1040 <dvector@plt>
mov    %rax,-0x50(%rbp)
movl   $0x0,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    1399 <dft2d+0x259>
movl   $0x0,-0x38(%rbp)
mov    -0x38(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1386 <dft2d+0x246>
mov    -0x50(%rbp),%rax
mov    -0x8(%rbp),%ecx
imul   -0x3c(%rbp),%ecx
add    -0x38(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x48(%rbp),%rax
mov    -0x8(%rbp),%ecx
imul   -0x3c(%rbp),%ecx
add    -0x38(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
movl   $0x0,-0x40(%rbp)
mov    -0x40(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1373 <dft2d+0x233>
cvtsi2sdl -0x8(%rbp),%xmm0
movsd  %xmm0,-0x70(%rbp)
movsd  0xde8(%rip),%xmm0
mulsd  -0x30(%rbp),%xmm0
cvtsi2sdl -0x38(%rbp),%xmm1
mulsd  %xmm1,%xmm0
cvtsi2sdl -0x40(%rbp),%xmm1
mulsd  %xmm1,%xmm0
divsd  -0x70(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
cmpl   $0x0,-0xc(%rbp)
je     126c <dft2d+0x12c>
movsd  -0x58(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x58(%rbp),%xmm0
call   1050 <cos@plt>
movsd  %xmm0,-0x60(%rbp)
movsd  -0x58(%rbp),%xmm0
call   1030 <sin@plt>
movsd  %xmm0,-0x68(%rbp)
mov    -0x18(%rbp),%rax
mov    -0x8(%rbp),%ecx
imul   -0x3c(%rbp),%ecx
add    -0x40(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  -0x60(%rbp),%xmm2
mov    -0x20(%rbp),%rax
mov    -0x8(%rbp),%ecx
imul   -0x3c(%rbp),%ecx
add    -0x40(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm1
mulsd  -0x68(%rbp),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x48(%rbp),%rax
mov    -0x8(%rbp),%ecx
imul   -0x3c(%rbp),%ecx
add    -0x38(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
addsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x18(%rbp),%rax
mov    -0x8(%rbp),%ecx
imul   -0x3c(%rbp),%ecx
add    -0x40(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  -0x68(%rbp),%xmm2
mov    -0x20(%rbp),%rax
mov    -0x8(%rbp),%ecx
imul   -0x3c(%rbp),%ecx
add    -0x40(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm1
mulsd  -0x60(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x50(%rbp),%rax
mov    -0x8(%rbp),%ecx
imul   -0x3c(%rbp),%ecx
add    -0x38(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
addsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x40(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x40(%rbp)
jmp    1202 <dft2d+0xc2>
jmp    1378 <dft2d+0x238>
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    11b7 <dft2d+0x77>
jmp    138b <dft2d+0x24b>
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    11a4 <dft2d+0x64>
movl   $0x0,-0x40(%rbp)
mov    -0x40(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1640 <dft2d+0x500>
movl   $0x0,-0x38(%rbp)
mov    -0x38(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    162d <dft2d+0x4ed>
mov    0x10(%rbp),%rax
mov    -0x8(%rbp),%ecx
imul   -0x38(%rbp),%ecx
add    -0x40(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x28(%rbp),%rax
mov    -0x8(%rbp),%ecx
imul   -0x38(%rbp),%ecx
add    -0x40(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
movl   $0x0,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    156f <dft2d+0x42f>
cvtsi2sdl -0x4(%rbp),%xmm0
movsd  %xmm0,-0x78(%rbp)
movsd  0xbec(%rip),%xmm0
mulsd  -0x30(%rbp),%xmm0
cvtsi2sdl -0x38(%rbp),%xmm1
mulsd  %xmm1,%xmm0
cvtsi2sdl -0x3c(%rbp),%xmm1
mulsd  %xmm1,%xmm0
divsd  -0x78(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
cmpl   $0x0,-0xc(%rbp)
je     1468 <dft2d+0x328>
movsd  -0x58(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x58(%rbp),%xmm0
call   1050 <cos@plt>
movsd  %xmm0,-0x60(%rbp)
movsd  -0x58(%rbp),%xmm0
call   1030 <sin@plt>
movsd  %xmm0,-0x68(%rbp)
mov    -0x48(%rbp),%rax
mov    -0x8(%rbp),%ecx
imul   -0x3c(%rbp),%ecx
add    -0x40(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  -0x60(%rbp),%xmm2
mov    -0x50(%rbp),%rax
mov    -0x8(%rbp),%ecx
imul   -0x3c(%rbp),%ecx
add    -0x40(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm1
mulsd  -0x68(%rbp),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x28(%rbp),%rax
mov    -0x8(%rbp),%ecx
imul   -0x38(%rbp),%ecx
add    -0x40(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
addsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x48(%rbp),%rax
mov    -0x8(%rbp),%ecx
imul   -0x3c(%rbp),%ecx
add    -0x40(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  -0x68(%rbp),%xmm2
mov    -0x50(%rbp),%rax
mov    -0x8(%rbp),%ecx
imul   -0x3c(%rbp),%ecx
add    -0x40(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm1
mulsd  -0x60(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    0x10(%rbp),%rax
mov    -0x8(%rbp),%ecx
imul   -0x38(%rbp),%ecx
add    -0x40(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
addsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    13fe <dft2d+0x2be>
cmpl   $0x0,-0xc(%rbp)
je     15cc <dft2d+0x48c>
cvtsi2sdl -0x4(%rbp),%xmm1
mov    -0x28(%rbp),%rax
mov    -0x8(%rbp),%ecx
imul   -0x38(%rbp),%ecx
add    -0x40(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
cvtsi2sdl -0x4(%rbp),%xmm1
mov    0x10(%rbp),%rax
mov    -0x8(%rbp),%ecx
imul   -0x38(%rbp),%ecx
add    -0x40(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
jmp    161a <dft2d+0x4da>
cvtsi2sdl -0x8(%rbp),%xmm1
mov    -0x28(%rbp),%rax
mov    -0x8(%rbp),%ecx
imul   -0x38(%rbp),%ecx
add    -0x40(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
cvtsi2sdl -0x8(%rbp),%xmm1
mov    0x10(%rbp),%rax
mov    -0x8(%rbp),%ecx
imul   -0x38(%rbp),%ecx
add    -0x40(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
jmp    161f <dft2d+0x4df>
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    13b3 <dft2d+0x273>
jmp    1632 <dft2d+0x4f2>
mov    -0x40(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x40(%rbp)
jmp    13a0 <dft2d+0x260>
mov    -0x48(%rbp),%rdi
mov    -0x34(%rbp),%edx
mov    $0x1,%esi
call   1060 <free_dvector@plt>
mov    -0x50(%rbp),%rdi
mov    -0x34(%rbp),%edx
mov    $0x1,%esi
call   1060 <free_dvector@plt>
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dft2d>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x88,%rsp
mov    %r9,0x68(%rsp)
mov    %r8,%r12
mov    %rcx,%r15
mov    %edx,0x14(%rsp)
mov    %esi,%ebx
mov    %edi,%r13d
mov    0xc0(%rsp),%rax
mov    %rax,0x60(%rsp)
mov    %esi,0xc(%rsp)
imul   %edi,%ebx
mov    $0x1,%edi
mov    %ebx,%esi
call   1040 <dvector@plt>
mov    %rax,%rbp
mov    $0x1,%edi
mov    %ebx,0x5c(%rsp)
mov    %ebx,%esi
call   1040 <dvector@plt>
mov    %rax,%r14
mov    %r13d,0x10(%rsp)
test   %r13d,%r13d
jle    1327 <dft2d+0x1e7>
mov    0xc(%rsp),%eax
cvtsi2sd %eax,%xmm0
movsd  %xmm0,0x30(%rsp)
mov    %eax,%eax
mov    %rax,0x20(%rsp)
xor    %eax,%eax
mov    %rax,0x38(%rsp)
mov    $0x1,%eax
mov    %rax,0x18(%rsp)
jmp    1206 <dft2d+0xc6>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    0x38(%rsp),%rax
add    $0x1,%eax
mov    0x18(%rsp),%rcx
add    0x20(%rsp),%rcx
mov    %rcx,0x18(%rsp)
mov    %rax,0x38(%rsp)
cmp    0x10(%rsp),%eax
je     1327 <dft2d+0x1e7>
cmpl   $0x0,0xc(%rsp)
jle    11e0 <dft2d+0xa0>
mov    0x38(%rsp),%rax
imul   0xc(%rsp),%eax
add    $0x1,%eax
mov    %rax,0x28(%rsp)
xor    %ecx,%ecx
jmp    1240 <dft2d+0x100>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    0x40(%rsp),%rcx
add    $0x1,%rcx
cmp    0x20(%rsp),%rcx
je     11e0 <dft2d+0xa0>
mov    0x28(%rsp),%rax
add    %ecx,%eax
movslq %eax,%r13
movq   $0x0,(%r14,%r13,8)
movq   $0x0,0x0(%rbp,%r13,8)
mov    %rcx,0x40(%rsp)
xorps  %xmm0,%xmm0
cvtsi2sd %ecx,%xmm0
mulsd  0xd91(%rip),%xmm0
movsd  %xmm0,0x48(%rsp)
xor    %ebx,%ebx
jmp    12fc <dft2d+0x1bc>
nopl   0x0(%rax)
movapd %xmm0,0x70(%rsp)
call   1050 <cos@plt>
movsd  %xmm0,0x50(%rsp)
movapd 0x70(%rsp),%xmm0
call   1030 <sin@plt>
mov    0x18(%rsp),%rax
add    %ebx,%eax
cltq
movsd  (%r12,%rax,8),%xmm1
mulsd  %xmm0,%xmm1
movsd  (%r15,%rax,8),%xmm2
movsd  0x50(%rsp),%xmm3
mulsd  %xmm3,%xmm2
subsd  %xmm1,%xmm2
addsd  0x0(%rbp,%r13,8),%xmm2
movsd  %xmm2,0x0(%rbp,%r13,8)
mulsd  (%r12,%rax,8),%xmm3
mulsd  (%r15,%rax,8),%xmm0
addsd  %xmm3,%xmm0
addsd  (%r14,%r13,8),%xmm0
movsd  %xmm0,(%r14,%r13,8)
add    $0x1,%rbx
cmp    %rbx,0x20(%rsp)
je     1230 <dft2d+0xf0>
xorps  %xmm0,%xmm0
cvtsi2sd %ebx,%xmm0
mulsd  0x48(%rsp),%xmm0
divsd  0x30(%rsp),%xmm0
cmpl   $0x0,0x14(%rsp)
je     1280 <dft2d+0x140>
xorpd  0xcee(%rip),%xmm0
jmp    1280 <dft2d+0x140>
cmpl   $0x0,0xc(%rsp)
mov    0x68(%rsp),%rcx
mov    0x60(%rsp),%rdx
jle    14df <dft2d+0x39f>
mov    0x10(%rsp),%eax
xorps  %xmm1,%xmm1
cvtsi2sd %eax,%xmm1
mov    %eax,%r15d
cmpl   $0x0,0x14(%rsp)
je     1359 <dft2d+0x219>
movsd  %xmm1,0x28(%rsp)
jmp    1368 <dft2d+0x228>
xorps  %xmm0,%xmm0
cvtsi2sdl 0xc(%rsp),%xmm0
movsd  %xmm0,0x28(%rsp)
xor    %esi,%esi
movl   $0x1,0x30(%rsp)
movsd  %xmm1,0x48(%rsp)
jmp    138f <dft2d+0x24f>
nopw   0x0(%rax,%rax,1)
addl   $0x1,0x30(%rsp)
cmp    0xc(%rsp),%esi
je     14df <dft2d+0x39f>
add    $0x1,%esi
cmpl   $0x0,0x10(%rsp)
jle    1380 <dft2d+0x240>
xor    %eax,%eax
mov    %rsi,0x40(%rsp)
jmp    13e5 <dft2d+0x2a5>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movsd  (%rcx,%rbx,8),%xmm0
movsd  0x28(%rsp),%xmm2
divsd  %xmm2,%xmm0
movsd  %xmm0,(%rcx,%rbx,8)
movsd  (%rdx,%rbx,8),%xmm0
divsd  %xmm2,%xmm0
movsd  %xmm0,(%rdx,%rbx,8)
mov    0x18(%rsp),%rax
add    $0x1,%rax
cmp    %r15,%rax
mov    0x40(%rsp),%rsi
je     1380 <dft2d+0x240>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mov    %rax,0x18(%rsp)
imul   0xc(%rsp),%eax
add    %esi,%eax
movslq %eax,%rbx
movq   $0x0,(%rdx,%rbx,8)
movq   $0x0,(%rcx,%rbx,8)
mulsd  0xbed(%rip),%xmm0
movsd  %xmm0,0x20(%rsp)
mov    0x30(%rsp),%eax
mov    %eax,%r12d
xor    %r13d,%r13d
jmp    14b5 <dft2d+0x375>
nopl   0x0(%rax,%rax,1)
movapd %xmm0,0x70(%rsp)
call   1050 <cos@plt>
movsd  %xmm0,0x50(%rsp)
movapd 0x70(%rsp),%xmm0
call   1030 <sin@plt>
movslq %r12d,%r12
movsd  (%r14,%r12,8),%xmm1
mulsd  %xmm0,%xmm1
movsd  0x0(%rbp,%r12,8),%xmm2
movsd  0x50(%rsp),%xmm3
mulsd  %xmm3,%xmm2
subsd  %xmm1,%xmm2
mov    0x68(%rsp),%rcx
addsd  (%rcx,%rbx,8),%xmm2
movsd  %xmm2,(%rcx,%rbx,8)
mulsd  (%r14,%r12,8),%xmm3
mulsd  0x0(%rbp,%r12,8),%xmm0
addsd  %xmm3,%xmm0
mov    0x60(%rsp),%rdx
addsd  (%rdx,%rbx,8),%xmm0
movsd  %xmm0,(%rdx,%rbx,8)
add    $0x1,%r13
add    0xc(%rsp),%r12d
cmp    %r13,%r15
movsd  0x48(%rsp),%xmm1
je     13b0 <dft2d+0x270>
xorps  %xmm0,%xmm0
cvtsi2sd %r13d,%xmm0
mulsd  0x20(%rsp),%xmm0
divsd  %xmm1,%xmm0
cmpl   $0x0,0x14(%rsp)
je     1430 <dft2d+0x2f0>
xorpd  0xb36(%rip),%xmm0
jmp    1430 <dft2d+0x2f0>
mov    %rbp,%rdi
mov    $0x1,%esi
mov    0x5c(%rsp),%ebx
mov    %ebx,%edx
call   1060 <free_dvector@plt>
mov    %r14,%rdi
mov    $0x1,%esi
mov    %ebx,%edx
add    $0x88,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1060 <free_dvector@plt>

LLVM IR (-O0):
define void @dft2d(i32 %0, i32 %1, i32 %2, double* %3, double* %4, double* %5, double* %6) {
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca double*
%12 = alloca double*
%13 = alloca double*
%14 = alloca double*
%15 = alloca double
%16 = alloca i32
%17 = alloca i32
%18 = alloca i32
%19 = alloca i32
%20 = alloca double*
%21 = alloca double*
%22 = alloca double
%23 = alloca double
%24 = alloca double
%25 = alloca double
%26 = alloca double
store i32 %0, i32* %8
store i32 %1, i32* %9
store i32 %2, i32* %10
store double* %3, double** %11
store double* %4, double** %12
store double* %5, double** %13
store double* %6, double** %14
store double 0x400921FB54442D18, double* %15
%27 = load i32, i32* %8
%28 = load i32, i32* %9
%29 = mul nsw i32 %27, %28
store i32 %29, i32* %16
%30 = load i32, i32* %16
%31 = call double* @dvector(i32 1, i32 %30)
store double* %31, double** %20
%32 = load i32, i32* %16
%33 = call double* @dvector(i32 1, i32 %32)
store double* %33, double** %21
store i32 0, i32* %18
br label %34
34: ; preds = %168, %7
%35 = load i32, i32* %18
%36 = load i32, i32* %8
%37 = icmp slt i32 %35, %36
br i1 %37, label %38, label %171
38: ; preds = %34
store i32 0, i32* %17
br label %39
39: ; preds = %164, %38
%40 = load i32, i32* %17
%41 = load i32, i32* %9
%42 = icmp slt i32 %40, %41
br i1 %42, label %43, label %167
43: ; preds = %39
%44 = load double*, double** %21
%45 = load i32, i32* %9
%46 = load i32, i32* %18
%47 = mul nsw i32 %45, %46
%48 = load i32, i32* %17
%49 = add nsw i32 %47, %48
%50 = add nsw i32 %49, 1
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds double, double* %44, i64 %51
store double 0.000000e+00, double* %52
%53 = load double*, double** %20
%54 = load i32, i32* %9
%55 = load i32, i32* %18
%56 = mul nsw i32 %54, %55
%57 = load i32, i32* %17
%58 = add nsw i32 %56, %57
%59 = add nsw i32 %58, 1
%60 = sext i32 %59 to i64
%61 = getelementptr inbounds double, double* %53, i64 %60
store double 0.000000e+00, double* %61
store i32 0, i32* %19
br label %62
62: ; preds = %160, %43
%63 = load i32, i32* %19
%64 = load i32, i32* %9
%65 = icmp slt i32 %63, %64
br i1 %65, label %66, label %163
66: ; preds = %62
%67 = load i32, i32* %9
%68 = sitofp i32 %67 to double
store double %68, double* %25
%69 = load double, double* %15
%70 = fmul double 2.000000e+00, %69
%71 = load i32, i32* %17
%72 = sitofp i32 %71 to double
%73 = fmul double %70, %72
%74 = load i32, i32* %19
%75 = sitofp i32 %74 to double
%76 = fmul double %73, %75
%77 = load double, double* %25
%78 = fdiv double %76, %77
store double %78, double* %22
%79 = load i32, i32* %10
%80 = icmp ne i32 %79, 0
br i1 %80, label %81, label %84
81: ; preds = %66
%82 = load double, double* %22
%83 = fneg double %82
store double %83, double* %22
br label %84
84: ; preds = %81, %66
%85 = load double, double* %22
%86 = call double @cos(double %85)
store double %86, double* %23
%87 = load double, double* %22
%88 = call double @sin(double %87)
store double %88, double* %24
%89 = load double*, double** %11
%90 = load i32, i32* %9
%91 = load i32, i32* %18
%92 = mul nsw i32 %90, %91
%93 = load i32, i32* %19
%94 = add nsw i32 %92, %93
%95 = add nsw i32 %94, 1
%96 = sext i32 %95 to i64
%97 = getelementptr inbounds double, double* %89, i64 %96
%98 = load double, double* %97
%99 = load double, double* %23
%100 = load double*, double** %12
%101 = load i32, i32* %9
%102 = load i32, i32* %18
%103 = mul nsw i32 %101, %102
%104 = load i32, i32* %19
%105 = add nsw i32 %103, %104
%106 = add nsw i32 %105, 1
%107 = sext i32 %106 to i64
%108 = getelementptr inbounds double, double* %100, i64 %107
%109 = load double, double* %108
%110 = load double, double* %24
%111 = fmul double %109, %110
%112 = fneg double %111
%113 = call double @llvm.fmuladd.f64(double %98, double %99, double %112)
%114 = load double*, double** %20
%115 = load i32, i32* %9
%116 = load i32, i32* %18
%117 = mul nsw i32 %115, %116
%118 = load i32, i32* %17
%119 = add nsw i32 %117, %118
%120 = add nsw i32 %119, 1
%121 = sext i32 %120 to i64
%122 = getelementptr inbounds double, double* %114, i64 %121
%123 = load double, double* %122
%124 = fadd double %123, %113
store double %124, double* %122
%125 = load double*, double** %11
%126 = load i32, i32* %9
%127 = load i32, i32* %18
%128 = mul nsw i32 %126, %127
%129 = load i32, i32* %19
%130 = add nsw i32 %128, %129
%131 = add nsw i32 %130, 1
%132 = sext i32 %131 to i64
%133 = getelementptr inbounds double, double* %125, i64 %132
%134 = load double, double* %133
%135 = load double, double* %24
%136 = load double*, double** %12
%137 = load i32, i32* %9
%138 = load i32, i32* %18
%139 = mul nsw i32 %137, %138
%140 = load i32, i32* %19
%141 = add nsw i32 %139, %140
%142 = add nsw i32 %141, 1
%143 = sext i32 %142 to i64
%144 = getelementptr inbounds double, double* %136, i64 %143
%145 = load double, double* %144
%146 = load double, double* %23
%147 = fmul double %145, %146
%148 = call double @llvm.fmuladd.f64(double %134, double %135, double %147)
%149 = load double*, double** %21
%150 = load i32, i32* %9
%151 = load i32, i32* %18
%152 = mul nsw i32 %150, %151
%153 = load i32, i32* %17
%154 = add nsw i32 %152, %153
%155 = add nsw i32 %154, 1
%156 = sext i32 %155 to i64
%157 = getelementptr inbounds double, double* %149, i64 %156
%158 = load double, double* %157
%159 = fadd double %158, %148
store double %159, double* %157
br label %160
160: ; preds = %84
%161 = load i32, i32* %19
%162 = add nsw i32 %161, 1
store i32 %162, i32* %19
br label %62
163: ; preds = %62
br label %164
164: ; preds = %163
%165 = load i32, i32* %17
%166 = add nsw i32 %165, 1
store i32 %166, i32* %17
br label %39
167: ; preds = %39
br label %168
168: ; preds = %167
%169 = load i32, i32* %18
%170 = add nsw i32 %169, 1
store i32 %170, i32* %18
br label %34
171: ; preds = %34
store i32 0, i32* %19
br label %172
172: ; preds = %363, %171
%173 = load i32, i32* %19
%174 = load i32, i32* %9
%175 = icmp slt i32 %173, %174
br i1 %175, label %176, label %366
176: ; preds = %172
store i32 0, i32* %17
br label %177
177: ; preds = %359, %176
%178 = load i32, i32* %17
%179 = load i32, i32* %8
%180 = icmp slt i32 %178, %179
br i1 %180, label %181, label %362
181: ; preds = %177
%182 = load double*, double** %14
%183 = load i32, i32* %9
%184 = load i32, i32* %17
%185 = mul nsw i32 %183, %184
%186 = load i32, i32* %19
%187 = add nsw i32 %185, %186
%188 = add nsw i32 %187, 1
%189 = sext i32 %188 to i64
%190 = getelementptr inbounds double, double* %182, i64 %189
store double 0.000000e+00, double* %190
%191 = load double*, double** %13
%192 = load i32, i32* %9
%193 = load i32, i32* %17
%194 = mul nsw i32 %192, %193
%195 = load i32, i32* %19
%196 = add nsw i32 %194, %195
%197 = add nsw i32 %196, 1
%198 = sext i32 %197 to i64
%199 = getelementptr inbounds double, double* %191, i64 %198
store double 0.000000e+00, double* %199
store i32 0, i32* %18
br label %200
200: ; preds = %298, %181
%201 = load i32, i32* %18
%202 = load i32, i32* %8
%203 = icmp slt i32 %201, %202
br i1 %203, label %204, label %301
204: ; preds = %200
%205 = load i32, i32* %8
%206 = sitofp i32 %205 to double
store double %206, double* %26
%207 = load double, double* %15
%208 = fmul double 2.000000e+00, %207
%209 = load i32, i32* %17
%210 = sitofp i32 %209 to double
%211 = fmul double %208, %210
%212 = load i32, i32* %18
%213 = sitofp i32 %212 to double
%214 = fmul double %211, %213
%215 = load double, double* %26
%216 = fdiv double %214, %215
store double %216, double* %22
%217 = load i32, i32* %10
%218 = icmp ne i32 %217, 0
br i1 %218, label %219, label %222
219: ; preds = %204
%220 = load double, double* %22
%221 = fneg double %220
store double %221, double* %22
br label %222
222: ; preds = %219, %204
%223 = load double, double* %22
%224 = call double @cos(double %223)
store double %224, double* %23
%225 = load double, double* %22
%226 = call double @sin(double %225)
store double %226, double* %24
%227 = load double*, double** %20
%228 = load i32, i32* %9
%229 = load i32, i32* %18
%230 = mul nsw i32 %228, %229
%231 = load i32, i32* %19
%232 = add nsw i32 %230, %231
%233 = add nsw i32 %232, 1
%234 = sext i32 %233 to i64
%235 = getelementptr inbounds double, double* %227, i64 %234
%236 = load double, double* %235
%237 = load double, double* %23
%238 = load double*, double** %21
%239 = load i32, i32* %9
%240 = load i32, i32* %18
%241 = mul nsw i32 %239, %240
%242 = load i32, i32* %19
%243 = add nsw i32 %241, %242
%244 = add nsw i32 %243, 1
%245 = sext i32 %244 to i64
%246 = getelementptr inbounds double, double* %238, i64 %245
%247 = load double, double* %246
%248 = load double, double* %24
%249 = fmul double %247, %248
%250 = fneg double %249
%251 = call double @llvm.fmuladd.f64(double %236, double %237, double %250)
%252 = load double*, double** %13
%253 = load i32, i32* %9
%254 = load i32, i32* %17
%255 = mul nsw i32 %253, %254
%256 = load i32, i32* %19
%257 = add nsw i32 %255, %256
%258 = add nsw i32 %257, 1
%259 = sext i32 %258 to i64
%260 = getelementptr inbounds double, double* %252, i64 %259
%261 = load double, double* %260
%262 = fadd double %261, %251
store double %262, double* %260
%263 = load double*, double** %20
%264 = load i32, i32* %9
%265 = load i32, i32* %18
%266 = mul nsw i32 %264, %265
%267 = load i32, i32* %19
%268 = add nsw i32 %266, %267
%269 = add nsw i32 %268, 1
%270 = sext i32 %269 to i64
%271 = getelementptr inbounds double, double* %263, i64 %270
%272 = load double, double* %271
%273 = load double, double* %24
%274 = load double*, double** %21
%275 = load i32, i32* %9
%276 = load i32, i32* %18
%277 = mul nsw i32 %275, %276
%278 = load i32, i32* %19
%279 = add nsw i32 %277, %278
%280 = add nsw i32 %279, 1
%281 = sext i32 %280 to i64
%282 = getelementptr inbounds double, double* %274, i64 %281
%283 = load double, double* %282
%284 = load double, double* %23
%285 = fmul double %283, %284
%286 = call double @llvm.fmuladd.f64(double %272, double %273, double %285)
%287 = load double*, double** %14
%288 = load i32, i32* %9
%289 = load i32, i32* %17
%290 = mul nsw i32 %288, %289
%291 = load i32, i32* %19
%292 = add nsw i32 %290, %291
%293 = add nsw i32 %292, 1
%294 = sext i32 %293 to i64
%295 = getelementptr inbounds double, double* %287, i64 %294
%296 = load double, double* %295
%297 = fadd double %296, %286
store double %297, double* %295
br label %298
298: ; preds = %222
%299 = load i32, i32* %18
%300 = add nsw i32 %299, 1
store i32 %300, i32* %18
br label %200
301: ; preds = %200
%302 = load i32, i32* %10
%303 = icmp ne i32 %302, 0
br i1 %303, label %304, label %331
304: ; preds = %301
%305 = load i32, i32* %8
%306 = sitofp i32 %305 to double
%307 = load double*, double** %13
%308 = load i32, i32* %9
%309 = load i32, i32* %17
%310 = mul nsw i32 %308, %309
%311 = load i32, i32* %19
%312 = add nsw i32 %310, %311
%313 = add nsw i32 %312, 1
%314 = sext i32 %313 to i64
%315 = getelementptr inbounds double, double* %307, i64 %314
%316 = load double, double* %315
%317 = fdiv double %316, %306
store double %317, double* %315
%318 = load i32, i32* %8
%319 = sitofp i32 %318 to double
%320 = load double*, double** %14
%321 = load i32, i32* %9
%322 = load i32, i32* %17
%323 = mul nsw i32 %321, %322
%324 = load i32, i32* %19
%325 = add nsw i32 %323, %324
%326 = add nsw i32 %325, 1
%327 = sext i32 %326 to i64
%328 = getelementptr inbounds double, double* %320, i64 %327
%329 = load double, double* %328
%330 = fdiv double %329, %319
store double %330, double* %328
br label %358
331: ; preds = %301
%332 = load i32, i32* %9
%333 = sitofp i32 %332 to double
%334 = load double*, double** %13
%335 = load i32, i32* %9
%336 = load i32, i32* %17
%337 = mul nsw i32 %335, %336
%338 = load i32, i32* %19
%339 = add nsw i32 %337, %338
%340 = add nsw i32 %339, 1
%341 = sext i32 %340 to i64
%342 = getelementptr inbounds double, double* %334, i64 %341
%343 = load double, double* %342
%344 = fdiv double %343, %333
store double %344, double* %342
%345 = load i32, i32* %9
%346 = sitofp i32 %345 to double
%347 = load double*, double** %14
%348 = load i32, i32* %9
%349 = load i32, i32* %17
%350 = mul nsw i32 %348, %349
%351 = load i32, i32* %19
%352 = add nsw i32 %350, %351
%353 = add nsw i32 %352, 1
%354 = sext i32 %353 to i64
%355 = getelementptr inbounds double, double* %347, i64 %354
%356 = load double, double* %355
%357 = fdiv double %356, %346
store double %357, double* %355
br label %358
358: ; preds = %331, %304
br label %359
359: ; preds = %358
%360 = load i32, i32* %17
%361 = add nsw i32 %360, 1
store i32 %361, i32* %17
br label %177
362: ; preds = %177
br label %363
363: ; preds = %362
%364 = load i32, i32* %19
%365 = add nsw i32 %364, 1
store i32 %365, i32* %19
br label %172
366: ; preds = %172
%367 = load double*, double** %20
%368 = load i32, i32* %16
%369 = call i32 @free_dvector(double* %367, i32 1, i32 %368)
%370 = load double*, double** %21
%371 = load i32, i32* %16
%372 = call i32 @free_dvector(double* %370, i32 1, i32 %371)
ret void
}

LLVM IR (-O2):
define void @dft2d(i32 %0, i32 %1, i32 %2, double* nocapture %3, double* nocapture %4, double* nocapture %5, double* nocapture %6) {
%8 = mul nsw i32 %1, %0
%9 = tail call double* @dvector(i32 1, i32 %8)
%10 = tail call double* @dvector(i32 1, i32 %8)
%11 = icmp sgt i32 %0, 0
br i1 %11, label %12, label %22
12: ; preds = %7
%13 = icmp sgt i32 %1, 0
%14 = sitofp i32 %1 to double
%15 = icmp eq i32 %2, 0
%16 = zext i32 %1 to i64
br label %17
17: ; preds = %12, %71
%18 = phi i32 [ 0, %12 ], [ %72, %71 ]
br i1 %13, label %19, label %71
19: ; preds = %17
%20 = mul nsw i32 %18, %1
%21 = add i32 %20, 1
br label %30
22: ; preds = %71, %7
%23 = icmp sgt i32 %1, 0
br i1 %23, label %24, label %128
24: ; preds = %22
%25 = sitofp i32 %0 to double
%26 = icmp eq i32 %2, 0
%27 = sitofp i32 %1 to double
%28 = zext i32 %0 to i64
%29 = select i1 %26, double %27, double %25
br label %74
30: ; preds = %68, %19
%31 = phi i64 [ 0, %19 ], [ %69, %68 ]
%32 = trunc i64 %31 to i32
%33 = add i32 %21, %32
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds double, double* %10, i64 %34
store double 0.000000e+00, double* %35
%36 = getelementptr inbounds double, double* %9, i64 %34
store double 0.000000e+00, double* %36
%37 = sitofp i32 %32 to double
%38 = fmul double %37, 0x401921FB54442D18
br label %39
39: ; preds = %30, %39
%40 = phi i64 [ 0, %30 ], [ %66, %39 ]
%41 = trunc i64 %40 to i32
%42 = sitofp i32 %41 to double
%43 = fmul double %38, %42
%44 = fdiv double %43, %14
%45 = fneg double %44
%46 = select i1 %15, double %44, double %45
%47 = tail call double @cos(double %46)
%48 = tail call double @sin(double %46)
%49 = add i32 %21, %41
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds double, double* %3, i64 %50
%52 = load double, double* %51
%53 = getelementptr inbounds double, double* %4, i64 %50
%54 = load double, double* %53
%55 = fneg double %54
%56 = fmul double %48, %55
%57 = tail call double @llvm.fmuladd.f64(double %52, double %47, double %56)
%58 = load double, double* %36
%59 = fadd double %58, %57
store double %59, double* %36
%60 = load double, double* %51
%61 = load double, double* %53
%62 = fmul double %47, %61
%63 = tail call double @llvm.fmuladd.f64(double %60, double %48, double %62)
%64 = load double, double* %35
%65 = fadd double %64, %63
store double %65, double* %35
%66 = add nuw nsw i64 %40, 1
%67 = icmp eq i64 %66, %16
br i1 %67, label %68, label %39
68: ; preds = %39
%69 = add nuw nsw i64 %31, 1
%70 = icmp eq i64 %69, %16
br i1 %70, label %71, label %30
71: ; preds = %68, %17
%72 = add nuw nsw i32 %18, 1
%73 = icmp eq i32 %72, %0
br i1 %73, label %22, label %17
74: ; preds = %24, %126
%75 = phi i32 [ 0, %24 ], [ %76, %126 ]
%76 = add nuw nsw i32 %75, 1
br i1 %11, label %77, label %126
77: ; preds = %74, %119
%78 = phi i64 [ %124, %119 ], [ 0, %74 ]
%79 = trunc i64 %78 to i32
%80 = mul i32 %79, %1
%81 = add i32 %76, %80
%82 = sext i32 %81 to i64
%83 = getelementptr inbounds double, double* %6, i64 %82
store double 0.000000e+00, double* %83
%84 = getelementptr inbounds double, double* %5, i64 %82
store double 0.000000e+00, double* %84
%85 = trunc i64 %78 to i32
%86 = sitofp i32 %85 to double
%87 = fmul double %86, 0x401921FB54442D18
br label %88
88: ; preds = %77, %88
%89 = phi i64 [ 0, %77 ], [ %117, %88 ]
%90 = trunc i64 %89 to i32
%91 = sitofp i32 %90 to double
%92 = fmul double %87, %91
%93 = fdiv double %92, %25
%94 = fneg double %93
%95 = select i1 %26, double %93, double %94
%96 = tail call double @cos(double %95)
%97 = tail call double @sin(double %95)
%98 = trunc i64 %89 to i32
%99 = mul i32 %98, %1
%100 = add i32 %76, %99
%101 = sext i32 %100 to i64
%102 = getelementptr inbounds double, double* %9, i64 %101
%103 = load double, double* %102
%104 = getelementptr inbounds double, double* %10, i64 %101
%105 = load double, double* %104
%106 = fneg double %105
%107 = fmul double %97, %106
%108 = tail call double @llvm.fmuladd.f64(double %103, double %96, double %107)
%109 = load double, double* %84
%110 = fadd double %109, %108
store double %110, double* %84
%111 = load double, double* %102
%112 = load double, double* %104
%113 = fmul double %96, %112
%114 = tail call double @llvm.fmuladd.f64(double %111, double %97, double %113)
%115 = load double, double* %83
%116 = fadd double %115, %114
store double %116, double* %83
%117 = add nuw nsw i64 %89, 1
%118 = icmp eq i64 %117, %28
br i1 %118, label %119, label %88
119: ; preds = %88
%120 = load double, double* %84
%121 = fdiv double %120, %29
store double %121, double* %84
%122 = load double, double* %83
%123 = fdiv double %122, %29
store double %123, double* %83
%124 = add nuw nsw i64 %78, 1
%125 = icmp eq i64 %124, %28
br i1 %125, label %126, label %77
126: ; preds = %119, %74
%127 = icmp eq i32 %76, %1
br i1 %127, label %128, label %74
128: ; preds = %126, %22
%129 = tail call i32 @free_dvector(double* %9, i32 1, i32 %8)
%130 = tail call i32 @free_dvector(double* %10, i32 1, i32 %8)
ret void
}