#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 */
float cos(double);
void fftCosInit(int M, float *Utbl) {
  unsigned int fftN = ((unsigned long)1 << (M));
  unsigned int i1;
  Utbl[0] = 1.0;
  for (i1 = 1; i1 < fftN / 4; i1++)
    Utbl[i1] =
        cos((2.0 * 3.141592653589793238462643383279502884197 * i1) / 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),%eax
mov    %eax,%ecx
mov    $0x1,%eax
shl    %cl,%rax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
movss  0xec5(%rip),%xmm0
movss  %xmm0,(%rax)
movl   $0x1,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    -0x14(%rbp),%ecx
shr    $0x2,%ecx
cmp    %ecx,%eax
jae    1196 <fftCosInit+0x86>
mov    -0x18(%rbp),%eax
cvtsi2sd %rax,%xmm0
movsd  0xea1(%rip),%xmm1
mulsd  %xmm1,%xmm0
mov    -0x14(%rbp),%eax
cvtsi2sd %rax,%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    1146 <fftCosInit+0x36>
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    %rsi,%r13
mov    %edi,%ecx
mov    $0x1,%eax
shl    %cl,%rax
mov    $0x1,%ebp
movl   $0x3f800000,(%rsi)
mov    %eax,%r14d
shr    $0x2,%r14d
cmp    $0x8,%eax
jb     1208 <fftCosInit+0xf8>
mov    %eax,%ecx
cvtsi2sd %rcx,%xmm0
cmp    $0x3,%r14d
mov    $0x2,%r15d
cmovae %r14d,%r15d
add    $0xffffffffffffffff,%r15
cmp    $0xc,%eax
jb     11dc <fftCosInit+0xcc>
mov    %r15,%r12
and    $0xfffffffffffffffe,%r12
mov    $0x1,%ebp
movsd  %xmm0,(%rsp)
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %ebp,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
movsd  0xe6e(%rip),%xmm1
mulsd  %xmm1,%xmm0
divsd  (%rsp),%xmm0
call   1030 <cos@plt>
movss  %xmm0,0x0(%r13,%rbp,4)
lea    0x1(%rbp),%rbx
mov    %ebx,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
mulsd  0xe43(%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     1208 <fftCosInit+0xf8>
mov    %ebp,%eax
movapd %xmm0,%xmm1
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
mulsd  0xe08(%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 = zext i32 %7 to i64
%9 = shl i64 1, %8
%10 = trunc i64 %9 to i32
store i32 %10, i32* %5
%11 = load float*, float** %4
%12 = getelementptr inbounds float, float* %11, i64 0
store float 1.000000e+00, float* %12
store i32 1, i32* %6
br label %13
13: ; preds = %30, %2
%14 = load i32, i32* %6
%15 = load i32, i32* %5
%16 = udiv i32 %15, 4
%17 = icmp ult i32 %14, %16
br i1 %17, label %18, label %33
18: ; preds = %13
%19 = load i32, i32* %6
%20 = uitofp i32 %19 to double
%21 = fmul double 0x401921FB54442D18, %20
%22 = load i32, i32* %5
%23 = uitofp i32 %22 to double
%24 = fdiv double %21, %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 = %18
%31 = load i32, i32* %6
%32 = add i32 %31, 1
store i32 %32, i32* %6
br label %13
33: ; preds = %13
%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 = zext i32 %0 to i64
%4 = shl nuw i64 1, %3
%5 = trunc i64 %4 to i32
store float 1.000000e+00, float* %1
%6 = lshr i32 %5, 2
%7 = icmp ugt i32 %5, 7
br i1 %7, label %8, label %46
8: ; preds = %2
%9 = uitofp i32 %5 to double
%10 = call i32 @llvm.umax.i32(i32 %6, i32 2)
%11 = zext i32 %10 to i64
%12 = add nsw i64 %11, -1
%13 = and i64 %12, 1
%14 = icmp ult i32 %5, 12
br i1 %14, label %36, label %15
15: ; preds = %8
%16 = and i64 %12, -2
br label %17
17: ; preds = %17, %15
%18 = phi i64 [ 1, %15 ], [ %33, %17 ]
%19 = phi i64 [ 0, %15 ], [ %34, %17 ]
%20 = trunc i64 %18 to i32
%21 = uitofp i32 %20 to double
%22 = fmul double %21, 0x401921FB54442D18
%23 = fdiv double %22, %9
%24 = tail call float @cos(double %23)
%25 = getelementptr inbounds float, float* %1, i64 %18
store float %24, float* %25
%26 = add nuw nsw i64 %18, 1
%27 = trunc i64 %26 to i32
%28 = uitofp i32 %27 to double
%29 = fmul double %28, 0x401921FB54442D18
%30 = fdiv double %29, %9
%31 = tail call float @cos(double %30)
%32 = getelementptr inbounds float, float* %1, i64 %26
store float %31, float* %32
%33 = add nuw nsw i64 %18, 2
%34 = add i64 %19, 2
%35 = icmp eq i64 %34, %16
br i1 %35, label %36, label %17
36: ; preds = %17, %8
%37 = phi i64 [ 1, %8 ], [ %33, %17 ]
%38 = icmp eq i64 %13, 0
br i1 %38, label %46, label %39
39: ; preds = %36
%40 = trunc i64 %37 to i32
%41 = uitofp i32 %40 to double
%42 = fmul double %41, 0x401921FB54442D18
%43 = fdiv double %42, %9
%44 = tail call float @cos(double %43)
%45 = getelementptr inbounds float, float* %1, i64 %37
store float %44, float* %45
br label %46
46: ; preds = %39, %36, %2
%47 = zext i32 %6 to i64
%48 = getelementptr inbounds float, float* %1, i64 %47
store float 0.000000e+00, float* %48
ret void
}