#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 */
int atan(double);
double cos(double);
int /*<<< orphan*/ printf(char *, ...);
double sin(double);
void twiddles(int n, double *w) {
  int i;
  double delta = atan(1.0) / n;
  w[0] = 1;
  w[1] = 0;
  w[n] = cos(delta * n);
  w[n + 1] = w[n];
  printf("delta is: %lg\n", delta);
#pragma mta assert no dependence
  for (i = 2; i < n; i += 2) {
    double x = cos(delta * i);
    double y = sin(delta * i);
    printf("i is: %d\n", i);
    printf("x is: %lg, y is: %lg\n", x, y);
    w[i] = x;
    w[i + 1] = y;
    w[2 * n - i] = y;
    w[2 * n - i + 1] = x;
  }
  printf("w is:");
  for (i = 0; i < n * 2; i++) {
    printf(" %lg", w[i]);
  }
  printf("\n");
}


x86 assembly (clang, -O0):
<twiddles>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
movsd  0xea9(%rip),%xmm0
call   1050 <atan@plt>
cltd
idivl  -0x4(%rbp)
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x10(%rbp),%rax
movsd  0xe8b(%rip),%xmm0
movsd  %xmm0,(%rax)
mov    -0x10(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,0x8(%rax)
movsd  -0x20(%rbp),%xmm0
cvtsi2sdl -0x4(%rbp),%xmm1
mulsd  %xmm1,%xmm0
call   1060 <cos@plt>
mov    -0x10(%rbp),%rax
movslq -0x4(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x10(%rbp),%rax
movslq -0x4(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x10(%rbp),%rax
mov    -0x4(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
movsd  -0x20(%rbp),%xmm0
lea    0xe38(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movl   $0x2,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    12b1 <twiddles+0x171>
movsd  -0x20(%rbp),%xmm0
cvtsi2sdl -0x14(%rbp),%xmm1
mulsd  %xmm1,%xmm0
call   1060 <cos@plt>
movsd  %xmm0,-0x28(%rbp)
movsd  -0x20(%rbp),%xmm0
cvtsi2sdl -0x14(%rbp),%xmm1
mulsd  %xmm1,%xmm0
call   1040 <sin@plt>
movsd  %xmm0,-0x30(%rbp)
mov    -0x14(%rbp),%esi
lea    0xdf3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movsd  -0x28(%rbp),%xmm0
movsd  -0x30(%rbp),%xmm1
lea    0xde5(%rip),%rdi
mov    $0x2,%al
call   1030 <printf@plt>
movsd  -0x28(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
movsd  -0x30(%rbp),%xmm0
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
movsd  -0x30(%rbp),%xmm0
mov    -0x10(%rbp),%rax
mov    -0x4(%rbp),%ecx
shl    $0x1,%ecx
sub    -0x14(%rbp),%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
movsd  -0x28(%rbp),%xmm0
mov    -0x10(%rbp),%rax
mov    -0x4(%rbp),%ecx
shl    $0x1,%ecx
sub    -0x14(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x14(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x14(%rbp)
jmp    11de <twiddles+0x9e>
lea    0xd7f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    -0x4(%rbp),%ecx
shl    $0x1,%ecx
cmp    %ecx,%eax
jge    1300 <twiddles+0x1c0>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
lea    0xd52(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    12c6 <twiddles+0x186>
lea    0xd18(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<twiddles>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rsi,%r12
mov    %edi,%ebx
movsd  0xe95(%rip),%xmm0
call   1060 <atan@plt>
cltd
idiv   %ebx
cvtsi2sd %eax,%xmm1
movsd  %xmm1,0x18(%rsp)
movsd  0xe7b(%rip),%xmm0
movups %xmm0,(%r12)
xorps  %xmm0,%xmm0
cvtsi2sd %ebx,%xmm0
mulsd  %xmm1,%xmm0
call   1070 <cos@plt>
mov    %ebx,0x14(%rsp)
movslq %ebx,%r13
movsd  %xmm0,(%r12,%r13,8)
movsd  %xmm0,0x8(%r12,%r13,8)
lea    0xe53(%rip),%rdi
movsd  0x18(%rsp),%xmm0
mov    $0x1,%al
call   1040 <printf@plt>
lea    0x0(%r13,%r13,1),%eax
mov    %eax,0x4(%rsp)
cmp    $0x3,%r13d
jl     12a2 <twiddles+0x152>
movabs $0xfffffffe00000000,%rax
ff ff ff
movslq 0x4(%rsp),%r14
lea    (%r12,%r14,8),%r15
add    $0xfffffffffffffff0,%r15
shl    $0x20,%r14
add    %rax,%r14
mov    $0x2,%ebp
lea    0xe22(%rip),%rbx
nop
xorps  %xmm0,%xmm0
cvtsi2sd %ebp,%xmm0
mulsd  0x18(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
call   1070 <cos@plt>
movsd  %xmm0,0x20(%rsp)
movsd  0x8(%rsp),%xmm0
call   1050 <sin@plt>
movsd  %xmm0,0x8(%rsp)
lea    0xde1(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
movsd  0x20(%rsp),%xmm0
movsd  0x8(%rsp),%xmm1
mov    $0x2,%al
call   1040 <printf@plt>
movsd  0x20(%rsp),%xmm0
movsd  %xmm0,(%r12,%rbp,8)
movsd  0x8(%rsp),%xmm1
movsd  %xmm1,0x8(%r12,%rbp,8)
movsd  %xmm1,(%r15)
mov    %r14,%rax
sar    $0x1d,%rax
or     $0x8,%rax
movsd  %xmm0,(%r12,%rax,1)
add    $0x2,%rbp
movabs $0xfffffffe00000000,%rax
ff ff ff
add    %rax,%r14
add    $0xfffffffffffffff0,%r15
cmp    %r13,%rbp
jl     1200 <twiddles+0xb0>
lea    0xd8e(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
cmpl   $0x0,0x14(%rsp)
jle    12e9 <twiddles+0x199>
mov    0x4(%rsp),%eax
cmp    $0x2,%eax
mov    $0x1,%ebp
cmovge %eax,%ebp
xor    %ebx,%ebx
lea    0xd6e(%rip),%r14
nop
movsd  (%r12,%rbx,8),%xmm0
mov    %r14,%rdi
mov    $0x1,%al
call   1040 <printf@plt>
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    12d0 <twiddles+0x180>
mov    $0xa,%edi
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <putchar@plt>

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

LLVM IR (-O2):
@.str = [15 x i8] c"delta is: %lg\0A\00"
@.str.1 = [10 x i8] c"i is: %d\0A\00"
@.str.2 = [22 x i8] c"x is: %lg, y is: %lg\0A\00"
@.str.3 = [6 x i8] c"w is:\00"
@.str.4 = [5 x i8] c" %lg\00"
define void @twiddles(i32 %0, double* nocapture %1) {
%3 = tail call i32 @atan(double 1.000000e+00)
%4 = sdiv i32 %3, %0
%5 = sitofp i32 %4 to double
%6 = bitcast double* %1 to <2 x double>*
store <2 x double> <double 1.000000e+00, double 0.000000e+00>, <2 x double>* %6
%7 = sitofp i32 %0 to double
%8 = fmul double %7, %5
%9 = tail call double @cos(double %8)
%10 = sext i32 %0 to i64
%11 = getelementptr inbounds double, double* %1, i64 %10
store double %9, double* %11
%12 = add nsw i32 %0, 1
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds double, double* %1, i64 %13
store double %9, double* %14
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), double %5)
%16 = icmp sgt i32 %0, 2
%17 = shl i32 %0, 1
br i1 %16, label %18, label %40
18: ; preds = %2
%19 = sext i32 %17 to i64
br label %20
20: ; preds = %18, %20
%21 = phi i64 [ 2, %18 ], [ %38, %20 ]
%22 = trunc i64 %21 to i32
%23 = sitofp i32 %22 to double
%24 = fmul double %5, %23
%25 = tail call double @cos(double %24)
%26 = tail call double @sin(double %24)
%27 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32 %22)
%28 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), double %25, double %26)
%29 = getelementptr inbounds double, double* %1, i64 %21
store double %25, double* %29
%30 = or i64 %21, 1
%31 = getelementptr inbounds double, double* %1, i64 %30
store double %26, double* %31
%32 = sub nsw i64 %19, %21
%33 = getelementptr inbounds double, double* %1, i64 %32
store double %26, double* %33
%34 = shl i64 %32, 32
%35 = ashr exact i64 %34, 32
%36 = or i64 %35, 1
%37 = getelementptr inbounds double, double* %1, i64 %36
store double %25, double* %37
%38 = add nuw i64 %21, 2
%39 = icmp slt i64 %38, %10
br i1 %39, label %20, label %40
40: ; preds = %20, %2
%41 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%42 = icmp sgt i32 %0, 0
br i1 %42, label %43, label %53
43: ; preds = %40
%44 = call i32 @llvm.smax.i32(i32 %17, i32 1)
%45 = zext i32 %44 to i64
br label %46
46: ; preds = %43, %46
%47 = phi i64 [ 0, %43 ], [ %51, %46 ]
%48 = getelementptr inbounds double, double* %1, i64 %47
%49 = load double, double* %48
%50 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), double %49)
%51 = add nuw nsw i64 %47, 1
%52 = icmp eq i64 %51, %45
br i1 %52, label %53, label %46
53: ; preds = %46, %40
%54 = tail call i32 @putchar(i32 10)
ret void
}