#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 /*<<< orphan*/ fourier_coef(double, double, double, int, double *);
void fourier_coef_array(int n, double *ca, double *sa, double *vals, int m,
                        double *coefs) {
  for (int i = 0; i < m; i++) {
    coefs[i] = 0;
  }
  for (int i = 0; i < n; i++) {
    fourier_coef(ca[i], sa[i], vals[i], m, coefs);
  }
}


x86 assembly (clang, -O0):
<fourier_coef_array>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8d,-0x24(%rbp)
mov    %r9,-0x30(%rbp)
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x24(%rbp),%eax
jge    1160 <fourier_coef_array+0x50>
mov    -0x30(%rbp),%rax
movslq -0x34(%rbp),%rcx
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1136 <fourier_coef_array+0x26>
movl   $0x0,-0x38(%rbp)
mov    -0x38(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11b4 <fourier_coef_array+0xa4>
mov    -0x10(%rbp),%rax
movslq -0x38(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x18(%rbp),%rax
movslq -0x38(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
mov    -0x20(%rbp),%rax
movslq -0x38(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm2
mov    -0x24(%rbp),%edi
mov    -0x30(%rbp),%rsi
call   1030 <fourier_coef@plt>
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    1167 <fourier_coef_array+0x57>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fourier_coef_array>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r9,%rbp
mov    %r8d,%r12d
mov    %rdx,%rbx
mov    %edi,%r15d
test   %r8d,%r8d
jle    1159 <fourier_coef_array+0x39>
mov    %r12d,%edx
shl    $0x3,%rdx
mov    %rbp,%rdi
mov    %rsi,%r13
xor    %esi,%esi
mov    %rcx,%r14
call   1040 <memset@plt>
mov    %r13,%rsi
mov    %r14,%rcx
test   %r15d,%r15d
jle    11a9 <fourier_coef_array+0x89>
mov    %r15d,%eax
mov    %rax,(%rsp)
xor    %r14d,%r14d
nopl   0x0(%rax,%rax,1)
movsd  (%rsi,%r14,8),%xmm0
movsd  (%rbx,%r14,8),%xmm1
movsd  (%rcx,%r14,8),%xmm2
mov    %r12d,%edi
mov    %r12d,%r13d
mov    %rsi,%r12
mov    %rbp,%rsi
mov    %rcx,%r15
call   1030 <fourier_coef@plt>
mov    %r12,%rsi
mov    %r13d,%r12d
mov    %r15,%rcx
add    $0x1,%r14
cmp    %r14,(%rsp)
jne    1170 <fourier_coef_array+0x50>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define void @fourier_coef_array(i32 %0, double* nocapture %1, double* nocapture %2, double* nocapture %3, i32 %4, double* %5) {
%7 = icmp sgt i32 %4, 0
br i1 %7, label %8, label %12
8: ; preds = %6
%9 = bitcast double* %5 to i8*
%10 = zext i32 %4 to i64
%11 = shl nuw nsw i64 %10, 3
br label %12
12: ; preds = %8, %6
%13 = icmp sgt i32 %0, 0
br i1 %13, label %14, label %16
14: ; preds = %12
%15 = zext i32 %0 to i64
br label %17
16: ; preds = %17, %12
ret void
17: ; preds = %14, %17
%18 = phi i64 [ 0, %14 ], [ %26, %17 ]
%19 = getelementptr inbounds double, double* %1, i64 %18
%20 = load double, double* %19
%21 = getelementptr inbounds double, double* %2, i64 %18
%22 = load double, double* %21
%23 = getelementptr inbounds double, double* %3, i64 %18
%24 = load double, double* %23
%25 = tail call i32 @fourier_coef(double %20, double %22, double %24, i32 %4, double* %5)
%26 = add nuw nsw i64 %18, 1
%27 = icmp eq i64 %26, %15
br i1 %27, label %16, label %17
}