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