; LLVM IR from Lut1n/ImpGears :: src/ImpGears/Geometry/Path.ll (ZN3imp12IntersectionC2ENS_4EdgeES1_)

; 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.imp::Vec3" = type { %"class.imp::Vec.base", [4 x i8] }
%"class.imp::Vec.base" = type <{ %"class.imp::Object", [3 x float] }>
%"class.imp::Object" = type { ptr, %"class.std::shared_ptr" }
%"class.std::shared_ptr" = type { %"class.std::__shared_ptr" }
%"class.std::__shared_ptr" = type { ptr, %"class.std::__shared_count" }
%"class.std::__shared_count" = type { ptr }
%"class.imp::Intersection" = type { %"class.imp::Object", [2 x %"class.imp::Edge"], %"class.imp::Vec3", %"class.imp::Vec3" }
%"class.imp::Edge" = type { %"class.imp::Object", %"class.imp::Vec3", %"class.imp::Vec3" }

@_ZN3imp4Vec31ZE = external global %"class.imp::Vec3", align 8
@_ZTVN3imp12IntersectionE = external dso_local unnamed_addr constant { [5 x ptr] }, align 8

declare i32 @__gxx_personality_v0(...)

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

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

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

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

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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN3imp12IntersectionC2ENS_4EdgeES1_(ptr noundef nonnull align 8 dereferenceable(312) %0, ptr noundef %1, ptr noundef %2) unnamed_addr #1 align 2 personality ptr @__gxx_personality_v0 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store ptr %2, ptr %6, align 8, !tbaa !5
  %9 = load ptr, ptr %4, align 8
  call void @_ZN3imp6ObjectC2Ev(ptr noundef nonnull align 8 dereferenceable(24) %9)
  store ptr getelementptr inbounds inrange(-16, 24) ({ [5 x ptr] }, ptr @_ZTVN3imp12IntersectionE, i32 0, i32 0, i32 2), ptr %9, align 8, !tbaa !9
  %10 = getelementptr inbounds %"class.imp::Intersection", ptr %9, i32 0, i32 1
  %11 = getelementptr inbounds [2 x %"class.imp::Edge"], ptr %10, i32 0, i32 0
  %12 = getelementptr inbounds %"class.imp::Edge", ptr %11, i64 2
  br label %13

13:                                               ; preds = %15, %3
  %14 = phi ptr [ %11, %3 ], [ %16, %15 ]
  invoke void @_ZN3imp4EdgeC1Ev(ptr noundef nonnull align 8 dereferenceable(104) %14)
          to label %15 unwind label %31

15:                                               ; preds = %13
  %16 = getelementptr inbounds %"class.imp::Edge", ptr %14, i64 1
  %17 = icmp eq ptr %16, %12
  br i1 %17, label %18, label %13

18:                                               ; preds = %15
  %19 = getelementptr inbounds %"class.imp::Intersection", ptr %9, i32 0, i32 2
  invoke void @_ZN3imp4Vec3C2Ev(ptr noundef nonnull align 8 dereferenceable(36) %19)
          to label %20 unwind label %41

20:                                               ; preds = %18
  %21 = getelementptr inbounds %"class.imp::Intersection", ptr %9, i32 0, i32 3
  invoke void @_ZN3imp4Vec3C2Ev(ptr noundef nonnull align 8 dereferenceable(36) %21)
          to label %22 unwind label %45

22:                                               ; preds = %20
  %23 = getelementptr inbounds %"class.imp::Intersection", ptr %9, i32 0, i32 2
  %24 = call noundef nonnull align 8 dereferenceable(36) ptr @_ZN3imp4Vec3aSERKS0_(ptr noundef nonnull align 8 dereferenceable(36) %23, ptr noundef nonnull align 8 dereferenceable(36) @_ZN3imp4Vec31ZE) #3
  %25 = getelementptr inbounds %"class.imp::Intersection", ptr %9, i32 0, i32 1
  %26 = getelementptr inbounds [2 x %"class.imp::Edge"], ptr %25, i64 0, i64 0
  %27 = call noundef nonnull align 8 dereferenceable(104) ptr @_ZN3imp4EdgeaSERKS0_(ptr noundef nonnull align 8 dereferenceable(104) %26, ptr noundef nonnull align 8 dereferenceable(104) %1) #3
  %28 = getelementptr inbounds %"class.imp::Intersection", ptr %9, i32 0, i32 1
  %29 = getelementptr inbounds [2 x %"class.imp::Edge"], ptr %28, i64 0, i64 1
  %30 = call noundef nonnull align 8 dereferenceable(104) ptr @_ZN3imp4EdgeaSERKS0_(ptr noundef nonnull align 8 dereferenceable(104) %29, ptr noundef nonnull align 8 dereferenceable(104) %2) #3
  ret void

31:                                               ; preds = %13
  %32 = landingpad { ptr, i32 }
          cleanup
  %33 = extractvalue { ptr, i32 } %32, 0
  store ptr %33, ptr %7, align 8
  %34 = extractvalue { ptr, i32 } %32, 1
  store i32 %34, ptr %8, align 4
  %35 = icmp eq ptr %11, %14
  br i1 %35, label %40, label %36

36:                                               ; preds = %36, %31
  %37 = phi ptr [ %14, %31 ], [ %38, %36 ]
  %38 = getelementptr inbounds %"class.imp::Edge", ptr %37, i64 -1
  call void @_ZN3imp4EdgeD2Ev(ptr noundef nonnull align 8 dereferenceable(104) %38) #3
  %39 = icmp eq ptr %38, %11
  br i1 %39, label %40, label %36

40:                                               ; preds = %36, %31
  br label %57

41:                                               ; preds = %18
  %42 = landingpad { ptr, i32 }
          cleanup
  %43 = extractvalue { ptr, i32 } %42, 0
  store ptr %43, ptr %7, align 8
  %44 = extractvalue { ptr, i32 } %42, 1
  store i32 %44, ptr %8, align 4
  br label %49

45:                                               ; preds = %20
  %46 = landingpad { ptr, i32 }
          cleanup
  %47 = extractvalue { ptr, i32 } %46, 0
  store ptr %47, ptr %7, align 8
  %48 = extractvalue { ptr, i32 } %46, 1
  store i32 %48, ptr %8, align 4
  call void @_ZN3imp6ObjectD2Ev(ptr noundef nonnull align 8 dereferenceable(36) %19) #3
  br label %49

49:                                               ; preds = %45, %41
  %50 = getelementptr inbounds [2 x %"class.imp::Edge"], ptr %10, i32 0, i32 0
  %51 = getelementptr inbounds %"class.imp::Edge", ptr %50, i64 2
  br label %52

52:                                               ; preds = %52, %49
  %53 = phi ptr [ %51, %49 ], [ %54, %52 ]
  %54 = getelementptr inbounds %"class.imp::Edge", ptr %53, i64 -1
  call void @_ZN3imp4EdgeD2Ev(ptr noundef nonnull align 8 dereferenceable(104) %54) #3
  %55 = icmp eq ptr %54, %50
  br i1 %55, label %56, label %52

56:                                               ; preds = %52
  br label %57

57:                                               ; preds = %56, %40
  call void @_ZN3imp6ObjectD2Ev(ptr noundef nonnull align 8 dereferenceable(24) %9) #3
  br label %58

58:                                               ; preds = %57
  %59 = load ptr, ptr %7, align 8
  %60 = load i32, ptr %8, align 4
  %61 = insertvalue { ptr, i32 } poison, ptr %59, 0
  %62 = insertvalue { ptr, i32 } %61, i32 %60, 1
  resume { ptr, i32 } %62
}

declare void @_ZN3imp4EdgeC1Ev(ptr)

attributes #0 = { 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 #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 = { inlinehint 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, !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}


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

%"class.imp::Vec3" = type { %"class.imp::Vec.base", [4 x i8] }
%"class.imp::Vec.base" = type <{ %"class.imp::Object", [3 x float] }>
%"class.imp::Object" = type { ptr, %"class.std::shared_ptr" }
%"class.std::shared_ptr" = type { %"class.std::__shared_ptr" }
%"class.std::__shared_ptr" = type { ptr, %"class.std::__shared_count" }
%"class.std::__shared_count" = type { ptr }

@_ZN3imp4Vec31ZE = external global %"class.imp::Vec3", align 8
@_ZTVN3imp12IntersectionE = external dso_local unnamed_addr constant { [5 x ptr] }, align 8

declare i32 @__gxx_personality_v0(...)

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

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

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

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

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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN3imp12IntersectionC2ENS_4EdgeES1_(ptr noundef nonnull align 8 dereferenceable(312) %0, ptr noundef %1, ptr noundef %2) unnamed_addr #1 align 2 personality ptr @__gxx_personality_v0 {
  tail call void @_ZN3imp6ObjectC2Ev(ptr noundef nonnull align 8 dereferenceable(24) %0)
  store ptr getelementptr inbounds inrange(-16, 24) (i8, ptr @_ZTVN3imp12IntersectionE, i64 16), ptr %0, align 8, !tbaa !5
  %.ptr.ptr = getelementptr inbounds i8, ptr %0, i64 24
  invoke void @_ZN3imp4EdgeC1Ev(ptr noundef nonnull align 8 dereferenceable(104) %.ptr.ptr)
          to label %5 unwind label %.thread

.thread:                                          ; preds = %3
  %4 = landingpad { ptr, i32 }
          cleanup
  br label %.loopexit

5:                                                ; preds = %3
  %.ptr.ptr.1 = getelementptr inbounds i8, ptr %0, i64 128
  invoke void @_ZN3imp4EdgeC1Ev(ptr noundef nonnull align 8 dereferenceable(104) %.ptr.ptr.1)
          to label %6 unwind label %.preheader.preheader

6:                                                ; preds = %5
  %7 = getelementptr inbounds i8, ptr %0, i64 232
  invoke void @_ZN3imp4Vec3C2Ev(ptr noundef nonnull align 8 dereferenceable(36) %7)
          to label %8 unwind label %15

8:                                                ; preds = %6
  %9 = getelementptr inbounds i8, ptr %0, i64 272
  invoke void @_ZN3imp4Vec3C2Ev(ptr noundef nonnull align 8 dereferenceable(36) %9)
          to label %10 unwind label %17

10:                                               ; preds = %8
  %11 = tail call noundef nonnull align 8 dereferenceable(36) ptr @_ZN3imp4Vec3aSERKS0_(ptr noundef nonnull align 8 dereferenceable(36) %7, ptr noundef nonnull align 8 dereferenceable(36) @_ZN3imp4Vec31ZE) #3
  %12 = tail call noundef nonnull align 8 dereferenceable(104) ptr @_ZN3imp4EdgeaSERKS0_(ptr noundef nonnull align 8 dereferenceable(104) %.ptr.ptr, ptr noundef nonnull align 8 dereferenceable(104) %1) #3
  %13 = tail call noundef nonnull align 8 dereferenceable(104) ptr @_ZN3imp4EdgeaSERKS0_(ptr noundef nonnull align 8 dereferenceable(104) %.ptr.ptr.1, ptr noundef nonnull align 8 dereferenceable(104) %2) #3
  ret void

.preheader.preheader:                             ; preds = %5
  %14 = landingpad { ptr, i32 }
          cleanup
  %.ptr12 = getelementptr inbounds i8, ptr %0, i64 24
  tail call void @_ZN3imp4EdgeD2Ev(ptr noundef nonnull align 8 dereferenceable(104) %.ptr12) #3
  br label %.loopexit

15:                                               ; preds = %6
  %16 = landingpad { ptr, i32 }
          cleanup
  br label %.loopexit.loopexit

17:                                               ; preds = %8
  %18 = landingpad { ptr, i32 }
          cleanup
  tail call void @_ZN3imp6ObjectD2Ev(ptr noundef nonnull align 8 dereferenceable(36) %7) #3
  br label %.loopexit.loopexit

.loopexit.loopexit:                               ; preds = %17, %15
  %.pn = phi { ptr, i32 } [ %18, %17 ], [ %16, %15 ]
  tail call void @_ZN3imp4EdgeD2Ev(ptr noundef nonnull align 8 dereferenceable(104) %.ptr.ptr.1) #3
  tail call void @_ZN3imp4EdgeD2Ev(ptr noundef nonnull align 8 dereferenceable(104) %.ptr.ptr) #3
  br label %.loopexit

.loopexit:                                        ; preds = %.preheader.preheader, %.thread, %.loopexit.loopexit
  %.pn.pn = phi { ptr, i32 } [ %.pn, %.loopexit.loopexit ], [ %4, %.thread ], [ %14, %.preheader.preheader ]
  tail call void @_ZN3imp6ObjectD2Ev(ptr noundef nonnull align 8 dereferenceable(24) %0) #3
  resume { ptr, i32 } %.pn.pn
}

declare void @_ZN3imp4EdgeC1Ev(ptr) local_unnamed_addr

attributes #0 = { 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 #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 = { inlinehint 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, !6, i64 0}
!6 = !{!"vtable pointer", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,InstCombinePass,JumpThreadingPass,LCSSAPass,LoopSimplifyPass,SROAPass,SimplifyCFGPass,TailCallElimPass