; LLVM IR from jianboqi/CSF :: src/point_cloud.ll (ZN3csf10PointCloud18computeBoundingBoxERNS_5PointES2_)

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

%"struct.csf::Point" = type { %union.anon }
%union.anon = type { %struct.anon }
%struct.anon = type { double, double, double }

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN3csf10PointCloud18computeBoundingBoxERNS_5PointES2_(ptr noundef nonnull align 8 dereferenceable(24) %0, ptr noundef nonnull align 8 dereferenceable(24) %1, ptr noundef nonnull align 8 dereferenceable(24) %2) #0 align 2 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca %"struct.csf::Point", align 8
  %8 = alloca i64, align 8
  %9 = alloca i32, align 4
  %10 = alloca ptr, align 8
  %11 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store ptr %2, ptr %6, align 8, !tbaa !5
  %12 = load ptr, ptr %4, align 8
  %13 = call noundef zeroext i1 @_ZNKSt6vectorIN3csf5PointESaIS1_EE5emptyEv(ptr noundef nonnull align 8 dereferenceable(24) %12) #4
  br i1 %13, label %14, label %17

14:                                               ; preds = %3
  call void @llvm.lifetime.start.p0(i64 24, ptr %7) #4
  call void @_ZN3csf5PointC2Ev(ptr noundef nonnull align 8 dereferenceable(24) %7)
  %15 = load ptr, ptr %6, align 8, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %15, ptr align 8 %7, i64 24, i1 false), !tbaa.struct !9
  %16 = load ptr, ptr %5, align 8, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %16, ptr align 8 %15, i64 24, i1 false), !tbaa.struct !9
  call void @llvm.lifetime.end.p0(i64 24, ptr %7) #4
  br label %94

17:                                               ; preds = %3
  %18 = call noundef nonnull align 8 dereferenceable(24) ptr @_ZNSt6vectorIN3csf5PointESaIS1_EE2atEm(ptr noundef nonnull align 8 dereferenceable(24) %12, i64 noundef 0)
  %19 = load ptr, ptr %6, align 8, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %19, ptr align 8 %18, i64 24, i1 false), !tbaa.struct !9
  %20 = load ptr, ptr %5, align 8, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %20, ptr align 8 %19, i64 24, i1 false), !tbaa.struct !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #4
  store i64 1, ptr %8, align 8, !tbaa !11
  br label %21

21:                                               ; preds = %91, %17
  %22 = load i64, ptr %8, align 8, !tbaa !11
  %23 = call noundef i64 @_ZNKSt6vectorIN3csf5PointESaIS1_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %12) #4
  %24 = icmp ult i64 %22, %23
  br i1 %24, label %26, label %25

25:                                               ; preds = %21
  store i32 2, ptr %9, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  br label %94

26:                                               ; preds = %21
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #4
  %27 = load i64, ptr %8, align 8, !tbaa !11
  %28 = call noundef nonnull align 8 dereferenceable(24) ptr @_ZNSt6vectorIN3csf5PointESaIS1_EE2atEm(ptr noundef nonnull align 8 dereferenceable(24) %12, i64 noundef %27)
  store ptr %28, ptr %10, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #4
  store i32 0, ptr %11, align 4, !tbaa !13
  br label %29

29:                                               ; preds = %87, %26
  %30 = load i32, ptr %11, align 4, !tbaa !13
  %31 = icmp slt i32 %30, 3
  br i1 %31, label %33, label %32

32:                                               ; preds = %29
  store i32 5, ptr %9, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #4
  br label %90

33:                                               ; preds = %29
  %34 = load ptr, ptr %10, align 8, !tbaa !5
  %35 = getelementptr inbounds %"struct.csf::Point", ptr %34, i32 0, i32 0
  %36 = load i32, ptr %11, align 4, !tbaa !13
  %37 = sext i32 %36 to i64
  %38 = getelementptr inbounds [3 x double], ptr %35, i64 0, i64 %37
  %39 = load double, ptr %38, align 8, !tbaa !10
  %40 = load ptr, ptr %5, align 8, !tbaa !5
  %41 = getelementptr inbounds %"struct.csf::Point", ptr %40, i32 0, i32 0
  %42 = load i32, ptr %11, align 4, !tbaa !13
  %43 = sext i32 %42 to i64
  %44 = getelementptr inbounds [3 x double], ptr %41, i64 0, i64 %43
  %45 = load double, ptr %44, align 8, !tbaa !10
  %46 = fcmp olt double %39, %45
  br i1 %46, label %47, label %59

47:                                               ; preds = %33
  %48 = load ptr, ptr %10, align 8, !tbaa !5
  %49 = getelementptr inbounds %"struct.csf::Point", ptr %48, i32 0, i32 0
  %50 = load i32, ptr %11, align 4, !tbaa !13
  %51 = sext i32 %50 to i64
  %52 = getelementptr inbounds [3 x double], ptr %49, i64 0, i64 %51
  %53 = load double, ptr %52, align 8, !tbaa !10
  %54 = load ptr, ptr %5, align 8, !tbaa !5
  %55 = getelementptr inbounds %"struct.csf::Point", ptr %54, i32 0, i32 0
  %56 = load i32, ptr %11, align 4, !tbaa !13
  %57 = sext i32 %56 to i64
  %58 = getelementptr inbounds [3 x double], ptr %55, i64 0, i64 %57
  store double %53, ptr %58, align 8, !tbaa !10
  br label %86

59:                                               ; preds = %33
  %60 = load ptr, ptr %10, align 8, !tbaa !5
  %61 = getelementptr inbounds %"struct.csf::Point", ptr %60, i32 0, i32 0
  %62 = load i32, ptr %11, align 4, !tbaa !13
  %63 = sext i32 %62 to i64
  %64 = getelementptr inbounds [3 x double], ptr %61, i64 0, i64 %63
  %65 = load double, ptr %64, align 8, !tbaa !10
  %66 = load ptr, ptr %6, align 8, !tbaa !5
  %67 = getelementptr inbounds %"struct.csf::Point", ptr %66, i32 0, i32 0
  %68 = load i32, ptr %11, align 4, !tbaa !13
  %69 = sext i32 %68 to i64
  %70 = getelementptr inbounds [3 x double], ptr %67, i64 0, i64 %69
  %71 = load double, ptr %70, align 8, !tbaa !10
  %72 = fcmp ogt double %65, %71
  br i1 %72, label %73, label %85

73:                                               ; preds = %59
  %74 = load ptr, ptr %10, align 8, !tbaa !5
  %75 = getelementptr inbounds %"struct.csf::Point", ptr %74, i32 0, i32 0
  %76 = load i32, ptr %11, align 4, !tbaa !13
  %77 = sext i32 %76 to i64
  %78 = getelementptr inbounds [3 x double], ptr %75, i64 0, i64 %77
  %79 = load double, ptr %78, align 8, !tbaa !10
  %80 = load ptr, ptr %6, align 8, !tbaa !5
  %81 = getelementptr inbounds %"struct.csf::Point", ptr %80, i32 0, i32 0
  %82 = load i32, ptr %11, align 4, !tbaa !13
  %83 = sext i32 %82 to i64
  %84 = getelementptr inbounds [3 x double], ptr %81, i64 0, i64 %83
  store double %79, ptr %84, align 8, !tbaa !10
  br label %85

85:                                               ; preds = %73, %59
  br label %86

86:                                               ; preds = %85, %47
  br label %87

87:                                               ; preds = %86
  %88 = load i32, ptr %11, align 4, !tbaa !13
  %89 = add nsw i32 %88, 1
  store i32 %89, ptr %11, align 4, !tbaa !13
  br label %29, !llvm.loop !15

90:                                               ; preds = %32
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #4
  br label %91

91:                                               ; preds = %90
  %92 = load i64, ptr %8, align 8, !tbaa !11
  %93 = add i64 %92, 1
  store i64 %93, ptr %8, align 8, !tbaa !11
  br label %21, !llvm.loop !17

94:                                               ; preds = %25, %14
  ret void
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNKSt6vectorIN3csf5PointESaIS1_EE5emptyEv(ptr noundef nonnull align 8 dereferenceable(24)) #1 align 2

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN3csf5PointC2Ev(ptr noundef nonnull align 8 dereferenceable(24)) unnamed_addr #1 align 2

; 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) #3

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef nonnull align 8 dereferenceable(24) ptr @_ZNSt6vectorIN3csf5PointESaIS1_EE2atEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZNKSt6vectorIN3csf5PointESaIS1_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24)) #1 align 2

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


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

%"struct.csf::Point" = type { %union.anon }
%union.anon = type { %struct.anon }
%struct.anon = type { double, double, double }

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN3csf10PointCloud18computeBoundingBoxERNS_5PointES2_(ptr noundef nonnull align 8 dereferenceable(24) %0, ptr nocapture noundef nonnull align 8 dereferenceable(24) %1, ptr nocapture noundef nonnull align 8 dereferenceable(24) %2) local_unnamed_addr #0 align 2 {
  %4 = alloca %"struct.csf::Point", align 8
  %5 = tail call noundef zeroext i1 @_ZNKSt6vectorIN3csf5PointESaIS1_EE5emptyEv(ptr noundef nonnull align 8 dereferenceable(24) %0) #5
  br i1 %5, label %6, label %7

6:                                                ; preds = %3
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %4) #5
  call void @_ZN3csf5PointC2Ev(ptr noundef nonnull align 8 dereferenceable(24) %4)
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(24) %2, ptr noundef nonnull align 8 dereferenceable(24) %4, i64 24, i1 false), !tbaa.struct !5
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(24) %1, ptr noundef nonnull align 8 dereferenceable(24) %4, i64 24, i1 false)
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %4) #5
  br label %.loopexit

7:                                                ; preds = %3
  %8 = tail call noundef nonnull align 8 dereferenceable(24) ptr @_ZNSt6vectorIN3csf5PointESaIS1_EE2atEm(ptr noundef nonnull align 8 dereferenceable(24) %0, i64 noundef 0)
  tail call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(24) %2, ptr noundef nonnull align 8 dereferenceable(24) %8, i64 24, i1 false), !tbaa.struct !5
  tail call void @llvm.memmove.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(24) %1, ptr noundef nonnull align 8 dereferenceable(24) %8, i64 24, i1 false)
  %9 = tail call noundef i64 @_ZNKSt6vectorIN3csf5PointESaIS1_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %0) #5
  %10 = icmp ugt i64 %9, 1
  br i1 %10, label %.lr.ph.preheader, label %.loopexit

.lr.ph.preheader:                                 ; preds = %7
  %11 = getelementptr inbounds i8, ptr %1, i64 8
  %12 = getelementptr inbounds i8, ptr %2, i64 8
  %13 = getelementptr inbounds i8, ptr %1, i64 16
  %14 = getelementptr inbounds i8, ptr %2, i64 16
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph.preheader, %38
  %.02528 = phi i64 [ %39, %38 ], [ 1, %.lr.ph.preheader ]
  %15 = tail call noundef nonnull align 8 dereferenceable(24) ptr @_ZNSt6vectorIN3csf5PointESaIS1_EE2atEm(ptr noundef nonnull align 8 dereferenceable(24) %0, i64 noundef %.02528)
  %16 = load double, ptr %15, align 8, !tbaa !6
  %17 = load double, ptr %1, align 8, !tbaa !6
  %18 = fcmp olt double %16, %17
  br i1 %18, label %.sink.split, label %19

19:                                               ; preds = %.lr.ph
  %20 = load double, ptr %2, align 8, !tbaa !6
  %21 = fcmp ogt double %16, %20
  br i1 %21, label %.sink.split, label %22

.sink.split:                                      ; preds = %19, %.lr.ph
  %.sink = phi ptr [ %1, %.lr.ph ], [ %2, %19 ]
  store double %16, ptr %.sink, align 8, !tbaa !6
  br label %22

22:                                               ; preds = %.sink.split, %19
  %23 = getelementptr inbounds i8, ptr %15, i64 8
  %24 = load double, ptr %23, align 8, !tbaa !6
  %25 = load double, ptr %11, align 8, !tbaa !6
  %26 = fcmp olt double %24, %25
  br i1 %26, label %.sink.split30, label %27

27:                                               ; preds = %22
  %28 = load double, ptr %12, align 8, !tbaa !6
  %29 = fcmp ogt double %24, %28
  br i1 %29, label %.sink.split30, label %30

.sink.split30:                                    ; preds = %22, %27
  %.sink31 = phi ptr [ %12, %27 ], [ %11, %22 ]
  store double %24, ptr %.sink31, align 8, !tbaa !6
  br label %30

30:                                               ; preds = %.sink.split30, %27
  %31 = getelementptr inbounds i8, ptr %15, i64 16
  %32 = load double, ptr %31, align 8, !tbaa !6
  %33 = load double, ptr %13, align 8, !tbaa !6
  %34 = fcmp olt double %32, %33
  br i1 %34, label %.sink.split32, label %35

35:                                               ; preds = %30
  %36 = load double, ptr %14, align 8, !tbaa !6
  %37 = fcmp ogt double %32, %36
  br i1 %37, label %.sink.split32, label %38

.sink.split32:                                    ; preds = %30, %35
  %.sink33 = phi ptr [ %14, %35 ], [ %13, %30 ]
  store double %32, ptr %.sink33, align 8, !tbaa !6
  br label %38

38:                                               ; preds = %.sink.split32, %35
  %39 = add nuw i64 %.02528, 1
  %40 = tail call noundef i64 @_ZNKSt6vectorIN3csf5PointESaIS1_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %0) #5
  %41 = icmp ult i64 %39, %40
  br i1 %41, label %.lr.ph, label %.loopexit, !llvm.loop !9

.loopexit:                                        ; preds = %38, %7, %6
  ret void
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNKSt6vectorIN3csf5PointESaIS1_EE5emptyEv(ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #1 align 2

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN3csf5PointC2Ev(ptr noundef nonnull align 8 dereferenceable(24)) unnamed_addr #1 align 2

; Function Attrs: mustprogress 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) #3

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef nonnull align 8 dereferenceable(24) ptr @_ZNSt6vectorIN3csf5PointESaIS1_EE2atEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZNKSt6vectorIN3csf5PointESaIS1_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #1 align 2

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

attributes #0 = { 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 #1 = { 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 nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 = !{i64 0, i64 24, !6}
!6 = !{!7, !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}


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