void mp_mul_csqu(int nfft, double dinout[]) {
  int j;
  double xr, xi;
  dinout[0] *= 2;
  dinout[1] *= dinout[1];
  dinout[2] *= dinout[2];
  for (j = 3; j < nfft; j += 2) {
    xr = dinout[j];
    xi = dinout[j + 1];
    dinout[j] = xr * xr - xi * xi;
    dinout[j + 1] = 2 * xr * xi;
  }
  dinout[nfft + 1] *= dinout[nfft + 1];
}


x86 assembly (clang, -O0):
<mp_mul_csqu>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsd  0xee9(%rip),%xmm0
mulsd  (%rax),%xmm0
movsd  %xmm0,(%rax)
mov    -0x10(%rbp),%rax
movsd  0x8(%rax),%xmm0
mov    -0x10(%rbp),%rax
mulsd  0x8(%rax),%xmm0
movsd  %xmm0,0x8(%rax)
mov    -0x10(%rbp),%rax
movsd  0x10(%rax),%xmm0
mov    -0x10(%rbp),%rax
mulsd  0x10(%rax),%xmm0
movsd  %xmm0,0x10(%rax)
movl   $0x3,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11fb <mp_mul_csqu+0xfb>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm2
movsd  -0x28(%rbp),%xmm1
mulsd  -0x28(%rbp),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
movsd  0xe2f(%rip),%xmm0
mulsd  -0x20(%rbp),%xmm0
mulsd  -0x28(%rbp),%xmm0
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x14(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x14(%rbp)
jmp    1154 <mp_mul_csqu+0x54>
mov    -0x10(%rbp),%rax
mov    -0x4(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x10(%rbp),%rax
mov    -0x4(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mulsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,(%rax,%rcx,8)
pop    %rbp
ret

x86 assembly (clang, -O2):
<mp_mul_csqu>:
movupd (%rsi),%xmm0
movapd %xmm0,%xmm1
movlpd 0xef0(%rip),%xmm1
mulpd  %xmm0,%xmm1
movupd %xmm1,(%rsi)
movsd  0x10(%rsi),%xmm0
mulsd  %xmm0,%xmm0
movsd  %xmm0,0x10(%rsi)
cmp    $0x4,%edi
jl     1217 <mp_mul_csqu+0x117>
mov    %edi,%r10d
cmp    $0x6,%r10
mov    $0x5,%r9d
cmovae %r10,%r9
add    $0xfffffffffffffffc,%r9
mov    $0x3,%ecx
cmp    $0x2,%r9
jb     11e0 <mp_mul_csqu+0xe0>
shr    %r9
add    $0x1,%r9
movabs $0x7ffffffffffffffe,%r8
ff ff 7f
and    %r9,%r8
lea    (%r9,%r9,1),%rcx
or     $0x3,%rcx
lea    0x18(%rsi),%rdx
mov    %r8,%rax
cs nopw 0x0(%rax,%rax,1)
movupd (%rdx),%xmm0
movupd 0x10(%rdx),%xmm1
movapd %xmm0,%xmm2
unpcklpd %xmm1,%xmm2
unpckhpd %xmm1,%xmm0
movapd %xmm2,%xmm1
addpd  %xmm2,%xmm2
mulpd  %xmm0,%xmm2
mulpd  %xmm0,%xmm0
mulpd  %xmm1,%xmm1
subpd  %xmm0,%xmm1
movapd %xmm1,%xmm0
unpckhpd %xmm2,%xmm0
unpcklpd %xmm2,%xmm1
movupd %xmm1,(%rdx)
movupd %xmm0,0x10(%rdx)
add    $0x20,%rdx
add    $0xfffffffffffffffe,%rax
jne    1180 <mp_mul_csqu+0x80>
cmp    %r8,%r9
je     1217 <mp_mul_csqu+0x117>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movsd  (%rsi,%rcx,8),%xmm0
movsd  0x8(%rsi,%rcx,8),%xmm1
movapd %xmm0,%xmm2
addsd  %xmm0,%xmm0
mulsd  %xmm1,%xmm0
mulsd  %xmm1,%xmm1
mulsd  %xmm2,%xmm2
subsd  %xmm1,%xmm2
movsd  %xmm2,(%rsi,%rcx,8)
movsd  %xmm0,0x8(%rsi,%rcx,8)
add    $0x2,%rcx
cmp    %r10,%rcx
jb     11e0 <mp_mul_csqu+0xe0>
movslq %edi,%rax
movsd  0x8(%rsi,%rax,8),%xmm0
mulsd  %xmm0,%xmm0
movsd  %xmm0,0x8(%rsi,%rax,8)
ret

LLVM IR (-O0):
define void @mp_mul_csqu(i32 %0, double* %1) {
%3 = alloca i32
%4 = alloca double*
%5 = alloca i32
%6 = alloca double
%7 = alloca double
store i32 %0, i32* %3
store double* %1, double** %4
%8 = load double*, double** %4
%9 = getelementptr inbounds double, double* %8, i64 0
%10 = load double, double* %9
%11 = fmul double %10, 2.000000e+00
store double %11, double* %9
%12 = load double*, double** %4
%13 = getelementptr inbounds double, double* %12, i64 1
%14 = load double, double* %13
%15 = load double*, double** %4
%16 = getelementptr inbounds double, double* %15, i64 1
%17 = load double, double* %16
%18 = fmul double %17, %14
store double %18, double* %16
%19 = load double*, double** %4
%20 = getelementptr inbounds double, double* %19, i64 2
%21 = load double, double* %20
%22 = load double*, double** %4
%23 = getelementptr inbounds double, double* %22, i64 2
%24 = load double, double* %23
%25 = fmul double %24, %21
store double %25, double* %23
store i32 3, i32* %5
br label %26
26: ; preds = %62, %2
%27 = load i32, i32* %5
%28 = load i32, i32* %3
%29 = icmp slt i32 %27, %28
br i1 %29, label %30, label %65
30: ; preds = %26
%31 = load double*, double** %4
%32 = load i32, i32* %5
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds double, double* %31, i64 %33
%35 = load double, double* %34
store double %35, double* %6
%36 = load double*, double** %4
%37 = load i32, i32* %5
%38 = add nsw i32 %37, 1
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds double, double* %36, i64 %39
%41 = load double, double* %40
store double %41, double* %7
%42 = load double, double* %6
%43 = load double, double* %6
%44 = load double, double* %7
%45 = load double, double* %7
%46 = fmul double %44, %45
%47 = fneg double %46
%48 = call double @llvm.fmuladd.f64(double %42, double %43, double %47)
%49 = load double*, double** %4
%50 = load i32, i32* %5
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds double, double* %49, i64 %51
store double %48, double* %52
%53 = load double, double* %6
%54 = fmul double 2.000000e+00, %53
%55 = load double, double* %7
%56 = fmul double %54, %55
%57 = load double*, double** %4
%58 = load i32, i32* %5
%59 = add nsw i32 %58, 1
%60 = sext i32 %59 to i64
%61 = getelementptr inbounds double, double* %57, i64 %60
store double %56, double* %61
br label %62
62: ; preds = %30
%63 = load i32, i32* %5
%64 = add nsw i32 %63, 2
store i32 %64, i32* %5
br label %26
65: ; preds = %26
%66 = load double*, double** %4
%67 = load i32, i32* %3
%68 = add nsw i32 %67, 1
%69 = sext i32 %68 to i64
%70 = getelementptr inbounds double, double* %66, i64 %69
%71 = load double, double* %70
%72 = load double*, double** %4
%73 = load i32, i32* %3
%74 = add nsw i32 %73, 1
%75 = sext i32 %74 to i64
%76 = getelementptr inbounds double, double* %72, i64 %75
%77 = load double, double* %76
%78 = fmul double %77, %71
store double %78, double* %76
ret void
}

LLVM IR (-O2):
define void @mp_mul_csqu(i32 %0, double* nocapture %1) {
%3 = bitcast double* %1 to <2 x double>*
%4 = load <2 x double>, <2 x double>* %3
%5 = insertelement <2 x double> %4, double 2.000000e+00, i64 0
%6 = fmul <2 x double> %4, %5
%7 = bitcast double* %1 to <2 x double>*
store <2 x double> %6, <2 x double>* %7
%8 = getelementptr inbounds double, double* %1, i64 2
%9 = load double, double* %8
%10 = fmul double %9, %9
store double %10, double* %8
%11 = icmp sgt i32 %0, 3
br i1 %11, label %12, label %62
12: ; preds = %2
%13 = zext i32 %0 to i64
%14 = call i64 @llvm.umax.i64(i64 %13, i64 5)
%15 = add nsw i64 %14, -4
%16 = lshr i64 %15, 1
%17 = add nuw nsw i64 %16, 1
%18 = icmp ult i64 %15, 2
br i1 %18, label %46, label %19
19: ; preds = %12
%20 = and i64 %17, 9223372036854775806
%21 = shl nuw i64 %17, 1
%22 = or i64 %21, 3
%23 = getelementptr inbounds double, double* %1, i64 -1
br label %24
24: ; preds = %24, %19
%25 = phi i64 [ 0, %19 ], [ %42, %24 ]
%26 = shl i64 %25, 1
%27 = or i64 %26, 3
%28 = getelementptr inbounds double, double* %1, i64 %27
%29 = bitcast double* %28 to <4 x double>*
%30 = load <4 x double>, <4 x double>* %29
%31 = shufflevector <4 x double> %30, <4 x double> poison, <2 x i32> <i32 0, i32 2>
%32 = shufflevector <4 x double> %30, <4 x double> poison, <2 x i32> <i32 1, i32 3>
%33 = add i64 %26, 4
%34 = fneg <2 x double> %32
%35 = fmul <2 x double> %32, %34
%36 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %31, <2 x double> %31, <2 x double> %35)
%37 = fmul <2 x double> %31, <double 2.000000e+00, double 2.000000e+00>
%38 = fmul <2 x double> %37, %32
%39 = getelementptr inbounds double, double* %23, i64 %33
%40 = bitcast double* %39 to <4 x double>*
%41 = shufflevector <2 x double> %36, <2 x double> %38, <4 x i32> <i32 0, i32 2, i32 1, i32 3>
store <4 x double> %41, <4 x double>* %40
%42 = add nuw i64 %25, 2
%43 = icmp eq i64 %42, %20
br i1 %43, label %44, label %24
44: ; preds = %24
%45 = icmp eq i64 %17, %20
br i1 %45, label %62, label %46
46: ; preds = %12, %44
%47 = phi i64 [ 3, %12 ], [ %22, %44 ]
br label %48
48: ; preds = %46, %48
%49 = phi i64 [ %60, %48 ], [ %47, %46 ]
%50 = getelementptr inbounds double, double* %1, i64 %49
%51 = load double, double* %50
%52 = add nuw nsw i64 %49, 1
%53 = getelementptr inbounds double, double* %1, i64 %52
%54 = load double, double* %53
%55 = fneg double %54
%56 = fmul double %54, %55
%57 = tail call double @llvm.fmuladd.f64(double %51, double %51, double %56)
store double %57, double* %50
%58 = fmul double %51, 2.000000e+00
%59 = fmul double %58, %54
store double %59, double* %53
%60 = add nuw nsw i64 %49, 2
%61 = icmp ult i64 %60, %13
br i1 %61, label %48, label %62
62: ; preds = %48, %44, %2
%63 = add nsw i32 %0, 1
%64 = sext i32 %63 to i64
%65 = getelementptr inbounds double, double* %1, i64 %64
%66 = load double, double* %65
%67 = fmul double %66, %66
store double %67, double* %65
ret void
}