; LLVM IR from aferikoglou/GenHLSOptimizer :: dataset/machsuite-backprop (backprop)

; Unoptimized IR (clang -disable-llvm-passes):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: nounwind uwtable
declare dso_local void @add_bias_to_activations(ptr noundef, ptr noundef, i32 noundef) #1

; Function Attrs: nounwind uwtable
define dso_local void @matrix_vector_product_with_bias_input_layer(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3) #1 {
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store ptr %2, ptr %7, align 8, !tbaa !5
  store ptr %3, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #3
  br label %11

11:                                               ; preds = %4
  store i32 0, ptr %10, align 4, !tbaa !9
  br label %12

12:                                               ; preds = %48, %11
  %13 = load i32, ptr %10, align 4, !tbaa !9
  %14 = icmp slt i32 %13, 64
  br i1 %14, label %15, label %51

15:                                               ; preds = %12
  %16 = load ptr, ptr %7, align 8, !tbaa !5
  %17 = load i32, ptr %10, align 4, !tbaa !9
  %18 = sext i32 %17 to i64
  %19 = getelementptr inbounds double, ptr %16, i64 %18
  store double 0.000000e+00, ptr %19, align 8, !tbaa !11
  br label %20

20:                                               ; preds = %15
  store i32 0, ptr %9, align 4, !tbaa !9
  br label %21

21:                                               ; preds = %44, %20
  %22 = load i32, ptr %9, align 4, !tbaa !9
  %23 = icmp slt i32 %22, 13
  br i1 %23, label %24, label %47

24:                                               ; preds = %21
  %25 = load ptr, ptr %6, align 8, !tbaa !5
  %26 = load i32, ptr %10, align 4, !tbaa !9
  %27 = mul nsw i32 %26, 13
  %28 = load i32, ptr %9, align 4, !tbaa !9
  %29 = add nsw i32 %27, %28
  %30 = sext i32 %29 to i64
  %31 = getelementptr inbounds double, ptr %25, i64 %30
  %32 = load double, ptr %31, align 8, !tbaa !11
  %33 = load ptr, ptr %8, align 8, !tbaa !5
  %34 = load i32, ptr %9, align 4, !tbaa !9
  %35 = sext i32 %34 to i64
  %36 = getelementptr inbounds double, ptr %33, i64 %35
  %37 = load double, ptr %36, align 8, !tbaa !11
  %38 = load ptr, ptr %7, align 8, !tbaa !5
  %39 = load i32, ptr %10, align 4, !tbaa !9
  %40 = sext i32 %39 to i64
  %41 = getelementptr inbounds double, ptr %38, i64 %40
  %42 = load double, ptr %41, align 8, !tbaa !11
  %43 = call double @llvm.fmuladd.f64(double %32, double %37, double %42)
  store double %43, ptr %41, align 8, !tbaa !11
  br label %44

44:                                               ; preds = %24
  %45 = load i32, ptr %9, align 4, !tbaa !9
  %46 = add nsw i32 %45, 1
  store i32 %46, ptr %9, align 4, !tbaa !9
  br label %21, !llvm.loop !13

47:                                               ; preds = %21
  br label %48

48:                                               ; preds = %47
  %49 = load i32, ptr %10, align 4, !tbaa !9
  %50 = add nsw i32 %49, 1
  store i32 %50, ptr %10, align 4, !tbaa !9
  br label %12, !llvm.loop !15

51:                                               ; preds = %12
  %52 = load ptr, ptr %5, align 8, !tbaa !5
  %53 = load ptr, ptr %7, align 8, !tbaa !5
  call void @add_bias_to_activations(ptr noundef %52, ptr noundef %53, i32 noundef 64)
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #3
  ret void
}

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #3 = { nounwind }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"double", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = distinct !{!15, !14}


; Optimized IR (opt -passes='default<O3>'):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

; Function Attrs: nounwind uwtable
declare dso_local void @add_bias_to_activations(ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local void @matrix_vector_product_with_bias_input_layer(ptr noundef %0, ptr nocapture noundef readonly %1, ptr noundef %2, ptr nocapture noundef readonly %3) local_unnamed_addr #0 {
  %invariant.gep = getelementptr inbounds i8, ptr %1, i64 8
  %5 = getelementptr inbounds i8, ptr %3, i64 8
  %invariant.gep19 = getelementptr inbounds i8, ptr %1, i64 16
  %6 = getelementptr inbounds i8, ptr %3, i64 16
  %invariant.gep21 = getelementptr inbounds i8, ptr %1, i64 24
  %7 = getelementptr inbounds i8, ptr %3, i64 24
  %invariant.gep23 = getelementptr inbounds i8, ptr %1, i64 32
  %8 = getelementptr inbounds i8, ptr %3, i64 32
  %invariant.gep25 = getelementptr inbounds i8, ptr %1, i64 40
  %9 = getelementptr inbounds i8, ptr %3, i64 40
  %invariant.gep27 = getelementptr inbounds i8, ptr %1, i64 48
  %10 = getelementptr inbounds i8, ptr %3, i64 48
  %invariant.gep29 = getelementptr inbounds i8, ptr %1, i64 56
  %11 = getelementptr inbounds i8, ptr %3, i64 56
  %invariant.gep31 = getelementptr inbounds i8, ptr %1, i64 64
  %12 = getelementptr inbounds i8, ptr %3, i64 64
  %invariant.gep33 = getelementptr inbounds i8, ptr %1, i64 72
  %13 = getelementptr inbounds i8, ptr %3, i64 72
  %invariant.gep35 = getelementptr inbounds i8, ptr %1, i64 80
  %14 = getelementptr inbounds i8, ptr %3, i64 80
  %invariant.gep37 = getelementptr inbounds i8, ptr %1, i64 88
  %15 = getelementptr inbounds i8, ptr %3, i64 88
  %invariant.gep39 = getelementptr inbounds i8, ptr %1, i64 96
  %16 = getelementptr inbounds i8, ptr %3, i64 96
  br label %17

17:                                               ; preds = %4, %17
  %indvars.iv = phi i64 [ 0, %4 ], [ %indvars.iv.next, %17 ]
  %18 = getelementptr inbounds double, ptr %2, i64 %indvars.iv
  store double 0.000000e+00, ptr %18, align 8, !tbaa !5
  %19 = mul nuw nsw i64 %indvars.iv, 13
  %20 = getelementptr inbounds double, ptr %1, i64 %19
  %21 = load double, ptr %20, align 8, !tbaa !5
  %22 = load double, ptr %3, align 8, !tbaa !5
  %23 = tail call double @llvm.fmuladd.f64(double %21, double %22, double 0.000000e+00)
  store double %23, ptr %18, align 8, !tbaa !5
  %gep = getelementptr inbounds double, ptr %invariant.gep, i64 %19
  %24 = load double, ptr %gep, align 8, !tbaa !5
  %25 = load double, ptr %5, align 8, !tbaa !5
  %26 = tail call double @llvm.fmuladd.f64(double %24, double %25, double %23)
  store double %26, ptr %18, align 8, !tbaa !5
  %gep20 = getelementptr inbounds double, ptr %invariant.gep19, i64 %19
  %27 = load double, ptr %gep20, align 8, !tbaa !5
  %28 = load double, ptr %6, align 8, !tbaa !5
  %29 = tail call double @llvm.fmuladd.f64(double %27, double %28, double %26)
  store double %29, ptr %18, align 8, !tbaa !5
  %gep22 = getelementptr inbounds double, ptr %invariant.gep21, i64 %19
  %30 = load double, ptr %gep22, align 8, !tbaa !5
  %31 = load double, ptr %7, align 8, !tbaa !5
  %32 = tail call double @llvm.fmuladd.f64(double %30, double %31, double %29)
  store double %32, ptr %18, align 8, !tbaa !5
  %gep24 = getelementptr inbounds double, ptr %invariant.gep23, i64 %19
  %33 = load double, ptr %gep24, align 8, !tbaa !5
  %34 = load double, ptr %8, align 8, !tbaa !5
  %35 = tail call double @llvm.fmuladd.f64(double %33, double %34, double %32)
  store double %35, ptr %18, align 8, !tbaa !5
  %gep26 = getelementptr inbounds double, ptr %invariant.gep25, i64 %19
  %36 = load double, ptr %gep26, align 8, !tbaa !5
  %37 = load double, ptr %9, align 8, !tbaa !5
  %38 = tail call double @llvm.fmuladd.f64(double %36, double %37, double %35)
  store double %38, ptr %18, align 8, !tbaa !5
  %gep28 = getelementptr inbounds double, ptr %invariant.gep27, i64 %19
  %39 = load double, ptr %gep28, align 8, !tbaa !5
  %40 = load double, ptr %10, align 8, !tbaa !5
  %41 = tail call double @llvm.fmuladd.f64(double %39, double %40, double %38)
  store double %41, ptr %18, align 8, !tbaa !5
  %gep30 = getelementptr inbounds double, ptr %invariant.gep29, i64 %19
  %42 = load double, ptr %gep30, align 8, !tbaa !5
  %43 = load double, ptr %11, align 8, !tbaa !5
  %44 = tail call double @llvm.fmuladd.f64(double %42, double %43, double %41)
  store double %44, ptr %18, align 8, !tbaa !5
  %gep32 = getelementptr inbounds double, ptr %invariant.gep31, i64 %19
  %45 = load double, ptr %gep32, align 8, !tbaa !5
  %46 = load double, ptr %12, align 8, !tbaa !5
  %47 = tail call double @llvm.fmuladd.f64(double %45, double %46, double %44)
  store double %47, ptr %18, align 8, !tbaa !5
  %gep34 = getelementptr inbounds double, ptr %invariant.gep33, i64 %19
  %48 = load double, ptr %gep34, align 8, !tbaa !5
  %49 = load double, ptr %13, align 8, !tbaa !5
  %50 = tail call double @llvm.fmuladd.f64(double %48, double %49, double %47)
  store double %50, ptr %18, align 8, !tbaa !5
  %gep36 = getelementptr inbounds double, ptr %invariant.gep35, i64 %19
  %51 = load double, ptr %gep36, align 8, !tbaa !5
  %52 = load double, ptr %14, align 8, !tbaa !5
  %53 = tail call double @llvm.fmuladd.f64(double %51, double %52, double %50)
  store double %53, ptr %18, align 8, !tbaa !5
  %gep38 = getelementptr inbounds double, ptr %invariant.gep37, i64 %19
  %54 = load double, ptr %gep38, align 8, !tbaa !5
  %55 = load double, ptr %15, align 8, !tbaa !5
  %56 = tail call double @llvm.fmuladd.f64(double %54, double %55, double %53)
  store double %56, ptr %18, align 8, !tbaa !5
  %gep40 = getelementptr inbounds double, ptr %invariant.gep39, i64 %19
  %57 = load double, ptr %gep40, align 8, !tbaa !5
  %58 = load double, ptr %16, align 8, !tbaa !5
  %59 = tail call double @llvm.fmuladd.f64(double %57, double %58, double %56)
  store double %59, ptr %18, align 8, !tbaa !5
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, 64
  br i1 %exitcond.not, label %60, label %17, !llvm.loop !9

60:                                               ; preds = %17
  tail call void @add_bias_to_activations(ptr noundef %0, ptr noundef nonnull %2, i32 noundef 64)
  ret void
}

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #1

attributes #0 = { nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"double", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LICMPass,LoopRotatePass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass