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

; 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__._ZN10CPU_Matrix11addWeightedER6MatrixffS1_ = external hidden unnamed_addr constant [12 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

; 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 @_ZN10CPU_Matrix11addWeightedER6MatrixffS1_(ptr noundef nonnull align 8 dereferenceable(49) %0, ptr noundef nonnull align 8 dereferenceable(49) %1, float noundef %2, float noundef %3, ptr noundef nonnull align 8 dereferenceable(49) %4) unnamed_addr #3 align 2 {
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca float, align 4
  %9 = alloca float, align 4
  %10 = alloca ptr, align 8
  %11 = alloca i64, align 8
  %12 = alloca i32, align 4
  %13 = alloca i64, align 8
  store ptr %0, ptr %6, align 8, !tbaa !5
  store ptr %1, ptr %7, align 8, !tbaa !5
  store float %2, ptr %8, align 4, !tbaa !9
  store float %3, ptr %9, align 4, !tbaa !9
  store ptr %4, ptr %10, align 8, !tbaa !5
  %14 = load ptr, ptr %6, align 8
  %15 = getelementptr inbounds %class.Matrix, ptr %14, i32 0, i32 5
  %16 = load i64, ptr %15, align 8, !tbaa !11
  %17 = icmp ugt i64 %16, 0
  br i1 %17, label %18, label %24

18:                                               ; preds = %5
  %19 = getelementptr inbounds %class.Matrix, ptr %14, i32 0, i32 5
  %20 = load i64, ptr %19, align 8, !tbaa !11
  %21 = load ptr, ptr %7, align 8, !tbaa !5
  %22 = call noundef i64 @_ZNK6Matrix15get_numElementsEv(ptr noundef nonnull align 8 dereferenceable(49) %21)
  %23 = icmp eq i64 %20, %22
  br label %24

24:                                               ; preds = %18, %5
  %25 = phi i1 [ false, %5 ], [ %23, %18 ]
  call void @_Z10_my_assertbPKciS0_(i1 noundef zeroext %25, ptr noundef @.str, i32 noundef 368, ptr noundef @__FUNCTION__._ZN10CPU_Matrix11addWeightedER6MatrixffS1_)
  %26 = load ptr, ptr %7, align 8, !tbaa !5
  %27 = call noundef zeroext i1 @_ZNK6Matrix8isSameAsERS_(ptr noundef nonnull align 8 dereferenceable(49) %14, ptr noundef nonnull align 8 dereferenceable(49) %26)
  call void @_Z10_my_assertbPKciS0_(i1 noundef zeroext %27, ptr noundef @.str, i32 noundef 369, ptr noundef @__FUNCTION__._ZN10CPU_Matrix11addWeightedER6MatrixffS1_)
  %28 = load ptr, ptr %10, align 8, !tbaa !5
  %29 = call noundef zeroext i1 @_ZNK6Matrix8isSameAsERS_(ptr noundef nonnull align 8 dereferenceable(49) %14, ptr noundef nonnull align 8 dereferenceable(49) %28)
  br i1 %29, label %35, label %30

30:                                               ; preds = %24
  %31 = load ptr, ptr %10, align 8, !tbaa !5
  %32 = load ptr, ptr %31, align 8, !tbaa !16
  %33 = getelementptr inbounds ptr, ptr %32, i64 27
  %34 = load ptr, ptr %33, align 8
  call void %34(ptr noundef nonnull align 8 dereferenceable(49) %31, ptr noundef nonnull align 8 dereferenceable(49) %14)
  br label %35

35:                                               ; preds = %30, %24
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #4
  store i64 0, ptr %11, align 8, !tbaa !18
  br label %36

36:                                               ; preds = %77, %35
  %37 = load i64, ptr %11, align 8, !tbaa !18
  %38 = getelementptr inbounds %class.Matrix, ptr %14, i32 0, i32 3
  %39 = load i64, ptr %38, align 8, !tbaa !19
  %40 = icmp ult i64 %37, %39
  br i1 %40, label %42, label %41

41:                                               ; preds = %36
  store i32 2, ptr %12, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #4
  br label %80

42:                                               ; preds = %36
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #4
  store i64 0, ptr %13, align 8, !tbaa !18
  br label %43

43:                                               ; preds = %73, %42
  %44 = load i64, ptr %13, align 8, !tbaa !18
  %45 = getelementptr inbounds %class.Matrix, ptr %14, i32 0, i32 4
  %46 = load i64, ptr %45, align 8, !tbaa !20
  %47 = icmp ult i64 %44, %46
  br i1 %47, label %49, label %48

48:                                               ; preds = %43
  store i32 5, ptr %12, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #4
  br label %76

49:                                               ; preds = %43
  %50 = load float, ptr %8, align 4, !tbaa !9
  %51 = getelementptr inbounds %class.Matrix, ptr %14, i32 0, i32 6
  %52 = load ptr, ptr %51, align 8, !tbaa !21
  %53 = load i64, ptr %13, align 8, !tbaa !18
  %54 = load i64, ptr %11, align 8, !tbaa !18
  %55 = getelementptr inbounds %class.Matrix, ptr %14, i32 0, i32 4
  %56 = load i64, ptr %55, align 8, !tbaa !20
  %57 = mul i64 %54, %56
  %58 = add i64 %53, %57
  %59 = getelementptr inbounds float, ptr %52, i64 %58
  %60 = load float, ptr %59, align 4, !tbaa !9
  %61 = load float, ptr %9, align 4, !tbaa !9
  %62 = load ptr, ptr %7, align 8, !tbaa !5
  %63 = load i64, ptr %11, align 8, !tbaa !18
  %64 = load i64, ptr %13, align 8, !tbaa !18
  %65 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZN6MatrixclEmm(ptr noundef nonnull align 8 dereferenceable(49) %62, i64 noundef %63, i64 noundef %64)
  %66 = load float, ptr %65, align 4, !tbaa !9
  %67 = fmul float %61, %66
  %68 = call float @llvm.fmuladd.f32(float %50, float %60, float %67)
  %69 = load ptr, ptr %10, align 8, !tbaa !5
  %70 = load i64, ptr %11, align 8, !tbaa !18
  %71 = load i64, ptr %13, align 8, !tbaa !18
  %72 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZN6MatrixclEmm(ptr noundef nonnull align 8 dereferenceable(49) %69, i64 noundef %70, i64 noundef %71)
  store float %68, ptr %72, align 4, !tbaa !9
  br label %73

73:                                               ; preds = %49
  %74 = load i64, ptr %13, align 8, !tbaa !18
  %75 = add i64 %74, 1
  store i64 %75, ptr %13, align 8, !tbaa !18
  br label %43, !llvm.loop !22

76:                                               ; preds = %48
  br label %77

77:                                               ; preds = %76
  %78 = load i64, ptr %11, align 8, !tbaa !18
  %79 = add i64 %78, 1
  store i64 %79, ptr %11, align 8, !tbaa !18
  br label %36, !llvm.loop !24

80:                                               ; preds = %41
  ret void
}

declare noundef zeroext i1 @_ZNK6Matrix8isSameAsERS_(ptr noundef nonnull align 8 dereferenceable(49), ptr noundef nonnull align 8 dereferenceable(49)) #0

declare noundef nonnull align 4 dereferenceable(4) ptr @_ZN6MatrixclEmm(ptr noundef nonnull align 8 dereferenceable(49), i64 noundef, i64 noundef) #0

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, !10, i64 0}
!10 = !{!"float", !7, i64 0}
!11 = !{!12, !14, i64 32}
!12 = !{!"_ZTS6Matrix", !13, i64 8, !14, i64 16, !14, i64 24, !14, i64 32, !6, i64 40, !15, i64 48}
!13 = !{!"_ZTS11DEVICE_NAME", !7, i64 0}
!14 = !{!"long", !7, i64 0}
!15 = !{!"bool", !7, i64 0}
!16 = !{!17, !17, i64 0}
!17 = !{!"vtable pointer", !8, i64 0}
!18 = !{!14, !14, i64 0}
!19 = !{!12, !14, i64 16}
!20 = !{!12, !14, i64 24}
!21 = !{!12, !6, i64 40}
!22 = distinct !{!22, !23}
!23 = !{!"llvm.loop.mustprogress"}
!24 = distinct !{!24, !23}


; 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__._ZN10CPU_Matrix11addWeightedER6MatrixffS1_ = external hidden unnamed_addr constant [12 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

; 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 @_ZN10CPU_Matrix11addWeightedER6MatrixffS1_(ptr noundef nonnull align 8 dereferenceable(49) %0, ptr noundef nonnull align 8 dereferenceable(49) %1, float noundef %2, float noundef %3, ptr noundef nonnull align 8 dereferenceable(49) %4) unnamed_addr #2 align 2 {
  %6 = getelementptr inbounds i8, ptr %0, i64 32
  %7 = load i64, ptr %6, align 8, !tbaa !5
  %.not = icmp eq i64 %7, 0
  br i1 %.not, label %11, label %8

8:                                                ; preds = %5
  %9 = tail call noundef i64 @_ZNK6Matrix15get_numElementsEv(ptr noundef nonnull align 8 dereferenceable(49) %1)
  %10 = icmp eq i64 %7, %9
  br label %11

11:                                               ; preds = %8, %5
  %12 = phi i1 [ false, %5 ], [ %10, %8 ]
  tail call void @_Z10_my_assertbPKciS0_(i1 noundef zeroext %12, ptr noundef nonnull @.str, i32 noundef 368, ptr noundef nonnull @__FUNCTION__._ZN10CPU_Matrix11addWeightedER6MatrixffS1_)
  %13 = tail call noundef zeroext i1 @_ZNK6Matrix8isSameAsERS_(ptr noundef nonnull align 8 dereferenceable(49) %0, ptr noundef nonnull align 8 dereferenceable(49) %1)
  tail call void @_Z10_my_assertbPKciS0_(i1 noundef zeroext %13, ptr noundef nonnull @.str, i32 noundef 369, ptr noundef nonnull @__FUNCTION__._ZN10CPU_Matrix11addWeightedER6MatrixffS1_)
  %14 = tail call noundef zeroext i1 @_ZNK6Matrix8isSameAsERS_(ptr noundef nonnull align 8 dereferenceable(49) %0, ptr noundef nonnull align 8 dereferenceable(49) %4)
  br i1 %14, label %19, label %15

15:                                               ; preds = %11
  %16 = load ptr, ptr %4, align 8, !tbaa !13
  %17 = getelementptr inbounds i8, ptr %16, i64 216
  %18 = load ptr, ptr %17, align 8
  tail call void %18(ptr noundef nonnull align 8 dereferenceable(49) %4, ptr noundef nonnull align 8 dereferenceable(49) %0)
  br label %19

19:                                               ; preds = %15, %11
  %20 = getelementptr inbounds i8, ptr %0, i64 16
  %21 = load i64, ptr %20, align 8, !tbaa !15
  %.not24 = icmp eq i64 %21, 0
  br i1 %.not24, label %._crit_edge23, label %.preheader.lr.ph

.preheader.lr.ph:                                 ; preds = %19
  %22 = getelementptr inbounds i8, ptr %0, i64 24
  %23 = getelementptr inbounds i8, ptr %0, i64 40
  %24 = load i64, ptr %22, align 8, !tbaa !16
  %.not25 = icmp eq i64 %24, 0
  br i1 %.not25, label %._crit_edge23, label %.preheader

.preheader:                                       ; preds = %.preheader.lr.ph, %._crit_edge
  %25 = phi i64 [ %27, %._crit_edge ], [ %21, %.preheader.lr.ph ]
  %26 = phi i64 [ %28, %._crit_edge ], [ %24, %.preheader.lr.ph ]
  %.01822 = phi i64 [ %29, %._crit_edge ], [ 0, %.preheader.lr.ph ]
  %.not26 = icmp eq i64 %26, 0
  br i1 %.not26, label %._crit_edge, label %.lr.ph

._crit_edge23:                                    ; preds = %._crit_edge, %.preheader.lr.ph, %19
  ret void

._crit_edge.loopexit:                             ; preds = %.lr.ph
  %.pre = load i64, ptr %20, align 8, !tbaa !15
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit, %.preheader
  %27 = phi i64 [ %.pre, %._crit_edge.loopexit ], [ %25, %.preheader ]
  %28 = phi i64 [ %43, %._crit_edge.loopexit ], [ 0, %.preheader ]
  %29 = add nuw i64 %.01822, 1
  %30 = icmp ult i64 %29, %27
  br i1 %30, label %.preheader, label %._crit_edge23, !llvm.loop !17

.lr.ph:                                           ; preds = %.preheader, %.lr.ph
  %31 = phi i64 [ %43, %.lr.ph ], [ %26, %.preheader ]
  %.021 = phi i64 [ %42, %.lr.ph ], [ 0, %.preheader ]
  %32 = load ptr, ptr %23, align 8, !tbaa !20
  %33 = mul i64 %31, %.01822
  %34 = getelementptr float, ptr %32, i64 %.021
  %35 = getelementptr float, ptr %34, i64 %33
  %36 = load float, ptr %35, align 4, !tbaa !21
  %37 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZN6MatrixclEmm(ptr noundef nonnull align 8 dereferenceable(49) %1, i64 noundef %.01822, i64 noundef %.021)
  %38 = load float, ptr %37, align 4, !tbaa !21
  %39 = fmul float %38, %3
  %40 = tail call float @llvm.fmuladd.f32(float %2, float %36, float %39)
  %41 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZN6MatrixclEmm(ptr noundef nonnull align 8 dereferenceable(49) %4, i64 noundef %.01822, i64 noundef %.021)
  store float %40, ptr %41, align 4, !tbaa !21
  %42 = add nuw i64 %.021, 1
  %43 = load i64, ptr %22, align 8, !tbaa !16
  %44 = icmp ult i64 %42, %43
  br i1 %44, label %.lr.ph, label %._crit_edge.loopexit, !llvm.loop !23
}

declare noundef zeroext i1 @_ZNK6Matrix8isSameAsERS_(ptr noundef nonnull align 8 dereferenceable(49), ptr noundef nonnull align 8 dereferenceable(49)) local_unnamed_addr #0

declare noundef nonnull align 4 dereferenceable(4) ptr @_ZN6MatrixclEmm(ptr noundef nonnull align 8 dereferenceable(49), i64 noundef, i64 noundef) local_unnamed_addr #0

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 = !{!14, !14, i64 0}
!14 = !{!"vtable pointer", !9, i64 0}
!15 = !{!6, !10, i64 16}
!16 = !{!6, !10, i64 24}
!17 = distinct !{!17, !18, !19}
!18 = !{!"llvm.loop.mustprogress"}
!19 = !{!"llvm.loop.unswitch.partial.disable"}
!20 = !{!6, !11, i64 40}
!21 = !{!22, !22, i64 0}
!22 = !{!"float", !8, i64 0}
!23 = distinct !{!23, !18}


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