; LLVM IR from artvns/SimpleFvm :: simplefvm/src/MeshLoader/CellsNumeration (InteriorCellsNumerator)

; 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.meshloader::InteriorCellsNumerator" = type { ptr, ptr, i64, i64, i64 }

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN10meshloader22InteriorCellsNumerator13numerateCellsEv(ptr noundef nonnull align 8 dereferenceable(40) %0) #0 align 2 {
  %2 = alloca ptr, align 8
  %3 = alloca i64, align 8
  %4 = alloca i64, align 8
  %5 = alloca i32, align 4
  %6 = alloca i64, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  %7 = load ptr, ptr %2, align 8
  call void @_ZN10meshloader22InteriorCellsNumerator12createMatrixEv(ptr noundef nonnull align 8 dereferenceable(40) %7)
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #3
  store i64 1, ptr %3, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #3
  store i64 0, ptr %4, align 8, !tbaa !9
  br label %8

8:                                                ; preds = %47, %1
  %9 = load i64, ptr %4, align 8, !tbaa !9
  %10 = getelementptr inbounds %"class.meshloader::InteriorCellsNumerator", ptr %7, i32 0, i32 2
  %11 = load i64, ptr %10, align 8, !tbaa !11
  %12 = icmp ult i64 %9, %11
  br i1 %12, label %14, label %13

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

14:                                               ; preds = %8
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  store i64 0, ptr %6, align 8, !tbaa !9
  br label %15

15:                                               ; preds = %43, %14
  %16 = load i64, ptr %6, align 8, !tbaa !9
  %17 = getelementptr inbounds %"class.meshloader::InteriorCellsNumerator", ptr %7, i32 0, i32 3
  %18 = load i64, ptr %17, align 8, !tbaa !13
  %19 = icmp ult i64 %16, %18
  br i1 %19, label %21, label %20

20:                                               ; preds = %15
  store i32 5, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  br label %46

21:                                               ; preds = %15
  %22 = getelementptr inbounds %"class.meshloader::InteriorCellsNumerator", ptr %7, i32 0, i32 0
  %23 = load ptr, ptr %22, align 8, !tbaa !14
  %24 = load i64, ptr %4, align 8, !tbaa !9
  %25 = load i64, ptr %6, align 8, !tbaa !9
  %26 = call noundef signext i8 @_ZNK10meshloader10BaseMatrix8getValueEmm(ptr noundef nonnull align 8 dereferenceable(40) %23, i64 noundef %24, i64 noundef %25)
  %27 = sext i8 %26 to i32
  %28 = icmp ne i32 48, %27
  br i1 %28, label %29, label %37

29:                                               ; preds = %21
  %30 = getelementptr inbounds %"class.meshloader::InteriorCellsNumerator", ptr %7, i32 0, i32 1
  %31 = load ptr, ptr %30, align 8, !tbaa !15
  %32 = load i64, ptr %4, align 8, !tbaa !9
  %33 = load i64, ptr %6, align 8, !tbaa !9
  %34 = load i64, ptr %3, align 8, !tbaa !9
  call void @_ZN10meshloader10NumsMatrix8setValueEmmm(ptr noundef nonnull align 8 dereferenceable(40) %31, i64 noundef %32, i64 noundef %33, i64 noundef %34)
  %35 = load i64, ptr %3, align 8, !tbaa !9
  %36 = add i64 %35, 1
  store i64 %36, ptr %3, align 8, !tbaa !9
  br label %42

37:                                               ; preds = %21
  %38 = getelementptr inbounds %"class.meshloader::InteriorCellsNumerator", ptr %7, i32 0, i32 1
  %39 = load ptr, ptr %38, align 8, !tbaa !15
  %40 = load i64, ptr %4, align 8, !tbaa !9
  %41 = load i64, ptr %6, align 8, !tbaa !9
  call void @_ZN10meshloader10NumsMatrix8setValueEmmm(ptr noundef nonnull align 8 dereferenceable(40) %39, i64 noundef %40, i64 noundef %41, i64 noundef 0)
  br label %42

42:                                               ; preds = %37, %29
  br label %43

43:                                               ; preds = %42
  %44 = load i64, ptr %6, align 8, !tbaa !9
  %45 = add i64 %44, 1
  store i64 %45, ptr %6, align 8, !tbaa !9
  br label %15, !llvm.loop !16

46:                                               ; preds = %20
  br label %47

47:                                               ; preds = %46
  %48 = load i64, ptr %4, align 8, !tbaa !9
  %49 = add i64 %48, 1
  store i64 %49, ptr %4, align 8, !tbaa !9
  br label %8, !llvm.loop !18

50:                                               ; preds = %13
  %51 = load i64, ptr %3, align 8, !tbaa !9
  %52 = getelementptr inbounds %"class.meshloader::InteriorCellsNumerator", ptr %7, i32 0, i32 4
  store i64 %51, ptr %52, align 8, !tbaa !19
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #3
  ret void
}

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN10meshloader22InteriorCellsNumerator12createMatrixEv(ptr noundef nonnull align 8 dereferenceable(40)) #0 align 2

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

declare noundef signext i8 @_ZNK10meshloader10BaseMatrix8getValueEmm(ptr noundef nonnull align 8 dereferenceable(40), i64 noundef, i64 noundef) #2

declare void @_ZN10meshloader10NumsMatrix8setValueEmmm(ptr noundef nonnull align 8 dereferenceable(40), i64 noundef, i64 noundef, i64 noundef) #2

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

attributes #0 = { 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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { "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, !10, i64 0}
!10 = !{!"long", !7, i64 0}
!11 = !{!12, !10, i64 16}
!12 = !{!"_ZTSN10meshloader22InteriorCellsNumeratorE", !6, i64 0, !6, i64 8, !10, i64 16, !10, i64 24, !10, i64 32}
!13 = !{!12, !10, i64 24}
!14 = !{!12, !6, i64 0}
!15 = !{!12, !6, i64 8}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}
!18 = distinct !{!18, !17}
!19 = !{!12, !10, i64 32}


; 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: mustprogress uwtable
define dso_local void @_ZN10meshloader22InteriorCellsNumerator13numerateCellsEv(ptr noundef nonnull align 8 dereferenceable(40) %0) local_unnamed_addr #0 align 2 {
  tail call void @_ZN10meshloader22InteriorCellsNumerator12createMatrixEv(ptr noundef nonnull align 8 dereferenceable(40) %0)
  %2 = getelementptr inbounds i8, ptr %0, i64 16
  %3 = load i64, ptr %2, align 8, !tbaa !5
  %.not21 = icmp eq i64 %3, 0
  br i1 %.not21, label %._crit_edge19, label %.preheader.lr.ph

.preheader.lr.ph:                                 ; preds = %1
  %4 = getelementptr inbounds i8, ptr %0, i64 24
  %5 = getelementptr inbounds i8, ptr %0, i64 8
  %6 = load i64, ptr %4, align 8, !tbaa !11
  %.not22 = icmp eq i64 %6, 0
  br i1 %.not22, label %._crit_edge19, label %.preheader

.preheader:                                       ; preds = %.preheader.lr.ph, %._crit_edge
  %7 = phi i64 [ %10, %._crit_edge ], [ %3, %.preheader.lr.ph ]
  %8 = phi i64 [ %11, %._crit_edge ], [ 1, %.preheader.lr.ph ]
  %.01318 = phi i64 [ %12, %._crit_edge ], [ 0, %.preheader.lr.ph ]
  %.01417 = phi i64 [ %.1.lcssa, %._crit_edge ], [ 1, %.preheader.lr.ph ]
  %.not23 = icmp eq i64 %8, 0
  br i1 %.not23, label %._crit_edge, label %.lr.ph

._crit_edge19:                                    ; preds = %._crit_edge, %.preheader.lr.ph, %1
  %.014.lcssa = phi i64 [ 1, %1 ], [ 1, %.preheader.lr.ph ], [ %.1.lcssa, %._crit_edge ]
  %9 = getelementptr inbounds i8, ptr %0, i64 32
  store i64 %.014.lcssa, ptr %9, align 8, !tbaa !12
  ret void

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

._crit_edge:                                      ; preds = %._crit_edge.loopexit, %.preheader
  %10 = phi i64 [ %7, %.preheader ], [ %.pre, %._crit_edge.loopexit ]
  %11 = phi i64 [ 0, %.preheader ], [ %22, %._crit_edge.loopexit ]
  %.1.lcssa = phi i64 [ %.01417, %.preheader ], [ %.2, %._crit_edge.loopexit ]
  %12 = add nuw i64 %.01318, 1
  %13 = icmp ult i64 %12, %10
  br i1 %13, label %.preheader, label %._crit_edge19, !llvm.loop !13

.lr.ph:                                           ; preds = %.preheader, %20
  %.016 = phi i64 [ %21, %20 ], [ 0, %.preheader ]
  %.115 = phi i64 [ %.2, %20 ], [ %.01417, %.preheader ]
  %14 = load ptr, ptr %0, align 8, !tbaa !16
  %15 = tail call noundef signext i8 @_ZNK10meshloader10BaseMatrix8getValueEmm(ptr noundef nonnull align 8 dereferenceable(40) %14, i64 noundef %.01318, i64 noundef %.016)
  %.not = icmp eq i8 %15, 48
  %16 = load ptr, ptr %5, align 8, !tbaa !17
  br i1 %.not, label %19, label %17

17:                                               ; preds = %.lr.ph
  tail call void @_ZN10meshloader10NumsMatrix8setValueEmmm(ptr noundef nonnull align 8 dereferenceable(40) %16, i64 noundef %.01318, i64 noundef %.016, i64 noundef %.115)
  %18 = add i64 %.115, 1
  br label %20

19:                                               ; preds = %.lr.ph
  tail call void @_ZN10meshloader10NumsMatrix8setValueEmmm(ptr noundef nonnull align 8 dereferenceable(40) %16, i64 noundef %.01318, i64 noundef %.016, i64 noundef 0)
  br label %20

20:                                               ; preds = %17, %19
  %.2 = phi i64 [ %18, %17 ], [ %.115, %19 ]
  %21 = add nuw i64 %.016, 1
  %22 = load i64, ptr %4, align 8, !tbaa !11
  %23 = icmp ult i64 %21, %22
  br i1 %23, label %.lr.ph, label %._crit_edge.loopexit, !llvm.loop !18
}

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN10meshloader22InteriorCellsNumerator12createMatrixEv(ptr noundef nonnull align 8 dereferenceable(40)) local_unnamed_addr #0 align 2

declare noundef signext i8 @_ZNK10meshloader10BaseMatrix8getValueEmm(ptr noundef nonnull align 8 dereferenceable(40), i64 noundef, i64 noundef) local_unnamed_addr #1

declare void @_ZN10meshloader10NumsMatrix8setValueEmmm(ptr noundef nonnull align 8 dereferenceable(40), i64 noundef, i64 noundef, i64 noundef) local_unnamed_addr #1

attributes #0 = { 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 = { "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 16}
!6 = !{!"_ZTSN10meshloader22InteriorCellsNumeratorE", !7, i64 0, !7, i64 8, !10, i64 16, !10, i64 24, !10, i64 32}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"long", !8, i64 0}
!11 = !{!6, !10, i64 24}
!12 = !{!6, !10, i64 32}
!13 = distinct !{!13, !14, !15}
!14 = !{!"llvm.loop.mustprogress"}
!15 = !{!"llvm.loop.unswitch.partial.disable"}
!16 = !{!6, !7, i64 0}
!17 = !{!6, !7, i64 8}
!18 = distinct !{!18, !14}


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