#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 const cos(double);
double gee(const double *FreqGrille, const double *ad, const double *x,
           const double *y, const double *des, const double *wt, double comp,
           int nut, int l, int nz, double *E) {
  double sum = 0;
  double dot = 0;
  for (int i = 0; i < nz; i++) {
    double v = ad[i] / (cos(6.2831853071795865 * FreqGrille[l]) - x[i]);
    sum += v;
    dot += v * y[i];
  }
  dot /= sum;
  *E = (dot - des[l]) * wt[l];
  return nut * (*E) - comp;
}


x86 assembly (clang, -O0):
<gee>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    0x28(%rbp),%rax
mov    0x20(%rbp),%eax
mov    0x18(%rbp),%eax
mov    0x10(%rbp),%eax
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
movsd  %xmm0,-0x38(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x40(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x48(%rbp)
movl   $0x0,-0x4c(%rbp)
mov    -0x4c(%rbp),%eax
cmp    0x20(%rbp),%eax
jge    11f0 <gee+0xe0>
mov    -0x10(%rbp),%rax
movslq -0x4c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x60(%rbp)
mov    -0x8(%rbp),%rax
movslq 0x18(%rbp),%rcx
movsd  0xe79(%rip),%xmm0
mulsd  (%rax,%rcx,8),%xmm0
call   1030 <cos@plt>
movaps %xmm0,%xmm1
movsd  -0x60(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movslq -0x4c(%rbp),%rcx
subsd  (%rax,%rcx,8),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x58(%rbp),%xmm0
addsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x58(%rbp),%xmm0
mov    -0x20(%rbp),%rax
movslq -0x4c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm2
movsd  -0x48(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
mov    -0x4c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4c(%rbp)
jmp    1159 <gee+0x49>
movsd  -0x40(%rbp),%xmm1
movsd  -0x48(%rbp),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x48(%rbp),%xmm0
mov    -0x28(%rbp),%rax
movslq 0x18(%rbp),%rcx
subsd  (%rax,%rcx,8),%xmm0
mov    -0x30(%rbp),%rax
movslq 0x18(%rbp),%rcx
mulsd  (%rax,%rcx,8),%xmm0
mov    0x28(%rbp),%rax
movsd  %xmm0,(%rax)
cvtsi2sdl 0x10(%rbp),%xmm0
mov    0x28(%rbp),%rax
movsd  (%rax),%xmm2
movsd  -0x38(%rbp),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gee>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
movapd %xmm0,%xmm1
mov    0x88(%rsp),%rbx
mov    0x80(%rsp),%r10d
mov    0x70(%rsp),%eax
movslq 0x78(%rsp),%r13
test   %r10d,%r10d
jle    11f8 <gee+0xe8>
mov    %rcx,%r14
mov    %rsi,%rbp
mov    %rdi,%r15
mov    %r8,(%rsp)
mov    %r9,0x8(%rsp)
movsd  %xmm1,0x10(%rsp)
mov    %r10d,%eax
mov    %rax,0x18(%rsp)
xorpd  %xmm0,%xmm0
xor    %r12d,%r12d
xorpd  %xmm2,%xmm2
nop
movsd  %xmm0,0x28(%rsp)
movsd  %xmm2,0x30(%rsp)
movsd  0x0(%rbp,%r12,8),%xmm0
movsd  %xmm0,0x20(%rsp)
movsd  (%r15,%r13,8),%xmm0
mulsd  0xe71(%rip),%xmm0
mov    %rdx,%rbx
call   1030 <cos@plt>
movsd  0x30(%rsp),%xmm2
mov    %rbx,%rdx
subsd  (%rbx,%r12,8),%xmm0
movsd  0x20(%rsp),%xmm1
divsd  %xmm0,%xmm1
movsd  0x28(%rsp),%xmm0
addsd  %xmm1,%xmm0
mulsd  (%r14,%r12,8),%xmm1
addsd  %xmm1,%xmm2
add    $0x1,%r12
cmp    %r12,0x18(%rsp)
jne    1170 <gee+0x60>
divsd  %xmm0,%xmm2
movsd  0x10(%rsp),%xmm1
mov    0x8(%rsp),%r9
mov    (%rsp),%r8
mov    0x88(%rsp),%rbx
mov    0x70(%rsp),%eax
jmp    1200 <gee+0xf0>
movsd  0xe00(%rip),%xmm2
subsd  (%r8,%r13,8),%xmm2
mulsd  (%r9,%r13,8),%xmm2
movsd  %xmm2,(%rbx)
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mulsd  %xmm2,%xmm0
subsd  %xmm1,%xmm0
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define double @gee(double* nocapture %0, double* nocapture %1, double* nocapture %2, double* nocapture %3, double* nocapture %4, double* nocapture %5, double %6, i32 %7, i32 %8, i32 %9, double* nocapture writeonly %10) {
%12 = icmp sgt i32 %9, 0
%13 = sext i32 %8 to i64
br i1 %12, label %14, label %19
14: ; preds = %11
%15 = getelementptr inbounds double, double* %0, i64 %13
%16 = zext i32 %9 to i64
br label %30
17: ; preds = %30
%18 = fdiv double %46, %43
br label %19
19: ; preds = %11, %17
%20 = phi double [ %18, %17 ], [ 0x7FF8000000000000, %11 ]
%21 = getelementptr inbounds double, double* %4, i64 %13
%22 = load double, double* %21
%23 = fsub double %20, %22
%24 = getelementptr inbounds double, double* %5, i64 %13
%25 = load double, double* %24
%26 = fmul double %23, %25
store double %26, double* %10
%27 = sitofp i32 %7 to double
%28 = fneg double %6
%29 = tail call double @llvm.fmuladd.f64(double %27, double %26, double %28)
ret double %29
30: ; preds = %14, %30
%31 = phi i64 [ 0, %14 ], [ %47, %30 ]
%32 = phi double [ 0.000000e+00, %14 ], [ %43, %30 ]
%33 = phi double [ 0.000000e+00, %14 ], [ %46, %30 ]
%34 = getelementptr inbounds double, double* %1, i64 %31
%35 = load double, double* %34
%36 = load double, double* %15
%37 = fmul double %36, 0x401921FB54442D18
%38 = tail call double @cos(double %37)
%39 = getelementptr inbounds double, double* %2, i64 %31
%40 = load double, double* %39
%41 = fsub double %38, %40
%42 = fdiv double %35, %41
%43 = fadd double %32, %42
%44 = getelementptr inbounds double, double* %3, i64 %31
%45 = load double, double* %44
%46 = tail call double @llvm.fmuladd.f64(double %42, double %45, double %33)
%47 = add nuw nsw i64 %31, 1
%48 = icmp eq i64 %47, %16
br i1 %48, label %17, label %30
}