; LLVM IR from niessner/Matterport :: code/gaps/pkgs/R3Graphics/R3Scene.ll (ZN7R3Scene12ReadMeshFileEPKcP11R3SceneNode)

; 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.R3Scene = type { ptr, %class.RNArray, %class.RNArray.0, %class.RNArray.1, %class.RNArray.2, %class.RNArray.3, %class.RNArray.4, %class.RNSymbolTable, %class.R3Viewer, %class.RNRgb, %class.RNRgb, ptr, ptr, ptr }
%class.RNArray = type { %class.RNVArray }
%class.RNVArray = type { ptr, i32, i32 }
%class.RNArray.0 = type { %class.RNVArray }
%class.RNArray.1 = type { %class.RNVArray }
%class.RNArray.2 = type { %class.RNVArray }
%class.RNArray.3 = type { %class.RNVArray }
%class.RNArray.4 = type { %class.RNVArray }
%class.RNSymbolTable = type { %class.RNMap }
%class.RNMap = type { ptr }
%class.R3Viewer = type { ptr, %class.R3Camera, %class.R2Viewport }
%class.R3Camera = type { %class.R3CoordSystem, double, double, double, double, double, ptr }
%class.R3CoordSystem = type { %class.R3Point, %class.R3Triad }
%class.R3Point = type { [3 x double] }
%class.R3Triad = type { [3 x %class.R3Vector] }
%class.R3Vector = type { [3 x double] }
%class.R2Viewport = type { i32, i32, i32, i32 }
%class.RNRgb = type { [3 x double] }

declare i32 @__gxx_personality_v0(...)

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

declare void @_ZN11R3SceneNodeC1EP7R3Scene(ptr noundef nonnull align 8 dereferenceable(432), ptr noundef) unnamed_addr #1

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

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #3

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #3

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZN7R3Scene12ReadMeshFileEPKcP11R3SceneNode(ptr noundef nonnull align 8 dereferenceable(352) %0, ptr noundef %1, ptr noundef %2) #4 align 2 personality ptr @__gxx_personality_v0 {
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca i32, align 4
  %13 = alloca ptr, align 8
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store ptr %2, ptr %7, align 8, !tbaa !5
  %14 = load ptr, ptr %5, align 8
  %15 = load ptr, ptr %7, align 8, !tbaa !5
  %16 = icmp ne ptr %15, null
  br i1 %16, label %20, label %17

17:                                               ; preds = %3
  %18 = getelementptr inbounds %class.R3Scene, ptr %14, i32 0, i32 0
  %19 = load ptr, ptr %18, align 8, !tbaa !9
  store ptr %19, ptr %7, align 8, !tbaa !5
  br label %20

20:                                               ; preds = %17, %3
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #5
  %21 = load ptr, ptr %6, align 8, !tbaa !5
  %22 = call noundef ptr @_ZL8ReadMeshPKc(ptr noundef %21)
  store ptr %22, ptr %8, align 8, !tbaa !5
  %23 = load ptr, ptr %8, align 8, !tbaa !5
  %24 = icmp ne ptr %23, null
  br i1 %24, label %26, label %25

25:                                               ; preds = %20
  store i32 0, ptr %4, align 4
  store i32 1, ptr %9, align 4
  br label %46

26:                                               ; preds = %20
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #5
  %27 = call noalias noundef nonnull ptr @_Znwm(i64 noundef 96) #6
  invoke void @_ZN14R3SceneElementC1EP10R3Material(ptr noundef nonnull align 8 dereferenceable(96) %27, ptr noundef null)
          to label %28 unwind label %37

28:                                               ; preds = %26
  store ptr %27, ptr %10, align 8, !tbaa !5
  %29 = load ptr, ptr %10, align 8, !tbaa !5
  %30 = load ptr, ptr %8, align 8, !tbaa !5
  call void @_ZN14R3SceneElement11InsertShapeEP7R3Shape(ptr noundef nonnull align 8 dereferenceable(96) %29, ptr noundef %30)
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #5
  %31 = call noalias noundef nonnull ptr @_Znwm(i64 noundef 432) #6
  invoke void @_ZN11R3SceneNodeC1EP7R3Scene(ptr noundef nonnull align 8 dereferenceable(432) %31, ptr noundef %14)
          to label %32 unwind label %41

32:                                               ; preds = %28
  store ptr %31, ptr %13, align 8, !tbaa !5
  %33 = load ptr, ptr %13, align 8, !tbaa !5
  %34 = load ptr, ptr %10, align 8, !tbaa !5
  call void @_ZN11R3SceneNode13InsertElementEP14R3SceneElement(ptr noundef nonnull align 8 dereferenceable(432) %33, ptr noundef %34)
  %35 = load ptr, ptr %7, align 8, !tbaa !5
  %36 = load ptr, ptr %13, align 8, !tbaa !5
  call void @_ZN11R3SceneNode11InsertChildEPS_(ptr noundef nonnull align 8 dereferenceable(432) %35, ptr noundef %36)
  store i32 1, ptr %4, align 4
  store i32 1, ptr %9, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #5
  br label %46

37:                                               ; preds = %26
  %38 = landingpad { ptr, i32 }
          cleanup
  %39 = extractvalue { ptr, i32 } %38, 0
  store ptr %39, ptr %11, align 8
  %40 = extractvalue { ptr, i32 } %38, 1
  store i32 %40, ptr %12, align 4
  call void @_ZdlPvm(ptr noundef %27, i64 noundef 96) #7
  br label %45

41:                                               ; preds = %28
  %42 = landingpad { ptr, i32 }
          cleanup
  %43 = extractvalue { ptr, i32 } %42, 0
  store ptr %43, ptr %11, align 8
  %44 = extractvalue { ptr, i32 } %42, 1
  store i32 %44, ptr %12, align 4
  call void @_ZdlPvm(ptr noundef %31, i64 noundef 432) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #5
  br label %45

45:                                               ; preds = %41, %37
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #5
  br label %48

46:                                               ; preds = %32, %25
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #5
  %47 = load i32, ptr %4, align 4
  ret i32 %47

48:                                               ; preds = %45
  %49 = load ptr, ptr %11, align 8
  %50 = load i32, ptr %12, align 4
  %51 = insertvalue { ptr, i32 } poison, ptr %49, 0
  %52 = insertvalue { ptr, i32 } %51, i32 %50, 1
  resume { ptr, i32 } %52
}

declare void @_ZN11R3SceneNode11InsertChildEPS_(ptr noundef nonnull align 8 dereferenceable(432), ptr noundef) #1

; Function Attrs: mustprogress uwtable
declare hidden noundef ptr @_ZL8ReadMeshPKc(ptr noundef) #4

declare void @_ZN14R3SceneElementC1EP10R3Material(ptr noundef nonnull align 8 dereferenceable(96), ptr noundef) unnamed_addr #1

declare void @_ZN14R3SceneElement11InsertShapeEP7R3Shape(ptr noundef nonnull align 8 dereferenceable(96), ptr noundef) #1

declare void @_ZN11R3SceneNode13InsertElementEP14R3SceneElement(ptr noundef nonnull align 8 dereferenceable(432), ptr noundef) #1

attributes #0 = { 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 #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 = { 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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { 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 #5 = { nounwind }
attributes #6 = { builtin allocsize(0) }
attributes #7 = { 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, !6, i64 0}
!10 = !{!"_ZTS7R3Scene", !6, i64 0, !11, i64 8, !14, i64 24, !15, i64 40, !16, i64 56, !17, i64 72, !18, i64 88, !19, i64 104, !21, i64 112, !28, i64 280, !28, i64 304, !6, i64 328, !6, i64 336, !6, i64 344}
!11 = !{!"_ZTS7RNArrayIP11R3SceneNodeE", !12, i64 0}
!12 = !{!"_ZTS8RNVArray", !6, i64 0, !13, i64 8, !13, i64 12}
!13 = !{!"int", !7, i64 0}
!14 = !{!"_ZTS7RNArrayIP7R3LightE", !12, i64 0}
!15 = !{!"_ZTS7RNArrayIP10R3MaterialE", !12, i64 0}
!16 = !{!"_ZTS7RNArrayIP6R3BrdfE", !12, i64 0}
!17 = !{!"_ZTS7RNArrayIP9R2TextureE", !12, i64 0}
!18 = !{!"_ZTS7RNArrayIP7R3SceneE", !12, i64 0}
!19 = !{!"_ZTS13RNSymbolTableIPKcE", !20, i64 0}
!20 = !{!"_ZTS5RNMapINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEPKcE", !6, i64 0}
!21 = !{!"_ZTS8R3Viewer", !22, i64 8, !27, i64 152}
!22 = !{!"_ZTS8R3Camera", !23, i64 0, !26, i64 96, !26, i64 104, !26, i64 112, !26, i64 120, !26, i64 128, !6, i64 136}
!23 = !{!"_ZTS13R3CoordSystem", !24, i64 0, !25, i64 24}
!24 = !{!"_ZTS7R3Point", !7, i64 0}
!25 = !{!"_ZTS7R3Triad", !7, i64 0}
!26 = !{!"double", !7, i64 0}
!27 = !{!"_ZTS10R2Viewport", !13, i64 0, !13, i64 4, !13, i64 8, !13, i64 12}
!28 = !{!"_ZTS5RNRgb", !7, 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: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znwm(i64 noundef) local_unnamed_addr #0

declare void @_ZN11R3SceneNodeC1EP7R3Scene(ptr noundef nonnull align 8 dereferenceable(432), ptr noundef) unnamed_addr #1

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

; Function Attrs: mustprogress uwtable
define dso_local noundef range(i32 0, 2) i32 @_ZN7R3Scene12ReadMeshFileEPKcP11R3SceneNode(ptr noundef nonnull align 8 dereferenceable(352) %0, ptr noundef %1, ptr noundef %2) local_unnamed_addr #3 align 2 personality ptr @__gxx_personality_v0 {
  %.not = icmp eq ptr %2, null
  %4 = load ptr, ptr %0, align 8
  %spec.select = select i1 %.not, ptr %4, ptr %2
  %5 = tail call noundef ptr @_ZL8ReadMeshPKc(ptr noundef %1)
  %.not17 = icmp eq ptr %5, null
  br i1 %.not17, label %16, label %6

6:                                                ; preds = %3
  %7 = tail call noalias noundef nonnull dereferenceable(96) ptr @_Znwm(i64 noundef 96) #4
  invoke void @_ZN14R3SceneElementC1EP10R3Material(ptr noundef nonnull align 8 dereferenceable(96) %7, ptr noundef null)
          to label %8 unwind label %11

8:                                                ; preds = %6
  tail call void @_ZN14R3SceneElement11InsertShapeEP7R3Shape(ptr noundef nonnull align 8 dereferenceable(96) %7, ptr noundef nonnull %5)
  %9 = tail call noalias noundef nonnull dereferenceable(432) ptr @_Znwm(i64 noundef 432) #4
  invoke void @_ZN11R3SceneNodeC1EP7R3Scene(ptr noundef nonnull align 8 dereferenceable(432) %9, ptr noundef nonnull %0)
          to label %10 unwind label %13

10:                                               ; preds = %8
  tail call void @_ZN11R3SceneNode13InsertElementEP14R3SceneElement(ptr noundef nonnull align 8 dereferenceable(432) %9, ptr noundef nonnull %7)
  tail call void @_ZN11R3SceneNode11InsertChildEPS_(ptr noundef nonnull align 8 dereferenceable(432) %spec.select, ptr noundef nonnull %9)
  br label %16

11:                                               ; preds = %6
  %12 = landingpad { ptr, i32 }
          cleanup
  tail call void @_ZdlPvm(ptr noundef nonnull %7, i64 noundef 96) #5
  br label %15

13:                                               ; preds = %8
  %14 = landingpad { ptr, i32 }
          cleanup
  tail call void @_ZdlPvm(ptr noundef nonnull %9, i64 noundef 432) #5
  br label %15

15:                                               ; preds = %13, %11
  %.pn = phi { ptr, i32 } [ %14, %13 ], [ %12, %11 ]
  resume { ptr, i32 } %.pn

16:                                               ; preds = %3, %10
  %.0 = phi i32 [ 1, %10 ], [ 0, %3 ]
  ret i32 %.0
}

declare void @_ZN11R3SceneNode11InsertChildEPS_(ptr noundef nonnull align 8 dereferenceable(432), ptr noundef) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
declare hidden noundef ptr @_ZL8ReadMeshPKc(ptr noundef) local_unnamed_addr #3

declare void @_ZN14R3SceneElementC1EP10R3Material(ptr noundef nonnull align 8 dereferenceable(96), ptr noundef) unnamed_addr #1

declare void @_ZN14R3SceneElement11InsertShapeEP7R3Shape(ptr noundef nonnull align 8 dereferenceable(96), ptr noundef) local_unnamed_addr #1

declare void @_ZN11R3SceneNode13InsertElementEP14R3SceneElement(ptr noundef nonnull align 8 dereferenceable(432), ptr noundef) local_unnamed_addr #1

attributes #0 = { 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 #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 = { 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 = { 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 #4 = { builtin allocsize(0) }
attributes #5 = { 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)"}


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