#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 cos(double);
double sin(double);
void dft_input_real_raw(int npoint, int interval, double din_re[],
                        double out_re[], double out_im[]) {
  int i;
  int fi, findex_max;
  double dth, th;
  double npoint_inv;
  double sum_c, sum_s;
  double x;
  if (npoint == 0)
    return;
  findex_max = npoint / 2;
  dth = 2.0 * 3.14159265358979323846 / (double)npoint;
  npoint_inv = 1.0 / (double)npoint;
  for (fi = 0; fi <= findex_max; fi++) {
    sum_c = 0.0;
    sum_s = 0.0;
    for (i = 0; i < npoint; i++) {
      x = din_re[interval * i];
      th = dth * (double)(fi * i);
      sum_c += x * cos(th);
      sum_s += x * (-sin(th));
    }
    out_re[fi] = npoint_inv * sum_c;
    out_im[fi] = npoint_inv * sum_s;
  }
}


x86 assembly (clang, -O0):
<dft_input_real_raw>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
mov    %r8,-0x20(%rbp)
cmpl   $0x0,-0x4(%rbp)
jne    1149 <dft_input_real_raw+0x29>
jmp    12a7 <dft_input_real_raw+0x187>
mov    -0x4(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x2c(%rbp)
cvtsi2sdl -0x4(%rbp),%xmm1
movsd  0xea4(%rip),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
cvtsi2sdl -0x4(%rbp),%xmm1
movsd  0xe86(%rip),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x2c(%rbp),%eax
jg     12a7 <dft_input_real_raw+0x187>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x50(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x58(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    126b <dft_input_real_raw+0x14b>
mov    -0x10(%rbp),%rax
mov    -0x8(%rbp),%ecx
imul   -0x24(%rbp),%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x38(%rbp),%xmm0
mov    -0x28(%rbp),%eax
imul   -0x24(%rbp),%eax
cvtsi2sd %eax,%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x60(%rbp),%xmm0
movsd  %xmm0,-0x70(%rbp)
movsd  -0x40(%rbp),%xmm0
call   1040 <cos@plt>
movaps %xmm0,%xmm2
movsd  -0x70(%rbp),%xmm0
movsd  -0x50(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x60(%rbp),%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x40(%rbp),%xmm0
call   1030 <sin@plt>
movaps %xmm0,%xmm1
movsd  -0x68(%rbp),%xmm0
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm2
movsd  -0x58(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x58(%rbp)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    11ad <dft_input_real_raw+0x8d>
movsd  -0x48(%rbp),%xmm0
mulsd  -0x50(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movslq -0x28(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
movsd  -0x48(%rbp),%xmm0
mulsd  -0x58(%rbp),%xmm0
mov    -0x20(%rbp),%rax
movslq -0x28(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    118a <dft_input_real_raw+0x6a>
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dft_input_real_raw>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x78,%rsp
mov    %r8,0x28(%rsp)
mov    %rcx,0x20(%rsp)
mov    %rdx,0x10(%rsp)
mov    %edi,0x4(%rsp)
test   %edi,%edi
je     114c <dft_input_real_raw+0x2c>
cmpl   $0xffffffff,0x4(%rsp)
jge    115b <dft_input_real_raw+0x3b>
add    $0x78,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x4(%rsp),%eax
cvtsi2sd %eax,%xmm0
movsd  0xe95(%rip),%xmm1
divsd  %xmm0,%xmm1
movsd  0xe91(%rip),%xmm2
divsd  %xmm0,%xmm2
movsd  %xmm2,0x18(%rsp)
mov    %eax,%ebx
shr    $0x1f,%ebx
add    %eax,%ebx
sar    %ebx
movslq %esi,%rbp
add    $0x1,%ebx
mov    %eax,%eax
mov    %rax,0x8(%rsp)
shl    $0x3,%rbp
xor    %r15d,%r15d
movsd  %xmm1,0x30(%rsp)
jmp    11ed <dft_input_real_raw+0xcd>
cs nopw 0x0(%rax,%rax,1)
xorpd  %xmm3,%xmm3
movsd  0x18(%rsp),%xmm2
movapd %xmm2,%xmm0
mulsd  %xmm3,%xmm0
mov    0x20(%rsp),%rax
movsd  %xmm0,(%rax,%r15,8)
unpckhpd %xmm3,%xmm3
mulsd  %xmm2,%xmm3
mov    0x28(%rsp),%rax
movsd  %xmm3,(%rax,%r15,8)
add    $0x1,%r15
cmp    %rbx,%r15
je     114c <dft_input_real_raw+0x2c>
cmpl   $0x0,0x4(%rsp)
jle    11b0 <dft_input_real_raw+0x90>
xorpd  %xmm0,%xmm0
xor    %r14d,%r14d
mov    0x8(%rsp),%r12
mov    0x10(%rsp),%r13
cs nopw 0x0(%rax,%rax,1)
nop
movapd %xmm0,0x60(%rsp)
xorps  %xmm2,%xmm2
cvtsi2sd %r14d,%xmm2
mulsd  %xmm1,%xmm2
movsd  %xmm2,0x38(%rsp)
movsd  0x0(%r13),%xmm0
movaps %xmm0,0x50(%rsp)
movapd %xmm2,%xmm0
call   1040 <cos@plt>
movapd %xmm0,0x40(%rsp)
movsd  0x38(%rsp),%xmm0
call   1030 <sin@plt>
movapd 0x40(%rsp),%xmm3
movapd 0xdb5(%rip),%xmm2
movsd  0x30(%rsp),%xmm1
xorpd  %xmm2,%xmm0
movapd 0x60(%rsp),%xmm2
movapd 0x50(%rsp),%xmm4
unpcklpd %xmm4,%xmm4
unpcklpd %xmm0,%xmm3
mulpd  %xmm4,%xmm3
movapd %xmm3,%xmm0
addpd  %xmm2,%xmm0
add    %r15d,%r14d
add    %rbp,%r13
add    $0xffffffffffffffff,%r12
jne    1210 <dft_input_real_raw+0xf0>
addpd  %xmm2,%xmm3
jmp    11b4 <dft_input_real_raw+0x94>

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

LLVM IR (-O2):
define void @dft_input_real_raw(i32 %0, i32 %1, double* nocapture %2, double* nocapture writeonly %3, double* nocapture writeonly %4) {
%6 = icmp eq i32 %0, 0
br i1 %6, label %53, label %7
7: ; preds = %5
%8 = sitofp i32 %0 to double
%9 = fdiv double 0x401921FB54442D18, %8
%10 = fdiv double 1.000000e+00, %8
%11 = icmp slt i32 %0, -1
br i1 %11, label %53, label %12
12: ; preds = %7
%13 = sdiv i32 %0, 2
%14 = icmp sgt i32 %0, 0
%15 = sext i32 %1 to i64
%16 = add nuw nsw i32 %13, 1
%17 = zext i32 %16 to i64
%18 = zext i32 %0 to i64
br label %19
19: ; preds = %12, %43
%20 = phi i64 [ 0, %12 ], [ %51, %43 ]
br i1 %14, label %21, label %43
21: ; preds = %19, %21
%22 = phi i64 [ %39, %21 ], [ 0, %19 ]
%23 = phi <2 x double> [ %38, %21 ], [ zeroinitializer, %19 ]
%24 = mul nsw i64 %22, %15
%25 = getelementptr inbounds double, double* %2, i64 %24
%26 = load double, double* %25
%27 = mul nuw nsw i64 %22, %20
%28 = trunc i64 %27 to i32
%29 = sitofp i32 %28 to double
%30 = fmul double %9, %29
%31 = tail call double @cos(double %30)
%32 = tail call double @sin(double %30)
%33 = fneg double %32
%34 = insertelement <2 x double> poison, double %26, i64 0
%35 = shufflevector <2 x double> %34, <2 x double> poison, <2 x i32> zeroinitializer
%36 = insertelement <2 x double> poison, double %31, i64 0
%37 = insertelement <2 x double> %36, double %33, i64 1
%38 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %35, <2 x double> %37, <2 x double> %23)
%39 = add nuw nsw i64 %22, 1
%40 = icmp eq i64 %39, %18
br i1 %40, label %41, label %21
41: ; preds = %21
%42 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %35, <2 x double> %37, <2 x double> %23)
br label %43
43: ; preds = %41, %19
%44 = phi <2 x double> [ zeroinitializer, %19 ], [ %42, %41 ]
%45 = extractelement <2 x double> %44, i64 0
%46 = fmul double %10, %45
%47 = getelementptr inbounds double, double* %3, i64 %20
store double %46, double* %47
%48 = extractelement <2 x double> %44, i64 1
%49 = fmul double %10, %48
%50 = getelementptr inbounds double, double* %4, i64 %20
store double %49, double* %50
%51 = add nuw nsw i64 %20, 1
%52 = icmp eq i64 %51, %17
br i1 %52, label %53, label %19
53: ; preds = %43, %7, %5
ret void
}