#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);
int matrizdft(double *matrizr, double *matrizi, int n) {
  int i, j;
  double pi2divn = -3.1415926535897932384626433832795029L * 2 / n;
  for (i = 0; i < n; i++, matrizr += n, matrizi += n) {
    for (j = 0; j < n; j++) {
      *(matrizr + j) = cos(pi2divn * i * j);
      *(matrizi + j) = sin(pi2divn * i * j);
    }
  }
}


x86 assembly (clang, -O0):
<matrizdft>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x34(%rbp)
fildl  -0x34(%rbp)
fldt   0xebe(%rip)
fdivp  %st,%st(1)
fstpl  -0x40(%rbp)
movsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    1214 <matrizdft+0xf4>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    11d7 <matrizdft+0xb7>
movsd  -0x30(%rbp),%xmm0
cvtsi2sdl -0x20(%rbp),%xmm1
mulsd  %xmm1,%xmm0
cvtsi2sdl -0x24(%rbp),%xmm1
mulsd  %xmm1,%xmm0
call   1040 <cos@plt>
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
movsd  -0x30(%rbp),%xmm0
cvtsi2sdl -0x20(%rbp),%xmm1
mulsd  %xmm1,%xmm0
cvtsi2sdl -0x24(%rbp),%xmm1
mulsd  %xmm1,%xmm0
call   1030 <sin@plt>
mov    -0x18(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    116b <matrizdft+0x4b>
jmp    11dc <matrizdft+0xbc>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
mov    -0x1c(%rbp),%ecx
mov    -0x10(%rbp),%rax
movslq %ecx,%rcx
shl    $0x3,%rcx
add    %rcx,%rax
mov    %rax,-0x10(%rbp)
mov    -0x1c(%rbp),%ecx
mov    -0x18(%rbp),%rax
movslq %ecx,%rcx
shl    $0x3,%rcx
add    %rcx,%rax
mov    %rax,-0x18(%rbp)
jmp    1158 <matrizdft+0x38>
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<matrizdft>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
mov    %edx,0x24(%rsp)
fldt   0xec8(%rip)
fidivl 0x24(%rsp)
fstpl  0x40(%rsp)
test   %edx,%edx
jle    129a <matrizdft+0x17a>
mov    %rsi,%rbx
mov    %rdi,%rbp
movsd  0x40(%rsp),%xmm0
movsd  %xmm0,0x38(%rsp)
mov    %edx,%eax
mov    %eax,%r12d
and    $0xfffffffe,%r12d
mov    %rax,0x30(%rsp)
lea    0x0(,%rax,8),%r13
xor    %r15d,%r15d
xorpd  %xmm0,%xmm0
mov    %edx,0xc(%rsp)
jmp    119b <matrizdft+0x7b>
nopl   (%rax)
addsd  0xe88(%rip),%xmm0
add    $0x1,%r15d
add    %r13,%rbp
add    %r13,%rbx
cmp    %edx,%r15d
je     129a <matrizdft+0x17a>
movsd  0x38(%rsp),%xmm1
mulsd  %xmm0,%xmm1
cmp    $0x1,%edx
movsd  %xmm0,0x28(%rsp)
jne    11c0 <matrizdft+0xa0>
xor    %r14d,%r14d
testb  $0x1,0x30(%rsp)
je     1180 <matrizdft+0x60>
jmp    1258 <matrizdft+0x138>
nop
xor    %r14d,%r14d
movsd  %xmm1,0x10(%rsp)
nopl   0x0(%rax)
xorps  %xmm0,%xmm0
cvtsi2sd %r14d,%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,0x18(%rsp)
call   1040 <cos@plt>
movsd  %xmm0,0x0(%rbp,%r14,8)
movsd  0x18(%rsp),%xmm0
call   1030 <sin@plt>
movsd  %xmm0,(%rbx,%r14,8)
lea    0x1(%r14),%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mulsd  0x10(%rsp),%xmm0
movsd  %xmm0,0x18(%rsp)
call   1040 <cos@plt>
movsd  %xmm0,0x8(%rbp,%r14,8)
movsd  0x18(%rsp),%xmm0
call   1030 <sin@plt>
movsd  0x10(%rsp),%xmm1
movsd  %xmm0,0x8(%rbx,%r14,8)
add    $0x2,%r14
cmp    %r12,%r14
jne    11d0 <matrizdft+0xb0>
mov    0xc(%rsp),%edx
movsd  0x28(%rsp),%xmm0
testb  $0x1,0x30(%rsp)
je     1180 <matrizdft+0x60>
xorps  %xmm0,%xmm0
cvtsi2sd %r14d,%xmm0
mulsd  %xmm0,%xmm1
movsd  %xmm1,0x10(%rsp)
movapd %xmm1,%xmm0
call   1040 <cos@plt>
movsd  %xmm0,0x0(%rbp,%r14,8)
movsd  0x10(%rsp),%xmm0
call   1030 <sin@plt>
mov    0xc(%rsp),%edx
movsd  %xmm0,(%rbx,%r14,8)
movsd  0x28(%rsp),%xmm0
jmp    1180 <matrizdft+0x60>
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @matrizdft(double* %0, double* %1, i32 %2) {
%4 = alloca i32
%5 = alloca double*
%6 = alloca double*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca double
store double* %0, double** %5
store double* %1, double** %6
store i32 %2, i32* %7
%11 = load i32, i32* %7
%12 = sitofp i32 %11 to x86_fp80
%13 = fdiv x86_fp80 0xKC001C90FDAA22168C235, %12
%14 = fptrunc x86_fp80 %13 to double
store double %14, double* %10
store i32 0, i32* %8
br label %15
15: ; preds = %53, %3
%16 = load i32, i32* %8
%17 = load i32, i32* %7
%18 = icmp slt i32 %16, %17
br i1 %18, label %19, label %64
19: ; preds = %15
store i32 0, i32* %9
br label %20
20: ; preds = %49, %19
%21 = load i32, i32* %9
%22 = load i32, i32* %7
%23 = icmp slt i32 %21, %22
br i1 %23, label %24, label %52
24: ; preds = %20
%25 = load double, double* %10
%26 = load i32, i32* %8
%27 = sitofp i32 %26 to double
%28 = fmul double %25, %27
%29 = load i32, i32* %9
%30 = sitofp i32 %29 to double
%31 = fmul double %28, %30
%32 = call double @cos(double %31)
%33 = load double*, double** %5
%34 = load i32, i32* %9
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds double, double* %33, i64 %35
store double %32, double* %36
%37 = load double, double* %10
%38 = load i32, i32* %8
%39 = sitofp i32 %38 to double
%40 = fmul double %37, %39
%41 = load i32, i32* %9
%42 = sitofp i32 %41 to double
%43 = fmul double %40, %42
%44 = call double @sin(double %43)
%45 = load double*, double** %6
%46 = load i32, i32* %9
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds double, double* %45, i64 %47
store double %44, double* %48
br label %49
49: ; preds = %24
%50 = load i32, i32* %9
%51 = add nsw i32 %50, 1
store i32 %51, i32* %9
br label %20
52: ; preds = %20
br label %53
53: ; preds = %52
%54 = load i32, i32* %8
%55 = add nsw i32 %54, 1
store i32 %55, i32* %8
%56 = load i32, i32* %7
%57 = load double*, double** %5
%58 = sext i32 %56 to i64
%59 = getelementptr inbounds double, double* %57, i64 %58
store double* %59, double** %5
%60 = load i32, i32* %7
%61 = load double*, double** %6
%62 = sext i32 %60 to i64
%63 = getelementptr inbounds double, double* %61, i64 %62
store double* %63, double** %6
br label %15
64: ; preds = %15
%65 = load i32, i32* %4
ret i32 %65
}

LLVM IR (-O2):
define i32 @matrizdft(double* nocapture writeonly %0, double* nocapture writeonly %1, i32 %2) {
%4 = sitofp i32 %2 to x86_fp80
%5 = fdiv x86_fp80 0xKC001C90FDAA22168C235, %4
%6 = fptrunc x86_fp80 %5 to double
%7 = icmp sgt i32 %2, 0
br i1 %7, label %8, label %57
8: ; preds = %3
%9 = zext i32 %2 to i64
%10 = zext i32 %2 to i64
%11 = and i64 %10, 1
%12 = icmp eq i32 %2, 1
%13 = and i64 %10, 4294967294
%14 = icmp eq i64 %11, 0
br label %15
15: ; preds = %52, %8
%16 = phi double* [ %0, %8 ], [ %54, %52 ]
%17 = phi i32 [ 0, %8 ], [ %53, %52 ]
%18 = phi double* [ %1, %8 ], [ %55, %52 ]
%19 = sitofp i32 %17 to double
%20 = fmul double %6, %19
br i1 %12, label %42, label %21
21: ; preds = %15, %21
%22 = phi i64 [ %39, %21 ], [ 0, %15 ]
%23 = phi i64 [ %40, %21 ], [ 0, %15 ]
%24 = trunc i64 %22 to i32
%25 = sitofp i32 %24 to double
%26 = fmul double %20, %25
%27 = tail call double @cos(double %26)
%28 = getelementptr inbounds double, double* %16, i64 %22
store double %27, double* %28
%29 = tail call double @sin(double %26)
%30 = getelementptr inbounds double, double* %18, i64 %22
store double %29, double* %30
%31 = or i64 %22, 1
%32 = trunc i64 %31 to i32
%33 = sitofp i32 %32 to double
%34 = fmul double %20, %33
%35 = tail call double @cos(double %34)
%36 = getelementptr inbounds double, double* %16, i64 %31
store double %35, double* %36
%37 = tail call double @sin(double %34)
%38 = getelementptr inbounds double, double* %18, i64 %31
store double %37, double* %38
%39 = add nuw nsw i64 %22, 2
%40 = add i64 %23, 2
%41 = icmp eq i64 %40, %13
br i1 %41, label %42, label %21
42: ; preds = %21, %15
%43 = phi i64 [ 0, %15 ], [ %39, %21 ]
br i1 %14, label %52, label %44
44: ; preds = %42
%45 = trunc i64 %43 to i32
%46 = sitofp i32 %45 to double
%47 = fmul double %20, %46
%48 = tail call double @cos(double %47)
%49 = getelementptr inbounds double, double* %16, i64 %43
store double %48, double* %49
%50 = tail call double @sin(double %47)
%51 = getelementptr inbounds double, double* %18, i64 %43
store double %50, double* %51
br label %52
52: ; preds = %42, %44
%53 = add nuw nsw i32 %17, 1
%54 = getelementptr inbounds double, double* %16, i64 %9
%55 = getelementptr inbounds double, double* %18, i64 %9
%56 = icmp eq i32 %53, %2
br i1 %56, label %57, label %15
57: ; preds = %52, %3
ret i32 undef
}