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

; 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.RGBDImage = type { ptr, ptr, i32, %class.RNArray, i32, i32, %class.R3Affine, %class.R3Matrix, %class.R3Box, i32, ptr, ptr, ptr, i32, i32 }
%class.RNArray = type { %class.RNVArray }
%class.RNVArray = type { ptr, i32, i32 }
%class.R3Affine = type { %class.R3Transformation, %class.R4Matrix, %class.R4Matrix, %class.RNFlags }
%class.R3Transformation = type { ptr }
%class.R4Matrix = type { [4 x [4 x double]] }
%class.RNFlags = type { i64 }
%class.R3Matrix = type { [3 x [3 x double]] }
%class.R3Box = type { %class.R3Solid, %class.R3Point, %class.R3Point }
%class.R3Solid = type { %class.R3Shape }
%class.R3Shape = type { ptr }
%class.R3Point = type { [3 x double] }

@_ZTV9RGBDImage = external dso_local unnamed_addr constant { [43 x ptr] }, align 8

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

declare i32 @__gxx_personality_v0(...)

declare void @_ZN8R3AffineC1ERK8R4Matrixi(ptr noundef nonnull align 8 dereferenceable(272), ptr noundef nonnull align 8 dereferenceable(128), i32 noundef) unnamed_addr #1

declare void @_ZN5R3BoxC1Edddddd(ptr noundef nonnull align 8 dereferenceable(56), double noundef, double noundef, double noundef, double noundef, double noundef, double noundef) unnamed_addr #1

; Function Attrs: nounwind
declare void @_ZN8R3AffineD1Ev(ptr noundef nonnull align 8 dereferenceable(272)) unnamed_addr #2

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN9RGBDImageC2EPKcS1_RK8R3MatrixRK8R4Matrixii(ptr noundef nonnull align 8 dereferenceable(488) %0, ptr noundef %1, ptr noundef %2, ptr noundef nonnull align 8 dereferenceable(72) %3, ptr noundef nonnull align 8 dereferenceable(128) %4, i32 noundef %5, i32 noundef %6) unnamed_addr #0 align 2 personality ptr @__gxx_personality_v0 {
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca ptr, align 8
  %16 = alloca i32, align 4
  store ptr %0, ptr %8, align 8, !tbaa !5
  store ptr %1, ptr %9, align 8, !tbaa !5
  store ptr %2, ptr %10, align 8, !tbaa !5
  store ptr %3, ptr %11, align 8, !tbaa !5
  store ptr %4, ptr %12, align 8, !tbaa !5
  store i32 %5, ptr %13, align 4, !tbaa !9
  store i32 %6, ptr %14, align 4, !tbaa !9
  %17 = load ptr, ptr %8, align 8
  store ptr getelementptr inbounds inrange(-16, 328) ({ [43 x ptr] }, ptr @_ZTV9RGBDImage, i32 0, i32 0, i32 2), ptr %17, align 8, !tbaa !11
  %18 = getelementptr inbounds %class.RGBDImage, ptr %17, i32 0, i32 1
  store ptr null, ptr %18, align 8, !tbaa !13
  %19 = getelementptr inbounds %class.RGBDImage, ptr %17, i32 0, i32 2
  store i32 -1, ptr %19, align 8, !tbaa !27
  %20 = getelementptr inbounds %class.RGBDImage, ptr %17, i32 0, i32 3
  call void @_ZN7RNArrayIP6R2GridEC2Ev(ptr noundef nonnull align 8 dereferenceable(16) %20)
  %21 = getelementptr inbounds %class.RGBDImage, ptr %17, i32 0, i32 4
  %22 = load i32, ptr %13, align 4, !tbaa !9
  store i32 %22, ptr %21, align 8, !tbaa !28
  %23 = getelementptr inbounds %class.RGBDImage, ptr %17, i32 0, i32 5
  %24 = load i32, ptr %14, align 4, !tbaa !9
  store i32 %24, ptr %23, align 4, !tbaa !29
  %25 = getelementptr inbounds %class.RGBDImage, ptr %17, i32 0, i32 6
  %26 = load ptr, ptr %12, align 8, !tbaa !5
  invoke void @_ZN8R3AffineC1ERK8R4Matrixi(ptr noundef nonnull align 8 dereferenceable(272) %25, ptr noundef nonnull align 8 dereferenceable(128) %26, i32 noundef 0)
          to label %27 unwind label %47

27:                                               ; preds = %7
  %28 = getelementptr inbounds %class.RGBDImage, ptr %17, i32 0, i32 7
  %29 = load ptr, ptr %11, align 8, !tbaa !5
  invoke void @_ZN8R3MatrixC1ERKS_(ptr noundef nonnull align 8 dereferenceable(72) %28, ptr noundef nonnull align 8 dereferenceable(72) %29)
          to label %30 unwind label %51

30:                                               ; preds = %27
  %31 = getelementptr inbounds %class.RGBDImage, ptr %17, i32 0, i32 8
  invoke void @_ZN5R3BoxC1Edddddd(ptr noundef nonnull align 8 dereferenceable(56) %31, double noundef 0x47EFFFFFE0000000, double noundef 0x47EFFFFFE0000000, double noundef 0x47EFFFFFE0000000, double noundef 0xC7EFFFFFE0000000, double noundef 0xC7EFFFFFE0000000, double noundef 0xC7EFFFFFE0000000)
          to label %32 unwind label %51

32:                                               ; preds = %30
  %33 = getelementptr inbounds %class.RGBDImage, ptr %17, i32 0, i32 9
  store i32 -1, ptr %33, align 8, !tbaa !30
  %34 = getelementptr inbounds %class.RGBDImage, ptr %17, i32 0, i32 10
  store ptr null, ptr %34, align 8, !tbaa !31
  %35 = getelementptr inbounds %class.RGBDImage, ptr %17, i32 0, i32 11
  store ptr null, ptr %35, align 8, !tbaa !32
  %36 = getelementptr inbounds %class.RGBDImage, ptr %17, i32 0, i32 12
  store ptr null, ptr %36, align 8, !tbaa !33
  %37 = getelementptr inbounds %class.RGBDImage, ptr %17, i32 0, i32 13
  store i32 0, ptr %37, align 8, !tbaa !34
  %38 = getelementptr inbounds %class.RGBDImage, ptr %17, i32 0, i32 14
  store i32 0, ptr %38, align 4, !tbaa !35
  %39 = load ptr, ptr %10, align 8, !tbaa !5
  %40 = icmp ne ptr %39, null
  br i1 %40, label %41, label %59

41:                                               ; preds = %32
  %42 = load ptr, ptr %10, align 8, !tbaa !5
  %43 = load ptr, ptr %17, align 8, !tbaa !11
  %44 = getelementptr inbounds ptr, ptr %43, i64 37
  %45 = load ptr, ptr %44, align 8
  invoke void %45(ptr noundef nonnull align 8 dereferenceable(488) %17, ptr noundef %42)
          to label %46 unwind label %55

46:                                               ; preds = %41
  br label %59

47:                                               ; preds = %7
  %48 = landingpad { ptr, i32 }
          cleanup
  %49 = extractvalue { ptr, i32 } %48, 0
  store ptr %49, ptr %15, align 8
  %50 = extractvalue { ptr, i32 } %48, 1
  store i32 %50, ptr %16, align 4
  br label %70

51:                                               ; preds = %30, %27
  %52 = landingpad { ptr, i32 }
          cleanup
  %53 = extractvalue { ptr, i32 } %52, 0
  store ptr %53, ptr %15, align 8
  %54 = extractvalue { ptr, i32 } %52, 1
  store i32 %54, ptr %16, align 4
  br label %69

55:                                               ; preds = %62, %41
  %56 = landingpad { ptr, i32 }
          cleanup
  %57 = extractvalue { ptr, i32 } %56, 0
  store ptr %57, ptr %15, align 8
  %58 = extractvalue { ptr, i32 } %56, 1
  store i32 %58, ptr %16, align 4
  call void @_ZN7R3SolidD2Ev(ptr noundef nonnull align 8 dereferenceable(56) %31) #3
  br label %69

59:                                               ; preds = %46, %32
  %60 = load ptr, ptr %9, align 8, !tbaa !5
  %61 = icmp ne ptr %60, null
  br i1 %61, label %62, label %68

62:                                               ; preds = %59
  %63 = load ptr, ptr %9, align 8, !tbaa !5
  %64 = load ptr, ptr %17, align 8, !tbaa !11
  %65 = getelementptr inbounds ptr, ptr %64, i64 36
  %66 = load ptr, ptr %65, align 8
  invoke void %66(ptr noundef nonnull align 8 dereferenceable(488) %17, ptr noundef %63)
          to label %67 unwind label %55

67:                                               ; preds = %62
  br label %68

68:                                               ; preds = %67, %59
  ret void

69:                                               ; preds = %55, %51
  call void @_ZN8R3AffineD1Ev(ptr noundef nonnull align 8 dereferenceable(272) %25) #3
  br label %70

70:                                               ; preds = %69, %47
  call void @_ZN8RNVArrayD2Ev(ptr noundef nonnull align 8 dereferenceable(16) %20) #3
  br label %71

71:                                               ; preds = %70
  %72 = load ptr, ptr %15, align 8
  %73 = load i32, ptr %16, align 4
  %74 = insertvalue { ptr, i32 } poison, ptr %72, 0
  %75 = insertvalue { ptr, i32 } %74, i32 %73, 1
  resume { ptr, i32 } %75
}

declare void @_ZN8R3MatrixC1ERKS_(ptr noundef nonnull align 8 dereferenceable(72), ptr noundef nonnull align 8 dereferenceable(72)) unnamed_addr #1

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

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 = { "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 = { 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 #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 = !{!"int", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"vtable pointer", !8, i64 0}
!13 = !{!14, !6, i64 8}
!14 = !{!"_ZTS9RGBDImage", !6, i64 8, !10, i64 16, !15, i64 24, !10, i64 40, !10, i64 44, !17, i64 48, !22, i64 320, !23, i64 392, !10, i64 448, !6, i64 456, !6, i64 464, !6, i64 472, !10, i64 480, !10, i64 484}
!15 = !{!"_ZTS7RNArrayIP6R2GridE", !16, i64 0}
!16 = !{!"_ZTS8RNVArray", !6, i64 0, !10, i64 8, !10, i64 12}
!17 = !{!"_ZTS8R3Affine", !18, i64 0, !19, i64 8, !19, i64 136, !20, i64 264}
!18 = !{!"_ZTS16R3Transformation"}
!19 = !{!"_ZTS8R4Matrix", !7, i64 0}
!20 = !{!"_ZTS7RNFlags", !21, i64 0}
!21 = !{!"long", !7, i64 0}
!22 = !{!"_ZTS8R3Matrix", !7, i64 0}
!23 = !{!"_ZTS5R3Box", !24, i64 0, !26, i64 8, !26, i64 32}
!24 = !{!"_ZTS7R3Solid", !25, i64 0}
!25 = !{!"_ZTS7R3Shape"}
!26 = !{!"_ZTS7R3Point", !7, i64 0}
!27 = !{!14, !10, i64 16}
!28 = !{!14, !10, i64 40}
!29 = !{!14, !10, i64 44}
!30 = !{!14, !10, i64 448}
!31 = !{!14, !6, i64 456}
!32 = !{!14, !6, i64 464}
!33 = !{!14, !6, i64 472}
!34 = !{!14, !10, i64 480}
!35 = !{!14, !10, i64 484}


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

@_ZTV9RGBDImage = external dso_local unnamed_addr constant { [43 x ptr] }, align 8

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

declare i32 @__gxx_personality_v0(...)

declare void @_ZN8R3AffineC1ERK8R4Matrixi(ptr noundef nonnull align 8 dereferenceable(272), ptr noundef nonnull align 8 dereferenceable(128), i32 noundef) unnamed_addr #1

declare void @_ZN5R3BoxC1Edddddd(ptr noundef nonnull align 8 dereferenceable(56), double noundef, double noundef, double noundef, double noundef, double noundef, double noundef) unnamed_addr #1

; Function Attrs: nounwind
declare void @_ZN8R3AffineD1Ev(ptr noundef nonnull align 8 dereferenceable(272)) unnamed_addr #2

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN9RGBDImageC2EPKcS1_RK8R3MatrixRK8R4Matrixii(ptr noundef nonnull align 8 dereferenceable(488) %0, ptr noundef %1, ptr noundef %2, ptr noundef nonnull align 8 dereferenceable(72) %3, ptr noundef nonnull align 8 dereferenceable(128) %4, i32 noundef %5, i32 noundef %6) unnamed_addr #0 align 2 personality ptr @__gxx_personality_v0 {
  store ptr getelementptr inbounds inrange(-16, 328) (i8, ptr @_ZTV9RGBDImage, i64 16), ptr %0, align 8, !tbaa !5
  %8 = getelementptr inbounds i8, ptr %0, i64 8
  store ptr null, ptr %8, align 8, !tbaa !8
  %9 = getelementptr inbounds i8, ptr %0, i64 16
  store i32 -1, ptr %9, align 8, !tbaa !25
  %10 = getelementptr inbounds i8, ptr %0, i64 24
  tail call void @_ZN7RNArrayIP6R2GridEC2Ev(ptr noundef nonnull align 8 dereferenceable(16) %10)
  %11 = getelementptr inbounds i8, ptr %0, i64 40
  store i32 %5, ptr %11, align 8, !tbaa !26
  %12 = getelementptr inbounds i8, ptr %0, i64 44
  store i32 %6, ptr %12, align 4, !tbaa !27
  %13 = getelementptr inbounds i8, ptr %0, i64 48
  invoke void @_ZN8R3AffineC1ERK8R4Matrixi(ptr noundef nonnull align 8 dereferenceable(272) %13, ptr noundef nonnull align 8 dereferenceable(128) %4, i32 noundef 0)
          to label %14 unwind label %25

14:                                               ; preds = %7
  %15 = getelementptr inbounds i8, ptr %0, i64 320
  invoke void @_ZN8R3MatrixC1ERKS_(ptr noundef nonnull align 8 dereferenceable(72) %15, ptr noundef nonnull align 8 dereferenceable(72) %3)
          to label %16 unwind label %27

16:                                               ; preds = %14
  %17 = getelementptr inbounds i8, ptr %0, i64 392
  invoke void @_ZN5R3BoxC1Edddddd(ptr noundef nonnull align 8 dereferenceable(56) %17, double noundef 0x47EFFFFFE0000000, double noundef 0x47EFFFFFE0000000, double noundef 0x47EFFFFFE0000000, double noundef 0xC7EFFFFFE0000000, double noundef 0xC7EFFFFFE0000000, double noundef 0xC7EFFFFFE0000000)
          to label %18 unwind label %27

18:                                               ; preds = %16
  %19 = getelementptr inbounds i8, ptr %0, i64 448
  store i32 -1, ptr %19, align 8, !tbaa !28
  %20 = getelementptr inbounds i8, ptr %0, i64 456
  %.not = icmp eq ptr %2, null
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(32) %20, i8 0, i64 32, i1 false)
  br i1 %.not, label %31, label %21

21:                                               ; preds = %18
  %22 = load ptr, ptr %0, align 8, !tbaa !5
  %23 = getelementptr inbounds i8, ptr %22, i64 296
  %24 = load ptr, ptr %23, align 8
  invoke void %24(ptr noundef nonnull align 8 dereferenceable(488) %0, ptr noundef nonnull %2)
          to label %31 unwind label %29

25:                                               ; preds = %7
  %26 = landingpad { ptr, i32 }
          cleanup
  br label %38

27:                                               ; preds = %16, %14
  %28 = landingpad { ptr, i32 }
          cleanup
  br label %37

29:                                               ; preds = %32, %21
  %30 = landingpad { ptr, i32 }
          cleanup
  tail call void @_ZN7R3SolidD2Ev(ptr noundef nonnull align 8 dereferenceable(56) %17) #4
  br label %37

31:                                               ; preds = %21, %18
  %.not14 = icmp eq ptr %1, null
  br i1 %.not14, label %36, label %32

32:                                               ; preds = %31
  %33 = load ptr, ptr %0, align 8, !tbaa !5
  %34 = getelementptr inbounds i8, ptr %33, i64 288
  %35 = load ptr, ptr %34, align 8
  invoke void %35(ptr noundef nonnull align 8 dereferenceable(488) %0, ptr noundef nonnull %1)
          to label %36 unwind label %29

36:                                               ; preds = %32, %31
  ret void

37:                                               ; preds = %29, %27
  %.pn = phi { ptr, i32 } [ %30, %29 ], [ %28, %27 ]
  tail call void @_ZN8R3AffineD1Ev(ptr noundef nonnull align 8 dereferenceable(272) %13) #4
  br label %38

38:                                               ; preds = %37, %25
  %.pn.pn = phi { ptr, i32 } [ %.pn, %37 ], [ %26, %25 ]
  tail call void @_ZN8RNVArrayD2Ev(ptr noundef nonnull align 8 dereferenceable(16) %10) #4
  resume { ptr, i32 } %.pn.pn
}

declare void @_ZN8R3MatrixC1ERKS_(ptr noundef nonnull align 8 dereferenceable(72), ptr noundef nonnull align 8 dereferenceable(72)) unnamed_addr #1

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #3

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 = { "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 = { 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 #3 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #4 = { 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 = !{!9, !10, i64 8}
!9 = !{!"_ZTS9RGBDImage", !10, i64 8, !12, i64 16, !13, i64 24, !12, i64 40, !12, i64 44, !15, i64 48, !20, i64 320, !21, i64 392, !12, i64 448, !10, i64 456, !10, i64 464, !10, i64 472, !12, i64 480, !12, i64 484}
!10 = !{!"any pointer", !11, i64 0}
!11 = !{!"omnipotent char", !7, i64 0}
!12 = !{!"int", !11, i64 0}
!13 = !{!"_ZTS7RNArrayIP6R2GridE", !14, i64 0}
!14 = !{!"_ZTS8RNVArray", !10, i64 0, !12, i64 8, !12, i64 12}
!15 = !{!"_ZTS8R3Affine", !16, i64 0, !17, i64 8, !17, i64 136, !18, i64 264}
!16 = !{!"_ZTS16R3Transformation"}
!17 = !{!"_ZTS8R4Matrix", !11, i64 0}
!18 = !{!"_ZTS7RNFlags", !19, i64 0}
!19 = !{!"long", !11, i64 0}
!20 = !{!"_ZTS8R3Matrix", !11, i64 0}
!21 = !{!"_ZTS5R3Box", !22, i64 0, !24, i64 8, !24, i64 32}
!22 = !{!"_ZTS7R3Solid", !23, i64 0}
!23 = !{!"_ZTS7R3Shape"}
!24 = !{!"_ZTS7R3Point", !11, i64 0}
!25 = !{!9, !12, i64 16}
!26 = !{!9, !12, i64 40}
!27 = !{!9, !12, i64 44}
!28 = !{!9, !12, i64 448}


; Effective O3 passes: InstCombinePass,MemCpyOptPass,SROAPass,SimplifyCFGPass,TailCallElimPass