; LLVM IR from niessner/Matterport :: code/gaps/pkgs/R3Graphics (R3SceneNode)

; 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.RNFlags = type { i64 }
%class.R3SceneNode = type { ptr, i32, ptr, i32, %class.RNArray, %class.RNArray.0, %class.RNArray.1, %class.RNSymbolTable, %class.R3Affine, %class.R3Box, 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.RNSymbolTable = type { %class.RNMap }
%class.RNMap = type { ptr }
%class.R3Affine = type { %class.R3Transformation, %class.R4Matrix, %class.R4Matrix, %class.RNFlags }
%class.R3Transformation = type { ptr }
%class.R4Matrix = type { [4 x [4 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] }

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

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

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

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

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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZNK11R3SceneNode4DrawE7RNFlagsPK7RNArrayIP10R3MaterialE(ptr noundef nonnull align 8 dereferenceable(432) %0, i64 %1, ptr noundef %2) #2 align 2 {
  %4 = alloca %class.RNFlags, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca ptr, align 8
  %9 = alloca %class.RNFlags, align 8
  %10 = alloca i32, align 4
  %11 = alloca ptr, align 8
  %12 = alloca %class.RNFlags, align 8
  %13 = alloca i32, align 4
  %14 = alloca ptr, align 8
  %15 = alloca %class.RNFlags, align 8
  %16 = getelementptr inbounds %class.RNFlags, ptr %4, i32 0, i32 0
  store i64 %1, ptr %16, align 8
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %2, ptr %6, align 8, !tbaa !5
  %17 = load ptr, ptr %5, align 8
  %18 = getelementptr inbounds %class.R3SceneNode, ptr %17, i32 0, i32 8
  call void @_ZNK8R3Affine4PushEv(ptr noundef nonnull align 8 dereferenceable(272) %18)
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #5
  store i32 0, ptr %7, align 4, !tbaa !9
  br label %19

19:                                               ; preds = %33, %3
  %20 = load i32, ptr %7, align 4, !tbaa !9
  %21 = getelementptr inbounds %class.R3SceneNode, ptr %17, i32 0, i32 5
  %22 = call noundef i32 @_ZNK8RNVArray8NEntriesEv(ptr noundef nonnull align 8 dereferenceable(16) %21)
  %23 = icmp slt i32 %20, %22
  br i1 %23, label %25, label %24

24:                                               ; preds = %19
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #5
  br label %36

25:                                               ; preds = %19
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #5
  %26 = getelementptr inbounds %class.R3SceneNode, ptr %17, i32 0, i32 5
  %27 = load i32, ptr %7, align 4, !tbaa !9
  %28 = call noundef ptr @_ZNK7RNArrayIP14R3SceneElementE3KthEi(ptr noundef nonnull align 8 dereferenceable(16) %26, i32 noundef %27)
  store ptr %28, ptr %8, align 8, !tbaa !5
  %29 = load ptr, ptr %8, align 8, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %9, ptr align 8 %4, i64 8, i1 false), !tbaa.struct !11
  %30 = load ptr, ptr %6, align 8, !tbaa !5
  %31 = getelementptr inbounds %class.RNFlags, ptr %9, i32 0, i32 0
  %32 = load i64, ptr %31, align 8
  call void @_ZNK14R3SceneElement4DrawE7RNFlagsPK7RNArrayIP10R3MaterialE(ptr noundef nonnull align 8 dereferenceable(96) %29, i64 %32, ptr noundef %30)
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #5
  br label %33

33:                                               ; preds = %25
  %34 = load i32, ptr %7, align 4, !tbaa !9
  %35 = add nsw i32 %34, 1
  store i32 %35, ptr %7, align 4, !tbaa !9
  br label %19, !llvm.loop !14

36:                                               ; preds = %24
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #5
  store i32 0, ptr %10, align 4, !tbaa !9
  br label %37

37:                                               ; preds = %51, %36
  %38 = load i32, ptr %10, align 4, !tbaa !9
  %39 = getelementptr inbounds %class.R3SceneNode, ptr %17, i32 0, i32 6
  %40 = call noundef i32 @_ZNK8RNVArray8NEntriesEv(ptr noundef nonnull align 8 dereferenceable(16) %39)
  %41 = icmp slt i32 %38, %40
  br i1 %41, label %43, label %42

42:                                               ; preds = %37
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #5
  br label %54

43:                                               ; preds = %37
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #5
  %44 = getelementptr inbounds %class.R3SceneNode, ptr %17, i32 0, i32 6
  %45 = load i32, ptr %10, align 4, !tbaa !9
  %46 = call noundef ptr @_ZNK7RNArrayIP16R3SceneReferenceE3KthEi(ptr noundef nonnull align 8 dereferenceable(16) %44, i32 noundef %45)
  store ptr %46, ptr %11, align 8, !tbaa !5
  %47 = load ptr, ptr %11, align 8, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %12, ptr align 8 %4, i64 8, i1 false), !tbaa.struct !11
  %48 = load ptr, ptr %6, align 8, !tbaa !5
  %49 = getelementptr inbounds %class.RNFlags, ptr %12, i32 0, i32 0
  %50 = load i64, ptr %49, align 8
  call void @_ZNK16R3SceneReference4DrawE7RNFlagsPK7RNArrayIP10R3MaterialE(ptr noundef nonnull align 8 dereferenceable(48) %47, i64 %50, ptr noundef %48)
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #5
  br label %51

51:                                               ; preds = %43
  %52 = load i32, ptr %10, align 4, !tbaa !9
  %53 = add nsw i32 %52, 1
  store i32 %53, ptr %10, align 4, !tbaa !9
  br label %37, !llvm.loop !16

54:                                               ; preds = %42
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #5
  store i32 0, ptr %13, align 4, !tbaa !9
  br label %55

55:                                               ; preds = %69, %54
  %56 = load i32, ptr %13, align 4, !tbaa !9
  %57 = getelementptr inbounds %class.R3SceneNode, ptr %17, i32 0, i32 4
  %58 = call noundef i32 @_ZNK8RNVArray8NEntriesEv(ptr noundef nonnull align 8 dereferenceable(16) %57)
  %59 = icmp slt i32 %56, %58
  br i1 %59, label %61, label %60

60:                                               ; preds = %55
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #5
  br label %72

61:                                               ; preds = %55
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #5
  %62 = getelementptr inbounds %class.R3SceneNode, ptr %17, i32 0, i32 4
  %63 = load i32, ptr %13, align 4, !tbaa !9
  %64 = call noundef ptr @_ZNK7RNArrayIP11R3SceneNodeE3KthEi(ptr noundef nonnull align 8 dereferenceable(16) %62, i32 noundef %63)
  store ptr %64, ptr %14, align 8, !tbaa !5
  %65 = load ptr, ptr %14, align 8, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %15, ptr align 8 %4, i64 8, i1 false), !tbaa.struct !11
  %66 = load ptr, ptr %6, align 8, !tbaa !5
  %67 = getelementptr inbounds %class.RNFlags, ptr %15, i32 0, i32 0
  %68 = load i64, ptr %67, align 8
  call void @_ZNK11R3SceneNode4DrawE7RNFlagsPK7RNArrayIP10R3MaterialE(ptr noundef nonnull align 8 dereferenceable(432) %65, i64 %68, ptr noundef %66)
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #5
  br label %69

69:                                               ; preds = %61
  %70 = load i32, ptr %13, align 4, !tbaa !9
  %71 = add nsw i32 %70, 1
  store i32 %71, ptr %13, align 4, !tbaa !9
  br label %55, !llvm.loop !17

72:                                               ; preds = %60
  %73 = getelementptr inbounds %class.R3SceneNode, ptr %17, i32 0, i32 8
  call void @_ZNK8R3Affine3PopEv(ptr noundef nonnull align 8 dereferenceable(272) %73)
  ret void
}

declare void @_ZNK8R3Affine4PushEv(ptr noundef nonnull align 8 dereferenceable(272)) unnamed_addr #3

declare void @_ZNK14R3SceneElement4DrawE7RNFlagsPK7RNArrayIP10R3MaterialE(ptr noundef nonnull align 8 dereferenceable(96), i64, ptr noundef) #3

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #4

declare void @_ZNK16R3SceneReference4DrawE7RNFlagsPK7RNArrayIP10R3MaterialE(ptr noundef nonnull align 8 dereferenceable(48), i64, ptr noundef) #3

declare void @_ZNK8R3Affine3PopEv(ptr noundef nonnull align 8 dereferenceable(272)) unnamed_addr #3

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { 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 = { "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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #5 = { 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 = !{i64 0, i64 8, !12}
!12 = !{!13, !13, i64 0}
!13 = !{!"long", !7, i64 0}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}
!16 = distinct !{!16, !15}
!17 = distinct !{!17, !15}


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

; 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 ptr @_ZNK7RNArrayIP14R3SceneElementE3KthEi(ptr noundef nonnull align 8 dereferenceable(16), i32 noundef) local_unnamed_addr #1 align 2

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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZNK11R3SceneNode4DrawE7RNFlagsPK7RNArrayIP10R3MaterialE(ptr noundef nonnull align 8 dereferenceable(432) %0, i64 %1, ptr noundef %2) local_unnamed_addr #1 align 2 {
  %4 = getelementptr inbounds i8, ptr %0, i64 88
  tail call void @_ZNK8R3Affine4PushEv(ptr noundef nonnull align 8 dereferenceable(272) %4)
  %5 = getelementptr inbounds i8, ptr %0, i64 48
  %6 = tail call noundef i32 @_ZNK8RNVArray8NEntriesEv(ptr noundef nonnull align 8 dereferenceable(16) %5)
  %7 = icmp sgt i32 %6, 0
  br i1 %7, label %.lr.ph, label %.preheader22

.preheader22:                                     ; preds = %.lr.ph, %3
  %8 = getelementptr inbounds i8, ptr %0, i64 64
  %9 = tail call noundef i32 @_ZNK8RNVArray8NEntriesEv(ptr noundef nonnull align 8 dereferenceable(16) %8)
  %10 = icmp sgt i32 %9, 0
  br i1 %10, label %.lr.ph25, label %.preheader

.lr.ph:                                           ; preds = %3, %.lr.ph
  %.023 = phi i32 [ %12, %.lr.ph ], [ 0, %3 ]
  %11 = tail call noundef ptr @_ZNK7RNArrayIP14R3SceneElementE3KthEi(ptr noundef nonnull align 8 dereferenceable(16) %5, i32 noundef %.023)
  tail call void @_ZNK14R3SceneElement4DrawE7RNFlagsPK7RNArrayIP10R3MaterialE(ptr noundef nonnull align 8 dereferenceable(96) %11, i64 %1, ptr noundef %2)
  %12 = add nuw nsw i32 %.023, 1
  %13 = tail call noundef i32 @_ZNK8RNVArray8NEntriesEv(ptr noundef nonnull align 8 dereferenceable(16) %5)
  %14 = icmp slt i32 %12, %13
  br i1 %14, label %.lr.ph, label %.preheader22, !llvm.loop !5

.preheader:                                       ; preds = %.lr.ph25, %.preheader22
  %15 = getelementptr inbounds i8, ptr %0, i64 32
  %16 = tail call noundef i32 @_ZNK8RNVArray8NEntriesEv(ptr noundef nonnull align 8 dereferenceable(16) %15)
  %17 = icmp sgt i32 %16, 0
  br i1 %17, label %.lr.ph27, label %._crit_edge

.lr.ph25:                                         ; preds = %.preheader22, %.lr.ph25
  %.02024 = phi i32 [ %19, %.lr.ph25 ], [ 0, %.preheader22 ]
  %18 = tail call noundef ptr @_ZNK7RNArrayIP16R3SceneReferenceE3KthEi(ptr noundef nonnull align 8 dereferenceable(16) %8, i32 noundef %.02024)
  tail call void @_ZNK16R3SceneReference4DrawE7RNFlagsPK7RNArrayIP10R3MaterialE(ptr noundef nonnull align 8 dereferenceable(48) %18, i64 %1, ptr noundef %2)
  %19 = add nuw nsw i32 %.02024, 1
  %20 = tail call noundef i32 @_ZNK8RNVArray8NEntriesEv(ptr noundef nonnull align 8 dereferenceable(16) %8)
  %21 = icmp slt i32 %19, %20
  br i1 %21, label %.lr.ph25, label %.preheader, !llvm.loop !7

._crit_edge:                                      ; preds = %.lr.ph27, %.preheader
  tail call void @_ZNK8R3Affine3PopEv(ptr noundef nonnull align 8 dereferenceable(272) %4)
  ret void

.lr.ph27:                                         ; preds = %.preheader, %.lr.ph27
  %.02126 = phi i32 [ %23, %.lr.ph27 ], [ 0, %.preheader ]
  %22 = tail call noundef ptr @_ZNK7RNArrayIP11R3SceneNodeE3KthEi(ptr noundef nonnull align 8 dereferenceable(16) %15, i32 noundef %.02126)
  tail call void @_ZNK11R3SceneNode4DrawE7RNFlagsPK7RNArrayIP10R3MaterialE(ptr noundef nonnull align 8 dereferenceable(432) %22, i64 %1, ptr noundef %2)
  %23 = add nuw nsw i32 %.02126, 1
  %24 = tail call noundef i32 @_ZNK8RNVArray8NEntriesEv(ptr noundef nonnull align 8 dereferenceable(16) %15)
  %25 = icmp slt i32 %23, %24
  br i1 %25, label %.lr.ph27, label %._crit_edge, !llvm.loop !8
}

declare void @_ZNK8R3Affine4PushEv(ptr noundef nonnull align 8 dereferenceable(272)) unnamed_addr #2

declare void @_ZNK14R3SceneElement4DrawE7RNFlagsPK7RNArrayIP10R3MaterialE(ptr noundef nonnull align 8 dereferenceable(96), i64, ptr noundef) local_unnamed_addr #2

declare void @_ZNK16R3SceneReference4DrawE7RNFlagsPK7RNArrayIP10R3MaterialE(ptr noundef nonnull align 8 dereferenceable(48), i64, ptr noundef) local_unnamed_addr #2

declare void @_ZNK8R3Affine3PopEv(ptr noundef nonnull align 8 dereferenceable(272)) unnamed_addr #2

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 = { "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" }

!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 = distinct !{!7, !6}
!8 = distinct !{!8, !6}


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