; LLVM IR from artvns/SimpleFvm :: simplefvm/src/MeshLoader/SolverDataPackers/CellNumsPacker (NumsPackerU)

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

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

12:                                               ; preds = %44, %4
  %13 = load i64, ptr %9, align 8, !tbaa !9
  %14 = load i64, ptr %7, align 8, !tbaa !9
  %15 = icmp ult i64 %13, %14
  br i1 %15, label %17, label %16

16:                                               ; preds = %12
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #4
  br label %47

17:                                               ; preds = %12
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #4
  %18 = getelementptr inbounds %"class.meshloader::AbstractNumsPacker", ptr %11, i32 0, i32 3
  %19 = load ptr, ptr %18, align 8, !tbaa !11
  %20 = call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(32) %1, i64 noundef 0)
  %21 = load i8, ptr %20, align 1, !tbaa !13
  %22 = call noundef nonnull align 8 dereferenceable(24) ptr @_ZN10meshloader8NumsSets10getNumsSetEc(ptr noundef nonnull align 8 dereferenceable(80) %19, i8 noundef signext %21)
  %23 = load i64, ptr %9, align 8, !tbaa !9
  %24 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorImSaImEE2atEm(ptr noundef nonnull align 8 dereferenceable(24) %22, i64 noundef %23)
  %25 = load i64, ptr %24, align 8, !tbaa !9
  store i64 %25, ptr %10, align 8, !tbaa !9
  %26 = load ptr, ptr %8, align 8, !tbaa !5
  %27 = load i64, ptr %9, align 8, !tbaa !9
  %28 = getelementptr inbounds %"class.meshloader::AbstractNumsPacker", ptr %11, i32 0, i32 2
  %29 = load ptr, ptr %28, align 8, !tbaa !14
  %30 = load i64, ptr %10, align 8, !tbaa !9
  %31 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZN10meshloader4Mesh7getCellEm(ptr noundef nonnull align 8 dereferenceable(49) %29, i64 noundef %30)
  %32 = call noundef ptr @_ZNKSt10unique_ptrIN10meshloader9MacroCellESt14default_deleteIS1_EEptEv(ptr noundef nonnull align 8 dereferenceable(8) %31) #4
  %33 = call noundef nonnull align 8 dereferenceable(40) ptr @_ZN10meshloader9MacroCell8getCellPEv(ptr noundef nonnull align 8 dereferenceable(169) %32)
  %34 = call noundef i64 @_ZNK10meshloader4Cell14getInteriorNumEv(ptr noundef nonnull align 8 dereferenceable(40) %33)
  call void @_ZN10meshloader24AdjCellInteriorNumsUMask9set_numPpEmm(ptr noundef nonnull align 8 dereferenceable(8) %26, i64 noundef %27, i64 noundef %34)
  %35 = load ptr, ptr %8, align 8, !tbaa !5
  %36 = load i64, ptr %9, align 8, !tbaa !9
  %37 = getelementptr inbounds %"class.meshloader::AbstractNumsPacker", ptr %11, i32 0, i32 2
  %38 = load ptr, ptr %37, align 8, !tbaa !14
  %39 = load i64, ptr %10, align 8, !tbaa !9
  %40 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZN10meshloader4Mesh11getAdjCellWEm(ptr noundef nonnull align 8 dereferenceable(49) %38, i64 noundef %39)
  %41 = call noundef ptr @_ZNKSt10unique_ptrIN10meshloader9MacroCellESt14default_deleteIS1_EEptEv(ptr noundef nonnull align 8 dereferenceable(8) %40) #4
  %42 = call noundef nonnull align 8 dereferenceable(40) ptr @_ZN10meshloader9MacroCell8getCellPEv(ptr noundef nonnull align 8 dereferenceable(169) %41)
  %43 = call noundef i64 @_ZNK10meshloader4Cell14getInteriorNumEv(ptr noundef nonnull align 8 dereferenceable(40) %42)
  call void @_ZN10meshloader24AdjCellInteriorNumsUMask9set_numPwEmm(ptr noundef nonnull align 8 dereferenceable(8) %35, i64 noundef %36, i64 noundef %43)
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #4
  br label %44

44:                                               ; preds = %17
  %45 = load i64, ptr %9, align 8, !tbaa !9
  %46 = add i64 %45, 1
  store i64 %46, ptr %9, align 8, !tbaa !9
  br label %12, !llvm.loop !15

47:                                               ; preds = %16
  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 nonnull align 8 dereferenceable(24) ptr @_ZN10meshloader8NumsSets10getNumsSetEc(ptr noundef nonnull align 8 dereferenceable(80), i8 noundef signext) #2

; Function Attrs: mustprogress nounwind uwtable
declare noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(32), i64 noundef) #3 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorImSaImEE2atEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) #0 align 2

declare noundef nonnull align 8 dereferenceable(8) ptr @_ZN10meshloader4Mesh7getCellEm(ptr noundef nonnull align 8 dereferenceable(49), i64 noundef) #2

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

declare noundef i64 @_ZNK10meshloader4Cell14getInteriorNumEv(ptr noundef nonnull align 8 dereferenceable(40)) #2

declare noundef nonnull align 8 dereferenceable(8) ptr @_ZN10meshloader4Mesh11getAdjCellWEm(ptr noundef nonnull align 8 dereferenceable(49), i64 noundef) #2

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

declare noundef nonnull align 8 dereferenceable(40) ptr @_ZN10meshloader9MacroCell8getCellPEv(ptr noundef nonnull align 8 dereferenceable(169)) #2

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

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

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 = { 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 = { 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, !6, i64 24}
!12 = !{!"_ZTSN10meshloader18AbstractNumsPackerE", !6, i64 8, !6, i64 16, !6, i64 24}
!13 = !{!7, !7, i64 0}
!14 = !{!12, !6, i64 16}
!15 = distinct !{!15, !16}
!16 = !{!"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"

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN10meshloader11NumsPackerU22packAdjCellInteriorNumENSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEmRNS_24AdjCellInteriorNumsUMaskE(ptr nocapture noundef nonnull readonly align 8 dereferenceable(32) %0, ptr noundef %1, i64 noundef %2, ptr noundef nonnull align 8 dereferenceable(8) %3) local_unnamed_addr #0 align 2 {
  %.not = icmp eq i64 %2, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %4
  %5 = getelementptr inbounds i8, ptr %0, i64 24
  %6 = getelementptr inbounds i8, ptr %0, i64 16
  br label %7

._crit_edge:                                      ; preds = %7, %4
  ret void

7:                                                ; preds = %.lr.ph, %7
  %.010 = phi i64 [ 0, %.lr.ph ], [ %24, %7 ]
  %8 = load ptr, ptr %5, align 8, !tbaa !5
  %9 = tail call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(32) %1, i64 noundef 0)
  %10 = load i8, ptr %9, align 1, !tbaa !10
  %11 = tail call noundef nonnull align 8 dereferenceable(24) ptr @_ZN10meshloader8NumsSets10getNumsSetEc(ptr noundef nonnull align 8 dereferenceable(80) %8, i8 noundef signext %10)
  %12 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorImSaImEE2atEm(ptr noundef nonnull align 8 dereferenceable(24) %11, i64 noundef %.010)
  %13 = load i64, ptr %12, align 8, !tbaa !11
  %14 = load ptr, ptr %6, align 8, !tbaa !13
  %15 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZN10meshloader4Mesh7getCellEm(ptr noundef nonnull align 8 dereferenceable(49) %14, i64 noundef %13)
  %16 = tail call noundef ptr @_ZNKSt10unique_ptrIN10meshloader9MacroCellESt14default_deleteIS1_EEptEv(ptr noundef nonnull align 8 dereferenceable(8) %15) #3
  %17 = tail call noundef nonnull align 8 dereferenceable(40) ptr @_ZN10meshloader9MacroCell8getCellPEv(ptr noundef nonnull align 8 dereferenceable(169) %16)
  %18 = tail call noundef i64 @_ZNK10meshloader4Cell14getInteriorNumEv(ptr noundef nonnull align 8 dereferenceable(40) %17)
  tail call void @_ZN10meshloader24AdjCellInteriorNumsUMask9set_numPpEmm(ptr noundef nonnull align 8 dereferenceable(8) %3, i64 noundef %.010, i64 noundef %18)
  %19 = load ptr, ptr %6, align 8, !tbaa !13
  %20 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZN10meshloader4Mesh11getAdjCellWEm(ptr noundef nonnull align 8 dereferenceable(49) %19, i64 noundef %13)
  %21 = tail call noundef ptr @_ZNKSt10unique_ptrIN10meshloader9MacroCellESt14default_deleteIS1_EEptEv(ptr noundef nonnull align 8 dereferenceable(8) %20) #3
  %22 = tail call noundef nonnull align 8 dereferenceable(40) ptr @_ZN10meshloader9MacroCell8getCellPEv(ptr noundef nonnull align 8 dereferenceable(169) %21)
  %23 = tail call noundef i64 @_ZNK10meshloader4Cell14getInteriorNumEv(ptr noundef nonnull align 8 dereferenceable(40) %22)
  tail call void @_ZN10meshloader24AdjCellInteriorNumsUMask9set_numPwEmm(ptr noundef nonnull align 8 dereferenceable(8) %3, i64 noundef %.010, i64 noundef %23)
  %24 = add nuw i64 %.010, 1
  %exitcond.not = icmp eq i64 %24, %2
  br i1 %exitcond.not, label %._crit_edge, label %7, !llvm.loop !14
}

declare noundef nonnull align 8 dereferenceable(24) ptr @_ZN10meshloader8NumsSets10getNumsSetEc(ptr noundef nonnull align 8 dereferenceable(80), i8 noundef signext) local_unnamed_addr #1

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorImSaImEE2atEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) local_unnamed_addr #0 align 2

declare noundef nonnull align 8 dereferenceable(8) ptr @_ZN10meshloader4Mesh7getCellEm(ptr noundef nonnull align 8 dereferenceable(49), i64 noundef) local_unnamed_addr #1

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

declare noundef i64 @_ZNK10meshloader4Cell14getInteriorNumEv(ptr noundef nonnull align 8 dereferenceable(40)) local_unnamed_addr #1

declare noundef nonnull align 8 dereferenceable(8) ptr @_ZN10meshloader4Mesh11getAdjCellWEm(ptr noundef nonnull align 8 dereferenceable(49), i64 noundef) local_unnamed_addr #1

declare noundef nonnull align 8 dereferenceable(40) ptr @_ZN10meshloader9MacroCell8getCellPEv(ptr noundef nonnull align 8 dereferenceable(169)) local_unnamed_addr #1

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

declare void @_ZN10meshloader24AdjCellInteriorNumsUMask9set_numPwEmm(ptr noundef nonnull align 8 dereferenceable(8), 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" }
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 = { 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 24}
!6 = !{!"_ZTSN10meshloader18AbstractNumsPackerE", !7, i64 8, !7, i64 16, !7, i64 24}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!8, !8, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"long", !8, i64 0}
!13 = !{!6, !7, i64 16}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}


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