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

; 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.MPPanorama = type { ptr, i32, ptr, i32, ptr, %class.RNArray.0, %class.R3Point }
%class.RNArray.0 = type { %class.RNVArray }
%class.RNVArray = type { ptr, i32, i32 }
%class.R3Point = type { [3 x double] }

declare i32 @__gxx_personality_v0(...)

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

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN10MPPanoramaD2Ev(ptr noundef nonnull align 8 dereferenceable(80) %0) unnamed_addr #2 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.MPPanorama, ptr %3, i32 0, i32 5
  %6 = invoke noundef i32 @_ZNK8RNVArray7IsEmptyEv(ptr noundef nonnull align 8 dereferenceable(16) %5)
          to label %7 unwind label %33

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.MPPanorama, ptr %3, i32 0, i32 5
  %12 = invoke noundef ptr @_ZNK7RNArrayIP7MPImageE4TailEv(ptr noundef nonnull align 8 dereferenceable(16) %11)
          to label %13 unwind label %33

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

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

15:                                               ; preds = %7
  %16 = getelementptr inbounds %struct.MPPanorama, ptr %3, i32 0, i32 2
  %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.MPPanorama, ptr %3, i32 0, i32 2
  %21 = load ptr, ptr %20, align 8, !tbaa !11
  invoke void @_ZN8MPRegion14RemovePanoramaEP10MPPanorama(ptr noundef nonnull align 8 dereferenceable(192) %21, ptr noundef %3)
          to label %22 unwind label %33

22:                                               ; preds = %19
  br label %23

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

27:                                               ; preds = %23
  %28 = getelementptr inbounds %struct.MPPanorama, ptr %3, i32 0, i32 0
  %29 = load ptr, ptr %28, align 8, !tbaa !17
  invoke void @_ZN7MPHouse14RemovePanoramaEP10MPPanorama(ptr noundef nonnull align 8 dereferenceable(376) %29, ptr noundef %3)
          to label %30 unwind label %33

30:                                               ; preds = %27
  br label %31

31:                                               ; preds = %30, %23
  %32 = getelementptr inbounds %struct.MPPanorama, ptr %3, i32 0, i32 5
  call void @_ZN8RNVArrayD2Ev(ptr noundef nonnull align 8 dereferenceable(16) %32) #5
  ret void

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

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

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

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

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

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

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 = { 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 #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 = { 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 #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 16}
!12 = !{!"_ZTS10MPPanorama", !6, i64 0, !13, i64 8, !6, i64 16, !13, i64 24, !6, i64 32, !14, i64 40, !16, i64 56}
!13 = !{!"int", !7, i64 0}
!14 = !{!"_ZTS7RNArrayIP7MPImageE", !15, i64 0}
!15 = !{!"_ZTS8RNVArray", !6, i64 0, !13, i64 8, !13, i64 12}
!16 = !{!"_ZTS7R3Point", !7, i64 0}
!17 = !{!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: mustprogress uwtable
declare dso_local void @_ZN10MPPanorama11RemoveImageEP7MPImage(ptr noundef nonnull align 8 dereferenceable(80), ptr noundef) local_unnamed_addr #0 align 2

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN10MPPanoramaD2Ev(ptr noundef nonnull align 8 dereferenceable(80) %0) unnamed_addr #2 align 2 personality ptr @__gxx_personality_v0 {
  %2 = getelementptr inbounds i8, ptr %0, i64 40
  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 @_ZNK7RNArrayIP7MPImageE4TailEv(ptr noundef nonnull align 8 dereferenceable(16) %2)
          to label %7 unwind label %.loopexit

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

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

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

12:                                               ; preds = %11, %8
  %13 = load ptr, ptr %0, align 8, !tbaa !16
  %.not3 = icmp eq ptr %13, null
  br i1 %.not3, label %15, label %14

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

15:                                               ; preds = %14, %12
  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 %16

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

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

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

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

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

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

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

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 = { 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 #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 = { 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 #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 16}
!8 = !{!"_ZTS10MPPanorama", !9, i64 0, !12, i64 8, !9, i64 16, !12, i64 24, !9, i64 32, !13, i64 40, !15, i64 56}
!9 = !{!"any pointer", !10, i64 0}
!10 = !{!"omnipotent char", !11, i64 0}
!11 = !{!"Simple C++ TBAA"}
!12 = !{!"int", !10, i64 0}
!13 = !{!"_ZTS7RNArrayIP7MPImageE", !14, i64 0}
!14 = !{!"_ZTS8RNVArray", !9, i64 0, !12, i64 8, !12, i64 12}
!15 = !{!"_ZTS7R3Point", !10, i64 0}
!16 = !{!8, !9, i64 0}


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