#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
double cos(double);
double sin(double);
void twiddles8(double a_x[8], double a_y[8], int i, int n) {
  int reversed8[8] = {0, 4, 2, 6, 1, 5, 3, 7};
  int j;
  double phi, tmp, phi_x, phi_y;
  for (j = 1; j < 8; j++) {
    phi = ((-2 * 3.1415926535 * reversed8[j] / n) * i);
    phi_x = cos(phi);
    phi_y = sin(phi);
    tmp = a_x[j];
    a_x[j] = (a_x[j] * phi_x - a_y[j] * phi_y);
    a_y[j] = (tmp * phi_y + a_y[j] * phi_x);
  }
}


x86 assembly (clang, -O0):
<twiddles8>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    0xed3(%rip),%rax
mov    %rax,-0x40(%rbp)
mov    0xed0(%rip),%rax
mov    %rax,-0x38(%rbp)
mov    0xecd(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0xeca(%rip),%rax
mov    %rax,-0x28(%rbp)
movl   $0x1,-0x44(%rbp)
cmpl   $0x8,-0x44(%rbp)
jge    125f <twiddles8+0x13f>
movslq -0x44(%rbp),%rax
cvtsi2sdl -0x40(%rbp,%rax,4),%xmm1
movsd  0xe7b(%rip),%xmm0
mulsd  %xmm1,%xmm0
cvtsi2sdl -0x18(%rbp),%xmm1
divsd  %xmm1,%xmm0
cvtsi2sdl -0x14(%rbp),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x50(%rbp),%xmm0
call   1040 <cos@plt>
movsd  %xmm0,-0x60(%rbp)
movsd  -0x50(%rbp),%xmm0
call   1030 <sin@plt>
movsd  %xmm0,-0x68(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x44(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x58(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x44(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  -0x60(%rbp),%xmm2
mov    -0x10(%rbp),%rax
movslq -0x44(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
mulsd  -0x68(%rbp),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movslq -0x44(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
movsd  -0x58(%rbp),%xmm0
movsd  -0x68(%rbp),%xmm2
mov    -0x10(%rbp),%rax
movslq -0x44(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
mulsd  -0x60(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x10(%rbp),%rax
movslq -0x44(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    1169 <twiddles8+0x49>
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<twiddles8>:
push   %r14
push   %rbx
sub    $0x28,%rsp
cvtsi2sd %ecx,%xmm1
movsd  %xmm1,0x18(%rsp)
cvtsi2sd %edx,%xmm2
movsd  %xmm2,0x20(%rsp)
mov    %rsi,%rbx
mov    %rdi,%r14
movsd  0xeb7(%rip),%xmm0
divsd  %xmm1,%xmm0
mulsd  %xmm2,%xmm0
movsd  %xmm0,0x8(%rsp)
call   1040 <cos@plt>
movsd  %xmm0,0x10(%rsp)
movsd  0x8(%rsp),%xmm0
call   1030 <sin@plt>
movsd  0x8(%r14),%xmm1
movsd  0x8(%rbx),%xmm2
mulsd  %xmm0,%xmm2
movapd %xmm1,%xmm3
movsd  0x10(%rsp),%xmm4
mulsd  %xmm4,%xmm3
subsd  %xmm2,%xmm3
movsd  %xmm3,0x8(%r14)
mulsd  0x8(%rbx),%xmm4
mulsd  %xmm0,%xmm1
addsd  %xmm4,%xmm1
movsd  %xmm1,0x8(%rbx)
movsd  0xe5a(%rip),%xmm0
divsd  0x18(%rsp),%xmm0
mulsd  0x20(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
call   1040 <cos@plt>
movsd  %xmm0,0x10(%rsp)
movsd  0x8(%rsp),%xmm0
call   1030 <sin@plt>
movsd  0x10(%r14),%xmm1
movsd  0x10(%rbx),%xmm2
mulsd  %xmm0,%xmm2
movapd %xmm1,%xmm3
movsd  0x10(%rsp),%xmm4
mulsd  %xmm4,%xmm3
subsd  %xmm2,%xmm3
movsd  %xmm3,0x10(%r14)
mulsd  0x10(%rbx),%xmm4
mulsd  %xmm0,%xmm1
addsd  %xmm4,%xmm1
movsd  %xmm1,0x10(%rbx)
movsd  0xdf9(%rip),%xmm0
divsd  0x18(%rsp),%xmm0
mulsd  0x20(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
call   1040 <cos@plt>
movsd  %xmm0,0x10(%rsp)
movsd  0x8(%rsp),%xmm0
call   1030 <sin@plt>
movsd  0x18(%r14),%xmm1
movsd  0x18(%rbx),%xmm2
mulsd  %xmm0,%xmm2
movapd %xmm1,%xmm3
movsd  0x10(%rsp),%xmm4
mulsd  %xmm4,%xmm3
subsd  %xmm2,%xmm3
movsd  %xmm3,0x18(%r14)
mulsd  0x18(%rbx),%xmm4
mulsd  %xmm0,%xmm1
addsd  %xmm4,%xmm1
movsd  %xmm1,0x18(%rbx)
movsd  0xd98(%rip),%xmm0
divsd  0x18(%rsp),%xmm0
mulsd  0x20(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
call   1040 <cos@plt>
movsd  %xmm0,0x10(%rsp)
movsd  0x8(%rsp),%xmm0
call   1030 <sin@plt>
movsd  0x20(%r14),%xmm1
movsd  0x20(%rbx),%xmm2
mulsd  %xmm0,%xmm2
movapd %xmm1,%xmm3
movsd  0x10(%rsp),%xmm4
mulsd  %xmm4,%xmm3
subsd  %xmm2,%xmm3
movsd  %xmm3,0x20(%r14)
mulsd  0x20(%rbx),%xmm4
mulsd  %xmm0,%xmm1
addsd  %xmm4,%xmm1
movsd  %xmm1,0x20(%rbx)
movsd  0xd37(%rip),%xmm0
divsd  0x18(%rsp),%xmm0
mulsd  0x20(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
call   1040 <cos@plt>
movsd  %xmm0,0x10(%rsp)
movsd  0x8(%rsp),%xmm0
call   1030 <sin@plt>
movsd  0x28(%r14),%xmm1
movsd  0x28(%rbx),%xmm2
mulsd  %xmm0,%xmm2
movapd %xmm1,%xmm3
movsd  0x10(%rsp),%xmm4
mulsd  %xmm4,%xmm3
subsd  %xmm2,%xmm3
movsd  %xmm3,0x28(%r14)
mulsd  0x28(%rbx),%xmm4
mulsd  %xmm0,%xmm1
addsd  %xmm4,%xmm1
movsd  %xmm1,0x28(%rbx)
movsd  0xcd6(%rip),%xmm0
divsd  0x18(%rsp),%xmm0
mulsd  0x20(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
call   1040 <cos@plt>
movsd  %xmm0,0x10(%rsp)
movsd  0x8(%rsp),%xmm0
call   1030 <sin@plt>
movsd  0x30(%r14),%xmm1
movsd  0x30(%rbx),%xmm2
mulsd  %xmm0,%xmm2
movapd %xmm1,%xmm3
movsd  0x10(%rsp),%xmm4
mulsd  %xmm4,%xmm3
subsd  %xmm2,%xmm3
movsd  %xmm3,0x30(%r14)
mulsd  0x30(%rbx),%xmm4
mulsd  %xmm0,%xmm1
addsd  %xmm4,%xmm1
movsd  %xmm1,0x30(%rbx)
movsd  0xc75(%rip),%xmm0
divsd  0x18(%rsp),%xmm0
mulsd  0x20(%rsp),%xmm0
movsd  %xmm0,0x18(%rsp)
call   1040 <cos@plt>
movsd  %xmm0,0x20(%rsp)
movsd  0x18(%rsp),%xmm0
call   1030 <sin@plt>
movsd  0x38(%r14),%xmm1
movsd  0x38(%rbx),%xmm2
mulsd  %xmm0,%xmm2
movapd %xmm1,%xmm3
movsd  0x20(%rsp),%xmm4
mulsd  %xmm4,%xmm3
subsd  %xmm2,%xmm3
movsd  %xmm3,0x38(%r14)
mulsd  0x38(%rbx),%xmm4
mulsd  %xmm0,%xmm1
addsd  %xmm4,%xmm1
movsd  %xmm1,0x38(%rbx)
add    $0x28,%rsp
pop    %rbx
pop    %r14
ret

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

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