void polyev(int n, double s_r, double s_i, double *p_r, double *p_i,
            double *q_r, double *q_i, double *v_r, double *v_i) {
  int i;
  double t;
  q_r[0] = p_r[0];
  q_i[0] = p_i[0];
  *v_r = q_r[0];
  *v_i = q_i[0];
  for (i = 1; i < n; i++) {
    t = *v_r * s_r - *v_i * s_i + p_r[i];
    q_i[i] = *v_i = *v_r * s_i + *v_i * s_r + p_i[i];
    q_r[i] = *v_r = t;
  }
}


x86 assembly (clang, -O0):
<polyev>:
push   %rbp
mov    %rsp,%rbp
mov    0x10(%rbp),%rax
mov    %edi,-0x4(%rbp)
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
mov    %rsi,-0x20(%rbp)
mov    %rdx,-0x28(%rbp)
mov    %rcx,-0x30(%rbp)
mov    %r8,-0x38(%rbp)
mov    %r9,-0x40(%rbp)
mov    -0x20(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x30(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x28(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x38(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x30(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x40(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x38(%rbp),%rax
movsd  (%rax),%xmm0
mov    0x10(%rbp),%rax
movsd  %xmm0,(%rax)
movl   $0x1,-0x44(%rbp)
mov    -0x44(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    1233 <polyev+0x133>
mov    -0x40(%rbp),%rax
movsd  (%rax),%xmm0
movsd  -0x10(%rbp),%xmm2
mov    0x10(%rbp),%rax
movsd  (%rax),%xmm1
mulsd  -0x18(%rbp),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x20(%rbp),%rax
movslq -0x44(%rbp),%rcx
addsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x50(%rbp)
mov    -0x40(%rbp),%rax
movsd  (%rax),%xmm0
movsd  -0x18(%rbp),%xmm2
mov    0x10(%rbp),%rax
movsd  (%rax),%xmm1
mulsd  -0x10(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x28(%rbp),%rax
movslq -0x44(%rbp),%rcx
addsd  (%rax,%rcx,8),%xmm0
mov    0x10(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x38(%rbp),%rax
movslq -0x44(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
movsd  -0x50(%rbp),%xmm0
mov    -0x40(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x30(%rbp),%rax
movslq -0x44(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    1170 <polyev+0x70>
pop    %rbp
ret

x86 assembly (clang, -O2):
<polyev>:
mov    0x8(%rsp),%r10
movsd  (%rsi),%xmm2
movsd  %xmm2,(%rcx)
movsd  (%rdx),%xmm2
movsd  %xmm2,(%r8)
movsd  (%rcx),%xmm2
movsd  %xmm2,(%r9)
movsd  (%r8),%xmm2
movsd  %xmm2,(%r10)
cmp    $0x2,%edi
jl     1198 <polyev+0x98>
mov    %edi,%edi
add    $0xfffffffffffffffe,%rdi
xor    %eax,%eax
cs nopw 0x0(%rax,%rax,1)
movsd  (%r9),%xmm3
movapd %xmm2,%xmm4
mulsd  %xmm1,%xmm4
movapd %xmm3,%xmm5
mulsd  %xmm0,%xmm5
subsd  %xmm4,%xmm5
addsd  0x8(%rsi,%rax,8),%xmm5
mulsd  %xmm0,%xmm2
mulsd  %xmm1,%xmm3
addsd  %xmm2,%xmm3
addsd  0x8(%rdx,%rax,8),%xmm3
movsd  %xmm3,(%r10)
movsd  %xmm3,0x8(%r8,%rax,8)
movsd  %xmm5,(%r9)
movsd  %xmm5,0x8(%rcx,%rax,8)
cmp    %rax,%rdi
je     1198 <polyev+0x98>
movsd  (%r10),%xmm2
add    $0x1,%rax
jmp    1140 <polyev+0x40>
ret

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

LLVM IR (-O2):
define void @polyev(i32 %0, double %1, double %2, double* nocapture %3, double* nocapture %4, double* nocapture %5, double* nocapture %6, double* nocapture %7, double* nocapture %8) {
%10 = load double, double* %3
store double %10, double* %5
%11 = load double, double* %4
store double %11, double* %6
%12 = load double, double* %5
store double %12, double* %7
%13 = load double, double* %6
store double %13, double* %8
%14 = icmp sgt i32 %0, 1
br i1 %14, label %15, label %38
15: ; preds = %9
%16 = zext i32 %0 to i64
br label %17
17: ; preds = %36, %15
%18 = phi double [ %13, %15 ], [ %37, %36 ]
%19 = phi i64 [ 1, %15 ], [ %34, %36 ]
%20 = load double, double* %7
%21 = fneg double %18
%22 = fmul double %21, %2
%23 = tail call double @llvm.fmuladd.f64(double %20, double %1, double %22)
%24 = getelementptr inbounds double, double* %3, i64 %19
%25 = load double, double* %24
%26 = fadd double %25, %23
%27 = fmul double %18, %1
%28 = tail call double @llvm.fmuladd.f64(double %20, double %2, double %27)
%29 = getelementptr inbounds double, double* %4, i64 %19
%30 = load double, double* %29
%31 = fadd double %28, %30
store double %31, double* %8
%32 = getelementptr inbounds double, double* %6, i64 %19
store double %31, double* %32
store double %26, double* %7
%33 = getelementptr inbounds double, double* %5, i64 %19
store double %26, double* %33
%34 = add nuw nsw i64 %19, 1
%35 = icmp eq i64 %34, %16
br i1 %35, label %38, label %36
36: ; preds = %17
%37 = load double, double* %8
br label %17
38: ; preds = %17, %9
ret void
}