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

; 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::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::voronoicell_neighbor" = type { %"class.voro::voronoicell_base", ptr, ptr, ptr, ptr }

@_ZTVN4voro20voronoicell_neighborE = external dso_local unnamed_addr constant { [5 x ptr] }, align 8

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

declare i32 @__gxx_personality_v0(...)

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN4voro16voronoicell_baseC2Ev(ptr noundef nonnull align 8 dereferenceable(160)) unnamed_addr #1 align 2

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare { i64, i1 } @llvm.umul.with.overflow.i64(i64, i64) #2

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znam(i64 noundef) #3

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN4voro16voronoicell_baseD2Ev(ptr noundef nonnull align 8 dereferenceable(160)) unnamed_addr #4 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN4voro20voronoicell_neighborC2Ev(ptr noundef nonnull align 8 dereferenceable(192) %0) unnamed_addr #1 align 2 personality ptr @__gxx_personality_v0 {
  %2 = alloca ptr, align 8
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  %6 = load ptr, ptr %2, align 8
  call void @_ZN4voro16voronoicell_baseC2Ev(ptr noundef nonnull align 8 dereferenceable(160) %6)
  store ptr getelementptr inbounds inrange(-16, 24) ({ [5 x ptr] }, ptr @_ZTVN4voro20voronoicell_neighborE, i32 0, i32 0, i32 2), ptr %6, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #5
  %7 = getelementptr inbounds %"class.voro::voronoicell_base", ptr %6, i32 0, i32 2
  %8 = load i32, ptr %7, align 4, !tbaa !11
  %9 = sext i32 %8 to i64
  %10 = call { i64, i1 } @llvm.umul.with.overflow.i64(i64 %9, i64 8)
  %11 = extractvalue { i64, i1 } %10, 1
  %12 = extractvalue { i64, i1 } %10, 0
  %13 = select i1 %11, i64 -1, i64 %12
  %14 = invoke noalias noundef nonnull ptr @_Znam(i64 noundef %13) #6
          to label %15 unwind label %48

15:                                               ; preds = %1
  %16 = getelementptr inbounds %"class.voro::voronoicell_neighbor", ptr %6, i32 0, i32 1
  store ptr %14, ptr %16, align 8, !tbaa !15
  %17 = getelementptr inbounds %"class.voro::voronoicell_base", ptr %6, i32 0, i32 1
  %18 = load i32, ptr %17, align 8, !tbaa !17
  %19 = sext i32 %18 to i64
  %20 = call { i64, i1 } @llvm.umul.with.overflow.i64(i64 %19, i64 8)
  %21 = extractvalue { i64, i1 } %20, 1
  %22 = extractvalue { i64, i1 } %20, 0
  %23 = select i1 %21, i64 -1, i64 %22
  %24 = invoke noalias noundef nonnull ptr @_Znam(i64 noundef %23) #6
          to label %25 unwind label %48

25:                                               ; preds = %15
  %26 = getelementptr inbounds %"class.voro::voronoicell_neighbor", ptr %6, i32 0, i32 2
  store ptr %24, ptr %26, align 8, !tbaa !18
  store i32 0, ptr %3, align 4, !tbaa !19
  br label %27

27:                                               ; preds = %45, %25
  %28 = load i32, ptr %3, align 4, !tbaa !19
  %29 = icmp slt i32 %28, 3
  br i1 %29, label %30, label %52

30:                                               ; preds = %27
  %31 = load i32, ptr %3, align 4, !tbaa !19
  %32 = mul nsw i32 8, %31
  %33 = sext i32 %32 to i64
  %34 = call { i64, i1 } @llvm.umul.with.overflow.i64(i64 %33, i64 4)
  %35 = extractvalue { i64, i1 } %34, 1
  %36 = extractvalue { i64, i1 } %34, 0
  %37 = select i1 %35, i64 -1, i64 %36
  %38 = invoke noalias noundef nonnull ptr @_Znam(i64 noundef %37) #6
          to label %39 unwind label %48

39:                                               ; preds = %30
  %40 = getelementptr inbounds %"class.voro::voronoicell_neighbor", ptr %6, i32 0, i32 1
  %41 = load ptr, ptr %40, align 8, !tbaa !15
  %42 = load i32, ptr %3, align 4, !tbaa !19
  %43 = sext i32 %42 to i64
  %44 = getelementptr inbounds ptr, ptr %41, i64 %43
  store ptr %38, ptr %44, align 8, !tbaa !5
  br label %45

45:                                               ; preds = %39
  %46 = load i32, ptr %3, align 4, !tbaa !19
  %47 = add nsw i32 %46, 1
  store i32 %47, ptr %3, align 4, !tbaa !19
  br label %27, !llvm.loop !20

48:                                               ; preds = %63, %52, %30, %15, %1
  %49 = landingpad { ptr, i32 }
          cleanup
  %50 = extractvalue { ptr, i32 } %49, 0
  store ptr %50, ptr %4, align 8
  %51 = extractvalue { ptr, i32 } %49, 1
  store i32 %51, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #5
  call void @_ZN4voro16voronoicell_baseD2Ev(ptr noundef nonnull align 8 dereferenceable(160) %6) #5
  br label %82

52:                                               ; preds = %27
  %53 = invoke noalias noundef nonnull ptr @_Znam(i64 noundef 3072) #6
          to label %54 unwind label %48

54:                                               ; preds = %52
  %55 = getelementptr inbounds %"class.voro::voronoicell_neighbor", ptr %6, i32 0, i32 1
  %56 = load ptr, ptr %55, align 8, !tbaa !15
  %57 = getelementptr inbounds ptr, ptr %56, i64 3
  store ptr %53, ptr %57, align 8, !tbaa !5
  store i32 4, ptr %3, align 4, !tbaa !19
  br label %58

58:                                               ; preds = %78, %54
  %59 = load i32, ptr %3, align 4, !tbaa !19
  %60 = getelementptr inbounds %"class.voro::voronoicell_base", ptr %6, i32 0, i32 2
  %61 = load i32, ptr %60, align 4, !tbaa !11
  %62 = icmp slt i32 %59, %61
  br i1 %62, label %63, label %81

63:                                               ; preds = %58
  %64 = load i32, ptr %3, align 4, !tbaa !19
  %65 = mul nsw i32 8, %64
  %66 = sext i32 %65 to i64
  %67 = call { i64, i1 } @llvm.umul.with.overflow.i64(i64 %66, i64 4)
  %68 = extractvalue { i64, i1 } %67, 1
  %69 = extractvalue { i64, i1 } %67, 0
  %70 = select i1 %68, i64 -1, i64 %69
  %71 = invoke noalias noundef nonnull ptr @_Znam(i64 noundef %70) #6
          to label %72 unwind label %48

72:                                               ; preds = %63
  %73 = getelementptr inbounds %"class.voro::voronoicell_neighbor", ptr %6, i32 0, i32 1
  %74 = load ptr, ptr %73, align 8, !tbaa !15
  %75 = load i32, ptr %3, align 4, !tbaa !19
  %76 = sext i32 %75 to i64
  %77 = getelementptr inbounds ptr, ptr %74, i64 %76
  store ptr %71, ptr %77, align 8, !tbaa !5
  br label %78

78:                                               ; preds = %72
  %79 = load i32, ptr %3, align 4, !tbaa !19
  %80 = add nsw i32 %79, 1
  store i32 %80, ptr %3, align 4, !tbaa !19
  br label %58, !llvm.loop !22

81:                                               ; preds = %58
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #5
  ret void

82:                                               ; preds = %48
  %83 = load ptr, ptr %4, align 8
  %84 = load i32, ptr %5, align 4
  %85 = insertvalue { ptr, i32 } poison, ptr %83, 0
  %86 = insertvalue { ptr, i32 } %85, i32 %84, 1
  resume { ptr, i32 } %86
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #3 = { nobuiltin allocsize(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 = { 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 #5 = { nounwind }
attributes #6 = { builtin allocsize(0) }

!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 = !{!"vtable pointer", !8, i64 0}
!11 = !{!12, !13, i64 12}
!12 = !{!"_ZTSN4voro16voronoicell_baseE", !13, i64 8, !13, i64 12, !13, i64 16, !13, i64 20, !13, i64 24, !13, 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, !13, i64 112, !13, i64 116, !6, i64 120, !14, i64 128, !14, i64 136, !14, i64 144, !14, i64 152}
!13 = !{!"int", !7, i64 0}
!14 = !{!"double", !7, i64 0}
!15 = !{!16, !6, i64 160}
!16 = !{!"_ZTSN4voro20voronoicell_neighborE", !12, i64 0, !6, i64 160, !6, i64 168, !6, i64 176, !6, i64 184}
!17 = !{!12, !13, i64 8}
!18 = !{!16, !6, i64 168}
!19 = !{!13, !13, i64 0}
!20 = distinct !{!20, !21}
!21 = !{!"llvm.loop.mustprogress"}
!22 = distinct !{!22, !21}


; 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"

@_ZTVN4voro20voronoicell_neighborE = external dso_local unnamed_addr constant { [5 x ptr] }, align 8

declare i32 @__gxx_personality_v0(...)

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

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znam(i64 noundef) local_unnamed_addr #1

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN4voro20voronoicell_neighborC2Ev(ptr noundef nonnull align 8 dereferenceable(192) %0) unnamed_addr #0 align 2 personality ptr @__gxx_personality_v0 {
  tail call void @_ZN4voro16voronoicell_baseC2Ev(ptr noundef nonnull align 8 dereferenceable(160) %0)
  store ptr getelementptr inbounds inrange(-16, 24) (i8, ptr @_ZTVN4voro20voronoicell_neighborE, i64 16), ptr %0, align 8, !tbaa !5
  %2 = getelementptr inbounds i8, ptr %0, i64 12
  %3 = load i32, ptr %2, align 4, !tbaa !8
  %4 = sext i32 %3 to i64
  %5 = icmp slt i32 %3, 0
  %6 = shl nsw i64 %4, 3
  %7 = select i1 %5, i64 -1, i64 %6
  %8 = invoke noalias noundef nonnull ptr @_Znam(i64 noundef %7) #3
          to label %9 unwind label %.loopexit.split-lp.loopexit.split-lp

9:                                                ; preds = %1
  %10 = getelementptr inbounds i8, ptr %0, i64 160
  store ptr %8, ptr %10, align 8, !tbaa !14
  %11 = getelementptr inbounds i8, ptr %0, i64 8
  %12 = load i32, ptr %11, align 8, !tbaa !16
  %13 = sext i32 %12 to i64
  %14 = icmp slt i32 %12, 0
  %15 = shl nsw i64 %13, 3
  %16 = select i1 %14, i64 -1, i64 %15
  %17 = invoke noalias noundef nonnull ptr @_Znam(i64 noundef %16) #3
          to label %18 unwind label %.loopexit.split-lp.loopexit.split-lp

18:                                               ; preds = %9
  %19 = getelementptr inbounds i8, ptr %0, i64 168
  store ptr %17, ptr %19, align 8, !tbaa !17
  %20 = invoke noalias noundef nonnull ptr @_Znam(i64 noundef 0) #3
          to label %21 unwind label %.loopexit.split-lp.loopexit

21:                                               ; preds = %18
  store ptr %20, ptr %8, align 8, !tbaa !18
  %22 = invoke noalias noundef nonnull dereferenceable(32) ptr @_Znam(i64 noundef 32) #3
          to label %23 unwind label %.loopexit.split-lp.loopexit

23:                                               ; preds = %21
  %24 = getelementptr inbounds i8, ptr %8, i64 8
  store ptr %22, ptr %24, align 8, !tbaa !18
  %25 = invoke noalias noundef nonnull dereferenceable(64) ptr @_Znam(i64 noundef 64) #3
          to label %26 unwind label %.loopexit.split-lp.loopexit

26:                                               ; preds = %23
  %27 = getelementptr inbounds i8, ptr %8, i64 16
  store ptr %25, ptr %27, align 8, !tbaa !18
  %28 = invoke noalias noundef nonnull dereferenceable(3072) ptr @_Znam(i64 noundef 3072) #3
          to label %29 unwind label %.loopexit.split-lp.loopexit.split-lp

.loopexit:                                        ; preds = %.lr.ph
  %lpad.loopexit = landingpad { ptr, i32 }
          cleanup
  br label %.loopexit.split-lp

.loopexit.split-lp.loopexit:                      ; preds = %23, %21, %18
  %lpad.loopexit10 = landingpad { ptr, i32 }
          cleanup
  br label %.loopexit.split-lp

.loopexit.split-lp.loopexit.split-lp:             ; preds = %26, %9, %1
  %lpad.loopexit.split-lp11 = landingpad { ptr, i32 }
          cleanup
  br label %.loopexit.split-lp

.loopexit.split-lp:                               ; preds = %.loopexit.split-lp.loopexit, %.loopexit.split-lp.loopexit.split-lp, %.loopexit
  %lpad.phi = phi { ptr, i32 } [ %lpad.loopexit, %.loopexit ], [ %lpad.loopexit10, %.loopexit.split-lp.loopexit ], [ %lpad.loopexit.split-lp11, %.loopexit.split-lp.loopexit.split-lp ]
  tail call void @_ZN4voro16voronoicell_baseD2Ev(ptr noundef nonnull align 8 dereferenceable(160) %0) #4
  resume { ptr, i32 } %lpad.phi

29:                                               ; preds = %26
  %30 = getelementptr inbounds i8, ptr %8, i64 24
  store ptr %28, ptr %30, align 8, !tbaa !18
  %31 = icmp sgt i32 %3, 4
  br i1 %31, label %.lr.ph.preheader, label %._crit_edge

.lr.ph.preheader:                                 ; preds = %29
  %wide.trip.count = zext nneg i32 %3 to i64
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph.preheader, %34
  %indvars.iv = phi i64 [ 4, %.lr.ph.preheader ], [ %indvars.iv.next, %34 ]
  %32 = shl i64 %indvars.iv, 5
  %33 = invoke noalias noundef nonnull ptr @_Znam(i64 noundef %32) #3
          to label %34 unwind label %.loopexit

34:                                               ; preds = %.lr.ph
  %35 = load ptr, ptr %10, align 8, !tbaa !14
  %36 = getelementptr inbounds ptr, ptr %35, i64 %indvars.iv
  store ptr %33, ptr %36, align 8, !tbaa !18
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
  br i1 %exitcond.not, label %._crit_edge, label %.lr.ph, !llvm.loop !19

._crit_edge:                                      ; preds = %34, %29
  ret void
}

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 = { nobuiltin allocsize(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 = { 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 = { builtin allocsize(0) }
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 = !{!"vtable pointer", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}
!8 = !{!9, !10, i64 12}
!9 = !{!"_ZTSN4voro16voronoicell_baseE", !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20, !10, i64 24, !10, i64 28, !12, i64 32, !12, i64 40, !12, i64 48, !12, i64 56, !12, i64 64, !12, i64 72, !12, i64 80, !12, i64 88, !12, i64 96, !12, i64 104, !10, i64 112, !10, i64 116, !12, i64 120, !13, i64 128, !13, i64 136, !13, i64 144, !13, i64 152}
!10 = !{!"int", !11, i64 0}
!11 = !{!"omnipotent char", !7, i64 0}
!12 = !{!"any pointer", !11, i64 0}
!13 = !{!"double", !11, i64 0}
!14 = !{!15, !12, i64 160}
!15 = !{!"_ZTSN4voro20voronoicell_neighborE", !9, i64 0, !12, i64 160, !12, i64 168, !12, i64 176, !12, i64 184}
!16 = !{!9, !10, i64 8}
!17 = !{!15, !12, i64 168}
!18 = !{!12, !12, i64 0}
!19 = distinct !{!19, !20}
!20 = !{!"llvm.loop.mustprogress"}


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