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

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

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

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

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

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

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

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

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

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

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

; Function Attrs: mustprogress uwtable
define dso_local noundef double @_ZNK11R3SceneNode4AreaEv(ptr noundef nonnull align 8 dereferenceable(432) %0) #3 align 2 {
  %2 = alloca ptr, align 8
  %3 = alloca double, align 8
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca ptr, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  %11 = load ptr, ptr %2, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #5
  store double 0.000000e+00, ptr %3, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #5
  store i32 0, ptr %4, align 4, !tbaa !11
  br label %12

12:                                               ; preds = %24, %1
  %13 = load i32, ptr %4, align 4, !tbaa !11
  %14 = call noundef i32 @_ZNK11R3SceneNode9NElementsEv(ptr noundef nonnull align 8 dereferenceable(432) %11)
  %15 = icmp slt i32 %13, %14
  br i1 %15, label %17, label %16

16:                                               ; preds = %12
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #5
  br label %27

17:                                               ; preds = %12
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #5
  %18 = load i32, ptr %4, align 4, !tbaa !11
  %19 = call noundef ptr @_ZNK11R3SceneNode7ElementEi(ptr noundef nonnull align 8 dereferenceable(432) %11, i32 noundef %18)
  store ptr %19, ptr %5, align 8, !tbaa !5
  %20 = load ptr, ptr %5, align 8, !tbaa !5
  %21 = call noundef double @_ZNK14R3SceneElement4AreaEv(ptr noundef nonnull align 8 dereferenceable(96) %20)
  %22 = load double, ptr %3, align 8, !tbaa !9
  %23 = fadd double %22, %21
  store double %23, ptr %3, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #5
  br label %24

24:                                               ; preds = %17
  %25 = load i32, ptr %4, align 4, !tbaa !11
  %26 = add nsw i32 %25, 1
  store i32 %26, ptr %4, align 4, !tbaa !11
  br label %12, !llvm.loop !13

27:                                               ; preds = %16
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #5
  store i32 0, ptr %6, align 4, !tbaa !11
  br label %28

28:                                               ; preds = %46, %27
  %29 = load i32, ptr %6, align 4, !tbaa !11
  %30 = call noundef i32 @_ZNK11R3SceneNode11NReferencesEv(ptr noundef nonnull align 8 dereferenceable(432) %11)
  %31 = icmp slt i32 %29, %30
  br i1 %31, label %33, label %32

32:                                               ; preds = %28
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #5
  br label %49

33:                                               ; preds = %28
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #5
  %34 = load i32, ptr %6, align 4, !tbaa !11
  %35 = call noundef ptr @_ZNK11R3SceneNode9ReferenceEi(ptr noundef nonnull align 8 dereferenceable(432) %11, i32 noundef %34)
  store ptr %35, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #5
  %36 = load ptr, ptr %7, align 8, !tbaa !5
  %37 = call noundef ptr @_ZNK16R3SceneReference15ReferencedSceneEv(ptr noundef nonnull align 8 dereferenceable(48) %36)
  store ptr %37, ptr %8, align 8, !tbaa !5
  %38 = load ptr, ptr %8, align 8, !tbaa !5
  %39 = icmp ne ptr %38, null
  br i1 %39, label %40, label %45

40:                                               ; preds = %33
  %41 = load ptr, ptr %8, align 8, !tbaa !5
  %42 = call noundef double @_ZNK7R3Scene4AreaEv(ptr noundef nonnull align 8 dereferenceable(352) %41)
  %43 = load double, ptr %3, align 8, !tbaa !9
  %44 = fadd double %43, %42
  store double %44, ptr %3, align 8, !tbaa !9
  br label %45

45:                                               ; preds = %40, %33
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #5
  br label %46

46:                                               ; preds = %45
  %47 = load i32, ptr %6, align 4, !tbaa !11
  %48 = add nsw i32 %47, 1
  store i32 %48, ptr %6, align 4, !tbaa !11
  br label %28, !llvm.loop !15

49:                                               ; preds = %32
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #5
  store i32 0, ptr %9, align 4, !tbaa !11
  br label %50

50:                                               ; preds = %62, %49
  %51 = load i32, ptr %9, align 4, !tbaa !11
  %52 = call noundef i32 @_ZNK11R3SceneNode9NChildrenEv(ptr noundef nonnull align 8 dereferenceable(432) %11)
  %53 = icmp slt i32 %51, %52
  br i1 %53, label %55, label %54

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

55:                                               ; preds = %50
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #5
  %56 = load i32, ptr %9, align 4, !tbaa !11
  %57 = call noundef ptr @_ZNK11R3SceneNode5ChildEi(ptr noundef nonnull align 8 dereferenceable(432) %11, i32 noundef %56)
  store ptr %57, ptr %10, align 8, !tbaa !5
  %58 = load ptr, ptr %10, align 8, !tbaa !5
  %59 = call noundef double @_ZNK11R3SceneNode4AreaEv(ptr noundef nonnull align 8 dereferenceable(432) %58)
  %60 = load double, ptr %3, align 8, !tbaa !9
  %61 = fadd double %60, %59
  store double %61, ptr %3, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #5
  br label %62

62:                                               ; preds = %55
  %63 = load i32, ptr %9, align 4, !tbaa !11
  %64 = add nsw i32 %63, 1
  store i32 %64, ptr %9, align 4, !tbaa !11
  br label %50, !llvm.loop !16

65:                                               ; preds = %54
  %66 = load double, ptr %3, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #5
  ret double %66
}

declare noundef double @_ZNK14R3SceneElement4AreaEv(ptr noundef nonnull align 8 dereferenceable(96)) #4

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef double @_ZNK7R3Scene4AreaEv(ptr noundef nonnull align 8 dereferenceable(352)) #2 align 2

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

!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 = !{!"double", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = distinct !{!15, !14}
!16 = distinct !{!16, !14}


; 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 @_ZNK11R3SceneNode9NElementsEv(ptr noundef nonnull align 8 dereferenceable(432)) local_unnamed_addr #0 align 2

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

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

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

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

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

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

; Function Attrs: mustprogress uwtable
define dso_local noundef double @_ZNK11R3SceneNode4AreaEv(ptr noundef nonnull align 8 dereferenceable(432) %0) local_unnamed_addr #2 align 2 {
  %2 = tail call noundef i32 @_ZNK11R3SceneNode9NElementsEv(ptr noundef nonnull align 8 dereferenceable(432) %0)
  %3 = icmp sgt i32 %2, 0
  br i1 %3, label %.lr.ph, label %.preheader22

.preheader22:                                     ; preds = %.lr.ph, %1
  %.0.lcssa = phi double [ 0.000000e+00, %1 ], [ %8, %.lr.ph ]
  %4 = tail call noundef i32 @_ZNK11R3SceneNode11NReferencesEv(ptr noundef nonnull align 8 dereferenceable(432) %0)
  %5 = icmp sgt i32 %4, 0
  br i1 %5, label %.lr.ph27, label %.preheader

.lr.ph:                                           ; preds = %1, %.lr.ph
  %.024 = phi double [ %8, %.lr.ph ], [ 0.000000e+00, %1 ]
  %.01923 = phi i32 [ %9, %.lr.ph ], [ 0, %1 ]
  %6 = tail call noundef ptr @_ZNK11R3SceneNode7ElementEi(ptr noundef nonnull align 8 dereferenceable(432) %0, i32 noundef %.01923)
  %7 = tail call noundef double @_ZNK14R3SceneElement4AreaEv(ptr noundef nonnull align 8 dereferenceable(96) %6)
  %8 = fadd double %.024, %7
  %9 = add nuw nsw i32 %.01923, 1
  %10 = tail call noundef i32 @_ZNK11R3SceneNode9NElementsEv(ptr noundef nonnull align 8 dereferenceable(432) %0)
  %11 = icmp slt i32 %9, %10
  br i1 %11, label %.lr.ph, label %.preheader22, !llvm.loop !5

.preheader:                                       ; preds = %19, %.preheader22
  %.1.lcssa = phi double [ %.0.lcssa, %.preheader22 ], [ %.2, %19 ]
  %12 = tail call noundef i32 @_ZNK11R3SceneNode9NChildrenEv(ptr noundef nonnull align 8 dereferenceable(432) %0)
  %13 = icmp sgt i32 %12, 0
  br i1 %13, label %.lr.ph31, label %._crit_edge

.lr.ph27:                                         ; preds = %.preheader22, %19
  %.126 = phi double [ %.2, %19 ], [ %.0.lcssa, %.preheader22 ]
  %.02025 = phi i32 [ %20, %19 ], [ 0, %.preheader22 ]
  %14 = tail call noundef ptr @_ZNK11R3SceneNode9ReferenceEi(ptr noundef nonnull align 8 dereferenceable(432) %0, i32 noundef %.02025)
  %15 = tail call noundef ptr @_ZNK16R3SceneReference15ReferencedSceneEv(ptr noundef nonnull align 8 dereferenceable(48) %14)
  %.not = icmp eq ptr %15, null
  br i1 %.not, label %19, label %16

16:                                               ; preds = %.lr.ph27
  %17 = tail call noundef double @_ZNK7R3Scene4AreaEv(ptr noundef nonnull align 8 dereferenceable(352) %15)
  %18 = fadd double %.126, %17
  br label %19

19:                                               ; preds = %16, %.lr.ph27
  %.2 = phi double [ %18, %16 ], [ %.126, %.lr.ph27 ]
  %20 = add nuw nsw i32 %.02025, 1
  %21 = tail call noundef i32 @_ZNK11R3SceneNode11NReferencesEv(ptr noundef nonnull align 8 dereferenceable(432) %0)
  %22 = icmp slt i32 %20, %21
  br i1 %22, label %.lr.ph27, label %.preheader, !llvm.loop !7

._crit_edge:                                      ; preds = %.lr.ph31, %.preheader
  %.3.lcssa = phi double [ %.1.lcssa, %.preheader ], [ %25, %.lr.ph31 ]
  ret double %.3.lcssa

.lr.ph31:                                         ; preds = %.preheader, %.lr.ph31
  %.330 = phi double [ %25, %.lr.ph31 ], [ %.1.lcssa, %.preheader ]
  %.01829 = phi i32 [ %26, %.lr.ph31 ], [ 0, %.preheader ]
  %23 = tail call noundef ptr @_ZNK11R3SceneNode5ChildEi(ptr noundef nonnull align 8 dereferenceable(432) %0, i32 noundef %.01829)
  %24 = tail call noundef double @_ZNK11R3SceneNode4AreaEv(ptr noundef nonnull align 8 dereferenceable(432) %23)
  %25 = fadd double %.330, %24
  %26 = add nuw nsw i32 %.01829, 1
  %27 = tail call noundef i32 @_ZNK11R3SceneNode9NChildrenEv(ptr noundef nonnull align 8 dereferenceable(432) %0)
  %28 = icmp slt i32 %26, %27
  br i1 %28, label %.lr.ph31, label %._crit_edge, !llvm.loop !8
}

declare noundef double @_ZNK14R3SceneElement4AreaEv(ptr noundef nonnull align 8 dereferenceable(96)) local_unnamed_addr #3

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef double @_ZNK7R3Scene4AreaEv(ptr noundef nonnull align 8 dereferenceable(352)) local_unnamed_addr #1 align 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 = { 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 #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" }

!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: GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass