void lsx_ordered_partial_convolve(int n, double *a, const double *b) {
  int i;
  a[0] *= b[0];
  for (i = 2; i < n; i += 2) {
    double tmp = a[i];
    a[i] = b[i] * tmp - b[i + 1] * a[i + 1];
    a[i + 1] = b[i + 1] * tmp + b[i] * a[i + 1];
  }
  a[1] = b[i] * a[i] - b[i + 1] * a[i + 1];
}


x86 assembly (clang, -O0):
<lsx_ordered_partial_convolve>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x10(%rbp),%rax
mulsd  (%rax),%xmm0
movsd  %xmm0,(%rax)
movl   $0x2,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    1208 <lsx_ordered_partial_convolve+0x108>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  -0x28(%rbp),%xmm2
mov    -0x18(%rbp),%rax
mov    -0x1c(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm1
mov    -0x10(%rbp),%rax
mov    -0x1c(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mulsd  (%rax,%rcx,8),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x18(%rbp),%rax
mov    -0x1c(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  -0x28(%rbp),%xmm2
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
mov    -0x10(%rbp),%rax
mov    -0x1c(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mulsd  (%rax,%rcx,8),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x10(%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    112a <lsx_ordered_partial_convolve+0x2a>
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm2
mov    -0x18(%rbp),%rax
mov    -0x1c(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm1
mov    -0x10(%rbp),%rax
mov    -0x1c(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mulsd  (%rax,%rcx,8),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,0x8(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<lsx_ordered_partial_convolve>:
movsd  (%rdx),%xmm0
mulsd  (%rsi),%xmm0
movsd  %xmm0,(%rsi)
mov    $0x2,%eax
cmp    $0x3,%edi
jl     125d <lsx_ordered_partial_convolve+0x15d>
mov    %edi,%r10d
cmp    $0x5,%r10
mov    $0x4,%r9d
cmovae %r10,%r9
mov    $0x4,%ecx
add    $0xfffffffffffffffd,%r9
mov    $0x2,%eax
cmp    $0x2,%r9
jb     1210 <lsx_ordered_partial_convolve+0x110>
lea    0x10(%rsi),%r8
cmp    $0x5,%r10
cmovae %r10,%rcx
add    $0x1,%rcx
and    $0xfffffffffffffffe,%rcx
lea    (%rdx,%rcx,8),%rdi
cmp    %rdi,%r8
jae    1171 <lsx_ordered_partial_convolve+0x71>
lea    (%rsi,%rcx,8),%rcx
lea    0x10(%rdx),%rdi
cmp    %rcx,%rdi
jb     1210 <lsx_ordered_partial_convolve+0x110>
shr    %r9
add    $0x1,%r9
movabs $0x7ffffffffffffffe,%r8
ff ff 7f
and    %r9,%r8
lea    (%r9,%r9,1),%rax
or     $0x2,%rax
mov    $0x10,%edi
mov    %r8,%rcx
cs nopw 0x0(%rax,%rax,1)
nop
movupd (%rsi,%rdi,1),%xmm0
movupd 0x10(%rsi,%rdi,1),%xmm1
movapd %xmm0,%xmm2
unpcklpd %xmm1,%xmm2
unpckhpd %xmm1,%xmm0
movupd (%rdx,%rdi,1),%xmm1
movupd 0x10(%rdx,%rdi,1),%xmm3
movapd %xmm1,%xmm4
unpcklpd %xmm3,%xmm4
unpckhpd %xmm3,%xmm1
movapd %xmm0,%xmm3
mulpd  %xmm1,%xmm3
mulpd  %xmm4,%xmm0
mulpd  %xmm2,%xmm4
subpd  %xmm3,%xmm4
mulpd  %xmm2,%xmm1
addpd  %xmm0,%xmm1
movapd %xmm4,%xmm0
unpckhpd %xmm1,%xmm0
unpcklpd %xmm1,%xmm4
movupd %xmm4,(%rsi,%rdi,1)
movupd %xmm0,0x10(%rsi,%rdi,1)
add    $0x20,%rdi
add    $0xfffffffffffffffe,%rcx
jne    11a0 <lsx_ordered_partial_convolve+0xa0>
cmp    %r8,%r9
je     125d <lsx_ordered_partial_convolve+0x15d>
lea    0x0(,%rax,8),%rcx
movsd  (%rsi,%rax,8),%xmm0
or     $0x8,%rcx
movsd  (%rsi,%rcx,1),%xmm1
movsd  (%rdx,%rcx,1),%xmm2
mulsd  %xmm1,%xmm2
movsd  (%rdx,%rax,8),%xmm3
mulsd  %xmm0,%xmm3
subsd  %xmm2,%xmm3
movsd  %xmm3,(%rsi,%rax,8)
mulsd  (%rdx,%rax,8),%xmm1
mulsd  (%rdx,%rcx,1),%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,(%rsi,%rcx,1)
add    $0x2,%rax
cmp    %r10,%rax
jb     1210 <lsx_ordered_partial_convolve+0x110>
mov    %eax,%ecx
movsd  (%rdx,%rcx,8),%xmm0
or     $0x1,%eax
movsd  (%rsi,%rax,8),%xmm1
mulsd  (%rdx,%rax,8),%xmm1
mulsd  (%rsi,%rcx,8),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,0x8(%rsi)
ret

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

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