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


x86 assembly (clang, -O0):
<normalizing_constant_Q_flat>:
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    118b <normalizing_constant_Q_flat+0x8b>
mov    -0x8(%rbp),%rax
mov    -0x28(%rbp),%rcx
imul   -0x18(%rbp),%rcx
add    -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_flat+0x20>
movsd  -0x20(%rbp),%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<normalizing_constant_Q_flat>:
test   %rdx,%rdx
je     1113 <normalizing_constant_Q_flat+0x13>
cmp    $0x1,%rdx
jne    1117 <normalizing_constant_Q_flat+0x17>
xorpd  %xmm0,%xmm0
xor    %eax,%eax
jmp    1169 <normalizing_constant_Q_flat+0x69>
xorps  %xmm0,%xmm0
ret
mov    %rdx,%r8
and    $0xfffffffffffffffe,%r8
mov    %rdx,%r9
shl    $0x4,%r9
add    $0x10,%r9
xorpd  %xmm0,%xmm0
xor    %eax,%eax
mov    %rdi,%rcx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movsd  (%rcx),%xmm1
mulsd  (%rsi,%rax,8),%xmm1
subsd  %xmm1,%xmm0
movsd  0x8(%rcx,%rdx,8),%xmm1
mulsd  0x8(%rsi,%rax,8),%xmm1
subsd  %xmm1,%xmm0
add    $0x2,%rax
add    %r9,%rcx
cmp    %rax,%r8
jne    1140 <normalizing_constant_Q_flat+0x40>
test   $0x1,%dl
je     1183 <normalizing_constant_Q_flat+0x83>
imul   %rax,%rdx
add    %rax,%rdx
movsd  (%rdi,%rdx,8),%xmm1
mulsd  (%rsi,%rax,8),%xmm1
subsd  %xmm1,%xmm0
ret

LLVM IR (-O0):
define double @normalizing_constant_Q_flat(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 = %29, %3
%10 = load i64, i64* %8
%11 = load i64, i64* %6
%12 = icmp ult i64 %10, %11
br i1 %12, label %13, label %32
13: ; preds = %9
%14 = load double*, double** %4
%15 = load i64, i64* %8
%16 = load i64, i64* %6
%17 = mul i64 %15, %16
%18 = load i64, i64* %8
%19 = add i64 %17, %18
%20 = getelementptr inbounds double, double* %14, i64 %19
%21 = load double, double* %20
%22 = fneg double %21
%23 = load double*, double** %5
%24 = load i64, i64* %8
%25 = getelementptr inbounds double, double* %23, i64 %24
%26 = load double, double* %25
%27 = load double, double* %7
%28 = call double @llvm.fmuladd.f64(double %22, double %26, double %27)
store double %28, double* %7
br label %29
29: ; preds = %13
%30 = load i64, i64* %8
%31 = add i64 %30, 1
store i64 %31, i64* %8
br label %9
32: ; preds = %9
%33 = load double, double* %7
ret double %33
}

LLVM IR (-O2):
define double @normalizing_constant_Q_flat(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 = mul i64 %12, %2
%17 = add i64 %16, %12
%18 = getelementptr inbounds double, double* %0, i64 %17
%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 = mul i64 %27, %2
%31 = add i64 %30, %27
%32 = getelementptr inbounds double, double* %0, i64 %31
%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 = mul i64 %38, %2
%40 = add i64 %39, %38
%41 = getelementptr inbounds double, double* %0, i64 %40
%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
}