#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 normalizing_constant_Q(double **q, const double *freqs, size_t dim) {
  double subst = 0.0;
  for (size_t i = 0; i < dim; i++) {
    subst += -q[i][i] * freqs[i];
  }
  return subst;
}


x86 assembly (clang, -O0):
<normalizing_constant_Q>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%rax
cmp    -0x18(%rbp),%rax
jae    118a <normalizing_constant_Q+0x8a>
mov    -0x8(%rbp),%rax
mov    -0x28(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    -0x28(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mov    -0x10(%rbp),%rax
mov    -0x28(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm2
movsd  -0x20(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    1120 <normalizing_constant_Q+0x20>
movsd  -0x20(%rbp),%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<normalizing_constant_Q>:
test   %rdx,%rdx
je     1113 <normalizing_constant_Q+0x13>
cmp    $0x1,%rdx
jne    1117 <normalizing_constant_Q+0x17>
xorpd  %xmm0,%xmm0
xor    %eax,%eax
jmp    1160 <normalizing_constant_Q+0x60>
xorps  %xmm0,%xmm0
ret
mov    %rdx,%r8
and    $0xfffffffffffffffe,%r8
xorpd  %xmm0,%xmm0
xor    %eax,%eax
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    (%rdi,%rax,8),%rcx
movsd  (%rcx,%rax,8),%xmm1
mulsd  (%rsi,%rax,8),%xmm1
mov    0x8(%rdi,%rax,8),%rcx
movsd  0x8(%rcx,%rax,8),%xmm2
mulsd  0x8(%rsi,%rax,8),%xmm2
subsd  %xmm1,%xmm0
subsd  %xmm2,%xmm0
add    $0x2,%rax
cmp    %rax,%r8
jne    1130 <normalizing_constant_Q+0x30>
test   $0x1,%dl
je     1177 <normalizing_constant_Q+0x77>
mov    (%rdi,%rax,8),%rcx
movsd  (%rcx,%rax,8),%xmm1
mulsd  (%rsi,%rax,8),%xmm1
subsd  %xmm1,%xmm0
ret

LLVM IR (-O0):
define double @normalizing_constant_Q(double** %0, double* %1, i64 %2) {
%4 = alloca double**
%5 = alloca double*
%6 = alloca i64
%7 = alloca double
%8 = alloca i64
store double** %0, double*** %4
store double* %1, double** %5
store i64 %2, i64* %6
store double 0.000000e+00, double* %7
store i64 0, i64* %8
br label %9
9: ; preds = %28, %3
%10 = load i64, i64* %8
%11 = load i64, i64* %6
%12 = icmp ult i64 %10, %11
br i1 %12, label %13, label %31
13: ; preds = %9
%14 = load double**, double*** %4
%15 = load i64, i64* %8
%16 = getelementptr inbounds double*, double** %14, i64 %15
%17 = load double*, double** %16
%18 = load i64, i64* %8
%19 = getelementptr inbounds double, double* %17, i64 %18
%20 = load double, double* %19
%21 = fneg double %20
%22 = load double*, double** %5
%23 = load i64, i64* %8
%24 = getelementptr inbounds double, double* %22, i64 %23
%25 = load double, double* %24
%26 = load double, double* %7
%27 = call double @llvm.fmuladd.f64(double %21, double %25, double %26)
store double %27, double* %7
br label %28
28: ; preds = %13
%29 = load i64, i64* %8
%30 = add i64 %29, 1
store i64 %30, i64* %8
br label %9
31: ; preds = %9
%32 = load double, double* %7
ret double %32
}

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