void mp_mul_csqu_save_d1(int nfft, double d1[], double d2[], int ip[],
                         double w[]) {
  void makect(int nc, int *ip, double *c);
  void cdft(int n, int isgn, double *a, int *ip, double *w);
  void mp_mul_rcsqu_save(int n, double *a, double *b, int nc, double *c);
  double xr, xi;
  cdft(nfft, 1, &d1[1], ip, w);
  if (nfft > (ip[1] << 2)) {
    makect(nfft >> 2, ip, &w[ip[0]]);
  }
  d2[0] = 2 * d1[0];
  xr = d1[1] * d1[1] + d1[2] * d1[2];
  xi = 2 * d1[1] * d1[2];
  d2[1] = xr;
  d2[2] = xi;
  if (nfft > 2) {
    mp_mul_rcsqu_save(nfft, &d1[1], &d2[1], ip[1], &w[ip[0]]);
  }
  d2[nfft + 1] = d1[nfft + 1] * d1[nfft + 1];
  cdft(nfft, -1, &d2[1], ip, w);
}


x86 assembly (clang, -O0):
<mp_mul_csqu_save_d1>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rdx
add    $0x8,%rdx
mov    -0x20(%rbp),%rcx
mov    -0x28(%rbp),%r8
mov    $0x1,%esi
call   1040 <cdft@plt>
mov    -0x4(%rbp),%eax
mov    -0x20(%rbp),%rcx
mov    0x4(%rcx),%ecx
shl    $0x2,%ecx
cmp    %ecx,%eax
jle    119e <mp_mul_csqu_save_d1+0x6e>
mov    -0x4(%rbp),%edi
sar    $0x2,%edi
mov    -0x20(%rbp),%rsi
mov    -0x28(%rbp),%rdx
mov    -0x20(%rbp),%rax
movslq (%rax),%rax
shl    $0x3,%rax
add    %rax,%rdx
call   1050 <makect@plt>
mov    -0x10(%rbp),%rax
movsd  0xe56(%rip),%xmm0
mulsd  (%rax),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x10(%rbp),%rax
movsd  0x8(%rax),%xmm0
mov    -0x10(%rbp),%rax
movsd  0x8(%rax),%xmm2
mov    -0x10(%rbp),%rax
movsd  0x10(%rax),%xmm1
mov    -0x10(%rbp),%rax
mulsd  0x10(%rax),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0x10(%rbp),%rax
movsd  0xe0d(%rip),%xmm0
mulsd  0x8(%rax),%xmm0
mov    -0x10(%rbp),%rax
mulsd  0x10(%rax),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x30(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,0x8(%rax)
movsd  -0x38(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,0x10(%rax)
cmpl   $0x2,-0x4(%rbp)
jle    125d <mp_mul_csqu_save_d1+0x12d>
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
add    $0x8,%rsi
mov    -0x18(%rbp),%rdx
add    $0x8,%rdx
mov    -0x20(%rbp),%rax
mov    0x4(%rax),%ecx
mov    -0x28(%rbp),%r8
mov    -0x20(%rbp),%rax
movslq (%rax),%rax
shl    $0x3,%rax
add    %rax,%r8
call   1030 <mp_mul_rcsqu_save@plt>
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
mov    -0x18(%rbp),%rax
mov    -0x4(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x4(%rbp),%edi
mov    -0x18(%rbp),%rdx
add    $0x8,%rdx
mov    -0x20(%rbp),%rcx
mov    -0x28(%rbp),%r8
mov    $0xffffffff,%esi
call   1040 <cdft@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mp_mul_csqu_save_d1>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r8,%r14
mov    %rcx,%r15
mov    %rdx,%r12
mov    %rsi,%rbx
mov    %edi,%ebp
lea    0x8(%rsi),%rdx
mov    $0x1,%esi
mov    %rdx,(%rsp)
call   1040 <cdft@plt>
mov    0x4(%r15),%eax
shl    $0x2,%eax
cmp    %ebp,%eax
jge    117a <mp_mul_csqu_save_d1+0x4a>
mov    %ebp,%edi
sar    $0x2,%edi
movslq (%r15),%rax
lea    (%r14,%rax,8),%rdx
mov    %r15,%rsi
call   1050 <makect@plt>
movsd  (%rbx),%xmm0
addsd  %xmm0,%xmm0
movsd  %xmm0,(%r12)
movsd  0x8(%rbx),%xmm0
movsd  0x10(%rbx),%xmm1
movapd %xmm0,%xmm2
addsd  %xmm0,%xmm0
mulsd  %xmm1,%xmm0
mulsd  %xmm1,%xmm1
mulsd  %xmm2,%xmm2
addsd  %xmm1,%xmm2
lea    0x8(%r12),%r13
movsd  %xmm2,0x8(%r12)
movsd  %xmm0,0x10(%r12)
cmp    $0x3,%ebp
jl     11db <mp_mul_csqu_save_d1+0xab>
mov    0x4(%r15),%ecx
movslq (%r15),%rax
lea    (%r14,%rax,8),%r8
mov    %ebp,%edi
mov    (%rsp),%rsi
mov    %r13,%rdx
call   1030 <mp_mul_rcsqu_save@plt>
movslq %ebp,%rax
movsd  0x8(%rbx,%rax,8),%xmm0
mulsd  %xmm0,%xmm0
movsd  %xmm0,0x8(%r12,%rax,8)
mov    %ebp,%edi
mov    $0xffffffff,%esi
mov    %r13,%rdx
mov    %r15,%rcx
mov    %r14,%r8
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <cdft@plt>

LLVM IR (-O0):
define void @mp_mul_csqu_save_d1(i32 %0, double* %1, double* %2, i32* %3, double* %4) {
%6 = alloca i32
%7 = alloca double*
%8 = alloca double*
%9 = alloca i32*
%10 = alloca double*
%11 = alloca double
%12 = alloca double
store i32 %0, i32* %6
store double* %1, double** %7
store double* %2, double** %8
store i32* %3, i32** %9
store double* %4, double** %10
%13 = load i32, i32* %6
%14 = load double*, double** %7
%15 = getelementptr inbounds double, double* %14, i64 1
%16 = load i32*, i32** %9
%17 = load double*, double** %10
%18 = load i32, i32* %6
%19 = load i32*, i32** %9
%20 = getelementptr inbounds i32, i32* %19, i64 1
%21 = load i32, i32* %20
%22 = shl i32 %21, 2
%23 = icmp sgt i32 %18, %22
br i1 %23, label %24, label %34
24: ; preds = %5
%25 = load i32, i32* %6
%26 = ashr i32 %25, 2
%27 = load i32*, i32** %9
%28 = load double*, double** %10
%29 = load i32*, i32** %9
%30 = getelementptr inbounds i32, i32* %29, i64 0
%31 = load i32, i32* %30
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds double, double* %28, i64 %32
br label %34
34: ; preds = %24, %5
%35 = load double*, double** %7
%36 = getelementptr inbounds double, double* %35, i64 0
%37 = load double, double* %36
%38 = fmul double 2.000000e+00, %37
%39 = load double*, double** %8
%40 = getelementptr inbounds double, double* %39, i64 0
store double %38, double* %40
%41 = load double*, double** %7
%42 = getelementptr inbounds double, double* %41, i64 1
%43 = load double, double* %42
%44 = load double*, double** %7
%45 = getelementptr inbounds double, double* %44, i64 1
%46 = load double, double* %45
%47 = load double*, double** %7
%48 = getelementptr inbounds double, double* %47, i64 2
%49 = load double, double* %48
%50 = load double*, double** %7
%51 = getelementptr inbounds double, double* %50, i64 2
%52 = load double, double* %51
%53 = fmul double %49, %52
%54 = call double @llvm.fmuladd.f64(double %43, double %46, double %53)
store double %54, double* %11
%55 = load double*, double** %7
%56 = getelementptr inbounds double, double* %55, i64 1
%57 = load double, double* %56
%58 = fmul double 2.000000e+00, %57
%59 = load double*, double** %7
%60 = getelementptr inbounds double, double* %59, i64 2
%61 = load double, double* %60
%62 = fmul double %58, %61
store double %62, double* %12
%63 = load double, double* %11
%64 = load double*, double** %8
%65 = getelementptr inbounds double, double* %64, i64 1
store double %63, double* %65
%66 = load double, double* %12
%67 = load double*, double** %8
%68 = getelementptr inbounds double, double* %67, i64 2
store double %66, double* %68
%69 = load i32, i32* %6
%70 = icmp sgt i32 %69, 2
br i1 %70, label %71, label %86
71: ; preds = %34
%72 = load i32, i32* %6
%73 = load double*, double** %7
%74 = getelementptr inbounds double, double* %73, i64 1
%75 = load double*, double** %8
%76 = getelementptr inbounds double, double* %75, i64 1
%77 = load i32*, i32** %9
%78 = getelementptr inbounds i32, i32* %77, i64 1
%79 = load i32, i32* %78
%80 = load double*, double** %10
%81 = load i32*, i32** %9
%82 = getelementptr inbounds i32, i32* %81, i64 0
%83 = load i32, i32* %82
%84 = sext i32 %83 to i64
%85 = getelementptr inbounds double, double* %80, i64 %84
br label %86
86: ; preds = %71, %34
%87 = load double*, double** %7
%88 = load i32, i32* %6
%89 = add nsw i32 %88, 1
%90 = sext i32 %89 to i64
%91 = getelementptr inbounds double, double* %87, i64 %90
%92 = load double, double* %91
%93 = load double*, double** %7
%94 = load i32, i32* %6
%95 = add nsw i32 %94, 1
%96 = sext i32 %95 to i64
%97 = getelementptr inbounds double, double* %93, i64 %96
%98 = load double, double* %97
%99 = fmul double %92, %98
%100 = load double*, double** %8
%101 = load i32, i32* %6
%102 = add nsw i32 %101, 1
%103 = sext i32 %102 to i64
%104 = getelementptr inbounds double, double* %100, i64 %103
store double %99, double* %104
%105 = load i32, i32* %6
%106 = load double*, double** %8
%107 = getelementptr inbounds double, double* %106, i64 1
%108 = load i32*, i32** %9
%109 = load double*, double** %10
ret void
}

LLVM IR (-O2):
define void @mp_mul_csqu_save_d1(i32 %0, double* %1, double* %2, i32* %3, double* %4) {
%6 = getelementptr inbounds double, double* %1, i64 1
tail call void @cdft(i32 %0, i32 1, double* %6, i32* %3, double* %4)
%7 = getelementptr inbounds i32, i32* %3, i64 1
%8 = load i32, i32* %7
%9 = shl i32 %8, 2
%10 = icmp slt i32 %9, %0
br i1 %10, label %11, label %16
11: ; preds = %5
%12 = ashr i32 %0, 2
%13 = load i32, i32* %3
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds double, double* %4, i64 %14
tail call void @makect(i32 %12, i32* %3, double* %15)
br label %16
16: ; preds = %11, %5
%17 = load double, double* %1
%18 = fmul double %17, 2.000000e+00
store double %18, double* %2
%19 = load double, double* %6
%20 = getelementptr inbounds double, double* %1, i64 2
%21 = load double, double* %20
%22 = fmul double %21, %21
%23 = tail call double @llvm.fmuladd.f64(double %19, double %19, double %22)
%24 = fmul double %19, 2.000000e+00
%25 = fmul double %24, %21
%26 = getelementptr inbounds double, double* %2, i64 1
store double %23, double* %26
%27 = getelementptr inbounds double, double* %2, i64 2
store double %25, double* %27
%28 = icmp sgt i32 %0, 2
br i1 %28, label %29, label %34
29: ; preds = %16
%30 = load i32, i32* %7
%31 = load i32, i32* %3
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds double, double* %4, i64 %32
tail call void @mp_mul_rcsqu_save(i32 %0, double* %6, double* %26, i32 %30, double* %33)
br label %34
34: ; preds = %29, %16
%35 = add nsw i32 %0, 1
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds double, double* %1, i64 %36
%38 = load double, double* %37
%39 = fmul double %38, %38
%40 = getelementptr inbounds double, double* %2, i64 %36
store double %39, double* %40
tail call void @cdft(i32 %0, i32 -1, double* %26, i32* %3, double* %4)
ret void
}