; LLVM IR from niessner/Matterport :: code/gaps/pkgs/RGBD/RGBDConfiguration.ll (ZN17RGBDConfigurationD2Ev)

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

@_ZTV17RGBDConfiguration = external dso_local unnamed_addr constant { [19 x ptr] }, align 8

declare i32 @__gxx_personality_v0(...)

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN17RGBDConfigurationD2Ev(ptr noundef nonnull align 8 dereferenceable(128) %0) unnamed_addr #1 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
  store ptr getelementptr inbounds inrange(-16, 136) ({ [19 x ptr] }, ptr @_ZTV17RGBDConfiguration, i32 0, i32 0, i32 2), ptr %3, align 8, !tbaa !9
  br label %4

4:                                                ; preds = %19, %1
  %5 = invoke noundef i32 @_ZNK17RGBDConfiguration7NImagesEv(ptr noundef nonnull align 8 dereferenceable(128) %3)
          to label %6 unwind label %69

6:                                                ; preds = %4
  %7 = icmp sgt i32 %5, 0
  br i1 %7, label %8, label %20

8:                                                ; preds = %6
  %9 = invoke noundef i32 @_ZNK17RGBDConfiguration7NImagesEv(ptr noundef nonnull align 8 dereferenceable(128) %3)
          to label %10 unwind label %69

10:                                               ; preds = %8
  %11 = sub nsw i32 %9, 1
  %12 = invoke noundef ptr @_ZNK17RGBDConfiguration5ImageEi(ptr noundef nonnull align 8 dereferenceable(128) %3, i32 noundef %11)
          to label %13 unwind label %69

13:                                               ; preds = %10
  %14 = icmp eq ptr %12, null
  br i1 %14, label %19, label %15

15:                                               ; preds = %13
  %16 = load ptr, ptr %12, align 8, !tbaa !9
  %17 = getelementptr inbounds ptr, ptr %16, i64 1
  %18 = load ptr, ptr %17, align 8
  call void %18(ptr noundef nonnull align 8 dereferenceable(488) %12) #4
  br label %19

19:                                               ; preds = %15, %13
  br label %4, !llvm.loop !11

20:                                               ; preds = %6
  br label %21

21:                                               ; preds = %36, %20
  %22 = invoke noundef i32 @_ZNK17RGBDConfiguration9NSurfacesEv(ptr noundef nonnull align 8 dereferenceable(128) %3)
          to label %23 unwind label %69

23:                                               ; preds = %21
  %24 = icmp sgt i32 %22, 0
  br i1 %24, label %25, label %37

25:                                               ; preds = %23
  %26 = invoke noundef i32 @_ZNK17RGBDConfiguration9NSurfacesEv(ptr noundef nonnull align 8 dereferenceable(128) %3)
          to label %27 unwind label %69

27:                                               ; preds = %25
  %28 = sub nsw i32 %26, 1
  %29 = invoke noundef ptr @_ZNK17RGBDConfiguration7SurfaceEi(ptr noundef nonnull align 8 dereferenceable(128) %3, i32 noundef %28)
          to label %30 unwind label %69

30:                                               ; preds = %27
  %31 = icmp eq ptr %29, null
  br i1 %31, label %36, label %32

32:                                               ; preds = %30
  %33 = load ptr, ptr %29, align 8, !tbaa !9
  %34 = getelementptr inbounds ptr, ptr %33, i64 1
  %35 = load ptr, ptr %34, align 8
  call void %35(ptr noundef nonnull align 8 dereferenceable(144) %29) #4
  br label %36

36:                                               ; preds = %32, %30
  br label %21, !llvm.loop !13

37:                                               ; preds = %23
  %38 = getelementptr inbounds %class.RGBDConfiguration, ptr %3, i32 0, i32 3
  %39 = load ptr, ptr %38, align 8, !tbaa !14
  %40 = icmp ne ptr %39, null
  br i1 %40, label %41, label %44

41:                                               ; preds = %37
  %42 = getelementptr inbounds %class.RGBDConfiguration, ptr %3, i32 0, i32 3
  %43 = load ptr, ptr %42, align 8, !tbaa !14
  call void @free(ptr noundef %43) #4
  br label %44

44:                                               ; preds = %41, %37
  %45 = getelementptr inbounds %class.RGBDConfiguration, ptr %3, i32 0, i32 4
  %46 = load ptr, ptr %45, align 8, !tbaa !24
  %47 = icmp ne ptr %46, null
  br i1 %47, label %48, label %51

48:                                               ; preds = %44
  %49 = getelementptr inbounds %class.RGBDConfiguration, ptr %3, i32 0, i32 4
  %50 = load ptr, ptr %49, align 8, !tbaa !24
  call void @free(ptr noundef %50) #4
  br label %51

51:                                               ; preds = %48, %44
  %52 = getelementptr inbounds %class.RGBDConfiguration, ptr %3, i32 0, i32 5
  %53 = load ptr, ptr %52, align 8, !tbaa !25
  %54 = icmp ne ptr %53, null
  br i1 %54, label %55, label %58

55:                                               ; preds = %51
  %56 = getelementptr inbounds %class.RGBDConfiguration, ptr %3, i32 0, i32 5
  %57 = load ptr, ptr %56, align 8, !tbaa !25
  call void @free(ptr noundef %57) #4
  br label %58

58:                                               ; preds = %55, %51
  %59 = getelementptr inbounds %class.RGBDConfiguration, ptr %3, i32 0, i32 6
  %60 = load ptr, ptr %59, align 8, !tbaa !26
  %61 = icmp ne ptr %60, null
  br i1 %61, label %62, label %65

62:                                               ; preds = %58
  %63 = getelementptr inbounds %class.RGBDConfiguration, ptr %3, i32 0, i32 6
  %64 = load ptr, ptr %63, align 8, !tbaa !26
  call void @free(ptr noundef %64) #4
  br label %65

65:                                               ; preds = %62, %58
  %66 = getelementptr inbounds %class.RGBDConfiguration, ptr %3, i32 0, i32 7
  call void @_ZN7R3SolidD2Ev(ptr noundef nonnull align 8 dereferenceable(56) %66) #4
  %67 = getelementptr inbounds %class.RGBDConfiguration, ptr %3, i32 0, i32 2
  call void @_ZN8RNVArrayD2Ev(ptr noundef nonnull align 8 dereferenceable(16) %67) #4
  %68 = getelementptr inbounds %class.RGBDConfiguration, ptr %3, i32 0, i32 1
  call void @_ZN8RNVArrayD2Ev(ptr noundef nonnull align 8 dereferenceable(16) %68) #4
  ret void

69:                                               ; preds = %27, %25, %21, %10, %8, %4
  %70 = landingpad { ptr, i32 }
          catch ptr null
  %71 = extractvalue { ptr, i32 } %70, 0
  call void @__clang_call_terminate(ptr %71) #5
  unreachable
}

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef i32 @_ZNK17RGBDConfiguration7NImagesEv(ptr noundef nonnull align 8 dereferenceable(128)) #2 align 2

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef ptr @_ZNK17RGBDConfiguration5ImageEi(ptr noundef nonnull align 8 dereferenceable(128), i32 noundef) #2 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef i32 @_ZNK17RGBDConfiguration9NSurfacesEv(ptr noundef nonnull align 8 dereferenceable(128)) #2 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef ptr @_ZNK17RGBDConfiguration7SurfaceEi(ptr noundef nonnull align 8 dereferenceable(128), i32 noundef) #2 align 2

; Function Attrs: nounwind
declare void @free(ptr noundef) #0

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

attributes #0 = { 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 #1 = { 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 = { inlinehint 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 = { 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 #4 = { nounwind }
attributes #5 = { 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 = !{!10, !10, i64 0}
!10 = !{!"vtable pointer", !8, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}
!14 = !{!15, !6, i64 40}
!15 = !{!"_ZTS17RGBDConfiguration", !16, i64 8, !19, i64 24, !6, i64 40, !6, i64 48, !6, i64 56, !6, i64 64, !20, i64 72}
!16 = !{!"_ZTS7RNArrayIP9RGBDImageE", !17, i64 0}
!17 = !{!"_ZTS8RNVArray", !6, i64 0, !18, i64 8, !18, i64 12}
!18 = !{!"int", !7, i64 0}
!19 = !{!"_ZTS7RNArrayIP11RGBDSurfaceE", !17, i64 0}
!20 = !{!"_ZTS5R3Box", !21, i64 0, !23, i64 8, !23, i64 32}
!21 = !{!"_ZTS7R3Solid", !22, i64 0}
!22 = !{!"_ZTS7R3Shape"}
!23 = !{!"_ZTS7R3Point", !7, i64 0}
!24 = !{!15, !6, i64 48}
!25 = !{!15, !6, i64 56}
!26 = !{!15, !6, i64 64}


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

@_ZTV17RGBDConfiguration = external dso_local unnamed_addr constant { [19 x ptr] }, align 8

declare i32 @__gxx_personality_v0(...)

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN17RGBDConfigurationD2Ev(ptr noundef nonnull align 8 dereferenceable(128) %0) unnamed_addr #1 align 2 personality ptr @__gxx_personality_v0 {
  store ptr getelementptr inbounds inrange(-16, 136) (i8, ptr @_ZTV17RGBDConfiguration, i64 16), ptr %0, align 8, !tbaa !5
  br label %2

2:                                                ; preds = %.backedge, %1
  %3 = invoke noundef i32 @_ZNK17RGBDConfiguration7NImagesEv(ptr noundef nonnull align 8 dereferenceable(128) %0)
          to label %4 unwind label %.loopexit.split-lp

4:                                                ; preds = %2
  %5 = icmp sgt i32 %3, 0
  br i1 %5, label %6, label %.preheader

6:                                                ; preds = %4
  %7 = invoke noundef i32 @_ZNK17RGBDConfiguration7NImagesEv(ptr noundef nonnull align 8 dereferenceable(128) %0)
          to label %8 unwind label %.loopexit.split-lp

8:                                                ; preds = %6
  %9 = add nsw i32 %7, -1
  %10 = invoke noundef ptr @_ZNK17RGBDConfiguration5ImageEi(ptr noundef nonnull align 8 dereferenceable(128) %0, i32 noundef %9)
          to label %11 unwind label %.loopexit.split-lp

11:                                               ; preds = %8
  %12 = icmp eq ptr %10, null
  br i1 %12, label %.backedge, label %13

13:                                               ; preds = %11
  %14 = load ptr, ptr %10, align 8, !tbaa !5
  %15 = getelementptr inbounds i8, ptr %14, i64 8
  %16 = load ptr, ptr %15, align 8
  tail call void %16(ptr noundef nonnull align 8 dereferenceable(488) %10) #5
  br label %.backedge

.backedge:                                        ; preds = %13, %11
  br label %2, !llvm.loop !8

.preheader:                                       ; preds = %4, %.preheader.backedge
  %17 = invoke noundef i32 @_ZNK17RGBDConfiguration9NSurfacesEv(ptr noundef nonnull align 8 dereferenceable(128) %0)
          to label %18 unwind label %.loopexit

18:                                               ; preds = %.preheader
  %19 = icmp sgt i32 %17, 0
  br i1 %19, label %20, label %31

20:                                               ; preds = %18
  %21 = invoke noundef i32 @_ZNK17RGBDConfiguration9NSurfacesEv(ptr noundef nonnull align 8 dereferenceable(128) %0)
          to label %22 unwind label %.loopexit

22:                                               ; preds = %20
  %23 = add nsw i32 %21, -1
  %24 = invoke noundef ptr @_ZNK17RGBDConfiguration7SurfaceEi(ptr noundef nonnull align 8 dereferenceable(128) %0, i32 noundef %23)
          to label %25 unwind label %.loopexit

25:                                               ; preds = %22
  %26 = icmp eq ptr %24, null
  br i1 %26, label %.preheader.backedge, label %27

27:                                               ; preds = %25
  %28 = load ptr, ptr %24, align 8, !tbaa !5
  %29 = getelementptr inbounds i8, ptr %28, i64 8
  %30 = load ptr, ptr %29, align 8
  tail call void %30(ptr noundef nonnull align 8 dereferenceable(144) %24) #5
  br label %.preheader.backedge

.preheader.backedge:                              ; preds = %27, %25
  br label %.preheader, !llvm.loop !10

31:                                               ; preds = %18
  %32 = getelementptr inbounds i8, ptr %0, i64 40
  %33 = load ptr, ptr %32, align 8, !tbaa !11
  %.not = icmp eq ptr %33, null
  br i1 %.not, label %35, label %34

34:                                               ; preds = %31
  tail call void @free(ptr noundef nonnull %33) #5
  br label %35

35:                                               ; preds = %34, %31
  %36 = getelementptr inbounds i8, ptr %0, i64 48
  %37 = load ptr, ptr %36, align 8, !tbaa !23
  %.not6 = icmp eq ptr %37, null
  br i1 %.not6, label %39, label %38

38:                                               ; preds = %35
  tail call void @free(ptr noundef nonnull %37) #5
  br label %39

39:                                               ; preds = %38, %35
  %40 = getelementptr inbounds i8, ptr %0, i64 56
  %41 = load ptr, ptr %40, align 8, !tbaa !24
  %.not7 = icmp eq ptr %41, null
  br i1 %.not7, label %43, label %42

42:                                               ; preds = %39
  tail call void @free(ptr noundef nonnull %41) #5
  br label %43

43:                                               ; preds = %42, %39
  %44 = getelementptr inbounds i8, ptr %0, i64 64
  %45 = load ptr, ptr %44, align 8, !tbaa !25
  %.not8 = icmp eq ptr %45, null
  br i1 %.not8, label %47, label %46

46:                                               ; preds = %43
  tail call void @free(ptr noundef nonnull %45) #5
  br label %47

47:                                               ; preds = %46, %43
  %48 = getelementptr inbounds i8, ptr %0, i64 72
  tail call void @_ZN7R3SolidD2Ev(ptr noundef nonnull align 8 dereferenceable(56) %48) #5
  %49 = getelementptr inbounds i8, ptr %0, i64 24
  tail call void @_ZN8RNVArrayD2Ev(ptr noundef nonnull align 8 dereferenceable(16) %49) #5
  %50 = getelementptr inbounds i8, ptr %0, i64 8
  tail call void @_ZN8RNVArrayD2Ev(ptr noundef nonnull align 8 dereferenceable(16) %50) #5
  ret void

.loopexit:                                        ; preds = %.preheader, %20, %22
  %lpad.loopexit = landingpad { ptr, i32 }
          catch ptr null
  br label %51

.loopexit.split-lp:                               ; preds = %2, %6, %8
  %lpad.loopexit.split-lp = landingpad { ptr, i32 }
          catch ptr null
  br label %51

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef i32 @_ZNK17RGBDConfiguration7NImagesEv(ptr noundef nonnull align 8 dereferenceable(128)) local_unnamed_addr #2 align 2

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef ptr @_ZNK17RGBDConfiguration5ImageEi(ptr noundef nonnull align 8 dereferenceable(128), i32 noundef) local_unnamed_addr #2 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef i32 @_ZNK17RGBDConfiguration9NSurfacesEv(ptr noundef nonnull align 8 dereferenceable(128)) local_unnamed_addr #2 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef ptr @_ZNK17RGBDConfiguration7SurfaceEi(ptr noundef nonnull align 8 dereferenceable(128), i32 noundef) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite)
declare void @free(ptr allocptr nocapture noundef) local_unnamed_addr #4

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

attributes #0 = { 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 #1 = { 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 = { inlinehint 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 = { 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 #4 = { mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite) "alloc-family"="malloc" "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 = !{!"vtable pointer", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}
!8 = distinct !{!8, !9}
!9 = !{!"llvm.loop.mustprogress"}
!10 = distinct !{!10, !9}
!11 = !{!12, !15, i64 40}
!12 = !{!"_ZTS17RGBDConfiguration", !13, i64 8, !18, i64 24, !15, i64 40, !15, i64 48, !15, i64 56, !15, i64 64, !19, i64 72}
!13 = !{!"_ZTS7RNArrayIP9RGBDImageE", !14, i64 0}
!14 = !{!"_ZTS8RNVArray", !15, i64 0, !17, i64 8, !17, i64 12}
!15 = !{!"any pointer", !16, i64 0}
!16 = !{!"omnipotent char", !7, i64 0}
!17 = !{!"int", !16, i64 0}
!18 = !{!"_ZTS7RNArrayIP11RGBDSurfaceE", !14, i64 0}
!19 = !{!"_ZTS5R3Box", !20, i64 0, !22, i64 8, !22, i64 32}
!20 = !{!"_ZTS7R3Solid", !21, i64 0}
!21 = !{!"_ZTS7R3Shape"}
!22 = !{!"_ZTS7R3Point", !16, i64 0}
!23 = !{!12, !15, i64 48}
!24 = !{!12, !15, i64 56}
!25 = !{!12, !15, i64 64}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass