#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 atan(double);
int /*<<< orphan*/ bitrv2(int, int *, double *);
double cos(double);
double sin(double);
void makewt(int nw, int *ip, double *w) {
  int j, nwh;
  double delta, x, y;
  ip[0] = nw;
  ip[1] = 1;
  if (nw > 2) {
    nwh = nw >> 1;
    delta = atan(1.0) / (double)nwh;
    w[0] = 1;
    w[1] = 0;
    w[nwh] = cos(delta * (double)nwh);
    w[nwh + 1] = w[nwh];
    if (nwh > 2) {
      for (j = 2; j < nwh; j += 2) {
        x = cos(delta * (double)j);
        y = sin(delta * (double)j);
        w[j] = x;
        w[j + 1] = y;
        w[nw - j] = y;
        w[nw - j + 1] = x;
      }
      bitrv2(nw, ip + 2, w);
    }
  }
}


x86 assembly (clang, -O0):
<makewt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x4(%rbp),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x10(%rbp),%rax
movl   $0x1,0x4(%rax)
cmpl   $0x2,-0x4(%rbp)
jle    12be <makewt+0x17e>
mov    -0x4(%rbp),%eax
sar    $0x1,%eax
mov    %eax,-0x20(%rbp)
movsd  0xe7e(%rip),%xmm0
call   1040 <atan@plt>
cvtsi2sdl -0x20(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x18(%rbp),%rax
movsd  0xe5f(%rip),%xmm0
movsd  %xmm0,(%rax)
mov    -0x18(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,0x8(%rax)
movsd  -0x28(%rbp),%xmm0
cvtsi2sdl -0x20(%rbp),%xmm1
mulsd  %xmm1,%xmm0
call   1060 <cos@plt>
mov    -0x18(%rbp),%rax
movslq -0x20(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x18(%rbp),%rax
movslq -0x20(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x18(%rbp),%rax
mov    -0x20(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
cmpl   $0x2,-0x20(%rbp)
jle    12b9 <makewt+0x179>
movl   $0x2,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x20(%rbp),%eax
jge    12a5 <makewt+0x165>
movsd  -0x28(%rbp),%xmm0
cvtsi2sdl -0x1c(%rbp),%xmm1
mulsd  %xmm1,%xmm0
call   1060 <cos@plt>
movsd  %xmm0,-0x30(%rbp)
movsd  -0x28(%rbp),%xmm0
cvtsi2sdl -0x1c(%rbp),%xmm1
mulsd  %xmm1,%xmm0
call   1030 <sin@plt>
movsd  %xmm0,-0x38(%rbp)
movsd  -0x30(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
movsd  -0x38(%rbp),%xmm0
mov    -0x18(%rbp),%rax
mov    -0x1c(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
movsd  -0x38(%rbp),%xmm0
mov    -0x18(%rbp),%rax
mov    -0x4(%rbp),%ecx
sub    -0x1c(%rbp),%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
movsd  -0x30(%rbp),%xmm0
mov    -0x18(%rbp),%rax
mov    -0x4(%rbp),%ecx
sub    -0x1c(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x1c(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x1c(%rbp)
jmp    1201 <makewt+0xc1>
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
add    $0x8,%rsi
mov    -0x18(%rbp),%rdx
call   1050 <bitrv2@plt>
jmp    12be <makewt+0x17e>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<makewt>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %edi,(%rsi)
movl   $0x1,0x4(%rsi)
cmp    $0x3,%edi
jl     1253 <makewt+0x113>
mov    %rdx,%r13
mov    %rsi,%r14
mov    %edi,%r15d
mov    %edi,%r12d
shr    %r12d
movsd  0xe89(%rip),%xmm0
call   1040 <atan@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %r12d,%xmm0
movsd  0xe7c(%rip),%xmm2
divsd  %xmm0,%xmm2
movsd  0xe68(%rip),%xmm1
movups %xmm1,0x0(%r13)
movsd  %xmm2,(%rsp)
mulsd  %xmm2,%xmm0
call   1060 <cos@plt>
movsd  %xmm0,0x0(%r13,%r12,8)
movsd  %xmm0,0x8(%r13,%r12,8)
cmp    $0x6,%r15d
jb     1253 <makewt+0x113>
mov    %r15d,%eax
lea    -0x8(,%rax,8),%rbp
ff
add    %r13,%rbp
mov    $0x2,%ebx
cs nopw 0x0(%rax,%rax,1)
xorps  %xmm0,%xmm0
cvtsi2sd %ebx,%xmm0
mulsd  (%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
call   1060 <cos@plt>
movsd  %xmm0,0x10(%rsp)
movsd  0x8(%rsp),%xmm0
call   1030 <sin@plt>
movsd  0x10(%rsp),%xmm1
movsd  %xmm1,0x0(%r13,%rbx,8)
movsd  %xmm0,0x8(%r13,%rbx,8)
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,0x0(%rbp)
add    $0x2,%rbx
add    $0xfffffffffffffff0,%rbp
cmp    %r12,%rbx
jb     11e0 <makewt+0xa0>
add    $0x8,%r14
mov    %r15d,%edi
mov    %r14,%rsi
mov    %r13,%rdx
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1050 <bitrv2@plt>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define void @makewt(i32 %0, i32* %1, double* %2) {
store i32 %0, i32* %1
%4 = getelementptr inbounds i32, i32* %1, i64 1
store i32 1, i32* %4
%5 = icmp sgt i32 %0, 2
br i1 %5, label %6, label %41
6: ; preds = %3
%7 = lshr i32 %0, 1
%8 = tail call double @atan(double 1.000000e+00)
%9 = sitofp i32 %7 to double
%10 = fdiv double 0x3FE921FB54442D18, %9
%11 = bitcast double* %2 to <2 x double>*
store <2 x double> <double 1.000000e+00, double 0.000000e+00>, <2 x double>* %11
%12 = fmul double %10, %9
%13 = tail call double @cos(double %12)
%14 = zext i32 %7 to i64
%15 = getelementptr inbounds double, double* %2, i64 %14
store double %13, double* %15
%16 = add nuw nsw i32 %7, 1
%17 = zext i32 %16 to i64
%18 = getelementptr inbounds double, double* %2, i64 %17
store double %13, double* %18
%19 = icmp ugt i32 %0, 5
br i1 %19, label %20, label %41
20: ; preds = %6
%21 = zext i32 %0 to i64
br label %22
22: ; preds = %20, %22
%23 = phi i64 [ 2, %20 ], [ %36, %22 ]
%24 = trunc i64 %23 to i32
%25 = sitofp i32 %24 to double
%26 = fmul double %10, %25
%27 = tail call double @cos(double %26)
%28 = tail call double @sin(double %26)
%29 = getelementptr inbounds double, double* %2, i64 %23
store double %27, double* %29
%30 = or i64 %23, 1
%31 = getelementptr inbounds double, double* %2, i64 %30
store double %28, double* %31
%32 = sub nsw i64 %21, %23
%33 = getelementptr inbounds double, double* %2, i64 %32
store double %28, double* %33
%34 = add nsw i64 %32, 1
%35 = getelementptr inbounds double, double* %2, i64 %34
store double %27, double* %35
%36 = add nuw nsw i64 %23, 2
%37 = icmp ult i64 %36, %14
br i1 %37, label %22, label %38
38: ; preds = %22
%39 = getelementptr inbounds i32, i32* %1, i64 2
%40 = tail call i32 @bitrv2(i32 %0, i32* %39, double* %2)
br label %41
41: ; preds = %6, %38, %3
ret void
}