; LLVM IR from robotics-upo/Heuristic_path_planners :: include/voro++-0.4.6/src/container_prd.ll (ZN4voro18container_periodic5clearEv)

; 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.voro::container_periodic_base" = type { %"class.voro::unitcell", %"class.voro::voro_base", i32, i32, i32, i32, i32, i32, i32, ptr, ptr, ptr, ptr, ptr, i32, i32 }
%"class.voro::unitcell" = type { double, double, double, double, double, double, %"class.voro::voronoicell", double, double }
%"class.voro::voronoicell" = type { %"class.voro::voronoicell_base" }
%"class.voro::voronoicell_base" = type { ptr, i32, i32, i32, i32, i32, i32, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, i32, i32, ptr, double, double, double, double }
%"class.voro::voro_base" = type { i32, i32, i32, i32, i32, double, double, double, double, double, double, ptr }

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

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN4voro18container_periodic5clearEv(ptr noundef nonnull align 8 dereferenceable(544) %0) #1 align 2 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  %4 = load ptr, ptr %2, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #2
  %5 = getelementptr inbounds %"class.voro::container_periodic_base", ptr %4, i32 0, i32 11
  %6 = load ptr, ptr %5, align 8, !tbaa !9
  store ptr %6, ptr %3, align 8, !tbaa !5
  br label %7

7:                                                ; preds = %20, %1
  %8 = load ptr, ptr %3, align 8, !tbaa !5
  %9 = getelementptr inbounds %"class.voro::container_periodic_base", ptr %4, i32 0, i32 11
  %10 = load ptr, ptr %9, align 8, !tbaa !9
  %11 = getelementptr inbounds i8, ptr %4, i64 224
  %12 = getelementptr inbounds %"class.voro::voro_base", ptr %11, i32 0, i32 4
  %13 = load i32, ptr %12, align 8, !tbaa !17
  %14 = sext i32 %13 to i64
  %15 = getelementptr inbounds i32, ptr %10, i64 %14
  %16 = icmp ult ptr %8, %15
  br i1 %16, label %18, label %17

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

18:                                               ; preds = %7
  %19 = load ptr, ptr %3, align 8, !tbaa !5
  store i32 0, ptr %19, align 4, !tbaa !18
  br label %20

20:                                               ; preds = %18
  %21 = load ptr, ptr %3, align 8, !tbaa !5
  %22 = getelementptr inbounds i32, ptr %21, i32 1
  store ptr %22, ptr %3, align 8, !tbaa !5
  br label %7, !llvm.loop !19

23:                                               ; preds = %17
  ret void
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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, !6, i64 352}
!10 = !{!"_ZTSN4voro23container_periodic_baseE", !11, i64 0, !16, i64 224, !15, i64 304, !15, i64 308, !15, i64 312, !15, i64 316, !15, i64 320, !15, i64 324, !15, i64 328, !6, i64 336, !6, i64 344, !6, i64 352, !6, i64 360, !6, i64 368, !15, i64 376, !15, i64 380}
!11 = !{!"_ZTSN4voro8unitcellE", !12, i64 0, !12, i64 8, !12, i64 16, !12, i64 24, !12, i64 32, !12, i64 40, !13, i64 48, !12, i64 208, !12, i64 216}
!12 = !{!"double", !7, i64 0}
!13 = !{!"_ZTSN4voro11voronoicellE", !14, i64 0}
!14 = !{!"_ZTSN4voro16voronoicell_baseE", !15, i64 8, !15, i64 12, !15, i64 16, !15, i64 20, !15, i64 24, !15, i64 28, !6, i64 32, !6, i64 40, !6, i64 48, !6, i64 56, !6, i64 64, !6, i64 72, !6, i64 80, !6, i64 88, !6, i64 96, !6, i64 104, !15, i64 112, !15, i64 116, !6, i64 120, !12, i64 128, !12, i64 136, !12, i64 144, !12, i64 152}
!15 = !{!"int", !7, i64 0}
!16 = !{!"_ZTSN4voro9voro_baseE", !15, i64 0, !15, i64 4, !15, i64 8, !15, i64 12, !15, i64 16, !12, i64 24, !12, i64 32, !12, i64 40, !12, i64 48, !12, i64 56, !12, i64 64, !6, i64 72}
!17 = !{!16, !15, i64 16}
!18 = !{!15, !15, 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 nofree norecurse nosync nounwind memory(write, argmem: readwrite, inaccessiblemem: none) uwtable
define dso_local void @_ZN4voro18container_periodic5clearEv(ptr nocapture noundef nonnull readonly align 8 dereferenceable(544) %0) local_unnamed_addr #0 align 2 {
  %2 = getelementptr inbounds i8, ptr %0, i64 352
  %3 = load ptr, ptr %2, align 8, !tbaa !5
  %4 = getelementptr inbounds i8, ptr %0, i64 240
  %5 = load i32, ptr %4, align 8, !tbaa !16
  %6 = icmp sgt i32 %5, 0
  br i1 %6, label %.lr.ph, label %._crit_edge

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

.lr.ph:                                           ; preds = %1, %.lr.ph
  %.04 = phi ptr [ %7, %.lr.ph ], [ %3, %1 ]
  store i32 0, ptr %.04, align 4, !tbaa !17
  %7 = getelementptr inbounds i8, ptr %.04, i64 4
  %8 = load i32, ptr %4, align 8, !tbaa !16
  %9 = sext i32 %8 to i64
  %10 = getelementptr inbounds i32, ptr %3, i64 %9
  %11 = icmp ult ptr %7, %10
  br i1 %11, label %.lr.ph, label %._crit_edge, !llvm.loop !18
}

attributes #0 = { mustprogress nofree norecurse nosync nounwind memory(write, argmem: readwrite, inaccessiblemem: none) 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, !14, i64 352}
!6 = !{!"_ZTSN4voro23container_periodic_baseE", !7, i64 0, !15, i64 224, !13, i64 304, !13, i64 308, !13, i64 312, !13, i64 316, !13, i64 320, !13, i64 324, !13, i64 328, !14, i64 336, !14, i64 344, !14, i64 352, !14, i64 360, !14, i64 368, !13, i64 376, !13, i64 380}
!7 = !{!"_ZTSN4voro8unitcellE", !8, i64 0, !8, i64 8, !8, i64 16, !8, i64 24, !8, i64 32, !8, i64 40, !11, i64 48, !8, i64 208, !8, i64 216}
!8 = !{!"double", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C++ TBAA"}
!11 = !{!"_ZTSN4voro11voronoicellE", !12, i64 0}
!12 = !{!"_ZTSN4voro16voronoicell_baseE", !13, i64 8, !13, i64 12, !13, i64 16, !13, i64 20, !13, i64 24, !13, i64 28, !14, i64 32, !14, i64 40, !14, i64 48, !14, i64 56, !14, i64 64, !14, i64 72, !14, i64 80, !14, i64 88, !14, i64 96, !14, i64 104, !13, i64 112, !13, i64 116, !14, i64 120, !8, i64 128, !8, i64 136, !8, i64 144, !8, i64 152}
!13 = !{!"int", !9, i64 0}
!14 = !{!"any pointer", !9, i64 0}
!15 = !{!"_ZTSN4voro9voro_baseE", !13, i64 0, !13, i64 4, !13, i64 8, !13, i64 12, !13, i64 16, !8, i64 24, !8, i64 32, !8, i64 40, !8, i64 48, !8, i64 56, !8, i64 64, !14, i64 72}
!16 = !{!15, !13, i64 16}
!17 = !{!13, !13, i64 0}
!18 = distinct !{!18, !19}
!19 = !{!"llvm.loop.mustprogress"}


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