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

; 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_base" = type <{ %"class.voro::voro_base", %"class.voro::wall_list.base", [4 x i8], double, double, double, double, double, double, i8, i8, i8, [5 x i8], ptr, ptr, ptr, ptr, i32, [4 x i8] }>
%"class.voro::voro_base" = type { i32, i32, i32, i32, i32, double, double, double, double, double, double, ptr }
%"class.voro::wall_list.base" = type <{ ptr, ptr, ptr, i32 }>
%"class.voro::radius_poly" = type { ptr, double, double, double, double }

; 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 @_ZN4voro14container_poly5clearEv(ptr noundef nonnull align 8 dereferenceable(408) %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_base", ptr %4, i32 0, i32 15
  %6 = load ptr, ptr %5, align 8, !tbaa !9
  store ptr %6, ptr %3, align 8, !tbaa !5
  br label %7

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

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

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

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

22:                                               ; preds = %16
  %23 = getelementptr inbounds i8, ptr %4, i64 208
  %24 = getelementptr inbounds %"class.voro::radius_poly", ptr %23, i32 0, i32 1
  store double 0.000000e+00, ptr %24, align 8, !tbaa !20
  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 184}
!10 = !{!"_ZTSN4voro14container_baseE", !11, i64 0, !14, i64 80, !13, i64 112, !13, i64 120, !13, i64 128, !13, i64 136, !13, i64 144, !13, i64 152, !15, i64 160, !15, i64 161, !15, i64 162, !6, i64 168, !6, i64 176, !6, i64 184, !6, i64 192, !12, i64 200}
!11 = !{!"_ZTSN4voro9voro_baseE", !12, i64 0, !12, i64 4, !12, i64 8, !12, i64 12, !12, i64 16, !13, i64 24, !13, i64 32, !13, i64 40, !13, i64 48, !13, i64 56, !13, i64 64, !6, i64 72}
!12 = !{!"int", !7, i64 0}
!13 = !{!"double", !7, i64 0}
!14 = !{!"_ZTSN4voro9wall_listE", !6, i64 0, !6, i64 8, !6, i64 16, !12, i64 24}
!15 = !{!"bool", !7, i64 0}
!16 = !{!11, !12, i64 16}
!17 = !{!12, !12, i64 0}
!18 = distinct !{!18, !19}
!19 = !{!"llvm.loop.mustprogress"}
!20 = !{!21, !13, i64 8}
!21 = !{!"_ZTSN4voro11radius_polyE", !6, i64 0, !13, i64 8, !13, i64 16, !13, i64 24, !13, 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 nofree norecurse nosync nounwind memory(write, argmem: readwrite, inaccessiblemem: none) uwtable
define dso_local void @_ZN4voro14container_poly5clearEv(ptr nocapture noundef nonnull align 8 dereferenceable(408) %0) local_unnamed_addr #0 align 2 {
  %2 = getelementptr inbounds i8, ptr %0, i64 184
  %3 = load ptr, ptr %2, align 8, !tbaa !5
  %4 = getelementptr inbounds i8, ptr %0, i64 16
  %5 = load i32, ptr %4, align 8, !tbaa !15
  %6 = icmp sgt i32 %5, 0
  br i1 %6, label %.lr.ph, label %._crit_edge

._crit_edge:                                      ; preds = %.lr.ph, %1
  %7 = getelementptr inbounds i8, ptr %0, i64 216
  store double 0.000000e+00, ptr %7, align 8, !tbaa !16
  ret void

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

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, !12, i64 184}
!6 = !{!"_ZTSN4voro14container_baseE", !7, i64 0, !13, i64 80, !11, i64 112, !11, i64 120, !11, i64 128, !11, i64 136, !11, i64 144, !11, i64 152, !14, i64 160, !14, i64 161, !14, i64 162, !12, i64 168, !12, i64 176, !12, i64 184, !12, i64 192, !8, i64 200}
!7 = !{!"_ZTSN4voro9voro_baseE", !8, i64 0, !8, i64 4, !8, i64 8, !8, i64 12, !8, i64 16, !11, i64 24, !11, i64 32, !11, i64 40, !11, i64 48, !11, i64 56, !11, i64 64, !12, i64 72}
!8 = !{!"int", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C++ TBAA"}
!11 = !{!"double", !9, i64 0}
!12 = !{!"any pointer", !9, i64 0}
!13 = !{!"_ZTSN4voro9wall_listE", !12, i64 0, !12, i64 8, !12, i64 16, !8, i64 24}
!14 = !{!"bool", !9, i64 0}
!15 = !{!7, !8, i64 16}
!16 = !{!17, !11, i64 8}
!17 = !{!"_ZTSN4voro11radius_polyE", !12, i64 0, !11, i64 8, !11, i64 16, !11, i64 24, !11, i64 32}
!18 = !{!8, !8, i64 0}
!19 = distinct !{!19, !20}
!20 = !{!"llvm.loop.mustprogress"}


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