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


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

x86 assembly (clang, -O2):
<matrix_vector_product_with_bias_second_layer>:
add    $0x8,%rsi
xor    %r8d,%r8d
nopw   0x0(%rax,%rax,1)
movq   $0x0,(%rdx,%r8,8)
xorpd  %xmm0,%xmm0
xor    %eax,%eax
xchg   %ax,%ax
movsd  -0x8(%rsi,%rax,8),%xmm1
mulsd  (%rcx,%rax,8),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,(%rdx,%r8,8)
movsd  (%rsi,%rax,8),%xmm0
mulsd  0x8(%rcx,%rax,8),%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,(%rdx,%r8,8)
add    $0x2,%rax
cmp    $0x40,%rax
jne    1130 <matrix_vector_product_with_bias_second_layer+0x20>
add    $0x1,%r8
add    $0x200,%rsi
cmp    $0x40,%r8
jne    1120 <matrix_vector_product_with_bias_second_layer+0x10>
mov    %rdx,%rsi
mov    $0x40,%edx
jmp    1030 <add_bias_to_activations@plt>

LLVM IR (-O0):
define void @matrix_vector_product_with_bias_second_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* %9
br label %11
11: ; preds = %46, %4
%12 = load i32, i32* %9
%13 = icmp slt i32 %12, 64
br i1 %13, label %14, label %49
14: ; preds = %11
%15 = load double*, double** %7
%16 = load i32, i32* %9
%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* %10
br label %19
19: ; preds = %42, %14
%20 = load i32, i32* %10
%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* %9
%25 = mul nsw i32 %24, 64
%26 = load i32, i32* %10
%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* %10
%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* %9
%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* %10
%44 = add nsw i32 %43, 1
store i32 %44, i32* %10
br label %19
45: ; preds = %19
br label %46
46: ; preds = %45
%47 = load i32, i32* %9
%48 = add nsw i32 %47, 1
store i32 %48, i32* %9
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 64)
ret void
}

LLVM IR (-O2):
define void @matrix_vector_product_with_bias_second_layer(double* %0, double* nocapture %1, double* %2, double* nocapture %3) {
br label %5
5: ; preds = %4, %27
%6 = phi i64 [ 0, %4 ], [ %28, %27 ]
%7 = getelementptr inbounds double, double* %2, i64 %6
store double 0.000000e+00, double* %7
%8 = shl nsw i64 %6, 6
br label %9
9: ; preds = %9, %5
%10 = phi double [ 0.000000e+00, %5 ], [ %24, %9 ]
%11 = phi i64 [ 0, %5 ], [ %25, %9 ]
%12 = add nuw nsw i64 %11, %8
%13 = getelementptr inbounds double, double* %1, i64 %12
%14 = load double, double* %13
%15 = getelementptr inbounds double, double* %3, i64 %11
%16 = load double, double* %15
%17 = tail call double @llvm.fmuladd.f64(double %14, double %16, double %10)
store double %17, double* %7
%18 = or i64 %11, 1
%19 = add nuw nsw i64 %18, %8
%20 = getelementptr inbounds double, double* %1, i64 %19
%21 = load double, double* %20
%22 = getelementptr inbounds double, double* %3, i64 %18
%23 = load double, double* %22
%24 = tail call double @llvm.fmuladd.f64(double %21, double %23, double %17)
store double %24, double* %7
%25 = add nuw nsw i64 %11, 2
%26 = icmp eq i64 %25, 64
br i1 %26, label %27, label %9
27: ; preds = %9
%28 = add nuw nsw i64 %6, 1
%29 = icmp eq i64 %28, 64
br i1 %29, label %30, label %5
30: ; preds = %27
%31 = tail call i32 @add_bias_to_activations(double* %0, double* %2, i32 64)
ret void
}