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

; 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.ANNorthRect = type { ptr, 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 noundef i32 @_Z17tryCentroidShrinkPPdPiiiRK11ANNorthRectPFvS0_S1_S4_iiRiRdS5_ERS2_(ptr noundef %0, ptr noundef %1, i32 noundef %2, i32 noundef %3, ptr noundef nonnull align 8 dereferenceable(16) %4, ptr noundef %5, ptr noundef nonnull align 8 dereferenceable(16) %6) #1 {
  %8 = alloca i32, align 4
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca ptr, align 8
  %14 = alloca ptr, align 8
  %15 = alloca ptr, align 8
  %16 = alloca i32, align 4
  %17 = alloca i32, align 4
  %18 = alloca i32, align 4
  %19 = alloca i32, align 4
  %20 = alloca double, align 8
  %21 = alloca i32, align 4
  %22 = alloca i32, align 4
  store ptr %0, ptr %9, align 8, !tbaa !5
  store ptr %1, ptr %10, align 8, !tbaa !5
  store i32 %2, ptr %11, align 4, !tbaa !9
  store i32 %3, ptr %12, align 4, !tbaa !9
  store ptr %4, ptr %13, align 8, !tbaa !5
  store ptr %5, ptr %14, align 8, !tbaa !5
  store ptr %6, ptr %15, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #3
  %23 = load i32, ptr %11, align 4, !tbaa !9
  store i32 %23, ptr %16, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #3
  %24 = load i32, ptr %11, align 4, !tbaa !9
  %25 = sitofp i32 %24 to float
  %26 = fmul float %25, 5.000000e-01
  %27 = fptosi float %26 to i32
  store i32 %27, ptr %17, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #3
  store i32 0, ptr %18, align 4, !tbaa !9
  %28 = load i32, ptr %12, align 4, !tbaa !9
  %29 = load ptr, ptr %15, align 8, !tbaa !5
  %30 = load ptr, ptr %13, align 8, !tbaa !5
  call void @_Z13annAssignRectiR11ANNorthRectRKS_(i32 noundef %28, ptr noundef nonnull align 8 dereferenceable(16) %29, ptr noundef nonnull align 8 dereferenceable(16) %30)
  br label %31

31:                                               ; preds = %72, %7
  %32 = load i32, ptr %16, align 4, !tbaa !9
  %33 = load i32, ptr %17, align 4, !tbaa !9
  %34 = icmp sgt i32 %32, %33
  br i1 %34, label %35, label %73

35:                                               ; preds = %31
  call void @llvm.lifetime.start.p0(i64 4, ptr %19) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %20) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %21) #3
  %36 = load ptr, ptr %14, align 8, !tbaa !5
  %37 = load ptr, ptr %9, align 8, !tbaa !5
  %38 = load ptr, ptr %10, align 8, !tbaa !5
  %39 = load ptr, ptr %15, align 8, !tbaa !5
  %40 = load i32, ptr %16, align 4, !tbaa !9
  %41 = load i32, ptr %12, align 4, !tbaa !9
  call void %36(ptr noundef %37, ptr noundef %38, ptr noundef nonnull align 8 dereferenceable(16) %39, i32 noundef %40, i32 noundef %41, ptr noundef nonnull align 4 dereferenceable(4) %19, ptr noundef nonnull align 8 dereferenceable(8) %20, ptr noundef nonnull align 4 dereferenceable(4) %21)
  %42 = load i32, ptr %18, align 4, !tbaa !9
  %43 = add nsw i32 %42, 1
  store i32 %43, ptr %18, align 4, !tbaa !9
  %44 = load i32, ptr %21, align 4, !tbaa !9
  %45 = load i32, ptr %16, align 4, !tbaa !9
  %46 = sdiv i32 %45, 2
  %47 = icmp sge i32 %44, %46
  br i1 %47, label %48, label %57

48:                                               ; preds = %35
  %49 = load double, ptr %20, align 8, !tbaa !11
  %50 = load ptr, ptr %15, align 8, !tbaa !5
  %51 = getelementptr inbounds %class.ANNorthRect, ptr %50, i32 0, i32 1
  %52 = load ptr, ptr %51, align 8, !tbaa !13
  %53 = load i32, ptr %19, align 4, !tbaa !9
  %54 = sext i32 %53 to i64
  %55 = getelementptr inbounds double, ptr %52, i64 %54
  store double %49, ptr %55, align 8, !tbaa !11
  %56 = load i32, ptr %21, align 4, !tbaa !9
  store i32 %56, ptr %16, align 4, !tbaa !9
  br label %72

57:                                               ; preds = %35
  %58 = load double, ptr %20, align 8, !tbaa !11
  %59 = load ptr, ptr %15, align 8, !tbaa !5
  %60 = getelementptr inbounds %class.ANNorthRect, ptr %59, i32 0, i32 0
  %61 = load ptr, ptr %60, align 8, !tbaa !15
  %62 = load i32, ptr %19, align 4, !tbaa !9
  %63 = sext i32 %62 to i64
  %64 = getelementptr inbounds double, ptr %61, i64 %63
  store double %58, ptr %64, align 8, !tbaa !11
  %65 = load i32, ptr %21, align 4, !tbaa !9
  %66 = load ptr, ptr %10, align 8, !tbaa !5
  %67 = sext i32 %65 to i64
  %68 = getelementptr inbounds i32, ptr %66, i64 %67
  store ptr %68, ptr %10, align 8, !tbaa !5
  %69 = load i32, ptr %21, align 4, !tbaa !9
  %70 = load i32, ptr %16, align 4, !tbaa !9
  %71 = sub nsw i32 %70, %69
  store i32 %71, ptr %16, align 4, !tbaa !9
  br label %72

72:                                               ; preds = %57, %48
  call void @llvm.lifetime.end.p0(i64 4, ptr %21) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %20) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %19) #3
  br label %31, !llvm.loop !16

73:                                               ; preds = %31
  %74 = load i32, ptr %18, align 4, !tbaa !9
  %75 = sitofp i32 %74 to float
  %76 = load i32, ptr %12, align 4, !tbaa !9
  %77 = sitofp i32 %76 to float
  %78 = fmul float %77, 5.000000e-01
  %79 = fcmp ogt float %75, %78
  br i1 %79, label %80, label %81

80:                                               ; preds = %73
  store i32 1, ptr %8, align 4
  store i32 1, ptr %22, align 4
  br label %82

81:                                               ; preds = %73
  store i32 0, ptr %8, align 4
  store i32 1, ptr %22, align 4
  br label %82

82:                                               ; preds = %81, %80
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #3
  %83 = load i32, ptr %8, align 4
  ret i32 %83
}

declare void @_Z13annAssignRectiR11ANNorthRectRKS_(i32 noundef, ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(16)) #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 = { 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, !12, i64 0}
!12 = !{!"double", !7, i64 0}
!13 = !{!14, !6, i64 8}
!14 = !{!"_ZTS11ANNorthRect", !6, i64 0, !6, i64 8}
!15 = !{!14, !6, i64 0}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}


; 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: 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 noundef range(i32 0, 2) i32 @_Z17tryCentroidShrinkPPdPiiiRK11ANNorthRectPFvS0_S1_S4_iiRiRdS5_ERS2_(ptr noundef %0, ptr noundef %1, i32 noundef %2, i32 noundef %3, ptr noundef nonnull align 8 dereferenceable(16) %4, ptr nocapture noundef readonly %5, ptr noundef nonnull align 8 dereferenceable(16) %6) local_unnamed_addr #1 {
  %8 = alloca i32, align 4
  %9 = alloca double, align 8
  %10 = alloca i32, align 4
  %11 = sitofp i32 %2 to float
  %12 = fmul float %11, 5.000000e-01
  %13 = fptosi float %12 to i32
  tail call void @_Z13annAssignRectiR11ANNorthRectRKS_(i32 noundef %3, ptr noundef nonnull align 8 dereferenceable(16) %6, ptr noundef nonnull align 8 dereferenceable(16) %4)
  %14 = icmp slt i32 %13, %2
  br i1 %14, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %7
  %15 = getelementptr inbounds i8, ptr %6, i64 8
  br label %16

16:                                               ; preds = %.lr.ph, %32
  %.027 = phi i32 [ 0, %.lr.ph ], [ %17, %32 ]
  %.02226 = phi i32 [ %2, %.lr.ph ], [ %.1, %32 ]
  %.02325 = phi ptr [ %1, %.lr.ph ], [ %.124, %32 ]
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %8) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %9) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %10) #3
  call void %5(ptr noundef %0, ptr noundef %.02325, ptr noundef nonnull align 8 dereferenceable(16) %6, i32 noundef %.02226, i32 noundef %3, ptr noundef nonnull align 4 dereferenceable(4) %8, ptr noundef nonnull align 8 dereferenceable(8) %9, ptr noundef nonnull align 4 dereferenceable(4) %10)
  %17 = add nuw nsw i32 %.027, 1
  %18 = load i32, ptr %10, align 4, !tbaa !5
  %19 = sdiv i32 %.02226, 2
  %.not = icmp slt i32 %18, %19
  %20 = load double, ptr %9, align 8, !tbaa !9
  %21 = load i32, ptr %8, align 4, !tbaa !5
  %22 = sext i32 %21 to i64
  br i1 %.not, label %26, label %23

23:                                               ; preds = %16
  %24 = load ptr, ptr %15, align 8, !tbaa !11
  %25 = getelementptr inbounds double, ptr %24, i64 %22
  store double %20, ptr %25, align 8, !tbaa !9
  br label %32

26:                                               ; preds = %16
  %27 = load ptr, ptr %6, align 8, !tbaa !14
  %28 = getelementptr inbounds double, ptr %27, i64 %22
  store double %20, ptr %28, align 8, !tbaa !9
  %29 = sext i32 %18 to i64
  %30 = getelementptr inbounds i32, ptr %.02325, i64 %29
  %31 = sub nsw i32 %.02226, %18
  br label %32

32:                                               ; preds = %26, %23
  %.124 = phi ptr [ %.02325, %23 ], [ %30, %26 ]
  %.1 = phi i32 [ %18, %23 ], [ %31, %26 ]
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %10) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %9) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %8) #3
  %33 = icmp sgt i32 %.1, %13
  br i1 %33, label %16, label %._crit_edge.loopexit, !llvm.loop !15

._crit_edge.loopexit:                             ; preds = %32
  %34 = uitofp nneg i32 %17 to float
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit, %7
  %.0.lcssa = phi float [ 0.000000e+00, %7 ], [ %34, %._crit_edge.loopexit ]
  %35 = sitofp i32 %3 to float
  %36 = fmul float %35, 5.000000e-01
  %37 = fcmp olt float %36, %.0.lcssa
  %. = zext i1 %37 to i32
  ret i32 %.
}

declare void @_Z13annAssignRectiR11ANNorthRectRKS_(i32 noundef, ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #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 = { 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 = !{!"int", !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, !13, i64 8}
!12 = !{!"_ZTS11ANNorthRect", !13, i64 0, !13, i64 8}
!13 = !{!"any pointer", !7, i64 0}
!14 = !{!12, !13, i64 0}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass