#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 cosf_fast(float);
float sinf_fast(float);
void ambe_idft_cf(float *out, float *in_i, float *in_q, int N, int M) {
  int fb, ts;
  for (ts = 0; ts < M; ts++) {
    float r = 0.0f;
    for (fb = 0; fb <= (N / 2); fb++) {
      float angle = (-2.0f * (3.141592653589793f) / N) * fb * ts;
      float m = (fb == 0 || fb == (N / 2)) ? 1.0f : 2.0f;
      r += m * (in_i[fb] * cosf_fast(angle) + in_q[fb] * sinf_fast(angle));
    }
    out[ts] = r / N;
  }
}


x86 assembly (clang, -O0):
<ambe_idft_cf>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8d,-0x20(%rbp)
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x20(%rbp),%eax
jge    12bc <ambe_idft_cf+0x19c>
xorps  %xmm0,%xmm0
movss  %xmm0,-0x2c(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    %eax,-0x38(%rbp)
mov    -0x1c(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x38(%rbp),%eax
cmp    %ecx,%eax
jg     1293 <ambe_idft_cf+0x173>
cvtsi2ssl -0x1c(%rbp),%xmm1
movss  0xe78(%rip),%xmm0
divss  %xmm1,%xmm0
cvtsi2ssl -0x24(%rbp),%xmm1
mulss  %xmm1,%xmm0
cvtsi2ssl -0x28(%rbp),%xmm1
mulss  %xmm1,%xmm0
movss  %xmm0,-0x30(%rbp)
mov    $0x1,%al
cmpl   $0x0,-0x24(%rbp)
mov    %al,-0x39(%rbp)
je     11d0 <ambe_idft_cf+0xb0>
mov    -0x24(%rbp),%eax
mov    %eax,-0x40(%rbp)
mov    -0x1c(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x40(%rbp),%eax
cmp    %ecx,%eax
sete   %al
mov    %al,-0x39(%rbp)
mov    -0x39(%rbp),%al
movss  0xe29(%rip),%xmm0
movss  0xe25(%rip),%xmm1
movss  %xmm1,-0x48(%rbp)
test   $0x1,%al
movss  %xmm0,-0x44(%rbp)
jne    11ff <ambe_idft_cf+0xdf>
movss  -0x48(%rbp),%xmm0
movss  %xmm0,-0x44(%rbp)
movss  -0x44(%rbp),%xmm0
movss  %xmm0,-0x34(%rbp)
movss  -0x34(%rbp),%xmm0
movss  %xmm0,-0x4c(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm0
movss  %xmm0,-0x54(%rbp)
movss  -0x30(%rbp),%xmm0
call   1030 <cosf_fast@plt>
movss  %xmm0,-0x50(%rbp)
mov    -0x18(%rbp),%rax
movslq -0x24(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm0
movss  %xmm0,-0x58(%rbp)
movss  -0x30(%rbp),%xmm0
call   1040 <sinf_fast@plt>
movss  -0x58(%rbp),%xmm1
movss  -0x54(%rbp),%xmm2
movss  -0x50(%rbp),%xmm3
movaps %xmm0,%xmm4
movss  -0x4c(%rbp),%xmm0
mulss  %xmm4,%xmm1
mulss  %xmm3,%xmm2
addss  %xmm1,%xmm2
movss  -0x2c(%rbp),%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x2c(%rbp)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    115d <ambe_idft_cf+0x3d>
movss  -0x2c(%rbp),%xmm0
cvtsi2ssl -0x1c(%rbp),%xmm1
divss  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movslq -0x28(%rbp),%rcx
movss  %xmm0,(%rax,%rcx,4)
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1142 <ambe_idft_cf+0x22>
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ambe_idft_cf>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %ecx,(%rsp)
mov    %rdi,0x30(%rsp)
test   %r8d,%r8d
jle    1287 <ambe_idft_cf+0x167>
mov    %rdx,%r12
mov    %rsi,%r13
mov    (%rsp),%eax
mov    %eax,%ebp
shr    $0x1f,%ebp
add    %eax,%ebp
cvtsi2ss %eax,%xmm0
sar    %ebp
movss  0xea3(%rip),%xmm1
movss  %xmm0,0x4(%rsp)
divss  %xmm0,%xmm1
movss  %xmm1,0x8(%rsp)
mov    %ebp,%ebx
add    $0x1,%ebx
mov    %r8d,%eax
mov    %rax,0x28(%rsp)
xor    %r14d,%r14d
jmp    11a0 <ambe_idft_cf+0x80>
nop
divss  0x4(%rsp),%xmm0
mov    0x30(%rsp),%rax
movss  %xmm0,(%rax,%r14,4)
add    $0x1,%r14
cmp    0x28(%rsp),%r14
je     1287 <ambe_idft_cf+0x167>
xorps  %xmm0,%xmm0
cmpl   $0xffffffff,(%rsp)
jl     1180 <ambe_idft_cf+0x60>
xorps  %xmm0,%xmm0
cvtsi2ss %r14d,%xmm0
movss  %xmm0,0xc(%rsp)
xorps  %xmm0,%xmm0
xor    %r15d,%r15d
jmp    1255 <ambe_idft_cf+0x135>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movss  %xmm0,0x20(%rsp)
xorps  %xmm1,%xmm1
cvtsi2ss %r15d,%xmm1
mulss  0x8(%rsp),%xmm1
mulss  0xc(%rsp),%xmm1
movss  %xmm1,0x10(%rsp)
movss  0x0(%r13,%r15,4),%xmm0
movss  %xmm0,0x1c(%rsp)
movaps %xmm1,%xmm0
call   1030 <cosf_fast@plt>
movss  %xmm0,0x18(%rsp)
movss  (%r12,%r15,4),%xmm0
movss  %xmm0,0x14(%rsp)
movss  0x10(%rsp),%xmm0
call   1040 <sinf_fast@plt>
mulss  0x14(%rsp),%xmm0
movss  0x18(%rsp),%xmm1
mulss  0x1c(%rsp),%xmm1
addss  %xmm0,%xmm1
mulss  0x20(%rsp),%xmm1
movss  0x24(%rsp),%xmm0
addss  %xmm1,%xmm0
add    $0x1,%r15
cmp    %r15,%rbx
je     1180 <ambe_idft_cf+0x60>
movss  %xmm0,0x24(%rsp)
xor    %eax,%eax
cmp    %r15,%rbp
sete   %cl
movss  0xd99(%rip),%xmm0
test   %r15,%r15
je     11d0 <ambe_idft_cf+0xb0>
mov    %cl,%al
lea    0xd8b(%rip),%rcx
movss  (%rcx,%rax,4),%xmm0
jmp    11d0 <ambe_idft_cf+0xb0>
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @ambe_idft_cf(float* %0, float* %1, float* %2, i32 %3, i32 %4) {
%6 = alloca float*
%7 = alloca float*
%8 = alloca float*
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca float
%14 = alloca float
%15 = alloca float
store float* %0, float** %6
store float* %1, float** %7
store float* %2, float** %8
store i32 %3, i32* %9
store i32 %4, i32* %10
store i32 0, i32* %12
br label %16
16: ; preds = %78, %5
%17 = load i32, i32* %12
%18 = load i32, i32* %10
%19 = icmp slt i32 %17, %18
br i1 %19, label %20, label %81
20: ; preds = %16
store float 0.000000e+00, float* %13
store i32 0, i32* %11
br label %21
21: ; preds = %66, %20
%22 = load i32, i32* %11
%23 = load i32, i32* %9
%24 = sdiv i32 %23, 2
%25 = icmp sle i32 %22, %24
br i1 %25, label %26, label %69
26: ; preds = %21
%27 = load i32, i32* %9
%28 = sitofp i32 %27 to float
%29 = fdiv float 0xC01921FB60000000, %28
%30 = load i32, i32* %11
%31 = sitofp i32 %30 to float
%32 = fmul float %29, %31
%33 = load i32, i32* %12
%34 = sitofp i32 %33 to float
%35 = fmul float %32, %34
store float %35, float* %14
%36 = load i32, i32* %11
%37 = icmp eq i32 %36, 0
br i1 %37, label %43, label %38
38: ; preds = %26
%39 = load i32, i32* %11
%40 = load i32, i32* %9
%41 = sdiv i32 %40, 2
%42 = icmp eq i32 %39, %41
br label %43
43: ; preds = %38, %26
%44 = phi i1 [ true, %26 ], [ %42, %38 ]
%45 = zext i1 %44 to i64
%46 = select i1 %44, float 1.000000e+00, float 2.000000e+00
store float %46, float* %15
%47 = load float, float* %15
%48 = load float*, float** %7
%49 = load i32, i32* %11
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds float, float* %48, i64 %50
%52 = load float, float* %51
%53 = load float, float* %14
%54 = call float @cosf_fast(float %53)
%55 = load float*, float** %8
%56 = load i32, i32* %11
%57 = sext i32 %56 to i64
%58 = getelementptr inbounds float, float* %55, i64 %57
%59 = load float, float* %58
%60 = load float, float* %14
%61 = call float @sinf_fast(float %60)
%62 = fmul float %59, %61
%63 = call float @llvm.fmuladd.f32(float %52, float %54, float %62)
%64 = load float, float* %13
%65 = call float @llvm.fmuladd.f32(float %47, float %63, float %64)
store float %65, float* %13
br label %66
66: ; preds = %43
%67 = load i32, i32* %11
%68 = add nsw i32 %67, 1
store i32 %68, i32* %11
br label %21
69: ; preds = %21
%70 = load float, float* %13
%71 = load i32, i32* %9
%72 = sitofp i32 %71 to float
%73 = fdiv float %70, %72
%74 = load float*, float** %6
%75 = load i32, i32* %12
%76 = sext i32 %75 to i64
%77 = getelementptr inbounds float, float* %74, i64 %76
store float %73, float* %77
br label %78
78: ; preds = %69
%79 = load i32, i32* %12
%80 = add nsw i32 %79, 1
store i32 %80, i32* %12
br label %16
81: ; preds = %16
ret void
}

LLVM IR (-O2):
define void @ambe_idft_cf(float* nocapture writeonly %0, float* nocapture %1, float* nocapture %2, i32 %3, i32 %4) {
%6 = icmp sgt i32 %4, 0
br i1 %6, label %7, label %49
7: ; preds = %5
%8 = sdiv i32 %3, 2
%9 = icmp slt i32 %3, -1
%10 = sitofp i32 %3 to float
%11 = fdiv float 0xC01921FB60000000, %10
%12 = zext i32 %8 to i64
%13 = add nsw i32 %8, 1
%14 = zext i32 %4 to i64
%15 = zext i32 %13 to i64
br label %16
16: ; preds = %7, %43
%17 = phi i64 [ 0, %7 ], [ %47, %43 ]
br i1 %9, label %43, label %18
18: ; preds = %16
%19 = trunc i64 %17 to i32
%20 = sitofp i32 %19 to float
br label %21
21: ; preds = %18, %21
%22 = phi i64 [ 0, %18 ], [ %41, %21 ]
%23 = phi float [ 0.000000e+00, %18 ], [ %40, %21 ]
%24 = trunc i64 %22 to i32
%25 = sitofp i32 %24 to float
%26 = fmul float %11, %25
%27 = fmul float %26, %20
%28 = icmp eq i64 %22, 0
%29 = icmp eq i64 %22, %12
%30 = or i1 %28, %29
%31 = select i1 %30, float 1.000000e+00, float 2.000000e+00
%32 = getelementptr inbounds float, float* %1, i64 %22
%33 = load float, float* %32
%34 = tail call float @cosf_fast(float %27)
%35 = getelementptr inbounds float, float* %2, i64 %22
%36 = load float, float* %35
%37 = tail call float @sinf_fast(float %27)
%38 = fmul float %36, %37
%39 = tail call float @llvm.fmuladd.f32(float %33, float %34, float %38)
%40 = tail call float @llvm.fmuladd.f32(float %31, float %39, float %23)
%41 = add nuw nsw i64 %22, 1
%42 = icmp eq i64 %41, %15
br i1 %42, label %43, label %21
43: ; preds = %21, %16
%44 = phi float [ 0.000000e+00, %16 ], [ %40, %21 ]
%45 = fdiv float %44, %10
%46 = getelementptr inbounds float, float* %0, i64 %17
store float %45, float* %46
%47 = add nuw nsw i64 %17, 1
%48 = icmp eq i64 %47, %14
br i1 %48, label %49, label %16
49: ; preds = %43, %5
ret void
}