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


x86 assembly (clang, -O0):
<fourier_eval_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    -0x4(%rbp),%eax
jge    1183 <fourier_eval_array+0x73>
mov    -0x10(%rbp),%rax
movslq -0x34(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x18(%rbp),%rax
movslq -0x34(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
mov    -0x24(%rbp),%edi
mov    -0x30(%rbp),%rsi
call   1030 <fourier_eval@plt>
mov    -0x20(%rbp),%rax
movslq -0x34(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1136 <fourier_eval_array+0x26>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fourier_eval_array>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %edi,%edi
jle    1169 <fourier_eval_array+0x59>
mov    %r9,%r15
mov    %r8d,%r12d
mov    %rcx,%r13
mov    %rdx,%rbx
mov    %rsi,%rbp
mov    %edi,%eax
mov    %rax,(%rsp)
xor    %r14d,%r14d
nopw   0x0(%rax,%rax,1)
movsd  0x0(%rbp,%r14,8),%xmm0
movsd  (%rbx,%r14,8),%xmm1
mov    %r12d,%edi
mov    %r15,%rsi
call   1030 <fourier_eval@plt>
movsd  %xmm0,0x0(%r13,%r14,8)
add    $0x1,%r14
cmp    %r14,(%rsp)
jne    1140 <fourier_eval_array+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @fourier_eval_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
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 %14
14: ; preds = %36, %6
%15 = load i32, i32* %13
%16 = load i32, i32* %7
%17 = icmp slt i32 %15, %16
br i1 %17, label %18, label %39
18: ; preds = %14
%19 = load double*, double** %8
%20 = load i32, i32* %13
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds double, double* %19, i64 %21
%23 = load double, double* %22
%24 = load double*, double** %9
%25 = load i32, i32* %13
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds double, double* %24, i64 %26
%28 = load double, double* %27
%29 = load i32, i32* %11
%30 = load double*, double** %12
%31 = call double @fourier_eval(double %23, double %28, i32 %29, double* %30)
%32 = load double*, double** %10
%33 = load i32, i32* %13
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds double, double* %32, i64 %34
store double %31, double* %35
br label %36
36: ; preds = %18
%37 = load i32, i32* %13
%38 = add nsw i32 %37, 1
store i32 %38, i32* %13
br label %14
39: ; preds = %14
ret void
}

LLVM IR (-O2):
define void @fourier_eval_array(i32 %0, double* nocapture %1, double* nocapture %2, double* nocapture writeonly %3, i32 %4, double* %5) {
%7 = icmp sgt i32 %0, 0
br i1 %7, label %8, label %10
8: ; preds = %6
%9 = zext i32 %0 to i64
br label %11
10: ; preds = %11, %6
ret void
11: ; preds = %8, %11
%12 = phi i64 [ 0, %8 ], [ %19, %11 ]
%13 = getelementptr inbounds double, double* %1, i64 %12
%14 = load double, double* %13
%15 = getelementptr inbounds double, double* %2, i64 %12
%16 = load double, double* %15
%17 = tail call double @fourier_eval(double %14, double %16, i32 %4, double* %5)
%18 = getelementptr inbounds double, double* %3, i64 %12
store double %17, double* %18
%19 = add nuw nsw i64 %12, 1
%20 = icmp eq i64 %19, %9
br i1 %20, label %10, label %11
}