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

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

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

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

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

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

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

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

20:                                               ; preds = %14
  %21 = getelementptr inbounds %"class.meshloader::GlobalCellsNumerator", ptr %6, i32 0, i32 3
  %22 = load ptr, ptr %21, align 8, !tbaa !14
  %23 = load i64, ptr %3, align 8, !tbaa !9
  %24 = load i64, ptr %5, align 8, !tbaa !9
  %25 = getelementptr inbounds %"class.meshloader::GlobalCellsNumerator", ptr %6, i32 0, i32 2
  %26 = load ptr, ptr %25, align 8, !tbaa !15
  %27 = load i64, ptr %3, align 8, !tbaa !9
  %28 = load i64, ptr %5, align 8, !tbaa !9
  %29 = call noundef i64 @_ZNK10meshloader10NumsMatrix8getValueEmm(ptr noundef nonnull align 8 dereferenceable(40) %26, i64 noundef %27, i64 noundef %28)
  call void @_ZN10meshloader10NumsMatrix8setValueEmmm(ptr noundef nonnull align 8 dereferenceable(40) %22, i64 noundef %23, i64 noundef %24, i64 noundef %29)
  br label %30

30:                                               ; preds = %20
  %31 = load i64, ptr %5, align 8, !tbaa !9
  %32 = add i64 %31, 1
  store i64 %32, ptr %5, align 8, !tbaa !9
  br label %14, !llvm.loop !16

33:                                               ; preds = %19
  br label %34

34:                                               ; preds = %33
  %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 %7, !llvm.loop !18

37:                                               ; preds = %12
  ret void
}

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

declare noundef i64 @_ZNK10meshloader10NumsMatrix8getValueEmm(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 32}
!12 = !{!"_ZTSN10meshloader20GlobalCellsNumeratorE", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !10, i64 32, !10, i64 40}
!13 = !{!12, !10, i64 40}
!14 = !{!12, !6, i64 24}
!15 = !{!12, !6, i64 16}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}
!18 = distinct !{!18, !17}


; 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 @_ZN10meshloader20GlobalCellsNumerator18insertInteriorNumsEv(ptr nocapture noundef nonnull readonly align 8 dereferenceable(48) %0) local_unnamed_addr #0 align 2 {
  %2 = getelementptr inbounds i8, ptr %0, i64 32
  %3 = load i64, ptr %2, align 8, !tbaa !5
  %.not = icmp eq i64 %3, 0
  br i1 %.not, label %._crit_edge11, label %.preheader.lr.ph

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

.preheader:                                       ; preds = %.preheader.lr.ph, %._crit_edge
  %8 = phi i64 [ %10, %._crit_edge ], [ %3, %.preheader.lr.ph ]
  %9 = phi i64 [ %11, %._crit_edge ], [ 1, %.preheader.lr.ph ]
  %.0810 = phi i64 [ %12, %._crit_edge ], [ 0, %.preheader.lr.ph ]
  %.not13 = icmp eq i64 %9, 0
  br i1 %.not13, label %._crit_edge, label %.lr.ph

._crit_edge11:                                    ; preds = %._crit_edge, %.preheader.lr.ph, %1
  ret void

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

._crit_edge:                                      ; preds = %._crit_edge.loopexit, %.preheader
  %10 = phi i64 [ %.pre, %._crit_edge.loopexit ], [ %8, %.preheader ]
  %11 = phi i64 [ %18, %._crit_edge.loopexit ], [ 0, %.preheader ]
  %12 = add nuw i64 %.0810, 1
  %13 = icmp ult i64 %12, %10
  br i1 %13, label %.preheader, label %._crit_edge11, !llvm.loop !12

.lr.ph:                                           ; preds = %.preheader, %.lr.ph
  %.09 = phi i64 [ %17, %.lr.ph ], [ 0, %.preheader ]
  %14 = load ptr, ptr %5, align 8, !tbaa !15
  %15 = load ptr, ptr %6, align 8, !tbaa !16
  %16 = tail call noundef i64 @_ZNK10meshloader10NumsMatrix8getValueEmm(ptr noundef nonnull align 8 dereferenceable(40) %15, i64 noundef %.0810, i64 noundef %.09)
  tail call void @_ZN10meshloader10NumsMatrix8setValueEmmm(ptr noundef nonnull align 8 dereferenceable(40) %14, i64 noundef %.0810, i64 noundef %.09, i64 noundef %16)
  %17 = add nuw i64 %.09, 1
  %18 = load i64, ptr %4, align 8, !tbaa !11
  %19 = icmp ult i64 %17, %18
  br i1 %19, label %.lr.ph, label %._crit_edge.loopexit, !llvm.loop !17
}

declare noundef i64 @_ZNK10meshloader10NumsMatrix8getValueEmm(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 32}
!6 = !{!"_ZTSN10meshloader20GlobalCellsNumeratorE", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !10, i64 32, !10, i64 40}
!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 40}
!12 = distinct !{!12, !13, !14}
!13 = !{!"llvm.loop.mustprogress"}
!14 = !{!"llvm.loop.unswitch.partial.disable"}
!15 = !{!6, !7, i64 24}
!16 = !{!6, !7, i64 16}
!17 = distinct !{!17, !13}


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