#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*/ add_bias_to_activations(double *, double *, int);
void matrix_vector_product_with_bias_output_layer(
    double biases[3], double weights[64 * 3], double activations[3],
    double input_activations[64]) {
  int i, j;
  for (j = 0; j < 3; j++) {
    activations[j] = (double)0.0;
    for (i = 0; i < 64; i++) {
      activations[j] += weights[j * 64 + i] * input_activations[i];
    }
  }
  add_bias_to_activations(biases, activations, 3);
}


x86 assembly (clang, -O0):
<matrix_vector_product_with_bias_output_layer>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
movl   $0x0,-0x28(%rbp)
cmpl   $0x3,-0x28(%rbp)
jge    11b7 <matrix_vector_product_with_bias_output_layer+0xa7>
mov    -0x18(%rbp),%rax
movslq -0x28(%rbp),%rcx
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
movl   $0x0,-0x24(%rbp)
cmpl   $0x40,-0x24(%rbp)
jge    11a4 <matrix_vector_product_with_bias_output_layer+0x94>
mov    -0x10(%rbp),%rax
mov    -0x28(%rbp),%ecx
shl    $0x6,%ecx
add    -0x24(%rbp),%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x20(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm2
mov    -0x18(%rbp),%rax
movslq -0x28(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1150 <matrix_vector_product_with_bias_output_layer+0x40>
jmp    11a9 <matrix_vector_product_with_bias_output_layer+0x99>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    112f <matrix_vector_product_with_bias_output_layer+0x1f>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    $0x3,%edx
call   1030 <add_bias_to_activations@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<matrix_vector_product_with_bias_output_layer>:
movq   $0x0,(%rdx)
xorpd  %xmm0,%xmm0
xor    %eax,%eax
nopl   (%rax)
movsd  (%rsi,%rax,8),%xmm1
mulsd  (%rcx,%rax,8),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,(%rdx)
movsd  0x8(%rsi,%rax,8),%xmm0
mulsd  0x8(%rcx,%rax,8),%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,(%rdx)
movsd  0x10(%rsi,%rax,8),%xmm1
mulsd  0x10(%rcx,%rax,8),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,(%rdx)
movsd  0x18(%rsi,%rax,8),%xmm0
mulsd  0x18(%rcx,%rax,8),%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,(%rdx)
add    $0x4,%rax
cmp    $0x40,%rax
jne    1120 <matrix_vector_product_with_bias_output_layer+0x10>
movq   $0x0,0x8(%rdx)
xorpd  %xmm0,%xmm0
xor    %eax,%eax
cs nopw 0x0(%rax,%rax,1)
movsd  0x200(%rsi,%rax,8),%xmm1
mulsd  (%rcx,%rax,8),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%rdx)
movsd  0x208(%rsi,%rax,8),%xmm0
mulsd  0x8(%rcx,%rax,8),%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,0x8(%rdx)
add    $0x2,%rax
cmp    $0x40,%rax
jne    1190 <matrix_vector_product_with_bias_output_layer+0x80>
movq   $0x0,0x10(%rdx)
xorpd  %xmm0,%xmm0
xor    %eax,%eax
nopw   0x0(%rax,%rax,1)
movsd  0x400(%rsi,%rax,8),%xmm1
mulsd  (%rcx,%rax,8),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,0x10(%rdx)
movsd  0x408(%rsi,%rax,8),%xmm0
mulsd  0x8(%rcx,%rax,8),%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,0x10(%rdx)
add    $0x2,%rax
cmp    $0x40,%rax
jne    11e0 <matrix_vector_product_with_bias_output_layer+0xd0>
mov    %rdx,%rsi
mov    $0x3,%edx
jmp    1030 <add_bias_to_activations@plt>

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

LLVM IR (-O2):
define void @matrix_vector_product_with_bias_output_layer(double* %0, double* nocapture %1, double* %2, double* nocapture %3) {
store double 0.000000e+00, double* %2
br label %5
5: ; preds = %5, %4
%6 = phi double [ 0.000000e+00, %4 ], [ %30, %5 ]
%7 = phi i64 [ 0, %4 ], [ %31, %5 ]
%8 = getelementptr inbounds double, double* %1, i64 %7
%9 = load double, double* %8
%10 = getelementptr inbounds double, double* %3, i64 %7
%11 = load double, double* %10
%12 = tail call double @llvm.fmuladd.f64(double %9, double %11, double %6)
store double %12, double* %2
%13 = or i64 %7, 1
%14 = getelementptr inbounds double, double* %1, i64 %13
%15 = load double, double* %14
%16 = getelementptr inbounds double, double* %3, i64 %13
%17 = load double, double* %16
%18 = tail call double @llvm.fmuladd.f64(double %15, double %17, double %12)
store double %18, double* %2
%19 = or i64 %7, 2
%20 = getelementptr inbounds double, double* %1, i64 %19
%21 = load double, double* %20
%22 = getelementptr inbounds double, double* %3, i64 %19
%23 = load double, double* %22
%24 = tail call double @llvm.fmuladd.f64(double %21, double %23, double %18)
store double %24, double* %2
%25 = or i64 %7, 3
%26 = getelementptr inbounds double, double* %1, i64 %25
%27 = load double, double* %26
%28 = getelementptr inbounds double, double* %3, i64 %25
%29 = load double, double* %28
%30 = tail call double @llvm.fmuladd.f64(double %27, double %29, double %24)
store double %30, double* %2
%31 = add nuw nsw i64 %7, 4
%32 = icmp eq i64 %31, 64
br i1 %32, label %33, label %5
33: ; preds = %5
%34 = getelementptr inbounds double, double* %2, i64 1
store double 0.000000e+00, double* %34
br label %35
35: ; preds = %35, %33
%36 = phi double [ 0.000000e+00, %33 ], [ %50, %35 ]
%37 = phi i64 [ 0, %33 ], [ %51, %35 ]
%38 = add nuw nsw i64 %37, 64
%39 = getelementptr inbounds double, double* %1, i64 %38
%40 = load double, double* %39
%41 = getelementptr inbounds double, double* %3, i64 %37
%42 = load double, double* %41
%43 = tail call double @llvm.fmuladd.f64(double %40, double %42, double %36)
store double %43, double* %34
%44 = or i64 %37, 1
%45 = add nuw nsw i64 %37, 65
%46 = getelementptr inbounds double, double* %1, i64 %45
%47 = load double, double* %46
%48 = getelementptr inbounds double, double* %3, i64 %44
%49 = load double, double* %48
%50 = tail call double @llvm.fmuladd.f64(double %47, double %49, double %43)
store double %50, double* %34
%51 = add nuw nsw i64 %37, 2
%52 = icmp eq i64 %51, 64
br i1 %52, label %53, label %35
53: ; preds = %35
%54 = getelementptr inbounds double, double* %2, i64 2
store double 0.000000e+00, double* %54
br label %55
55: ; preds = %55, %53
%56 = phi double [ 0.000000e+00, %53 ], [ %70, %55 ]
%57 = phi i64 [ 0, %53 ], [ %71, %55 ]
%58 = add nuw nsw i64 %57, 128
%59 = getelementptr inbounds double, double* %1, i64 %58
%60 = load double, double* %59
%61 = getelementptr inbounds double, double* %3, i64 %57
%62 = load double, double* %61
%63 = tail call double @llvm.fmuladd.f64(double %60, double %62, double %56)
store double %63, double* %54
%64 = or i64 %57, 1
%65 = add nuw nsw i64 %57, 129
%66 = getelementptr inbounds double, double* %1, i64 %65
%67 = load double, double* %66
%68 = getelementptr inbounds double, double* %3, i64 %64
%69 = load double, double* %68
%70 = tail call double @llvm.fmuladd.f64(double %67, double %69, double %63)
store double %70, double* %54
%71 = add nuw nsw i64 %57, 2
%72 = icmp eq i64 %71, 64
br i1 %72, label %73, label %55
73: ; preds = %55
%74 = tail call i32 @add_bias_to_activations(double* %0, double* %2, i32 3)
ret void
}