; LLVM IR from yuikns/panther :: ann/src/bd_tree.ll (ZN12ANNbd_shrink8getStatsEiR10ANNkdStatsR11ANNorthRect)

; 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.ANNkdStats = type { i32, i32, i32, i32, i32, i32, i32, i32, float, float }
%class.ANNorthRect = type { ptr, ptr }
%class.ANNbd_shrink = type { %class.ANNkd_node, i32, ptr, [2 x ptr] }
%class.ANNkd_node = type { ptr }

; 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: mustprogress uwtable
define dso_local void @_ZN12ANNbd_shrink8getStatsEiR10ANNkdStatsR11ANNorthRect(ptr noundef nonnull align 8 dereferenceable(40) %0, i32 noundef %1, ptr noundef nonnull align 4 dereferenceable(40) %2, ptr noundef nonnull align 8 dereferenceable(16) %3) unnamed_addr #1 align 2 personality ptr @__gxx_personality_v0 {
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca %class.ANNkdStats, align 4
  %10 = alloca %class.ANNorthRect, align 8
  %11 = alloca ptr, align 8
  %12 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store i32 %1, ptr %6, align 4, !tbaa !9
  store ptr %2, ptr %7, align 8, !tbaa !5
  store ptr %3, ptr %8, align 8, !tbaa !5
  %13 = load ptr, ptr %5, align 8
  call void @llvm.lifetime.start.p0(i64 40, ptr %9) #4
  call void @_ZN10ANNkdStatsC2Ev(ptr noundef nonnull align 4 dereferenceable(40) %9)
  call void @llvm.lifetime.start.p0(i64 16, ptr %10) #4
  %14 = load i32, ptr %6, align 4, !tbaa !9
  call void @_ZN11ANNorthRectC2Eidd(ptr noundef nonnull align 8 dereferenceable(16) %10, i32 noundef %14, double noundef 0.000000e+00, double noundef 0.000000e+00)
  %15 = load ptr, ptr %8, align 8, !tbaa !5
  %16 = load i32, ptr %6, align 4, !tbaa !9
  %17 = getelementptr inbounds %class.ANNbd_shrink, ptr %13, i32 0, i32 1
  %18 = load i32, ptr %17, align 8, !tbaa !11
  %19 = getelementptr inbounds %class.ANNbd_shrink, ptr %13, i32 0, i32 2
  %20 = load ptr, ptr %19, align 8, !tbaa !14
  invoke void @_Z11annBnds2BoxRK11ANNorthRectiiP16ANNorthHalfSpaceRS_(ptr noundef nonnull align 8 dereferenceable(16) %15, i32 noundef %16, i32 noundef %18, ptr noundef %20, ptr noundef nonnull align 8 dereferenceable(16) %10)
          to label %21 unwind label %53

21:                                               ; preds = %4
  invoke void @_ZN10ANNkdStats5resetEiii(ptr noundef nonnull align 4 dereferenceable(40) %9, i32 noundef 0, i32 noundef 0, i32 noundef 0)
          to label %22 unwind label %53

22:                                               ; preds = %21
  %23 = getelementptr inbounds %class.ANNbd_shrink, ptr %13, i32 0, i32 3
  %24 = getelementptr inbounds [2 x ptr], ptr %23, i64 0, i64 0
  %25 = load ptr, ptr %24, align 8, !tbaa !5
  %26 = load i32, ptr %6, align 4, !tbaa !9
  %27 = load ptr, ptr %25, align 8, !tbaa !15
  %28 = getelementptr inbounds ptr, ptr %27, i64 5
  %29 = load ptr, ptr %28, align 8
  invoke void %29(ptr noundef nonnull align 8 dereferenceable(8) %25, i32 noundef %26, ptr noundef nonnull align 4 dereferenceable(40) %9, ptr noundef nonnull align 8 dereferenceable(16) %10)
          to label %30 unwind label %53

30:                                               ; preds = %22
  %31 = load ptr, ptr %7, align 8, !tbaa !5
  invoke void @_ZN10ANNkdStats5mergeERKS_(ptr noundef nonnull align 4 dereferenceable(40) %31, ptr noundef nonnull align 4 dereferenceable(40) %9)
          to label %32 unwind label %53

32:                                               ; preds = %30
  invoke void @_ZN10ANNkdStats5resetEiii(ptr noundef nonnull align 4 dereferenceable(40) %9, i32 noundef 0, i32 noundef 0, i32 noundef 0)
          to label %33 unwind label %53

33:                                               ; preds = %32
  %34 = getelementptr inbounds %class.ANNbd_shrink, ptr %13, i32 0, i32 3
  %35 = getelementptr inbounds [2 x ptr], ptr %34, i64 0, i64 1
  %36 = load ptr, ptr %35, align 8, !tbaa !5
  %37 = load i32, ptr %6, align 4, !tbaa !9
  %38 = load ptr, ptr %8, align 8, !tbaa !5
  %39 = load ptr, ptr %36, align 8, !tbaa !15
  %40 = getelementptr inbounds ptr, ptr %39, i64 5
  %41 = load ptr, ptr %40, align 8
  invoke void %41(ptr noundef nonnull align 8 dereferenceable(8) %36, i32 noundef %37, ptr noundef nonnull align 4 dereferenceable(40) %9, ptr noundef nonnull align 8 dereferenceable(16) %38)
          to label %42 unwind label %53

42:                                               ; preds = %33
  %43 = load ptr, ptr %7, align 8, !tbaa !5
  invoke void @_ZN10ANNkdStats5mergeERKS_(ptr noundef nonnull align 4 dereferenceable(40) %43, ptr noundef nonnull align 4 dereferenceable(40) %9)
          to label %44 unwind label %53

44:                                               ; preds = %42
  %45 = load ptr, ptr %7, align 8, !tbaa !5
  %46 = getelementptr inbounds %class.ANNkdStats, ptr %45, i32 0, i32 7
  %47 = load i32, ptr %46, align 4, !tbaa !17
  %48 = add nsw i32 %47, 1
  store i32 %48, ptr %46, align 4, !tbaa !17
  %49 = load ptr, ptr %7, align 8, !tbaa !5
  %50 = getelementptr inbounds %class.ANNkdStats, ptr %49, i32 0, i32 6
  %51 = load i32, ptr %50, align 4, !tbaa !20
  %52 = add nsw i32 %51, 1
  store i32 %52, ptr %50, align 4, !tbaa !20
  call void @_ZN11ANNorthRectD2Ev(ptr noundef nonnull align 8 dereferenceable(16) %10) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 40, ptr %9) #4
  ret void

53:                                               ; preds = %42, %33, %32, %30, %22, %21, %4
  %54 = landingpad { ptr, i32 }
          cleanup
  %55 = extractvalue { ptr, i32 } %54, 0
  store ptr %55, ptr %11, align 8
  %56 = extractvalue { ptr, i32 } %54, 1
  store i32 %56, ptr %12, align 4
  call void @_ZN11ANNorthRectD2Ev(ptr noundef nonnull align 8 dereferenceable(16) %10) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 40, ptr %9) #4
  br label %57

57:                                               ; preds = %53
  %58 = load ptr, ptr %11, align 8
  %59 = load i32, ptr %12, align 4
  %60 = insertvalue { ptr, i32 } poison, ptr %58, 0
  %61 = insertvalue { ptr, i32 } %60, i32 %59, 1
  resume { ptr, i32 } %61
}

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN10ANNkdStatsC2Ev(ptr noundef nonnull align 4 dereferenceable(40)) unnamed_addr #1 align 2

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

declare void @_Z11annBnds2BoxRK11ANNorthRectiiP16ANNorthHalfSpaceRS_(ptr noundef nonnull align 8 dereferenceable(16), i32 noundef, i32 noundef, ptr noundef, ptr noundef nonnull align 8 dereferenceable(16)) #2

declare i32 @__gxx_personality_v0(...)

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN10ANNkdStats5resetEiii(ptr noundef nonnull align 4 dereferenceable(40), i32 noundef, i32 noundef, i32 noundef) #3 align 2

declare void @_ZN10ANNkdStats5mergeERKS_(ptr noundef nonnull align 4 dereferenceable(40), ptr noundef nonnull align 4 dereferenceable(40)) #2

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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" }
attributes #3 = { 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 #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 = !{!"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, !10, i64 8}
!12 = !{!"_ZTS12ANNbd_shrink", !13, i64 0, !10, i64 8, !6, i64 16, !7, i64 24}
!13 = !{!"_ZTS10ANNkd_node"}
!14 = !{!12, !6, i64 16}
!15 = !{!16, !16, i64 0}
!16 = !{!"vtable pointer", !8, i64 0}
!17 = !{!18, !10, i64 28}
!18 = !{!"_ZTS10ANNkdStats", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20, !10, i64 24, !10, i64 28, !19, i64 32, !19, i64 36}
!19 = !{!"float", !7, i64 0}
!20 = !{!18, !10, i64 24}


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

%class.ANNkdStats = type { i32, i32, i32, i32, i32, i32, i32, i32, float, float }
%class.ANNorthRect = type { ptr, ptr }

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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN12ANNbd_shrink8getStatsEiR10ANNkdStatsR11ANNorthRect(ptr nocapture noundef nonnull readonly align 8 dereferenceable(40) %0, i32 noundef %1, ptr noundef nonnull align 4 dereferenceable(40) %2, ptr noundef nonnull align 8 dereferenceable(16) %3) unnamed_addr #1 align 2 personality ptr @__gxx_personality_v0 {
  %5 = alloca %class.ANNkdStats, align 4
  %6 = alloca %class.ANNorthRect, align 8
  call void @llvm.lifetime.start.p0(i64 40, ptr nonnull %5) #4
  call void @_ZN10ANNkdStatsC2Ev(ptr noundef nonnull align 4 dereferenceable(40) %5)
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %6) #4
  call void @_ZN11ANNorthRectC2Eidd(ptr noundef nonnull align 8 dereferenceable(16) %6, i32 noundef %1, double noundef 0.000000e+00, double noundef 0.000000e+00)
  %7 = getelementptr inbounds i8, ptr %0, i64 8
  %8 = load i32, ptr %7, align 8, !tbaa !5
  %9 = getelementptr inbounds i8, ptr %0, i64 16
  %10 = load ptr, ptr %9, align 8, !tbaa !12
  invoke void @_Z11annBnds2BoxRK11ANNorthRectiiP16ANNorthHalfSpaceRS_(ptr noundef nonnull align 8 dereferenceable(16) %3, i32 noundef %1, i32 noundef %8, ptr noundef %10, ptr noundef nonnull align 8 dereferenceable(16) %6)
          to label %11 unwind label %29

11:                                               ; preds = %4
  call void @_ZN10ANNkdStats5resetEiii(ptr noundef nonnull align 4 dereferenceable(40) %5, i32 noundef 0, i32 noundef 0, i32 noundef 0)
  %12 = getelementptr inbounds i8, ptr %0, i64 24
  %13 = load ptr, ptr %12, align 8, !tbaa !13
  %14 = load ptr, ptr %13, align 8, !tbaa !14
  %15 = getelementptr inbounds i8, ptr %14, i64 40
  %16 = load ptr, ptr %15, align 8
  invoke void %16(ptr noundef nonnull align 8 dereferenceable(8) %13, i32 noundef %1, ptr noundef nonnull align 4 dereferenceable(40) %5, ptr noundef nonnull align 8 dereferenceable(16) %6)
          to label %17 unwind label %29

17:                                               ; preds = %11
  invoke void @_ZN10ANNkdStats5mergeERKS_(ptr noundef nonnull align 4 dereferenceable(40) %2, ptr noundef nonnull align 4 dereferenceable(40) %5)
          to label %18 unwind label %29

18:                                               ; preds = %17
  call void @_ZN10ANNkdStats5resetEiii(ptr noundef nonnull align 4 dereferenceable(40) %5, i32 noundef 0, i32 noundef 0, i32 noundef 0)
  %19 = getelementptr inbounds i8, ptr %0, i64 32
  %20 = load ptr, ptr %19, align 8, !tbaa !13
  %21 = load ptr, ptr %20, align 8, !tbaa !14
  %22 = getelementptr inbounds i8, ptr %21, i64 40
  %23 = load ptr, ptr %22, align 8
  invoke void %23(ptr noundef nonnull align 8 dereferenceable(8) %20, i32 noundef %1, ptr noundef nonnull align 4 dereferenceable(40) %5, ptr noundef nonnull align 8 dereferenceable(16) %3)
          to label %24 unwind label %29

24:                                               ; preds = %18
  invoke void @_ZN10ANNkdStats5mergeERKS_(ptr noundef nonnull align 4 dereferenceable(40) %2, ptr noundef nonnull align 4 dereferenceable(40) %5)
          to label %25 unwind label %29

25:                                               ; preds = %24
  %26 = getelementptr inbounds i8, ptr %2, i64 24
  %27 = load <2 x i32>, ptr %26, align 4, !tbaa !16
  %28 = add nsw <2 x i32> %27, <i32 1, i32 1>
  store <2 x i32> %28, ptr %26, align 4, !tbaa !16
  call void @_ZN11ANNorthRectD2Ev(ptr noundef nonnull align 8 dereferenceable(16) %6) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %6) #4
  call void @llvm.lifetime.end.p0(i64 40, ptr nonnull %5) #4
  ret void

29:                                               ; preds = %24, %18, %17, %11, %4
  %30 = landingpad { ptr, i32 }
          cleanup
  call void @_ZN11ANNorthRectD2Ev(ptr noundef nonnull align 8 dereferenceable(16) %6) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %6) #4
  call void @llvm.lifetime.end.p0(i64 40, ptr nonnull %5) #4
  resume { ptr, i32 } %30
}

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN10ANNkdStatsC2Ev(ptr noundef nonnull align 4 dereferenceable(40)) unnamed_addr #1 align 2

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

declare void @_Z11annBnds2BoxRK11ANNorthRectiiP16ANNorthHalfSpaceRS_(ptr noundef nonnull align 8 dereferenceable(16), i32 noundef, i32 noundef, ptr noundef, ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #2

declare i32 @__gxx_personality_v0(...)

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN10ANNkdStats5resetEiii(ptr noundef nonnull align 4 dereferenceable(40), i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #3 align 2

declare void @_ZN10ANNkdStats5mergeERKS_(ptr noundef nonnull align 4 dereferenceable(40), ptr noundef nonnull align 4 dereferenceable(40)) local_unnamed_addr #2

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

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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" }
attributes #3 = { 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 #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, !8, i64 8}
!6 = !{!"_ZTS12ANNbd_shrink", !7, i64 0, !8, i64 8, !11, i64 16, !9, i64 24}
!7 = !{!"_ZTS10ANNkd_node"}
!8 = !{!"int", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C++ TBAA"}
!11 = !{!"any pointer", !9, i64 0}
!12 = !{!6, !11, i64 16}
!13 = !{!11, !11, i64 0}
!14 = !{!15, !15, i64 0}
!15 = !{!"vtable pointer", !10, i64 0}
!16 = !{!8, !8, i64 0}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,SLPVectorizerPass,SROAPass,SimplifyCFGPass