; LLVM IR from niessner/Matterport :: code/gaps/apps/mpview/mp.ll (ZN8MPObjectD2Ev)

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

%struct.MPObject = type { ptr, i32, ptr, i32, ptr, i32, %class.RNArray.3, %class.R3Point, %class.R3OrientedBox }
%class.RNArray.3 = type { %class.RNVArray }
%class.RNVArray = type { ptr, i32, i32 }
%class.R3Point = type { [3 x double] }
%class.R3OrientedBox = type { %class.R3Solid, %class.R3CoordSystem, [3 x double] }
%class.R3Solid = type { %class.R3Shape }
%class.R3Shape = type { ptr }
%class.R3CoordSystem = type { %class.R3Point, %class.R3Triad }
%class.R3Triad = type { [3 x %class.R3Vector] }
%class.R3Vector = type { [3 x double] }

declare i32 @__gxx_personality_v0(...)

; Function Attrs: noinline noreturn nounwind uwtable
declare hidden void @__clang_call_terminate(ptr noundef) #0

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK8RNVArray7IsEmptyEv(ptr noundef nonnull align 8 dereferenceable(16)) #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN8MPObject13RemoveSegmentEP9MPSegment(ptr noundef nonnull align 8 dereferenceable(216), ptr noundef) #2 align 2

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN8MPObjectD2Ev(ptr noundef nonnull align 8 dereferenceable(216) %0) unnamed_addr #3 align 2 personality ptr @__gxx_personality_v0 {
  %2 = alloca ptr, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  %3 = load ptr, ptr %2, align 8
  br label %4

4:                                                ; preds = %14, %1
  %5 = getelementptr inbounds %struct.MPObject, ptr %3, i32 0, i32 6
  %6 = invoke noundef i32 @_ZNK8RNVArray7IsEmptyEv(ptr noundef nonnull align 8 dereferenceable(16) %5)
          to label %7 unwind label %42

7:                                                ; preds = %4
  %8 = icmp ne i32 %6, 0
  %9 = xor i1 %8, true
  br i1 %9, label %10, label %15

10:                                               ; preds = %7
  %11 = getelementptr inbounds %struct.MPObject, ptr %3, i32 0, i32 6
  %12 = invoke noundef ptr @_ZNK7RNArrayIP9MPSegmentE4TailEv(ptr noundef nonnull align 8 dereferenceable(16) %11)
          to label %13 unwind label %42

13:                                               ; preds = %10
  invoke void @_ZN8MPObject13RemoveSegmentEP9MPSegment(ptr noundef nonnull align 8 dereferenceable(216) %3, ptr noundef %12)
          to label %14 unwind label %42

14:                                               ; preds = %13
  br label %4, !llvm.loop !9

15:                                               ; preds = %7
  %16 = getelementptr inbounds %struct.MPObject, ptr %3, i32 0, i32 4
  %17 = load ptr, ptr %16, align 8, !tbaa !11
  %18 = icmp ne ptr %17, null
  br i1 %18, label %19, label %23

19:                                               ; preds = %15
  %20 = getelementptr inbounds %struct.MPObject, ptr %3, i32 0, i32 4
  %21 = load ptr, ptr %20, align 8, !tbaa !11
  invoke void @_ZN10MPCategory12RemoveObjectEP8MPObject(ptr noundef nonnull align 8 dereferenceable(64) %21, ptr noundef %3)
          to label %22 unwind label %42

22:                                               ; preds = %19
  br label %23

23:                                               ; preds = %22, %15
  %24 = getelementptr inbounds %struct.MPObject, ptr %3, i32 0, i32 2
  %25 = load ptr, ptr %24, align 8, !tbaa !22
  %26 = icmp ne ptr %25, null
  br i1 %26, label %27, label %31

27:                                               ; preds = %23
  %28 = getelementptr inbounds %struct.MPObject, ptr %3, i32 0, i32 2
  %29 = load ptr, ptr %28, align 8, !tbaa !22
  invoke void @_ZN8MPRegion12RemoveObjectEP8MPObject(ptr noundef nonnull align 8 dereferenceable(192) %29, ptr noundef %3)
          to label %30 unwind label %42

30:                                               ; preds = %27
  br label %31

31:                                               ; preds = %30, %23
  %32 = getelementptr inbounds %struct.MPObject, ptr %3, i32 0, i32 0
  %33 = load ptr, ptr %32, align 8, !tbaa !23
  %34 = icmp ne ptr %33, null
  br i1 %34, label %35, label %39

35:                                               ; preds = %31
  %36 = getelementptr inbounds %struct.MPObject, ptr %3, i32 0, i32 0
  %37 = load ptr, ptr %36, align 8, !tbaa !23
  invoke void @_ZN7MPHouse12RemoveObjectEP8MPObject(ptr noundef nonnull align 8 dereferenceable(376) %37, ptr noundef %3)
          to label %38 unwind label %42

38:                                               ; preds = %35
  br label %39

39:                                               ; preds = %38, %31
  %40 = getelementptr inbounds %struct.MPObject, ptr %3, i32 0, i32 8
  call void @_ZN7R3SolidD2Ev(ptr noundef nonnull align 8 dereferenceable(128) %40) #5
  %41 = getelementptr inbounds %struct.MPObject, ptr %3, i32 0, i32 6
  call void @_ZN8RNVArrayD2Ev(ptr noundef nonnull align 8 dereferenceable(16) %41) #5
  ret void

42:                                               ; preds = %35, %27, %19, %13, %10, %4
  %43 = landingpad { ptr, i32 }
          catch ptr null
  %44 = extractvalue { ptr, i32 } %43, 0
  call void @__clang_call_terminate(ptr %44) #6
  unreachable
}

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_ZNK7RNArrayIP9MPSegmentE4TailEv(ptr noundef nonnull align 8 dereferenceable(16)) #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN10MPCategory12RemoveObjectEP8MPObject(ptr noundef nonnull align 8 dereferenceable(64), ptr noundef) #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN8MPRegion12RemoveObjectEP8MPObject(ptr noundef nonnull align 8 dereferenceable(192), ptr noundef) #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN7MPHouse12RemoveObjectEP8MPObject(ptr noundef nonnull align 8 dereferenceable(376), ptr noundef) #2 align 2

; Function Attrs: nounwind
declare void @_ZN7R3SolidD2Ev(ptr noundef nonnull align 8 dereferenceable(8)) unnamed_addr #4

; Function Attrs: nounwind
declare void @_ZN8RNVArrayD2Ev(ptr noundef nonnull align 8 dereferenceable(16)) unnamed_addr #4

attributes #0 = { noinline noreturn nounwind uwtable "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 = { 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 #2 = { 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 #3 = { 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 #4 = { nounwind "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 = { noreturn 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 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = !{!12, !6, i64 32}
!12 = !{!"_ZTS8MPObject", !6, i64 0, !13, i64 8, !6, i64 16, !13, i64 24, !6, i64 32, !13, i64 40, !14, i64 48, !16, i64 64, !17, i64 88}
!13 = !{!"int", !7, i64 0}
!14 = !{!"_ZTS7RNArrayIP9MPSegmentE", !15, i64 0}
!15 = !{!"_ZTS8RNVArray", !6, i64 0, !13, i64 8, !13, i64 12}
!16 = !{!"_ZTS7R3Point", !7, i64 0}
!17 = !{!"_ZTS13R3OrientedBox", !18, i64 0, !20, i64 8, !7, i64 104}
!18 = !{!"_ZTS7R3Solid", !19, i64 0}
!19 = !{!"_ZTS7R3Shape"}
!20 = !{!"_ZTS13R3CoordSystem", !16, i64 0, !21, i64 24}
!21 = !{!"_ZTS7R3Triad", !7, i64 0}
!22 = !{!12, !6, i64 16}
!23 = !{!12, !6, 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"

declare i32 @__gxx_personality_v0(...)

; Function Attrs: noinline noreturn nounwind uwtable
declare hidden void @__clang_call_terminate(ptr noundef) local_unnamed_addr #0

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK8RNVArray7IsEmptyEv(ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN8MPObject13RemoveSegmentEP9MPSegment(ptr noundef nonnull align 8 dereferenceable(216), ptr noundef) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN8MPObjectD2Ev(ptr noundef nonnull align 8 dereferenceable(216) %0) unnamed_addr #3 align 2 personality ptr @__gxx_personality_v0 {
  %2 = getelementptr inbounds i8, ptr %0, i64 48
  br label %3

3:                                                ; preds = %7, %1
  %4 = tail call noundef i32 @_ZNK8RNVArray7IsEmptyEv(ptr noundef nonnull align 8 dereferenceable(16) %2)
  %.not = icmp eq i32 %4, 0
  br i1 %.not, label %5, label %8

5:                                                ; preds = %3
  %6 = invoke noundef ptr @_ZNK7RNArrayIP9MPSegmentE4TailEv(ptr noundef nonnull align 8 dereferenceable(16) %2)
          to label %7 unwind label %.loopexit

7:                                                ; preds = %5
  invoke void @_ZN8MPObject13RemoveSegmentEP9MPSegment(ptr noundef nonnull align 8 dereferenceable(216) %0, ptr noundef %6)
          to label %3 unwind label %.loopexit, !llvm.loop !5

8:                                                ; preds = %3
  %9 = getelementptr inbounds i8, ptr %0, i64 32
  %10 = load ptr, ptr %9, align 8, !tbaa !7
  %.not3 = icmp eq ptr %10, null
  br i1 %.not3, label %12, label %11

11:                                               ; preds = %8
  invoke void @_ZN10MPCategory12RemoveObjectEP8MPObject(ptr noundef nonnull align 8 dereferenceable(64) %10, ptr noundef nonnull %0)
          to label %12 unwind label %.loopexit.split-lp

12:                                               ; preds = %11, %8
  %13 = getelementptr inbounds i8, ptr %0, i64 16
  %14 = load ptr, ptr %13, align 8, !tbaa !21
  %.not4 = icmp eq ptr %14, null
  br i1 %.not4, label %16, label %15

15:                                               ; preds = %12
  invoke void @_ZN8MPRegion12RemoveObjectEP8MPObject(ptr noundef nonnull align 8 dereferenceable(192) %14, ptr noundef nonnull %0)
          to label %16 unwind label %.loopexit.split-lp

16:                                               ; preds = %15, %12
  %17 = load ptr, ptr %0, align 8, !tbaa !22
  %.not5 = icmp eq ptr %17, null
  br i1 %.not5, label %19, label %18

18:                                               ; preds = %16
  invoke void @_ZN7MPHouse12RemoveObjectEP8MPObject(ptr noundef nonnull align 8 dereferenceable(376) %17, ptr noundef nonnull %0)
          to label %19 unwind label %.loopexit.split-lp

19:                                               ; preds = %18, %16
  %20 = getelementptr inbounds i8, ptr %0, i64 88
  tail call void @_ZN7R3SolidD2Ev(ptr noundef nonnull align 8 dereferenceable(128) %20) #5
  tail call void @_ZN8RNVArrayD2Ev(ptr noundef nonnull align 8 dereferenceable(16) %2) #5
  ret void

.loopexit:                                        ; preds = %5, %7
  %lpad.loopexit = landingpad { ptr, i32 }
          catch ptr null
  br label %21

.loopexit.split-lp:                               ; preds = %11, %15, %18
  %lpad.loopexit.split-lp = landingpad { ptr, i32 }
          catch ptr null
  br label %21

21:                                               ; preds = %.loopexit.split-lp, %.loopexit
  %lpad.phi = phi { ptr, i32 } [ %lpad.loopexit, %.loopexit ], [ %lpad.loopexit.split-lp, %.loopexit.split-lp ]
  %22 = extractvalue { ptr, i32 } %lpad.phi, 0
  tail call void @__clang_call_terminate(ptr %22) #6
  unreachable
}

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_ZNK7RNArrayIP9MPSegmentE4TailEv(ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN10MPCategory12RemoveObjectEP8MPObject(ptr noundef nonnull align 8 dereferenceable(64), ptr noundef) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN8MPRegion12RemoveObjectEP8MPObject(ptr noundef nonnull align 8 dereferenceable(192), ptr noundef) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN7MPHouse12RemoveObjectEP8MPObject(ptr noundef nonnull align 8 dereferenceable(376), ptr noundef) local_unnamed_addr #2 align 2

; Function Attrs: nounwind
declare void @_ZN7R3SolidD2Ev(ptr noundef nonnull align 8 dereferenceable(8)) unnamed_addr #4

; Function Attrs: nounwind
declare void @_ZN8RNVArrayD2Ev(ptr noundef nonnull align 8 dereferenceable(16)) unnamed_addr #4

attributes #0 = { noinline noreturn nounwind uwtable "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 = { 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 #2 = { 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 #3 = { 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 #4 = { nounwind "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 = { noreturn 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 = distinct !{!5, !6}
!6 = !{!"llvm.loop.mustprogress"}
!7 = !{!8, !9, i64 32}
!8 = !{!"_ZTS8MPObject", !9, i64 0, !12, i64 8, !9, i64 16, !12, i64 24, !9, i64 32, !12, i64 40, !13, i64 48, !15, i64 64, !16, i64 88}
!9 = !{!"any pointer", !10, i64 0}
!10 = !{!"omnipotent char", !11, i64 0}
!11 = !{!"Simple C++ TBAA"}
!12 = !{!"int", !10, i64 0}
!13 = !{!"_ZTS7RNArrayIP9MPSegmentE", !14, i64 0}
!14 = !{!"_ZTS8RNVArray", !9, i64 0, !12, i64 8, !12, i64 12}
!15 = !{!"_ZTS7R3Point", !10, i64 0}
!16 = !{!"_ZTS13R3OrientedBox", !17, i64 0, !19, i64 8, !10, i64 104}
!17 = !{!"_ZTS7R3Solid", !18, i64 0}
!18 = !{!"_ZTS7R3Shape"}
!19 = !{!"_ZTS13R3CoordSystem", !15, i64 0, !20, i64 24}
!20 = !{!"_ZTS7R3Triad", !10, i64 0}
!21 = !{!8, !9, i64 16}
!22 = !{!8, !9, i64 0}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InstCombinePass,LCSSAPass,LICMPass,LoopSimplifyPass,SROAPass,SimplifyCFGPass,TailCallElimPass