; LLVM IR from moarseniy/CudaFEMproject :: deprecated/Linal2/src/Linal2.ll (ZN6Matrix7ProductER7MyArray)

; 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.std::basic_ostream" = type { ptr, %"class.std::basic_ios" }
%"class.std::basic_ios" = type { %"class.std::ios_base", ptr, i8, i8, ptr, ptr, ptr, ptr }
%"class.std::ios_base" = type { ptr, i64, i64, i32, i32, i32, ptr, %"struct.std::ios_base::_Words", [8 x %"struct.std::ios_base::_Words"], i32, ptr, %"class.std::locale" }
%"struct.std::ios_base::_Words" = type { ptr, i64 }
%"class.std::locale" = type { ptr }
%class.MyArray = type { i32, ptr }
%class.Matrix = type { i32, i32, i8, i8, ptr }

@_ZSt4cout = external global %"class.std::basic_ostream", align 8
@.str.25 = external hidden unnamed_addr constant [35 x i8], align 1

; 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: inlinehint mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef) #1

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef) #2 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_(ptr noundef nonnull align 8 dereferenceable(8)) #1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZN7MyArray8get_sizeEv(ptr noundef nonnull align 8 dereferenceable(16)) #3 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZN7MyArrayixEi(ptr noundef nonnull align 8 dereferenceable(16), i32 noundef) #3 align 2

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

declare i32 @__gxx_personality_v0(...)

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN6Matrix7ProductER7MyArray(ptr dead_on_unwind noalias writable sret(%class.MyArray) align 8 %0, ptr noundef nonnull align 8 dereferenceable(24) %1, ptr noundef nonnull align 8 dereferenceable(16) %2) #2 align 2 personality ptr @__gxx_personality_v0 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i1, align 1
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca ptr, align 8
  %12 = alloca i32, align 4
  store ptr %0, ptr %4, align 8
  store ptr %1, ptr %5, align 8, !tbaa !5
  store ptr %2, ptr %6, align 8, !tbaa !5
  %13 = load ptr, ptr %5, align 8
  store i1 false, ptr %7, align 1
  %14 = getelementptr inbounds %class.Matrix, ptr %13, i32 0, i32 0
  %15 = load i32, ptr %14, align 8, !tbaa !9
  call void @_ZN7MyArrayC1Ei(ptr noundef nonnull align 8 dereferenceable(16) %0, i32 noundef %15)
  %16 = getelementptr inbounds %class.Matrix, ptr %13, i32 0, i32 1
  %17 = load i32, ptr %16, align 4, !tbaa !13
  %18 = load ptr, ptr %6, align 8, !tbaa !5
  %19 = call noundef i32 @_ZN7MyArray8get_sizeEv(ptr noundef nonnull align 8 dereferenceable(16) %18)
  %20 = icmp eq i32 %17, %19
  br i1 %20, label %21, label %65

21:                                               ; preds = %3
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #5
  store i32 0, ptr %8, align 4, !tbaa !14
  br label %22

22:                                               ; preds = %61, %21
  %23 = load i32, ptr %8, align 4, !tbaa !14
  %24 = getelementptr inbounds %class.Matrix, ptr %13, i32 0, i32 0
  %25 = load i32, ptr %24, align 8, !tbaa !9
  %26 = icmp slt i32 %23, %25
  br i1 %26, label %28, label %27

27:                                               ; preds = %22
  store i32 2, ptr %9, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #5
  br label %64

28:                                               ; preds = %22
  %29 = load i32, ptr %8, align 4, !tbaa !14
  %30 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZN7MyArrayixEi(ptr noundef nonnull align 8 dereferenceable(16) %0, i32 noundef %29)
  store float 0.000000e+00, ptr %30, align 4, !tbaa !15
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #5
  store i32 0, ptr %10, align 4, !tbaa !14
  br label %31

31:                                               ; preds = %57, %28
  %32 = load i32, ptr %10, align 4, !tbaa !14
  %33 = getelementptr inbounds %class.Matrix, ptr %13, i32 0, i32 1
  %34 = load i32, ptr %33, align 4, !tbaa !13
  %35 = icmp slt i32 %32, %34
  br i1 %35, label %37, label %36

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

37:                                               ; preds = %31
  %38 = getelementptr inbounds %class.Matrix, ptr %13, i32 0, i32 4
  %39 = load ptr, ptr %38, align 8, !tbaa !17
  %40 = load i32, ptr %10, align 4, !tbaa !14
  %41 = load i32, ptr %8, align 4, !tbaa !14
  %42 = getelementptr inbounds %class.Matrix, ptr %13, i32 0, i32 1
  %43 = load i32, ptr %42, align 4, !tbaa !13
  %44 = mul nsw i32 %41, %43
  %45 = add nsw i32 %40, %44
  %46 = sext i32 %45 to i64
  %47 = getelementptr inbounds float, ptr %39, i64 %46
  %48 = load float, ptr %47, align 4, !tbaa !15
  %49 = load ptr, ptr %6, align 8, !tbaa !5
  %50 = load i32, ptr %10, align 4, !tbaa !14
  %51 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZN7MyArrayixEi(ptr noundef nonnull align 8 dereferenceable(16) %49, i32 noundef %50)
  %52 = load float, ptr %51, align 4, !tbaa !15
  %53 = load i32, ptr %8, align 4, !tbaa !14
  %54 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZN7MyArrayixEi(ptr noundef nonnull align 8 dereferenceable(16) %0, i32 noundef %53)
  %55 = load float, ptr %54, align 4, !tbaa !15
  %56 = call float @llvm.fmuladd.f32(float %48, float %52, float %55)
  store float %56, ptr %54, align 4, !tbaa !15
  br label %57

57:                                               ; preds = %37
  %58 = load i32, ptr %10, align 4, !tbaa !14
  %59 = add nsw i32 %58, 1
  store i32 %59, ptr %10, align 4, !tbaa !14
  br label %31, !llvm.loop !18

60:                                               ; preds = %36
  br label %61

61:                                               ; preds = %60
  %62 = load i32, ptr %8, align 4, !tbaa !14
  %63 = add nsw i32 %62, 1
  store i32 %63, ptr %8, align 4, !tbaa !14
  br label %22, !llvm.loop !20

64:                                               ; preds = %27
  br label %74

65:                                               ; preds = %3
  %66 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, ptr noundef @.str.25)
          to label %67 unwind label %70

67:                                               ; preds = %65
  %68 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %66, ptr noundef @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
          to label %69 unwind label %70

69:                                               ; preds = %67
  br label %74

70:                                               ; preds = %67, %65
  %71 = landingpad { ptr, i32 }
          cleanup
  %72 = extractvalue { ptr, i32 } %71, 0
  store ptr %72, ptr %11, align 8
  %73 = extractvalue { ptr, i32 } %71, 1
  store i32 %73, ptr %12, align 4
  call void @_ZN7MyArrayD1Ev(ptr noundef nonnull align 8 dereferenceable(16) %0) #5
  br label %78

74:                                               ; preds = %69, %64
  store i1 true, ptr %7, align 1
  store i32 1, ptr %9, align 4
  %75 = load i1, ptr %7, align 1
  br i1 %75, label %77, label %76

76:                                               ; preds = %74
  call void @_ZN7MyArrayD1Ev(ptr noundef nonnull align 8 dereferenceable(16) %0) #5
  br label %77

77:                                               ; preds = %76, %74
  ret void

78:                                               ; preds = %70
  %79 = load ptr, ptr %11, align 8
  %80 = load i32, ptr %12, align 4
  %81 = insertvalue { ptr, i32 } poison, ptr %79, 0
  %82 = insertvalue { ptr, i32 } %81, i32 %80, 1
  resume { ptr, i32 } %82
}

declare void @_ZN7MyArrayC1Ei(ptr, i32)

declare void @_ZN7MyArrayD1Ev(ptr)

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { inlinehint 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 #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" }
attributes #3 = { mustprogress 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 #4 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #5 = { 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, !11, i64 0}
!10 = !{!"_ZTS6Matrix", !11, i64 0, !11, i64 4, !12, i64 8, !12, i64 9, !6, i64 16}
!11 = !{!"int", !7, i64 0}
!12 = !{!"bool", !7, i64 0}
!13 = !{!10, !11, i64 4}
!14 = !{!11, !11, i64 0}
!15 = !{!16, !16, i64 0}
!16 = !{!"float", !7, i64 0}
!17 = !{!10, !6, i64 16}
!18 = distinct !{!18, !19}
!19 = !{!"llvm.loop.mustprogress"}
!20 = distinct !{!20, !19}


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

%"class.std::basic_ostream" = type { ptr, %"class.std::basic_ios" }
%"class.std::basic_ios" = type { %"class.std::ios_base", ptr, i8, i8, ptr, ptr, ptr, ptr }
%"class.std::ios_base" = type { ptr, i64, i64, i32, i32, i32, ptr, %"struct.std::ios_base::_Words", [8 x %"struct.std::ios_base::_Words"], i32, ptr, %"class.std::locale" }
%"struct.std::ios_base::_Words" = type { ptr, i64 }
%"class.std::locale" = type { ptr }
%class.MyArray = type { i32, ptr }

@_ZSt4cout = external global %"class.std::basic_ostream", align 8
@.str.25 = external hidden unnamed_addr constant [35 x i8], align 1

; Function Attrs: inlinehint mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef) local_unnamed_addr #1 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_(ptr noundef nonnull align 8 dereferenceable(8)) #0

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZN7MyArray8get_sizeEv(ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZN7MyArrayixEi(ptr noundef nonnull align 8 dereferenceable(16), i32 noundef) local_unnamed_addr #2 align 2

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

declare i32 @__gxx_personality_v0(...)

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN6Matrix7ProductER7MyArray(ptr dead_on_unwind noalias writable sret(%class.MyArray) align 8 %0, ptr nocapture noundef nonnull readonly align 8 dereferenceable(24) %1, ptr noundef nonnull align 8 dereferenceable(16) %2) local_unnamed_addr #1 align 2 personality ptr @__gxx_personality_v0 {
  %4 = load i32, ptr %1, align 8, !tbaa !5
  tail call void @_ZN7MyArrayC1Ei(ptr noundef nonnull align 8 dereferenceable(16) %0, i32 noundef %4)
  %5 = getelementptr inbounds i8, ptr %1, i64 4
  %6 = load i32, ptr %5, align 4, !tbaa !12
  %7 = tail call noundef i32 @_ZN7MyArray8get_sizeEv(ptr noundef nonnull align 8 dereferenceable(16) %2)
  %8 = icmp eq i32 %6, %7
  br i1 %8, label %.preheader, label %34

.preheader:                                       ; preds = %3
  %9 = load i32, ptr %1, align 8, !tbaa !5
  %10 = icmp sgt i32 %9, 0
  br i1 %10, label %.lr.ph18, label %.loopexit

.lr.ph18:                                         ; preds = %.preheader
  %11 = getelementptr inbounds i8, ptr %1, i64 16
  br label %12

12:                                               ; preds = %.lr.ph18, %._crit_edge
  %.017 = phi i32 [ 0, %.lr.ph18 ], [ %16, %._crit_edge ]
  %13 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZN7MyArrayixEi(ptr noundef nonnull align 8 dereferenceable(16) %0, i32 noundef %.017)
  store float 0.000000e+00, ptr %13, align 4, !tbaa !13
  %14 = load i32, ptr %5, align 4, !tbaa !12
  %15 = icmp sgt i32 %14, 0
  br i1 %15, label %.lr.ph, label %._crit_edge

._crit_edge:                                      ; preds = %.lr.ph, %12
  %16 = add nuw nsw i32 %.017, 1
  %17 = load i32, ptr %1, align 8, !tbaa !5
  %18 = icmp slt i32 %16, %17
  br i1 %18, label %12, label %.loopexit, !llvm.loop !15

.lr.ph:                                           ; preds = %12, %.lr.ph
  %19 = phi i32 [ %32, %.lr.ph ], [ %14, %12 ]
  %.01416 = phi i32 [ %31, %.lr.ph ], [ 0, %12 ]
  %20 = load ptr, ptr %11, align 8, !tbaa !17
  %21 = mul nsw i32 %19, %.017
  %22 = add nsw i32 %21, %.01416
  %23 = sext i32 %22 to i64
  %24 = getelementptr inbounds float, ptr %20, i64 %23
  %25 = load float, ptr %24, align 4, !tbaa !13
  %26 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZN7MyArrayixEi(ptr noundef nonnull align 8 dereferenceable(16) %2, i32 noundef %.01416)
  %27 = load float, ptr %26, align 4, !tbaa !13
  %28 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZN7MyArrayixEi(ptr noundef nonnull align 8 dereferenceable(16) %0, i32 noundef %.017)
  %29 = load float, ptr %28, align 4, !tbaa !13
  %30 = tail call float @llvm.fmuladd.f32(float %25, float %27, float %29)
  store float %30, ptr %28, align 4, !tbaa !13
  %31 = add nuw nsw i32 %.01416, 1
  %32 = load i32, ptr %5, align 4, !tbaa !12
  %33 = icmp slt i32 %31, %32
  br i1 %33, label %.lr.ph, label %._crit_edge, !llvm.loop !18

34:                                               ; preds = %3
  %35 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, ptr noundef nonnull @.str.25)
          to label %36 unwind label %38

36:                                               ; preds = %34
  %37 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %35, ptr noundef nonnull @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
          to label %.loopexit unwind label %38

38:                                               ; preds = %36, %34
  %39 = landingpad { ptr, i32 }
          cleanup
  tail call void @_ZN7MyArrayD1Ev(ptr noundef nonnull align 8 dereferenceable(16) %0) #4
  resume { ptr, i32 } %39

.loopexit:                                        ; preds = %._crit_edge, %.preheader, %36
  ret void
}

declare void @_ZN7MyArrayC1Ei(ptr, i32) local_unnamed_addr

declare void @_ZN7MyArrayD1Ev(ptr) local_unnamed_addr

attributes #0 = { inlinehint 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 #1 = { 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 #2 = { mustprogress 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 #3 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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, !7, i64 0}
!6 = !{!"_ZTS6Matrix", !7, i64 0, !7, i64 4, !10, i64 8, !10, i64 9, !11, i64 16}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"bool", !8, i64 0}
!11 = !{!"any pointer", !8, i64 0}
!12 = !{!6, !7, i64 4}
!13 = !{!14, !14, i64 0}
!14 = !{!"float", !8, i64 0}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}
!17 = !{!6, !11, i64 16}
!18 = distinct !{!18, !16}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass