#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 EXIT_SUCCESS;
float cos(int);
int RealDFT(float *realIn, float *realOut, int n) {
  int i, k;
  for (i = 0; i < n; i++) {
    realOut[i] = 0.0;
    for (k = 0; k < n; k++) {
      realOut[i] += realIn[k] * cos(2 * 3.1415926535897932 * k * i / n);
    }
  }
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<RealDFT>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11da <RealDFT+0xca>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
xorps  %xmm0,%xmm0
movss  %xmm0,(%rax,%rcx,4)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11c7 <RealDFT+0xb7>
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm0
movss  %xmm0,-0x20(%rbp)
cvtsi2sdl -0x1c(%rbp),%xmm1
movsd  0xe88(%rip),%xmm0
mulsd  %xmm1,%xmm0
cvtsi2sdl -0x18(%rbp),%xmm1
mulsd  %xmm1,%xmm0
cvtsi2sdl -0x14(%rbp),%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1030 <cos@plt>
movaps %xmm0,%xmm2
movss  -0x20(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,(%rax,%rcx,4)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    114d <RealDFT+0x3d>
jmp    11cc <RealDFT+0xbc>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    112a <RealDFT+0x1a>
mov    0x2dff(%rip),%rax
mov    (%rax),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<RealDFT>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x20,%rsp
test   %edx,%edx
jle    11cc <RealDFT+0xbc>
mov    %rsi,%r12
mov    %rdi,%r14
cvtsi2sd %edx,%xmm1
mov    %edx,%r15d
xor    %r13d,%r13d
movsd  0xec3(%rip),%xmm2
movsd  %xmm1,0x10(%rsp)
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movl   $0x0,(%r12,%r13,4)
xorps  %xmm0,%xmm0
cvtsi2sd %r13d,%xmm0
movsd  %xmm0,0x18(%rsp)
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
movss  (%r14,%rbx,4),%xmm0
movss  %xmm0,0xc(%rsp)
xorps  %xmm0,%xmm0
cvtsi2sd %ebx,%xmm0
mulsd  %xmm2,%xmm0
mulsd  0x18(%rsp),%xmm0
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1030 <cos@plt>
movsd  0xe5e(%rip),%xmm2
movsd  0x10(%rsp),%xmm1
mulss  0xc(%rsp),%xmm0
addss  (%r12,%r13,4),%xmm0
movss  %xmm0,(%r12,%r13,4)
add    $0x1,%rbx
cmp    %rbx,%r15
jne    1170 <RealDFT+0x60>
add    $0x1,%r13
cmp    %r15,%r13
jne    1150 <RealDFT+0x40>
mov    0x2e0d(%rip),%rax
mov    (%rax),%eax
add    $0x20,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@EXIT_SUCCESS = global i32 0
define i32 @RealDFT(float* %0, float* %1, i32 %2) {
%4 = alloca float*
%5 = alloca float*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store float* %0, float** %4
store float* %1, float** %5
store i32 %2, i32* %6
store i32 0, i32* %7
br label %9
9: ; preds = %49, %3
%10 = load i32, i32* %7
%11 = load i32, i32* %6
%12 = icmp slt i32 %10, %11
br i1 %12, label %13, label %52
13: ; preds = %9
%14 = load float*, float** %5
%15 = load i32, i32* %7
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds float, float* %14, i64 %16
store float 0.000000e+00, float* %17
store i32 0, i32* %8
br label %18
18: ; preds = %45, %13
%19 = load i32, i32* %8
%20 = load i32, i32* %6
%21 = icmp slt i32 %19, %20
br i1 %21, label %22, label %48
22: ; preds = %18
%23 = load float*, float** %4
%24 = load i32, i32* %8
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds float, float* %23, i64 %25
%27 = load float, float* %26
%28 = load i32, i32* %8
%29 = sitofp i32 %28 to double
%30 = fmul double 0x401921FB54442D18, %29
%31 = load i32, i32* %7
%32 = sitofp i32 %31 to double
%33 = fmul double %30, %32
%34 = load i32, i32* %6
%35 = sitofp i32 %34 to double
%36 = fdiv double %33, %35
%37 = fptosi double %36 to i32
%38 = call float @cos(i32 %37)
%39 = load float*, float** %5
%40 = load i32, i32* %7
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds float, float* %39, i64 %41
%43 = load float, float* %42
%44 = call float @llvm.fmuladd.f32(float %27, float %38, float %43)
store float %44, float* %42
br label %45
45: ; preds = %22
%46 = load i32, i32* %8
%47 = add nsw i32 %46, 1
store i32 %47, i32* %8
br label %18
48: ; preds = %18
br label %49
49: ; preds = %48
%50 = load i32, i32* %7
%51 = add nsw i32 %50, 1
store i32 %51, i32* %7
br label %9
52: ; preds = %9
%53 = load i32, i32* @EXIT_SUCCESS
ret i32 %53
}

LLVM IR (-O2):
@EXIT_SUCCESS = global i32 0
define i32 @RealDFT(float* nocapture %0, float* nocapture %1, i32 %2) {
%4 = icmp sgt i32 %2, 0
br i1 %4, label %5, label %31
5: ; preds = %3
%6 = sitofp i32 %2 to double
%7 = zext i32 %2 to i64
br label %8
8: ; preds = %28, %5
%9 = phi i64 [ 0, %5 ], [ %29, %28 ]
%10 = getelementptr inbounds float, float* %1, i64 %9
store float 0.000000e+00, float* %10
%11 = trunc i64 %9 to i32
%12 = sitofp i32 %11 to double
br label %13
13: ; preds = %8, %13
%14 = phi i64 [ 0, %8 ], [ %26, %13 ]
%15 = getelementptr inbounds float, float* %0, i64 %14
%16 = load float, float* %15
%17 = trunc i64 %14 to i32
%18 = sitofp i32 %17 to double
%19 = fmul double %18, 0x401921FB54442D18
%20 = fmul double %19, %12
%21 = fdiv double %20, %6
%22 = fptosi double %21 to i32
%23 = tail call float @cos(i32 %22)
%24 = load float, float* %10
%25 = tail call float @llvm.fmuladd.f32(float %16, float %23, float %24)
store float %25, float* %10
%26 = add nuw nsw i64 %14, 1
%27 = icmp eq i64 %26, %7
br i1 %27, label %28, label %13
28: ; preds = %13
%29 = add nuw nsw i64 %9, 1
%30 = icmp eq i64 %29, %7
br i1 %30, label %31, label %8
31: ; preds = %28, %3
%32 = load i32, i32* @EXIT_SUCCESS
ret i32 %32
}