; LLVM IR from moarseniy/CudaFEMproject :: FEMproject/matrix_pack/src/cpu_matrix.ll (ZNK10CPU_Matrix13multiplyByVecERK6MatrixRS0_)

; 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"

%class.Matrix = type <{ ptr, i32, [4 x i8], i64, i64, i64, ptr, i8, [7 x i8] }>

@.str = external hidden unnamed_addr constant [100 x i8], align 1
@__FUNCTION__._ZNK10CPU_Matrix13multiplyByVecERK6MatrixRS0_ = external hidden unnamed_addr constant [14 x i8], align 1

declare void @_Z10_my_assertbPKciS0_(i1 noundef zeroext, ptr noundef, i32 noundef, ptr noundef) #0

declare noundef i64 @_ZNK6Matrix15get_numElementsEv(ptr noundef nonnull align 8 dereferenceable(49)) #0

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

declare noundef ptr @_ZNK6Matrix8get_dataEv(ptr noundef nonnull align 8 dereferenceable(49)) #0

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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZNK10CPU_Matrix13multiplyByVecERK6MatrixRS0_(ptr noundef nonnull align 8 dereferenceable(49) %0, ptr noundef nonnull align 8 dereferenceable(49) %1, ptr noundef nonnull align 8 dereferenceable(49) %2) unnamed_addr #3 align 2 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i64, align 8
  %8 = alloca i64, align 8
  %9 = alloca i64, align 8
  %10 = alloca i32, align 4
  %11 = alloca i64, align 8
  %12 = alloca i64, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store ptr %2, ptr %6, align 8, !tbaa !5
  %13 = load ptr, ptr %4, align 8
  %14 = getelementptr inbounds %class.Matrix, ptr %13, i32 0, i32 5
  %15 = load i64, ptr %14, align 8, !tbaa !9
  %16 = icmp ugt i64 %15, 0
  call void @_Z10_my_assertbPKciS0_(i1 noundef zeroext %16, ptr noundef @.str, i32 noundef 328, ptr noundef @__FUNCTION__._ZNK10CPU_Matrix13multiplyByVecERK6MatrixRS0_)
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #4
  %17 = getelementptr inbounds %class.Matrix, ptr %13, i32 0, i32 5
  %18 = load i64, ptr %17, align 8, !tbaa !9
  %19 = getelementptr inbounds %class.Matrix, ptr %13, i32 0, i32 4
  %20 = load i64, ptr %19, align 8, !tbaa !14
  %21 = udiv i64 %18, %20
  store i64 %21, ptr %7, align 8, !tbaa !15
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #4
  %22 = load ptr, ptr %5, align 8, !tbaa !5
  %23 = call noundef i64 @_ZNK6Matrix15get_numElementsEv(ptr noundef nonnull align 8 dereferenceable(49) %22)
  %24 = load i64, ptr %7, align 8, !tbaa !15
  %25 = udiv i64 %23, %24
  store i64 %25, ptr %8, align 8, !tbaa !15
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #4
  store i64 0, ptr %9, align 8, !tbaa !15
  br label %26

26:                                               ; preds = %94, %3
  %27 = load i64, ptr %9, align 8, !tbaa !15
  %28 = load i64, ptr %7, align 8, !tbaa !15
  %29 = icmp ult i64 %27, %28
  br i1 %29, label %31, label %30

30:                                               ; preds = %26
  store i32 2, ptr %10, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #4
  br label %97

31:                                               ; preds = %26
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #4
  store i64 0, ptr %11, align 8, !tbaa !15
  br label %32

32:                                               ; preds = %90, %31
  %33 = load i64, ptr %11, align 8, !tbaa !15
  %34 = load i64, ptr %8, align 8, !tbaa !15
  %35 = icmp ult i64 %33, %34
  br i1 %35, label %37, label %36

36:                                               ; preds = %32
  store i32 5, ptr %10, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #4
  br label %93

37:                                               ; preds = %32
  %38 = load ptr, ptr %6, align 8, !tbaa !5
  %39 = call noundef ptr @_ZNK6Matrix8get_dataEv(ptr noundef nonnull align 8 dereferenceable(49) %38)
  %40 = load i64, ptr %11, align 8, !tbaa !15
  %41 = load i64, ptr %9, align 8, !tbaa !15
  %42 = load i64, ptr %8, align 8, !tbaa !15
  %43 = mul i64 %41, %42
  %44 = add i64 %40, %43
  %45 = getelementptr inbounds float, ptr %39, i64 %44
  store float 0.000000e+00, ptr %45, align 4, !tbaa !16
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #4
  store i64 0, ptr %12, align 8, !tbaa !15
  br label %46

46:                                               ; preds = %86, %37
  %47 = load i64, ptr %12, align 8, !tbaa !15
  %48 = load i64, ptr %8, align 8, !tbaa !15
  %49 = icmp ult i64 %47, %48
  br i1 %49, label %51, label %50

50:                                               ; preds = %46
  store i32 8, ptr %10, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #4
  br label %89

51:                                               ; preds = %46
  %52 = getelementptr inbounds %class.Matrix, ptr %13, i32 0, i32 6
  %53 = load ptr, ptr %52, align 8, !tbaa !18
  %54 = load i64, ptr %12, align 8, !tbaa !15
  %55 = load i64, ptr %11, align 8, !tbaa !15
  %56 = load i64, ptr %8, align 8, !tbaa !15
  %57 = mul i64 %55, %56
  %58 = add i64 %54, %57
  %59 = load i64, ptr %9, align 8, !tbaa !15
  %60 = load i64, ptr %8, align 8, !tbaa !15
  %61 = mul i64 %59, %60
  %62 = load i64, ptr %8, align 8, !tbaa !15
  %63 = mul i64 %61, %62
  %64 = add i64 %58, %63
  %65 = getelementptr inbounds float, ptr %53, i64 %64
  %66 = load float, ptr %65, align 4, !tbaa !16
  %67 = load ptr, ptr %5, align 8, !tbaa !5
  %68 = call noundef ptr @_ZNK6Matrix8get_dataEv(ptr noundef nonnull align 8 dereferenceable(49) %67)
  %69 = load i64, ptr %12, align 8, !tbaa !15
  %70 = load i64, ptr %9, align 8, !tbaa !15
  %71 = load i64, ptr %8, align 8, !tbaa !15
  %72 = mul i64 %70, %71
  %73 = add i64 %69, %72
  %74 = getelementptr inbounds float, ptr %68, i64 %73
  %75 = load float, ptr %74, align 4, !tbaa !16
  %76 = load ptr, ptr %6, align 8, !tbaa !5
  %77 = call noundef ptr @_ZNK6Matrix8get_dataEv(ptr noundef nonnull align 8 dereferenceable(49) %76)
  %78 = load i64, ptr %11, align 8, !tbaa !15
  %79 = load i64, ptr %9, align 8, !tbaa !15
  %80 = load i64, ptr %8, align 8, !tbaa !15
  %81 = mul i64 %79, %80
  %82 = add i64 %78, %81
  %83 = getelementptr inbounds float, ptr %77, i64 %82
  %84 = load float, ptr %83, align 4, !tbaa !16
  %85 = call float @llvm.fmuladd.f32(float %66, float %75, float %84)
  store float %85, ptr %83, align 4, !tbaa !16
  br label %86

86:                                               ; preds = %51
  %87 = load i64, ptr %12, align 8, !tbaa !15
  %88 = add i64 %87, 1
  store i64 %88, ptr %12, align 8, !tbaa !15
  br label %46, !llvm.loop !19

89:                                               ; preds = %50
  br label %90

90:                                               ; preds = %89
  %91 = load i64, ptr %11, align 8, !tbaa !15
  %92 = add i64 %91, 1
  store i64 %92, ptr %11, align 8, !tbaa !15
  br label %32, !llvm.loop !21

93:                                               ; preds = %36
  br label %94

94:                                               ; preds = %93
  %95 = load i64, ptr %9, align 8, !tbaa !15
  %96 = add i64 %95, 1
  store i64 %96, ptr %9, align 8, !tbaa !15
  br label %26, !llvm.loop !22

97:                                               ; preds = %30
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #4
  ret void
}

attributes #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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #3 = { mustprogress 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 #4 = { 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++ TBAA"}
!9 = !{!10, !12, i64 32}
!10 = !{!"_ZTS6Matrix", !11, i64 8, !12, i64 16, !12, i64 24, !12, i64 32, !6, i64 40, !13, i64 48}
!11 = !{!"_ZTS11DEVICE_NAME", !7, i64 0}
!12 = !{!"long", !7, i64 0}
!13 = !{!"bool", !7, i64 0}
!14 = !{!10, !12, i64 24}
!15 = !{!12, !12, i64 0}
!16 = !{!17, !17, i64 0}
!17 = !{!"float", !7, i64 0}
!18 = !{!10, !6, i64 40}
!19 = distinct !{!19, !20}
!20 = !{!"llvm.loop.mustprogress"}
!21 = distinct !{!21, !20}
!22 = distinct !{!22, !20}


; 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"

@.str = external hidden unnamed_addr constant [100 x i8], align 1
@__FUNCTION__._ZNK10CPU_Matrix13multiplyByVecERK6MatrixRS0_ = external hidden unnamed_addr constant [14 x i8], align 1

declare void @_Z10_my_assertbPKciS0_(i1 noundef zeroext, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #0

declare noundef i64 @_ZNK6Matrix15get_numElementsEv(ptr noundef nonnull align 8 dereferenceable(49)) local_unnamed_addr #0

declare noundef ptr @_ZNK6Matrix8get_dataEv(ptr noundef nonnull align 8 dereferenceable(49)) local_unnamed_addr #0

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZNK10CPU_Matrix13multiplyByVecERK6MatrixRS0_(ptr nocapture noundef nonnull readonly align 8 dereferenceable(49) %0, ptr noundef nonnull align 8 dereferenceable(49) %1, ptr noundef nonnull align 8 dereferenceable(49) %2) unnamed_addr #2 align 2 {
  %4 = getelementptr inbounds i8, ptr %0, i64 32
  %5 = load i64, ptr %4, align 8, !tbaa !5
  %6 = icmp ne i64 %5, 0
  tail call void @_Z10_my_assertbPKciS0_(i1 noundef zeroext %6, ptr noundef nonnull @.str, i32 noundef 328, ptr noundef nonnull @__FUNCTION__._ZNK10CPU_Matrix13multiplyByVecERK6MatrixRS0_)
  %7 = load i64, ptr %4, align 8, !tbaa !5
  %8 = getelementptr inbounds i8, ptr %0, i64 24
  %9 = load i64, ptr %8, align 8, !tbaa !13
  %10 = udiv i64 %7, %9
  %11 = tail call noundef i64 @_ZNK6Matrix15get_numElementsEv(ptr noundef nonnull align 8 dereferenceable(49) %1)
  %12 = udiv i64 %11, %10
  %.not = icmp ugt i64 %10, %11
  %13 = getelementptr inbounds i8, ptr %0, i64 40
  br i1 %.not, label %.split36.us, label %.preheader.us

.preheader.us:                                    ; preds = %3, %._crit_edge.us
  %.03034.us = phi i64 [ %40, %._crit_edge.us ], [ 0, %3 ]
  %14 = mul i64 %.03034.us, %12
  %15 = mul i64 %14, %12
  br label %16

16:                                               ; preds = %.preheader.us, %21
  %.02933.us = phi i64 [ 0, %.preheader.us ], [ %22, %21 ]
  %17 = tail call noundef ptr @_ZNK6Matrix8get_dataEv(ptr noundef nonnull align 8 dereferenceable(49) %2)
  %18 = add i64 %.02933.us, %14
  %19 = getelementptr inbounds float, ptr %17, i64 %18
  store float 0.000000e+00, ptr %19, align 4, !tbaa !14
  %20 = mul i64 %.02933.us, %12
  br label %24

21:                                               ; preds = %24
  %22 = add nuw i64 %.02933.us, 1
  %23 = icmp ult i64 %22, %12
  br i1 %23, label %16, label %._crit_edge.us, !llvm.loop !16

24:                                               ; preds = %24, %16
  %.032.us = phi i64 [ 0, %16 ], [ %38, %24 ]
  %25 = load ptr, ptr %13, align 8, !tbaa !18
  %26 = getelementptr float, ptr %25, i64 %.032.us
  %27 = getelementptr float, ptr %26, i64 %20
  %28 = getelementptr float, ptr %27, i64 %15
  %29 = load float, ptr %28, align 4, !tbaa !14
  %30 = tail call noundef ptr @_ZNK6Matrix8get_dataEv(ptr noundef nonnull align 8 dereferenceable(49) %1)
  %31 = getelementptr float, ptr %30, i64 %.032.us
  %32 = getelementptr float, ptr %31, i64 %14
  %33 = load float, ptr %32, align 4, !tbaa !14
  %34 = tail call noundef ptr @_ZNK6Matrix8get_dataEv(ptr noundef nonnull align 8 dereferenceable(49) %2)
  %35 = getelementptr inbounds float, ptr %34, i64 %18
  %36 = load float, ptr %35, align 4, !tbaa !14
  %37 = tail call float @llvm.fmuladd.f32(float %29, float %33, float %36)
  store float %37, ptr %35, align 4, !tbaa !14
  %38 = add nuw i64 %.032.us, 1
  %39 = icmp ult i64 %38, %12
  br i1 %39, label %24, label %21, !llvm.loop !19

._crit_edge.us:                                   ; preds = %21
  %40 = add nuw i64 %.03034.us, 1
  %41 = icmp ult i64 %40, %10
  br i1 %41, label %.preheader.us, label %.split36.us, !llvm.loop !20

.split36.us:                                      ; preds = %._crit_edge.us, %3
  ret void
}

attributes #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) }
attributes #2 = { mustprogress 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" }

!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, !10, i64 32}
!6 = !{!"_ZTS6Matrix", !7, i64 8, !10, i64 16, !10, i64 24, !10, i64 32, !11, i64 40, !12, i64 48}
!7 = !{!"_ZTS11DEVICE_NAME", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"long", !8, i64 0}
!11 = !{!"any pointer", !8, i64 0}
!12 = !{!"bool", !8, i64 0}
!13 = !{!6, !10, i64 24}
!14 = !{!15, !15, i64 0}
!15 = !{!"float", !8, i64 0}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}
!18 = !{!6, !11, i64 40}
!19 = distinct !{!19, !17}
!20 = distinct !{!20, !17}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyCFGPass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass