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

; 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 void @_ZN3imp4EdgeD2Ev(ptr noundef nonnull align 8 dereferenceable(104)) unnamed_addr #2 align 2

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

9:                                                ; preds = %11, %1
  %10 = phi ptr [ %7, %1 ], [ %12, %11 ]
  invoke void @_ZN3imp4EdgeC1Ev(ptr noundef nonnull align 8 dereferenceable(104) %10)
          to label %11 unwind label %21

11:                                               ; preds = %9
  %12 = getelementptr inbounds %"class.imp::Edge", ptr %10, i64 1
  %13 = icmp eq ptr %12, %8
  br i1 %13, label %14, label %9

14:                                               ; preds = %11
  %15 = getelementptr inbounds %"class.imp::Intersection", ptr %5, i32 0, i32 2
  invoke void @_ZN3imp4Vec3C2Ev(ptr noundef nonnull align 8 dereferenceable(36) %15)
          to label %16 unwind label %31

16:                                               ; preds = %14
  %17 = getelementptr inbounds %"class.imp::Intersection", ptr %5, i32 0, i32 3
  invoke void @_ZN3imp4Vec3C2Ev(ptr noundef nonnull align 8 dereferenceable(36) %17)
          to label %18 unwind label %35

18:                                               ; preds = %16
  %19 = getelementptr inbounds %"class.imp::Intersection", ptr %5, i32 0, i32 2
  %20 = call noundef nonnull align 8 dereferenceable(36) ptr @_ZN3imp4Vec3aSERKS0_(ptr noundef nonnull align 8 dereferenceable(36) %19, ptr noundef nonnull align 8 dereferenceable(36) @_ZN3imp4Vec31ZE) #3
  ret void

21:                                               ; preds = %9
  %22 = landingpad { ptr, i32 }
          cleanup
  %23 = extractvalue { ptr, i32 } %22, 0
  store ptr %23, ptr %3, align 8
  %24 = extractvalue { ptr, i32 } %22, 1
  store i32 %24, ptr %4, align 4
  %25 = icmp eq ptr %7, %10
  br i1 %25, label %30, label %26

26:                                               ; preds = %26, %21
  %27 = phi ptr [ %10, %21 ], [ %28, %26 ]
  %28 = getelementptr inbounds %"class.imp::Edge", ptr %27, i64 -1
  call void @_ZN3imp4EdgeD2Ev(ptr noundef nonnull align 8 dereferenceable(104) %28) #3
  %29 = icmp eq ptr %28, %7
  br i1 %29, label %30, label %26

30:                                               ; preds = %26, %21
  br label %47

31:                                               ; preds = %14
  %32 = landingpad { ptr, i32 }
          cleanup
  %33 = extractvalue { ptr, i32 } %32, 0
  store ptr %33, ptr %3, align 8
  %34 = extractvalue { ptr, i32 } %32, 1
  store i32 %34, ptr %4, align 4
  br label %39

35:                                               ; preds = %16
  %36 = landingpad { ptr, i32 }
          cleanup
  %37 = extractvalue { ptr, i32 } %36, 0
  store ptr %37, ptr %3, align 8
  %38 = extractvalue { ptr, i32 } %36, 1
  store i32 %38, ptr %4, align 4
  call void @_ZN3imp6ObjectD2Ev(ptr noundef nonnull align 8 dereferenceable(36) %15) #3
  br label %39

39:                                               ; preds = %35, %31
  %40 = getelementptr inbounds [2 x %"class.imp::Edge"], ptr %6, i32 0, i32 0
  %41 = getelementptr inbounds %"class.imp::Edge", ptr %40, i64 2
  br label %42

42:                                               ; preds = %42, %39
  %43 = phi ptr [ %41, %39 ], [ %44, %42 ]
  %44 = getelementptr inbounds %"class.imp::Edge", ptr %43, i64 -1
  call void @_ZN3imp4EdgeD2Ev(ptr noundef nonnull align 8 dereferenceable(104) %44) #3
  %45 = icmp eq ptr %44, %40
  br i1 %45, label %46, label %42

46:                                               ; preds = %42
  br label %47

47:                                               ; preds = %46, %30
  call void @_ZN3imp6ObjectD2Ev(ptr noundef nonnull align 8 dereferenceable(24) %5) #3
  br label %48

48:                                               ; preds = %47
  %49 = load ptr, ptr %3, align 8
  %50 = load i32, ptr %4, align 4
  %51 = insertvalue { ptr, i32 } poison, ptr %49, 0
  %52 = insertvalue { ptr, i32 } %51, i32 %50, 1
  resume { ptr, i32 } %52
}

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 void @_ZN3imp4EdgeD2Ev(ptr noundef nonnull align 8 dereferenceable(104)) unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN3imp12IntersectionC2Ev(ptr noundef nonnull align 8 dereferenceable(312) %0) 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 %3 unwind label %.thread

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

3:                                                ; preds = %1
  %.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 %4 unwind label %.preheader.preheader

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

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

8:                                                ; preds = %6
  %9 = tail call noundef nonnull align 8 dereferenceable(36) ptr @_ZN3imp4Vec3aSERKS0_(ptr noundef nonnull align 8 dereferenceable(36) %5, ptr noundef nonnull align 8 dereferenceable(36) @_ZN3imp4Vec31ZE) #3
  ret void

.preheader.preheader:                             ; preds = %3
  %10 = 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

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

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

.loopexit.loopexit:                               ; preds = %13, %11
  %.pn = phi { ptr, i32 } [ %14, %13 ], [ %12, %11 ]
  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 ], [ %2, %.thread ], [ %10, %.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