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

; 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] }

declare i32 @__gxx_personality_v0(...)

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

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

; Function Attrs: nobuiltin nounwind
declare void @_ZdlPvm(ptr noundef, i64 noundef) #2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK6R2Grid11XResolutionEv(ptr noundef nonnull align 8 dereferenceable(208)) #0 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK6R2Grid11YResolutionEv(ptr noundef nonnull align 8 dereferenceable(208)) #0 align 2

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

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znwm(i64 noundef) #3

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZN9RGBDImage18CreateDepthChannelERK6R2Grid(ptr noundef nonnull align 8 dereferenceable(488) %0, ptr noundef nonnull align 8 dereferenceable(208) %1) unnamed_addr #1 align 2 personality ptr @__gxx_personality_v0 {
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  %8 = load ptr, ptr %4, align 8
  %9 = getelementptr inbounds %class.RGBDImage, ptr %8, i32 0, i32 14
  %10 = load i32, ptr %9, align 4, !tbaa !9
  %11 = add nsw i32 %10, 1
  store i32 %11, ptr %9, align 4, !tbaa !9
  %12 = icmp sgt i32 %10, 0
  br i1 %12, label %13, label %14

13:                                               ; preds = %2
  store i32 1, ptr %3, align 4
  br label %48

14:                                               ; preds = %2
  br label %15

15:                                               ; preds = %19, %14
  %16 = getelementptr inbounds %class.RGBDImage, ptr %8, i32 0, i32 3
  %17 = call noundef i32 @_ZNK8RNVArray8NEntriesEv(ptr noundef nonnull align 8 dereferenceable(16) %16)
  %18 = icmp sle i32 %17, 3
  br i1 %18, label %19, label %22

19:                                               ; preds = %15
  %20 = getelementptr inbounds %class.RGBDImage, ptr %8, i32 0, i32 3
  %21 = call noundef ptr @_ZN7RNArrayIP6R2GridE6InsertES1_(ptr noundef nonnull align 8 dereferenceable(16) %20, ptr noundef null)
  br label %15, !llvm.loop !24

22:                                               ; preds = %15
  %23 = getelementptr inbounds %class.RGBDImage, ptr %8, i32 0, i32 3
  %24 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZN7RNArrayIP6R2GridEixEi(ptr noundef nonnull align 8 dereferenceable(16) %23, i32 noundef 3)
  %25 = load ptr, ptr %24, align 8, !tbaa !5
  %26 = icmp ne ptr %25, null
  br i1 %26, label %37, label %27

27:                                               ; preds = %22
  %28 = call noalias noundef nonnull ptr @_Znwm(i64 noundef 208) #5
  %29 = load ptr, ptr %5, align 8, !tbaa !5
  invoke void @_ZN6R2GridC1ERKS_(ptr noundef nonnull align 8 dereferenceable(208) %28, ptr noundef nonnull align 8 dereferenceable(208) %29)
          to label %30 unwind label %33

30:                                               ; preds = %27
  %31 = getelementptr inbounds %class.RGBDImage, ptr %8, i32 0, i32 3
  %32 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZN7RNArrayIP6R2GridEixEi(ptr noundef nonnull align 8 dereferenceable(16) %31, i32 noundef 3)
  store ptr %28, ptr %32, align 8, !tbaa !5
  br label %37

33:                                               ; preds = %27
  %34 = landingpad { ptr, i32 }
          cleanup
  %35 = extractvalue { ptr, i32 } %34, 0
  store ptr %35, ptr %6, align 8
  %36 = extractvalue { ptr, i32 } %34, 1
  store i32 %36, ptr %7, align 4
  call void @_ZdlPvm(ptr noundef %28, i64 noundef 208) #6
  br label %50

37:                                               ; preds = %30, %22
  %38 = load ptr, ptr %5, align 8, !tbaa !5
  %39 = load ptr, ptr %8, align 8, !tbaa !26
  %40 = getelementptr inbounds ptr, ptr %39, i64 7
  %41 = load ptr, ptr %40, align 8
  call void %41(ptr noundef nonnull align 8 dereferenceable(488) %8, ptr noundef nonnull align 8 dereferenceable(208) %38)
  %42 = load ptr, ptr %5, align 8, !tbaa !5
  %43 = call noundef i32 @_ZNK6R2Grid11XResolutionEv(ptr noundef nonnull align 8 dereferenceable(208) %42)
  %44 = getelementptr inbounds %class.RGBDImage, ptr %8, i32 0, i32 4
  store i32 %43, ptr %44, align 8, !tbaa !28
  %45 = load ptr, ptr %5, align 8, !tbaa !5
  %46 = call noundef i32 @_ZNK6R2Grid11YResolutionEv(ptr noundef nonnull align 8 dereferenceable(208) %45)
  %47 = getelementptr inbounds %class.RGBDImage, ptr %8, i32 0, i32 5
  store i32 %46, ptr %47, align 4, !tbaa !29
  store i32 1, ptr %3, align 4
  br label %48

48:                                               ; preds = %37, %13
  %49 = load i32, ptr %3, align 4
  ret i32 %49

50:                                               ; preds = %33
  %51 = load ptr, ptr %6, align 8
  %52 = load i32, ptr %7, align 4
  %53 = insertvalue { ptr, i32 } poison, ptr %51, 0
  %54 = insertvalue { ptr, i32 } %53, i32 %52, 1
  resume { ptr, i32 } %54
}

declare void @_ZN6R2GridC1ERKS_(ptr noundef nonnull align 8 dereferenceable(208), ptr noundef nonnull align 8 dereferenceable(208)) unnamed_addr #4

attributes #0 = { 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 #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 = { nobuiltin 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 = { nobuiltin allocsize(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 = { "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 = { builtin allocsize(0) }
attributes #6 = { builtin 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, !11, i64 484}
!10 = !{!"_ZTS9RGBDImage", !6, i64 8, !11, i64 16, !12, i64 24, !11, i64 40, !11, i64 44, !14, i64 48, !19, i64 320, !20, i64 392, !11, i64 448, !6, i64 456, !6, i64 464, !6, i64 472, !11, i64 480, !11, i64 484}
!11 = !{!"int", !7, i64 0}
!12 = !{!"_ZTS7RNArrayIP6R2GridE", !13, i64 0}
!13 = !{!"_ZTS8RNVArray", !6, i64 0, !11, i64 8, !11, i64 12}
!14 = !{!"_ZTS8R3Affine", !15, i64 0, !16, i64 8, !16, i64 136, !17, i64 264}
!15 = !{!"_ZTS16R3Transformation"}
!16 = !{!"_ZTS8R4Matrix", !7, i64 0}
!17 = !{!"_ZTS7RNFlags", !18, i64 0}
!18 = !{!"long", !7, i64 0}
!19 = !{!"_ZTS8R3Matrix", !7, 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 = distinct !{!24, !25}
!25 = !{!"llvm.loop.mustprogress"}
!26 = !{!27, !27, i64 0}
!27 = !{!"vtable pointer", !8, i64 0}
!28 = !{!10, !11, i64 40}
!29 = !{!10, !11, i64 44}


; 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: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK8RNVArray8NEntriesEv(ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #0 align 2

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

; Function Attrs: nobuiltin nounwind
declare void @_ZdlPvm(ptr noundef, i64 noundef) local_unnamed_addr #2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK6R2Grid11XResolutionEv(ptr noundef nonnull align 8 dereferenceable(208)) local_unnamed_addr #0 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK6R2Grid11YResolutionEv(ptr noundef nonnull align 8 dereferenceable(208)) local_unnamed_addr #0 align 2

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

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znwm(i64 noundef) local_unnamed_addr #3

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZN9RGBDImage18CreateDepthChannelERK6R2Grid(ptr noundef nonnull align 8 dereferenceable(488) %0, ptr noundef nonnull align 8 dereferenceable(208) %1) unnamed_addr #1 align 2 personality ptr @__gxx_personality_v0 {
  %3 = getelementptr inbounds i8, ptr %0, i64 484
  %4 = load i32, ptr %3, align 4, !tbaa !5
  %5 = add nsw i32 %4, 1
  store i32 %5, ptr %3, align 4, !tbaa !5
  %6 = icmp sgt i32 %4, 0
  br i1 %6, label %29, label %.preheader

.preheader:                                       ; preds = %2
  %7 = getelementptr inbounds i8, ptr %0, i64 24
  %8 = tail call noundef i32 @_ZNK8RNVArray8NEntriesEv(ptr noundef nonnull align 8 dereferenceable(16) %7)
  %9 = icmp slt i32 %8, 4
  br i1 %9, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %.preheader, %.lr.ph
  %10 = tail call noundef ptr @_ZN7RNArrayIP6R2GridE6InsertES1_(ptr noundef nonnull align 8 dereferenceable(16) %7, ptr noundef null)
  %11 = tail call noundef i32 @_ZNK8RNVArray8NEntriesEv(ptr noundef nonnull align 8 dereferenceable(16) %7)
  %12 = icmp slt i32 %11, 4
  br i1 %12, label %.lr.ph, label %._crit_edge, !llvm.loop !23

._crit_edge:                                      ; preds = %.lr.ph, %.preheader
  %13 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZN7RNArrayIP6R2GridEixEi(ptr noundef nonnull align 8 dereferenceable(16) %7, i32 noundef 3)
  %14 = load ptr, ptr %13, align 8, !tbaa !25
  %.not = icmp eq ptr %14, null
  br i1 %.not, label %15, label %21

15:                                               ; preds = %._crit_edge
  %16 = tail call noalias noundef nonnull dereferenceable(208) ptr @_Znwm(i64 noundef 208) #5
  invoke void @_ZN6R2GridC1ERKS_(ptr noundef nonnull align 8 dereferenceable(208) %16, ptr noundef nonnull align 8 dereferenceable(208) %1)
          to label %17 unwind label %19

17:                                               ; preds = %15
  %18 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZN7RNArrayIP6R2GridEixEi(ptr noundef nonnull align 8 dereferenceable(16) %7, i32 noundef 3)
  store ptr %16, ptr %18, align 8, !tbaa !25
  br label %21

19:                                               ; preds = %15
  %20 = landingpad { ptr, i32 }
          cleanup
  tail call void @_ZdlPvm(ptr noundef nonnull %16, i64 noundef 208) #6
  resume { ptr, i32 } %20

21:                                               ; preds = %17, %._crit_edge
  %22 = load ptr, ptr %0, align 8, !tbaa !26
  %23 = getelementptr inbounds i8, ptr %22, i64 56
  %24 = load ptr, ptr %23, align 8
  tail call void %24(ptr noundef nonnull align 8 dereferenceable(488) %0, ptr noundef nonnull align 8 dereferenceable(208) %1)
  %25 = tail call noundef i32 @_ZNK6R2Grid11XResolutionEv(ptr noundef nonnull align 8 dereferenceable(208) %1)
  %26 = getelementptr inbounds i8, ptr %0, i64 40
  store i32 %25, ptr %26, align 8, !tbaa !28
  %27 = tail call noundef i32 @_ZNK6R2Grid11YResolutionEv(ptr noundef nonnull align 8 dereferenceable(208) %1)
  %28 = getelementptr inbounds i8, ptr %0, i64 44
  store i32 %27, ptr %28, align 4, !tbaa !29
  br label %29

29:                                               ; preds = %2, %21
  ret i32 1
}

declare void @_ZN6R2GridC1ERKS_(ptr noundef nonnull align 8 dereferenceable(208), ptr noundef nonnull align 8 dereferenceable(208)) unnamed_addr #4

attributes #0 = { 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 #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 = { nobuiltin 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 = { nobuiltin allocsize(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 = { "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 = { builtin allocsize(0) }
attributes #6 = { builtin 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, !10, i64 484}
!6 = !{!"_ZTS9RGBDImage", !7, i64 8, !10, i64 16, !11, i64 24, !10, i64 40, !10, i64 44, !13, i64 48, !18, i64 320, !19, i64 392, !10, i64 448, !7, i64 456, !7, i64 464, !7, i64 472, !10, i64 480, !10, i64 484}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!"_ZTS7RNArrayIP6R2GridE", !12, i64 0}
!12 = !{!"_ZTS8RNVArray", !7, i64 0, !10, i64 8, !10, i64 12}
!13 = !{!"_ZTS8R3Affine", !14, i64 0, !15, i64 8, !15, i64 136, !16, i64 264}
!14 = !{!"_ZTS16R3Transformation"}
!15 = !{!"_ZTS8R4Matrix", !8, i64 0}
!16 = !{!"_ZTS7RNFlags", !17, i64 0}
!17 = !{!"long", !8, i64 0}
!18 = !{!"_ZTS8R3Matrix", !8, i64 0}
!19 = !{!"_ZTS5R3Box", !20, i64 0, !22, i64 8, !22, i64 32}
!20 = !{!"_ZTS7R3Solid", !21, i64 0}
!21 = !{!"_ZTS7R3Shape"}
!22 = !{!"_ZTS7R3Point", !8, i64 0}
!23 = distinct !{!23, !24}
!24 = !{!"llvm.loop.mustprogress"}
!25 = !{!7, !7, i64 0}
!26 = !{!27, !27, i64 0}
!27 = !{!"vtable pointer", !9, i64 0}
!28 = !{!6, !10, i64 40}
!29 = !{!6, !10, i64 44}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,InstCombinePass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass