; LLVM IR from artvns/SimpleFvm :: simplefvm/src/MeshLoader/StaggeredMeshPart/CellsInteriorNumbering/AbstractCellsI_9fd50d6a (ZN10meshloader30AbstractCellsInteriorNumbering11numberCellsEv)

; 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::AbstractCellsInteriorNumbering" = type { ptr, ptr, ptr, %"class.std::vector" }
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<unsigned long, std::allocator<unsigned long>>::_Vector_impl" }
%"struct.std::_Vector_base<unsigned long, std::allocator<unsigned long>>::_Vector_impl" = type { %"struct.std::_Vector_base<unsigned long, std::allocator<unsigned long>>::_Vector_impl_data" }
%"struct.std::_Vector_base<unsigned long, std::allocator<unsigned long>>::_Vector_impl_data" = type { ptr, ptr, ptr }

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN10meshloader30AbstractCellsInteriorNumbering11numberCellsEv(ptr noundef nonnull align 8 dereferenceable(48) %0) #0 align 2 {
  %2 = alloca ptr, align 8
  %3 = alloca i64, align 8
  %4 = alloca i64, align 8
  %5 = alloca i64, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  %6 = load ptr, ptr %2, align 8
  call void @_ZN10meshloader30AbstractCellsInteriorNumbering11combineNumsEv(ptr noundef nonnull align 8 dereferenceable(48) %6)
  %7 = getelementptr inbounds %"class.meshloader::AbstractCellsInteriorNumbering", ptr %6, i32 0, i32 3
  call void @_ZN10meshloader30AbstractCellsInteriorNumbering10sortVectorERSt6vectorImSaImEE(ptr noundef nonnull align 8 dereferenceable(48) %6, ptr noundef nonnull align 8 dereferenceable(24) %7)
  %8 = getelementptr inbounds %"class.meshloader::AbstractCellsInteriorNumbering", ptr %6, i32 0, i32 3
  call void @_ZN10meshloader30AbstractCellsInteriorNumbering22removeDuplicatedValuesERSt6vectorImSaImEE(ptr noundef nonnull align 8 dereferenceable(48) %6, ptr noundef nonnull align 8 dereferenceable(24) %8)
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #4
  store i64 0, ptr %3, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #4
  store i64 0, ptr %4, align 8, !tbaa !9
  br label %9

9:                                                ; preds = %35, %1
  %10 = load i64, ptr %4, align 8, !tbaa !9
  %11 = getelementptr inbounds %"class.meshloader::AbstractCellsInteriorNumbering", ptr %6, i32 0, i32 3
  %12 = call noundef i64 @_ZNKSt6vectorImSaImEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %11) #4
  %13 = icmp ult i64 %10, %12
  br i1 %13, label %15, label %14

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

15:                                               ; preds = %9
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #4
  %16 = getelementptr inbounds %"class.meshloader::AbstractCellsInteriorNumbering", ptr %6, i32 0, i32 3
  %17 = load i64, ptr %4, align 8, !tbaa !9
  %18 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorImSaImEE2atEm(ptr noundef nonnull align 8 dereferenceable(24) %16, i64 noundef %17)
  %19 = load i64, ptr %18, align 8, !tbaa !9
  store i64 %19, ptr %5, align 8, !tbaa !9
  %20 = getelementptr inbounds %"class.meshloader::AbstractCellsInteriorNumbering", ptr %6, i32 0, i32 1
  %21 = load ptr, ptr %20, align 8, !tbaa !11
  %22 = load i64, ptr %5, align 8, !tbaa !9
  %23 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZN10meshloader4Mesh7getCellEm(ptr noundef nonnull align 8 dereferenceable(49) %21, i64 noundef %22)
  %24 = call noundef ptr @_ZNKSt10unique_ptrIN10meshloader9MacroCellESt14default_deleteIS1_EEptEv(ptr noundef nonnull align 8 dereferenceable(8) %23) #4
  %25 = call noundef zeroext i1 @_ZN10meshloader9MacroCell11isGhostCellEv(ptr noundef nonnull align 8 dereferenceable(169) %24)
  br i1 %25, label %34, label %26

26:                                               ; preds = %15
  %27 = load i64, ptr %3, align 8, !tbaa !9
  %28 = add i64 %27, 1
  store i64 %28, ptr %3, align 8, !tbaa !9
  %29 = load i64, ptr %5, align 8, !tbaa !9
  %30 = load i64, ptr %3, align 8, !tbaa !9
  %31 = load ptr, ptr %6, align 8, !tbaa !17
  %32 = getelementptr inbounds ptr, ptr %31, i64 2
  %33 = load ptr, ptr %32, align 8
  call void %33(ptr noundef nonnull align 8 dereferenceable(48) %6, i64 noundef %29, i64 noundef %30)
  br label %34

34:                                               ; preds = %26, %15
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #4
  br label %35

35:                                               ; preds = %34
  %36 = load i64, ptr %4, align 8, !tbaa !9
  %37 = add i64 %36, 1
  store i64 %37, ptr %4, align 8, !tbaa !9
  br label %9, !llvm.loop !19

38:                                               ; preds = %14
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #4
  ret void
}

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

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

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZNKSt6vectorImSaImEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24)) #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) #0 align 2

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

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

declare noundef zeroext i1 @_ZN10meshloader9MacroCell11isGhostCellEv(ptr noundef nonnull align 8 dereferenceable(169)) #3

; 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 = { 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 = { "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 8}
!12 = !{!"_ZTSN10meshloader30AbstractCellsInteriorNumberingE", !6, i64 8, !6, i64 16, !13, i64 24}
!13 = !{!"_ZTSSt6vectorImSaImEE", !14, i64 0}
!14 = !{!"_ZTSSt12_Vector_baseImSaImEE", !15, i64 0}
!15 = !{!"_ZTSNSt12_Vector_baseImSaImEE12_Vector_implE", !16, i64 0}
!16 = !{!"_ZTSNSt12_Vector_baseImSaImEE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!17 = !{!18, !18, i64 0}
!18 = !{!"vtable pointer", !8, i64 0}
!19 = distinct !{!19, !20}
!20 = !{!"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 @_ZN10meshloader30AbstractCellsInteriorNumbering11numberCellsEv(ptr noundef nonnull align 8 dereferenceable(48) %0) local_unnamed_addr #0 align 2 {
  tail call void @_ZN10meshloader30AbstractCellsInteriorNumbering11combineNumsEv(ptr noundef nonnull align 8 dereferenceable(48) %0)
  %2 = getelementptr inbounds i8, ptr %0, i64 24
  tail call void @_ZN10meshloader30AbstractCellsInteriorNumbering10sortVectorERSt6vectorImSaImEE(ptr noundef nonnull align 8 dereferenceable(48) %0, ptr noundef nonnull align 8 dereferenceable(24) %2)
  tail call void @_ZN10meshloader30AbstractCellsInteriorNumbering22removeDuplicatedValuesERSt6vectorImSaImEE(ptr noundef nonnull align 8 dereferenceable(48) %0, ptr noundef nonnull align 8 dereferenceable(24) %2)
  %3 = tail call noundef i64 @_ZNKSt6vectorImSaImEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %2) #3
  %.not = icmp eq i64 %3, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %1
  %4 = getelementptr inbounds i8, ptr %0, i64 8
  br label %5

._crit_edge:                                      ; preds = %17, %1
  ret void

5:                                                ; preds = %.lr.ph, %17
  %.09 = phi i64 [ 0, %.lr.ph ], [ %.1, %17 ]
  %.078 = phi i64 [ 0, %.lr.ph ], [ %18, %17 ]
  %6 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorImSaImEE2atEm(ptr noundef nonnull align 8 dereferenceable(24) %2, i64 noundef %.078)
  %7 = load i64, ptr %6, align 8, !tbaa !5
  %8 = load ptr, ptr %4, align 8, !tbaa !9
  %9 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZN10meshloader4Mesh7getCellEm(ptr noundef nonnull align 8 dereferenceable(49) %8, i64 noundef %7)
  %10 = tail call noundef ptr @_ZNKSt10unique_ptrIN10meshloader9MacroCellESt14default_deleteIS1_EEptEv(ptr noundef nonnull align 8 dereferenceable(8) %9) #3
  %11 = tail call noundef zeroext i1 @_ZN10meshloader9MacroCell11isGhostCellEv(ptr noundef nonnull align 8 dereferenceable(169) %10)
  br i1 %11, label %17, label %12

12:                                               ; preds = %5
  %13 = add i64 %.09, 1
  %14 = load ptr, ptr %0, align 8, !tbaa !16
  %15 = getelementptr inbounds i8, ptr %14, i64 16
  %16 = load ptr, ptr %15, align 8
  tail call void %16(ptr noundef nonnull align 8 dereferenceable(48) %0, i64 noundef %7, i64 noundef %13)
  br label %17

17:                                               ; preds = %12, %5
  %.1 = phi i64 [ %.09, %5 ], [ %13, %12 ]
  %18 = add nuw i64 %.078, 1
  %19 = tail call noundef i64 @_ZNKSt6vectorImSaImEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %2) #3
  %20 = icmp ult i64 %18, %19
  br i1 %20, label %5, label %._crit_edge, !llvm.loop !18
}

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

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZNKSt6vectorImSaImEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #1 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 #2

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

declare noundef zeroext i1 @_ZN10meshloader9MacroCell11isGhostCellEv(ptr noundef nonnull align 8 dereferenceable(169)) local_unnamed_addr #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 = { 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 #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 = !{!"long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !11, i64 8}
!10 = !{!"_ZTSN10meshloader30AbstractCellsInteriorNumberingE", !11, i64 8, !11, i64 16, !12, i64 24}
!11 = !{!"any pointer", !7, i64 0}
!12 = !{!"_ZTSSt6vectorImSaImEE", !13, i64 0}
!13 = !{!"_ZTSSt12_Vector_baseImSaImEE", !14, i64 0}
!14 = !{!"_ZTSNSt12_Vector_baseImSaImEE12_Vector_implE", !15, i64 0}
!15 = !{!"_ZTSNSt12_Vector_baseImSaImEE17_Vector_impl_dataE", !11, i64 0, !11, i64 8, !11, i64 16}
!16 = !{!17, !17, i64 0}
!17 = !{!"vtable pointer", !8, i64 0}
!18 = distinct !{!18, !19}
!19 = !{!"llvm.loop.mustprogress"}


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