void fft_output(const double *re, const double *im, double *output) {
  double *outputptr = output;
  const double *realptr = re;
  const double *imagptr = im;
  double *endptr = output + (1 << 9) / 2;
  while (outputptr <= endptr) {
    *outputptr = (*realptr * *realptr) + (*imagptr * *imagptr);
    outputptr++;
    realptr++;
    imagptr++;
  }
  *output /= 4;
  *endptr /= 4;
}


x86 assembly (clang, -O0):
<fft_output>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%rax
add    $0x800,%rax
mov    %rax,-0x38(%rbp)
mov    -0x20(%rbp),%rax
cmp    -0x38(%rbp),%rax
ja     119d <fft_output+0x9d>
mov    -0x28(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x28(%rbp),%rax
movsd  (%rax),%xmm2
mov    -0x30(%rbp),%rax
movsd  (%rax),%xmm1
mov    -0x30(%rbp),%rax
mulsd  (%rax),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x20(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x20(%rbp)
mov    -0x28(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x28(%rbp)
mov    -0x30(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x30(%rbp)
jmp    1136 <fft_output+0x36>
mov    -0x18(%rbp),%rax
movsd  (%rax),%xmm0
movsd  0xe53(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,(%rax)
mov    -0x38(%rbp),%rax
movsd  (%rax),%xmm0
movsd  0xe3b(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<fft_output>:
lea    0x808(%rdx),%rax
lea    0x808(%rdi),%rcx
lea    0x808(%rsi),%r8
cmp    %rdx,%rcx
seta   %r9b
cmp    %rdi,%rax
seta   %cl
and    %r9b,%cl
cmp    %rdx,%r8
seta   %r8b
cmp    %rsi,%rax
seta   %al
and    %r8b,%al
or     %cl,%al
je     1140 <fft_output+0x40>
xor    %ecx,%ecx
jmp    11e1 <fft_output+0xe1>
lea    0x800(%rsi),%r9
lea    0x800(%rdi),%r8
xor    %ecx,%ecx
movupd (%rdi,%rcx,8),%xmm0
movupd 0x10(%rdi,%rcx,8),%xmm1
movupd (%rsi,%rcx,8),%xmm2
movupd 0x10(%rsi,%rcx,8),%xmm3
mulpd  %xmm2,%xmm2
mulpd  %xmm3,%xmm3
mulpd  %xmm0,%xmm0
addpd  %xmm2,%xmm0
mulpd  %xmm1,%xmm1
addpd  %xmm3,%xmm1
movupd %xmm0,(%rdx,%rcx,8)
movupd %xmm1,0x10(%rdx,%rcx,8)
movupd 0x20(%rdi,%rcx,8),%xmm0
movupd 0x30(%rdi,%rcx,8),%xmm1
movupd 0x20(%rsi,%rcx,8),%xmm2
movupd 0x30(%rsi,%rcx,8),%xmm3
mulpd  %xmm2,%xmm2
mulpd  %xmm3,%xmm3
mulpd  %xmm0,%xmm0
addpd  %xmm2,%xmm0
mulpd  %xmm1,%xmm1
addpd  %xmm3,%xmm1
movupd %xmm0,0x20(%rdx,%rcx,8)
movupd %xmm1,0x30(%rdx,%rcx,8)
add    $0x8,%rcx
cmp    $0x100,%rcx
jne    1150 <fft_output+0x50>
mov    $0x100,%ecx
mov    %r9,%rsi
mov    %r8,%rdi
movsd  (%rdi),%xmm0
movsd  (%rsi),%xmm1
mulsd  %xmm1,%xmm1
mulsd  %xmm0,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,(%rdx,%rcx,8)
test   %al,%al
je     1264 <fft_output+0x164>
mov    $0x100,%r8d
sub    %rcx,%r8
lea    (%rdx,%rcx,8),%rcx
add    $0x10,%rcx
xor    %eax,%eax
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movsd  0x8(%rdi,%rax,8),%xmm0
movsd  0x8(%rsi,%rax,8),%xmm1
mulsd  %xmm1,%xmm1
mulsd  %xmm0,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rcx,%rax,8)
movsd  0x10(%rdi,%rax,8),%xmm0
movsd  0x10(%rsi,%rax,8),%xmm1
mulsd  %xmm1,%xmm1
mulsd  %xmm0,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,(%rcx,%rax,8)
add    $0x2,%rax
cmp    %rax,%r8
jne    1220 <fft_output+0x120>
movsd  0xd94(%rip),%xmm0
movsd  (%rdx),%xmm1
mulsd  %xmm0,%xmm1
movsd  %xmm1,(%rdx)
mulsd  0x800(%rdx),%xmm0
movsd  %xmm0,0x800(%rdx)
ret

LLVM IR (-O0):
define void @fft_output(double* %0, double* %1, double* %2) {
%4 = alloca double*
%5 = alloca double*
%6 = alloca double*
%7 = alloca double*
%8 = alloca double*
%9 = alloca double*
%10 = alloca double*
store double* %0, double** %4
store double* %1, double** %5
store double* %2, double** %6
%11 = load double*, double** %6
store double* %11, double** %7
%12 = load double*, double** %4
store double* %12, double** %8
%13 = load double*, double** %5
store double* %13, double** %9
%14 = load double*, double** %6
%15 = getelementptr inbounds double, double* %14, i64 256
store double* %15, double** %10
br label %16
16: ; preds = %20, %3
%17 = load double*, double** %7
%18 = load double*, double** %10
%19 = icmp ule double* %17, %18
br i1 %19, label %20, label %38
20: ; preds = %16
%21 = load double*, double** %8
%22 = load double, double* %21
%23 = load double*, double** %8
%24 = load double, double* %23
%25 = load double*, double** %9
%26 = load double, double* %25
%27 = load double*, double** %9
%28 = load double, double* %27
%29 = fmul double %26, %28
%30 = call double @llvm.fmuladd.f64(double %22, double %24, double %29)
%31 = load double*, double** %7
store double %30, double* %31
%32 = load double*, double** %7
%33 = getelementptr inbounds double, double* %32, i32 1
store double* %33, double** %7
%34 = load double*, double** %8
%35 = getelementptr inbounds double, double* %34, i32 1
store double* %35, double** %8
%36 = load double*, double** %9
%37 = getelementptr inbounds double, double* %36, i32 1
store double* %37, double** %9
br label %16
38: ; preds = %16
%39 = load double*, double** %6
%40 = load double, double* %39
%41 = fdiv double %40, 4.000000e+00
store double %41, double* %39
%42 = load double*, double** %10
%43 = load double, double* %42
%44 = fdiv double %43, 4.000000e+00
store double %44, double* %42
ret void
}

LLVM IR (-O2):
define void @fft_output(double* nocapture %0, double* nocapture %1, double* nocapture %2) {
%4 = getelementptr double, double* %2, i64 257
%5 = getelementptr double, double* %0, i64 257
%6 = getelementptr double, double* %1, i64 257
%7 = icmp ugt double* %5, %2
%8 = icmp ugt double* %4, %0
%9 = and i1 %7, %8
%10 = icmp ugt double* %6, %2
%11 = icmp ugt double* %4, %1
%12 = and i1 %10, %11
%13 = or i1 %9, %12
br i1 %13, label %62, label %14
14: ; preds = %3
%15 = getelementptr double, double* %1, i64 256
%16 = getelementptr double, double* %0, i64 256
br label %17
17: ; preds = %17, %14
%18 = phi i64 [ 0, %14 ], [ %60, %17 ]
%19 = getelementptr double, double* %1, i64 %18
%20 = getelementptr double, double* %0, i64 %18
%21 = getelementptr inbounds double, double* %2, i64 %18
%22 = bitcast double* %20 to <2 x double>*
%23 = load <2 x double>, <2 x double>* %22
%24 = getelementptr double, double* %20, i64 2
%25 = bitcast double* %24 to <2 x double>*
%26 = load <2 x double>, <2 x double>* %25
%27 = bitcast double* %19 to <2 x double>*
%28 = load <2 x double>, <2 x double>* %27
%29 = getelementptr double, double* %19, i64 2
%30 = bitcast double* %29 to <2 x double>*
%31 = load <2 x double>, <2 x double>* %30
%32 = fmul <2 x double> %28, %28
%33 = fmul <2 x double> %31, %31
%34 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %23, <2 x double> %23, <2 x double> %32)
%35 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %26, <2 x double> %26, <2 x double> %33)
%36 = bitcast double* %21 to <2 x double>*
store <2 x double> %34, <2 x double>* %36
%37 = getelementptr inbounds double, double* %21, i64 2
%38 = bitcast double* %37 to <2 x double>*
store <2 x double> %35, <2 x double>* %38
%39 = or i64 %18, 4
%40 = getelementptr double, double* %1, i64 %39
%41 = getelementptr double, double* %0, i64 %39
%42 = getelementptr inbounds double, double* %2, i64 %39
%43 = bitcast double* %41 to <2 x double>*
%44 = load <2 x double>, <2 x double>* %43
%45 = getelementptr double, double* %41, i64 2
%46 = bitcast double* %45 to <2 x double>*
%47 = load <2 x double>, <2 x double>* %46
%48 = bitcast double* %40 to <2 x double>*
%49 = load <2 x double>, <2 x double>* %48
%50 = getelementptr double, double* %40, i64 2
%51 = bitcast double* %50 to <2 x double>*
%52 = load <2 x double>, <2 x double>* %51
%53 = fmul <2 x double> %49, %49
%54 = fmul <2 x double> %52, %52
%55 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %44, <2 x double> %44, <2 x double> %53)
%56 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %47, <2 x double> %47, <2 x double> %54)
%57 = bitcast double* %42 to <2 x double>*
store <2 x double> %55, <2 x double>* %57
%58 = getelementptr inbounds double, double* %42, i64 2
%59 = bitcast double* %58 to <2 x double>*
store <2 x double> %56, <2 x double>* %59
%60 = add nuw nsw i64 %18, 8
%61 = icmp eq i64 %60, 256
br i1 %61, label %62, label %17
62: ; preds = %17, %3
%63 = phi i64 [ 0, %3 ], [ 256, %17 ]
%64 = phi double* [ %1, %3 ], [ %15, %17 ]
%65 = phi double* [ %0, %3 ], [ %16, %17 ]
%66 = getelementptr inbounds double, double* %2, i64 %63
%67 = load double, double* %65
%68 = load double, double* %64
%69 = fmul double %68, %68
%70 = tail call double @llvm.fmuladd.f64(double %67, double %67, double %69)
store double %70, double* %66
%71 = or i64 %63, 1
%72 = getelementptr inbounds double, double* %65, i64 1
%73 = getelementptr inbounds double, double* %64, i64 1
br i1 %13, label %74, label %95
74: ; preds = %62, %74
%75 = phi i64 [ %91, %74 ], [ %71, %62 ]
%76 = phi double* [ %93, %74 ], [ %73, %62 ]
%77 = phi double* [ %92, %74 ], [ %72, %62 ]
%78 = getelementptr inbounds double, double* %2, i64 %75
%79 = load double, double* %77
%80 = load double, double* %76
%81 = fmul double %80, %80
%82 = tail call double @llvm.fmuladd.f64(double %79, double %79, double %81)
store double %82, double* %78
%83 = add nuw nsw i64 %75, 1
%84 = getelementptr inbounds double, double* %77, i64 1
%85 = getelementptr inbounds double, double* %76, i64 1
%86 = getelementptr inbounds double, double* %2, i64 %83
%87 = load double, double* %84
%88 = load double, double* %85
%89 = fmul double %88, %88
%90 = tail call double @llvm.fmuladd.f64(double %87, double %87, double %89)
store double %90, double* %86
%91 = add nuw nsw i64 %75, 2
%92 = getelementptr inbounds double, double* %77, i64 2
%93 = getelementptr inbounds double, double* %76, i64 2
%94 = icmp eq i64 %91, 257
br i1 %94, label %95, label %74
95: ; preds = %74, %62
%96 = getelementptr inbounds double, double* %2, i64 256
%97 = load double, double* %2
%98 = fmul double %97, 2.500000e-01
store double %98, double* %2
%99 = load double, double* %96
%100 = fmul double %99, 2.500000e-01
store double %100, double* %96
ret void
}