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


x86 assembly (clang, -O0):
<mp_mul_cmul>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x18(%rbp),%rax
addsd  (%rax),%xmm0
movsd  %xmm0,(%rax)
mov    -0x10(%rbp),%rax
movsd  0x8(%rax),%xmm0
mov    -0x18(%rbp),%rax
mulsd  0x8(%rax),%xmm0
movsd  %xmm0,0x8(%rax)
mov    -0x10(%rbp),%rax
movsd  0x10(%rax),%xmm0
mov    -0x18(%rbp),%rax
mulsd  0x10(%rax),%xmm0
movsd  %xmm0,0x10(%rax)
movl   $0x3,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    1232 <mp_mul_cmul+0x132>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x1c(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x18(%rbp),%rax
mov    -0x1c(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  -0x38(%rbp),%xmm2
movsd  -0x30(%rbp),%xmm1
mulsd  -0x40(%rbp),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
movsd  -0x28(%rbp),%xmm0
movsd  -0x40(%rbp),%xmm2
movsd  -0x30(%rbp),%xmm1
mulsd  -0x38(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x18(%rbp),%rax
mov    -0x1c(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x1c(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x1c(%rbp)
jmp    1158 <mp_mul_cmul+0x58>
mov    -0x10(%rbp),%rax
mov    -0x4(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x18(%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_cmul>:
movsd  (%rsi),%xmm0
addsd  (%rdx),%xmm0
movsd  %xmm0,(%rdx)
movsd  0x8(%rsi),%xmm0
mulsd  0x8(%rdx),%xmm0
movsd  %xmm0,0x8(%rdx)
movsd  0x10(%rsi),%xmm0
mulsd  0x10(%rdx),%xmm0
movsd  %xmm0,0x10(%rdx)
cmp    $0x4,%edi
jl     127f <mp_mul_cmul+0x17f>
mov    %edi,%r10d
cmp    $0x6,%r10
mov    $0x5,%r8d
cmovae %r10,%r8
mov    $0x5,%eax
add    $0xfffffffffffffffc,%r8
mov    $0x3,%ecx
cmp    $0x2,%r8
jb     1230 <mp_mul_cmul+0x130>
lea    0x18(%rdx),%r11
cmp    $0x6,%r10
cmovae %r10,%rax
add    $0xfffffffffffffffc,%rax
movabs $0x1ffffffffffffffe,%r9
ff ff 1f
and    %rax,%r9
lea    (%rsi,%r9,8),%rax
add    $0x28,%rax
cmp    %rax,%r11
jae    119b <mp_mul_cmul+0x9b>
lea    (%rdx,%r9,8),%r9
add    $0x28,%r9
lea    0x18(%rsi),%rax
cmp    %r9,%rax
jb     1230 <mp_mul_cmul+0x130>
shr    %r8
add    $0x1,%r8
movabs $0x7ffffffffffffffe,%r9
ff ff 7f
and    %r8,%r9
lea    (%r8,%r8,1),%rcx
or     $0x3,%rcx
mov    $0x18,%eax
mov    %r9,%r11
nop
movupd (%rsi,%rax,1),%xmm0
movupd 0x10(%rsi,%rax,1),%xmm1
movapd %xmm0,%xmm2
unpcklpd %xmm1,%xmm2
unpckhpd %xmm1,%xmm0
movupd (%rdx,%rax,1),%xmm1
movupd 0x10(%rdx,%rax,1),%xmm3
movapd %xmm1,%xmm4
unpcklpd %xmm3,%xmm4
unpckhpd %xmm3,%xmm1
movapd %xmm1,%xmm3
mulpd  %xmm0,%xmm3
mulpd  %xmm2,%xmm1
mulpd  %xmm4,%xmm2
subpd  %xmm3,%xmm2
mulpd  %xmm0,%xmm4
addpd  %xmm4,%xmm1
movapd %xmm2,%xmm0
unpckhpd %xmm1,%xmm0
unpcklpd %xmm1,%xmm2
movupd %xmm2,(%rdx,%rax,1)
movupd %xmm0,0x10(%rdx,%rax,1)
add    $0x20,%rax
add    $0xfffffffffffffffe,%r11
jne    11c0 <mp_mul_cmul+0xc0>
cmp    %r9,%r8
je     127f <mp_mul_cmul+0x17f>
movapd 0xdc8(%rip),%xmm0
nopl   0x0(%rax,%rax,1)
movupd (%rdx,%rcx,8),%xmm1
movsd  (%rsi,%rcx,8),%xmm2
movsd  0x8(%rsi,%rcx,8),%xmm3
movapd %xmm3,%xmm4
xorpd  %xmm0,%xmm4
unpcklpd %xmm3,%xmm4
unpcklpd %xmm2,%xmm2
mulpd  %xmm1,%xmm2
shufpd $0x1,%xmm1,%xmm1
mulpd  %xmm4,%xmm1
addpd  %xmm1,%xmm2
movupd %xmm2,(%rdx,%rcx,8)
add    $0x2,%rcx
cmp    %r10,%rcx
jb     1240 <mp_mul_cmul+0x140>
movslq %edi,%rax
movsd  0x8(%rsi,%rax,8),%xmm0
mulsd  0x8(%rdx,%rax,8),%xmm0
movsd  %xmm0,0x8(%rdx,%rax,8)
ret

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

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