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

; 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_Matrix17divideElementwiseEf = external hidden unnamed_addr constant [18 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 willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN10CPU_Matrix17divideElementwiseER6MatrixS1_(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 #2 align 2 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = 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
  %8 = load ptr, ptr %4, align 8
  %9 = getelementptr inbounds %class.Matrix, ptr %8, i32 0, i32 5
  %10 = load i64, ptr %9, align 8, !tbaa !9
  %11 = icmp ugt i64 %10, 0
  br i1 %11, label %12, label %18

12:                                               ; preds = %3
  %13 = getelementptr inbounds %class.Matrix, ptr %8, i32 0, i32 5
  %14 = load i64, ptr %13, align 8, !tbaa !9
  %15 = load ptr, ptr %5, align 8, !tbaa !5
  %16 = call noundef i64 @_ZNK6Matrix15get_numElementsEv(ptr noundef nonnull align 8 dereferenceable(49) %15)
  %17 = icmp eq i64 %14, %16
  br label %18

18:                                               ; preds = %12, %3
  %19 = phi i1 [ false, %3 ], [ %17, %12 ]
  call void @_Z10_my_assertbPKciS0_(i1 noundef zeroext %19, ptr noundef @.str, i32 noundef 113, ptr noundef @__FUNCTION__._ZN10CPU_Matrix17divideElementwiseEf)
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  store i64 0, ptr %7, align 8, !tbaa !14
  br label %20

20:                                               ; preds = %42, %18
  %21 = load i64, ptr %7, align 8, !tbaa !14
  %22 = getelementptr inbounds %class.Matrix, ptr %8, i32 0, i32 5
  %23 = load i64, ptr %22, align 8, !tbaa !9
  %24 = icmp ult i64 %21, %23
  br i1 %24, label %26, label %25

25:                                               ; preds = %20
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  br label %45

26:                                               ; preds = %20
  %27 = getelementptr inbounds %class.Matrix, ptr %8, i32 0, i32 6
  %28 = load ptr, ptr %27, align 8, !tbaa !15
  %29 = load i64, ptr %7, align 8, !tbaa !14
  %30 = getelementptr inbounds float, ptr %28, i64 %29
  %31 = load float, ptr %30, align 4, !tbaa !16
  %32 = load ptr, ptr %5, align 8, !tbaa !5
  %33 = call noundef ptr @_ZNK6Matrix8get_dataEv(ptr noundef nonnull align 8 dereferenceable(49) %32)
  %34 = load i64, ptr %7, align 8, !tbaa !14
  %35 = getelementptr inbounds float, ptr %33, i64 %34
  %36 = load float, ptr %35, align 4, !tbaa !16
  %37 = fdiv float %31, %36
  %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 %7, align 8, !tbaa !14
  %41 = getelementptr inbounds float, ptr %39, i64 %40
  store float %37, ptr %41, align 4, !tbaa !16
  br label %42

42:                                               ; preds = %26
  %43 = load i64, ptr %7, align 8, !tbaa !14
  %44 = add i64 %43, 1
  store i64 %44, ptr %7, align 8, !tbaa !14
  br label %20, !llvm.loop !18

45:                                               ; preds = %25
  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 = { 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 = { 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 = !{!12, !12, i64 0}
!15 = !{!10, !6, i64 40}
!16 = !{!17, !17, i64 0}
!17 = !{!"float", !7, i64 0}
!18 = distinct !{!18, !19}
!19 = !{!"llvm.loop.mustprogress"}


; 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_Matrix17divideElementwiseEf = external hidden unnamed_addr constant [18 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 uwtable
define dso_local void @_ZN10CPU_Matrix17divideElementwiseER6MatrixS1_(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 #1 align 2 {
  %4 = getelementptr inbounds i8, ptr %0, i64 32
  %5 = load i64, ptr %4, align 8, !tbaa !5
  %.not = icmp eq i64 %5, 0
  br i1 %.not, label %9, label %6

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

9:                                                ; preds = %6, %3
  %10 = phi i1 [ false, %3 ], [ %8, %6 ]
  tail call void @_Z10_my_assertbPKciS0_(i1 noundef zeroext %10, ptr noundef nonnull @.str, i32 noundef 113, ptr noundef nonnull @__FUNCTION__._ZN10CPU_Matrix17divideElementwiseEf)
  %11 = load i64, ptr %4, align 8, !tbaa !5
  %.not10 = icmp eq i64 %11, 0
  br i1 %.not10, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %9
  %12 = getelementptr inbounds i8, ptr %0, i64 40
  br label %13

._crit_edge:                                      ; preds = %13, %9
  ret void

13:                                               ; preds = %.lr.ph, %13
  %.09 = phi i64 [ 0, %.lr.ph ], [ %23, %13 ]
  %14 = load ptr, ptr %12, align 8, !tbaa !13
  %15 = getelementptr inbounds float, ptr %14, i64 %.09
  %16 = load float, ptr %15, align 4, !tbaa !14
  %17 = tail call noundef ptr @_ZNK6Matrix8get_dataEv(ptr noundef nonnull align 8 dereferenceable(49) %1)
  %18 = getelementptr inbounds float, ptr %17, i64 %.09
  %19 = load float, ptr %18, align 4, !tbaa !14
  %20 = fdiv float %16, %19
  %21 = tail call noundef ptr @_ZNK6Matrix8get_dataEv(ptr noundef nonnull align 8 dereferenceable(49) %2)
  %22 = getelementptr inbounds float, ptr %21, i64 %.09
  store float %20, ptr %22, align 4, !tbaa !14
  %23 = add nuw i64 %.09, 1
  %24 = load i64, ptr %4, align 8, !tbaa !5
  %25 = icmp ult i64 %23, %24
  br i1 %25, label %13, label %._crit_edge, !llvm.loop !16
}

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 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, !11, i64 40}
!14 = !{!15, !15, i64 0}
!15 = !{!"float", !8, i64 0}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}


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