#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 */
typedef int uint32_t;

/* Variables and functions */
float cos(double);
void fftCosInit(int M, float *Utbl) {
  unsigned int fftN = ((uint32_t)1 << (M));
  unsigned int i1;
  Utbl[0] = 1.0;
  for (i1 = 1; i1 < fftN / 4; i1++)
    Utbl[i1] = cos((2.0 * 3.14159265358979323846 * (float)i1) / (float)fftN);
  Utbl[fftN / 4] = 0.0;
}


x86 assembly (clang, -O0):
<fftCosInit>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x4(%rbp),%ecx
mov    $0x1,%eax
shl    %cl,%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
movss  0xec8(%rip),%xmm0
movss  %xmm0,(%rax)
movl   $0x1,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    -0x14(%rbp),%ecx
shr    $0x2,%ecx
cmp    %ecx,%eax
jae    119b <fftCosInit+0x8b>
mov    -0x18(%rbp),%eax
cvtsi2ss %rax,%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xea0(%rip),%xmm1
mulsd  %xmm1,%xmm0
mov    -0x14(%rbp),%eax
cvtsi2ss %rax,%xmm1
cvtss2sd %xmm1,%xmm1
divsd  %xmm1,%xmm0
call   1030 <cos@plt>
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%ecx
movss  %xmm0,(%rax,%rcx,4)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1143 <fftCosInit+0x33>
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
shr    $0x2,%ecx
mov    %ecx,%ecx
xorps  %xmm0,%xmm0
movss  %xmm0,(%rax,%rcx,4)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fftCosInit>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edi,%ecx
mov    $0x1,%eax
shl    %cl,%eax
mov    %rsi,%r13
movl   $0x3f800000,(%rsi)
mov    %eax,%r14d
shr    $0x2,%r14d
cmp    $0x3,%edi
jb     1216 <fftCosInit+0x106>
mov    %eax,%eax
cvtsi2ss %rax,%xmm0
cmp    $0x3,%r14d
mov    $0x2,%r15d
cmovae %r14d,%r15d
cvtss2sd %xmm0,%xmm0
add    $0xffffffffffffffff,%r15
mov    $0x1,%ebp
cmp    $0x3,%ecx
je     11e7 <fftCosInit+0xd7>
mov    %r15,%r12
and    $0xfffffffffffffffe,%r12
mov    $0x1,%ebp
movsd  %xmm0,(%rsp)
nopl   0x0(%rax)
mov    %ebp,%eax
xorps  %xmm0,%xmm0
cvtsi2ss %rax,%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe6a(%rip),%xmm1
mulsd  %xmm1,%xmm0
divsd  (%rsp),%xmm0
call   1030 <cos@plt>
lea    0x1(%rbp),%rbx
mov    %ebx,%eax
xorps  %xmm1,%xmm1
cvtsi2ss %rax,%xmm1
movss  %xmm0,0x0(%r13,%rbp,4)
xorps  %xmm0,%xmm0
cvtss2sd %xmm1,%xmm0
mulsd  0xe38(%rip),%xmm0
divsd  (%rsp),%xmm0
call   1030 <cos@plt>
movss  %xmm0,0x4(%r13,%rbp,4)
add    $0x2,%rbp
cmp    %r12,%rbx
jne    1180 <fftCosInit+0x70>
movsd  (%rsp),%xmm0
test   $0x1,%r15b
je     1216 <fftCosInit+0x106>
mov    %ebp,%eax
movaps %xmm0,%xmm1
xorps  %xmm0,%xmm0
cvtsi2ss %rax,%xmm0
cvtss2sd %xmm0,%xmm0
mulsd  0xdfa(%rip),%xmm0
divsd  %xmm1,%xmm0
call   1030 <cos@plt>
movss  %xmm0,0x0(%r13,%rbp,4)
mov    %r14d,%eax
movl   $0x0,0x0(%r13,%rax,4)
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @fftCosInit(i32 %0, float* %1) {
%3 = alloca i32
%4 = alloca float*
%5 = alloca i32
%6 = alloca i32
store i32 %0, i32* %3
store float* %1, float** %4
%7 = load i32, i32* %3
%8 = shl i32 1, %7
store i32 %8, i32* %5
%9 = load float*, float** %4
%10 = getelementptr inbounds float, float* %9, i64 0
store float 1.000000e+00, float* %10
store i32 1, i32* %6
br label %11
11: ; preds = %30, %2
%12 = load i32, i32* %6
%13 = load i32, i32* %5
%14 = udiv i32 %13, 4
%15 = icmp ult i32 %12, %14
br i1 %15, label %16, label %33
16: ; preds = %11
%17 = load i32, i32* %6
%18 = uitofp i32 %17 to float
%19 = fpext float %18 to double
%20 = fmul double 0x401921FB54442D18, %19
%21 = load i32, i32* %5
%22 = uitofp i32 %21 to float
%23 = fpext float %22 to double
%24 = fdiv double %20, %23
%25 = call float @cos(double %24)
%26 = load float*, float** %4
%27 = load i32, i32* %6
%28 = zext i32 %27 to i64
%29 = getelementptr inbounds float, float* %26, i64 %28
store float %25, float* %29
br label %30
30: ; preds = %16
%31 = load i32, i32* %6
%32 = add i32 %31, 1
store i32 %32, i32* %6
br label %11
33: ; preds = %11
%34 = load float*, float** %4
%35 = load i32, i32* %5
%36 = udiv i32 %35, 4
%37 = zext i32 %36 to i64
%38 = getelementptr inbounds float, float* %34, i64 %37
store float 0.000000e+00, float* %38
ret void
}

LLVM IR (-O2):
define void @fftCosInit(i32 %0, float* nocapture writeonly %1) {
%3 = shl nuw i32 1, %0
store float 1.000000e+00, float* %1
%4 = lshr i32 %3, 2
%5 = icmp ugt i32 %0, 2
br i1 %5, label %6, label %48
6: ; preds = %2
%7 = uitofp i32 %3 to float
%8 = fpext float %7 to double
%9 = call i32 @llvm.umax.i32(i32 %4, i32 2)
%10 = zext i32 %9 to i64
%11 = add nsw i64 %10, -1
%12 = and i64 %11, 1
%13 = icmp eq i32 %0, 3
br i1 %13, label %37, label %14
14: ; preds = %6
%15 = and i64 %11, -2
br label %16
16: ; preds = %16, %14
%17 = phi i64 [ 1, %14 ], [ %34, %16 ]
%18 = phi i64 [ 0, %14 ], [ %35, %16 ]
%19 = trunc i64 %17 to i32
%20 = uitofp i32 %19 to float
%21 = fpext float %20 to double
%22 = fmul double %21, 0x401921FB54442D18
%23 = fdiv double %22, %8
%24 = tail call float @cos(double %23)
%25 = getelementptr inbounds float, float* %1, i64 %17
store float %24, float* %25
%26 = add nuw nsw i64 %17, 1
%27 = trunc i64 %26 to i32
%28 = uitofp i32 %27 to float
%29 = fpext float %28 to double
%30 = fmul double %29, 0x401921FB54442D18
%31 = fdiv double %30, %8
%32 = tail call float @cos(double %31)
%33 = getelementptr inbounds float, float* %1, i64 %26
store float %32, float* %33
%34 = add nuw nsw i64 %17, 2
%35 = add i64 %18, 2
%36 = icmp eq i64 %35, %15
br i1 %36, label %37, label %16
37: ; preds = %16, %6
%38 = phi i64 [ 1, %6 ], [ %34, %16 ]
%39 = icmp eq i64 %12, 0
br i1 %39, label %48, label %40
40: ; preds = %37
%41 = trunc i64 %38 to i32
%42 = uitofp i32 %41 to float
%43 = fpext float %42 to double
%44 = fmul double %43, 0x401921FB54442D18
%45 = fdiv double %44, %8
%46 = tail call float @cos(double %45)
%47 = getelementptr inbounds float, float* %1, i64 %38
store float %46, float* %47
br label %48
48: ; preds = %40, %37, %2
%49 = zext i32 %4 to i64
%50 = getelementptr inbounds float, float* %1, i64 %49
store float 0.000000e+00, float* %50
ret void
}