void phase(int l, double *a) {
  double re = a[0], im = a[1];
  switch ((l % 4 + 4) % 4) {
  case 0:
    break;
  case 1:
    a[0] = -im;
    a[1] = re;
    break;
  case 2:
    a[0] = -re;
    a[1] = -im;
    break;
  case 3:
    a[0] = im;
    a[1] = -re;
    break;
  }
}


x86 assembly (clang, -O0):
<phase>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movsd  0x8(%rax),%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x4(%rbp),%esi
mov    %esi,%eax
add    $0x3,%eax
test   %esi,%esi
mov    %esi,%ecx
cmovs  %eax,%ecx
and    $0xfffffffc,%ecx
mov    %esi,%eax
sub    %ecx,%eax
add    $0x4,%eax
neg    %ecx
mov    %ecx,%edx
mov    %esi,%ecx
lea    0x7(%rcx,%rdx,1),%edx
test   %eax,%eax
mov    %eax,%ecx
cmovs  %edx,%ecx
and    $0xfffffffc,%ecx
sub    %ecx,%eax
mov    %eax,%ecx
mov    %rcx,-0x28(%rbp)
sub    $0x3,%eax
ja     1234 <phase+0x134>
mov    -0x28(%rbp),%rax
lea    0xe91(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
jmp    1234 <phase+0x134>
movsd  -0x20(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x18(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,0x8(%rax)
jmp    1234 <phase+0x134>
movsd  -0x18(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x20(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,0x8(%rax)
jmp    1234 <phase+0x134>
movsd  -0x20(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x18(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,0x8(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<phase>:
movsd  (%rsi),%xmm0
movsd  0x8(%rsi),%xmm1
and    $0x3,%edi
cmp    $0x3,%edi
je     1127 <phase+0x27>
cmp    $0x2,%edi
je     1134 <phase+0x34>
cmp    $0x1,%edi
jne    114c <phase+0x4c>
xorps  0xede(%rip),%xmm1
movlps %xmm1,(%rsi)
jmp    1147 <phase+0x47>
movsd  %xmm1,(%rsi)
xorps  0xece(%rip),%xmm0
jmp    1147 <phase+0x47>
movaps 0xec5(%rip),%xmm2
xorps  %xmm2,%xmm0
movlps %xmm0,(%rsi)
xorps  %xmm2,%xmm1
movaps %xmm1,%xmm0
movsd  %xmm0,0x8(%rsi)
ret

LLVM IR (-O0):
define void @phase(i32 %0, double* %1) {
%3 = alloca i32
%4 = alloca double*
%5 = alloca double
%6 = alloca double
store i32 %0, i32* %3
store double* %1, double** %4
%7 = load double*, double** %4
%8 = getelementptr inbounds double, double* %7, i64 0
%9 = load double, double* %8
store double %9, double* %5
%10 = load double*, double** %4
%11 = getelementptr inbounds double, double* %10, i64 1
%12 = load double, double* %11
store double %12, double* %6
%13 = load i32, i32* %3
%14 = srem i32 %13, 4
%15 = add nsw i32 %14, 4
%16 = srem i32 %15, 4
switch i32 %16, label %43 [
i32 0, label %17
i32 1, label %18
i32 2, label %26
i32 3, label %35
]
17: ; preds = %2
br label %43
18: ; preds = %2
%19 = load double, double* %6
%20 = fneg double %19
%21 = load double*, double** %4
%22 = getelementptr inbounds double, double* %21, i64 0
store double %20, double* %22
%23 = load double, double* %5
%24 = load double*, double** %4
%25 = getelementptr inbounds double, double* %24, i64 1
store double %23, double* %25
br label %43
26: ; preds = %2
%27 = load double, double* %5
%28 = fneg double %27
%29 = load double*, double** %4
%30 = getelementptr inbounds double, double* %29, i64 0
store double %28, double* %30
%31 = load double, double* %6
%32 = fneg double %31
%33 = load double*, double** %4
%34 = getelementptr inbounds double, double* %33, i64 1
store double %32, double* %34
br label %43
35: ; preds = %2
%36 = load double, double* %6
%37 = load double*, double** %4
%38 = getelementptr inbounds double, double* %37, i64 0
store double %36, double* %38
%39 = load double, double* %5
%40 = fneg double %39
%41 = load double*, double** %4
%42 = getelementptr inbounds double, double* %41, i64 1
store double %40, double* %42
br label %43
43: ; preds = %2, %35, %26, %18, %17
ret void
}

LLVM IR (-O2):
define void @phase(i32 %0, double* nocapture %1) {
%3 = load double, double* %1
%4 = getelementptr inbounds double, double* %1, i64 1
%5 = load double, double* %4
%6 = and i32 %0, 3
switch i32 %6, label %16 [
i32 3, label %12
i32 1, label %7
i32 2, label %9
]
7: ; preds = %2
%8 = fneg double %5
store double %8, double* %1
br label %14
9: ; preds = %2
%10 = fneg double %3
store double %10, double* %1
%11 = fneg double %5
br label %14
12: ; preds = %2
store double %5, double* %1
%13 = fneg double %3
br label %14
14: ; preds = %7, %9, %12
%15 = phi double [ %13, %12 ], [ %11, %9 ], [ %3, %7 ]
store double %15, double* %4
br label %16
16: ; preds = %14, %2
ret void
}