; LLVM IR from ShahjalalShohag/code-library :: Geometry/Geometry 2D.ll (Z16geometric_medianSt6vectorI2PTSaIS0_EE)

; 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.PT = type { double, double }
%class.anon.18 = type { ptr }
%class.anon.19 = type { ptr }
%"struct.std::pair.20" = type { double, double }

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

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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_Z16geometric_medianSt6vectorI2PTSaIS0_EE(ptr dead_on_unwind noalias writable sret(%struct.PT) align 8 %0, ptr noundef %1) #2 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca %class.anon.18, align 8
  %6 = alloca %class.anon.19, align 8
  %7 = alloca double, align 8
  %8 = alloca double, align 8
  %9 = alloca i32, align 4
  %10 = alloca double, align 8
  %11 = alloca double, align 8
  %12 = alloca double, align 8
  %13 = alloca double, align 8
  %14 = alloca double, align 8
  %15 = alloca double, align 8
  %16 = alloca %"struct.std::pair.20", align 8
  %17 = alloca %"struct.std::pair.20", align 8
  %18 = alloca %"struct.std::pair.20", align 8
  store ptr %0, ptr %3, align 8
  store ptr %1, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #4
  %19 = getelementptr inbounds %class.anon.18, ptr %5, i32 0, i32 0
  store ptr %1, ptr %19, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #4
  %20 = getelementptr inbounds %class.anon.19, ptr %6, i32 0, i32 0
  store ptr %5, ptr %20, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #4
  store double -1.000000e+05, ptr %7, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #4
  store double 1.000000e+05, ptr %8, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #4
  store i32 0, ptr %9, align 4, !tbaa !11
  br label %21

21:                                               ; preds = %67, %2
  %22 = load i32, ptr %9, align 4, !tbaa !11
  %23 = icmp slt i32 %22, 60
  br i1 %23, label %25, label %24

24:                                               ; preds = %21
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  br label %70

25:                                               ; preds = %21
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #4
  %26 = load double, ptr %7, align 8, !tbaa !9
  %27 = load double, ptr %8, align 8, !tbaa !9
  %28 = load double, ptr %7, align 8, !tbaa !9
  %29 = fsub double %27, %28
  %30 = fdiv double %29, 3.000000e+00
  %31 = fadd double %26, %30
  store double %31, ptr %10, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #4
  %32 = load double, ptr %8, align 8, !tbaa !9
  %33 = load double, ptr %8, align 8, !tbaa !9
  %34 = load double, ptr %7, align 8, !tbaa !9
  %35 = fsub double %33, %34
  %36 = fdiv double %35, 3.000000e+00
  %37 = fsub double %32, %36
  store double %37, ptr %11, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #4
  call void @llvm.lifetime.start.p0(i64 16, ptr %16) #4
  %38 = load double, ptr %10, align 8, !tbaa !9
  %39 = call { double, double } @"_ZZ16geometric_medianSt6vectorI2PTSaIS0_EEENK3$_1clEd"(ptr noundef nonnull align 8 dereferenceable(8) %6, double noundef %38)
  %40 = getelementptr inbounds { double, double }, ptr %16, i32 0, i32 0
  %41 = extractvalue { double, double } %39, 0
  store double %41, ptr %40, align 8
  %42 = getelementptr inbounds { double, double }, ptr %16, i32 0, i32 1
  %43 = extractvalue { double, double } %39, 1
  store double %43, ptr %42, align 8
  %44 = getelementptr inbounds %"struct.std::pair.20", ptr %16, i32 0, i32 0
  %45 = load double, ptr %44, align 8, !tbaa !13
  store double %45, ptr %12, align 8, !tbaa !9
  %46 = getelementptr inbounds %"struct.std::pair.20", ptr %16, i32 0, i32 1
  %47 = load double, ptr %46, align 8, !tbaa !15
  store double %47, ptr %13, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 16, ptr %17) #4
  %48 = load double, ptr %11, align 8, !tbaa !9
  %49 = call { double, double } @"_ZZ16geometric_medianSt6vectorI2PTSaIS0_EEENK3$_1clEd"(ptr noundef nonnull align 8 dereferenceable(8) %6, double noundef %48)
  %50 = getelementptr inbounds { double, double }, ptr %17, i32 0, i32 0
  %51 = extractvalue { double, double } %49, 0
  store double %51, ptr %50, align 8
  %52 = getelementptr inbounds { double, double }, ptr %17, i32 0, i32 1
  %53 = extractvalue { double, double } %49, 1
  store double %53, ptr %52, align 8
  %54 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt4pairIddEaSEOS0_(ptr noundef nonnull align 8 dereferenceable(16) %16, ptr noundef nonnull align 8 dereferenceable(16) %17) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr %17) #4
  %55 = getelementptr inbounds %"struct.std::pair.20", ptr %16, i32 0, i32 0
  %56 = load double, ptr %55, align 8, !tbaa !13
  store double %56, ptr %14, align 8, !tbaa !9
  %57 = getelementptr inbounds %"struct.std::pair.20", ptr %16, i32 0, i32 1
  %58 = load double, ptr %57, align 8, !tbaa !15
  store double %58, ptr %15, align 8, !tbaa !9
  %59 = load double, ptr %13, align 8, !tbaa !9
  %60 = load double, ptr %15, align 8, !tbaa !9
  %61 = fcmp olt double %59, %60
  br i1 %61, label %62, label %64

62:                                               ; preds = %25
  %63 = load double, ptr %11, align 8, !tbaa !9
  store double %63, ptr %8, align 8, !tbaa !9
  br label %66

64:                                               ; preds = %25
  %65 = load double, ptr %10, align 8, !tbaa !9
  store double %65, ptr %7, align 8, !tbaa !9
  br label %66

66:                                               ; preds = %64, %62
  call void @llvm.lifetime.end.p0(i64 16, ptr %16) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #4
  br label %67

67:                                               ; preds = %66
  %68 = load i32, ptr %9, align 4, !tbaa !11
  %69 = add nsw i32 %68, 1
  store i32 %69, ptr %9, align 4, !tbaa !11
  br label %21, !llvm.loop !16

70:                                               ; preds = %24
  %71 = load double, ptr %7, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 16, ptr %18) #4
  %72 = load double, ptr %7, align 8, !tbaa !9
  %73 = call { double, double } @"_ZZ16geometric_medianSt6vectorI2PTSaIS0_EEENK3$_1clEd"(ptr noundef nonnull align 8 dereferenceable(8) %6, double noundef %72)
  %74 = getelementptr inbounds { double, double }, ptr %18, i32 0, i32 0
  %75 = extractvalue { double, double } %73, 0
  store double %75, ptr %74, align 8
  %76 = getelementptr inbounds { double, double }, ptr %18, i32 0, i32 1
  %77 = extractvalue { double, double } %73, 1
  store double %77, ptr %76, align 8
  %78 = getelementptr inbounds %"struct.std::pair.20", ptr %18, i32 0, i32 0
  %79 = load double, ptr %78, align 8, !tbaa !13
  call void @_ZN2PTC2Edd(ptr noundef nonnull align 8 dereferenceable(16) %0, double noundef %71, double noundef %79)
  call void @llvm.lifetime.end.p0(i64 16, ptr %18) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #4
  ret void
}

; Function Attrs: inlinehint mustprogress uwtable
declare hidden { double, double } @"_ZZ16geometric_medianSt6vectorI2PTSaIS0_EEENK3$_1clEd"(ptr noundef nonnull align 8 dereferenceable(8), double noundef) #3 align 2

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

attributes #0 = { 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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 #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 = !{!"double", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!14, !10, i64 0}
!14 = !{!"_ZTSSt4pairIddE", !10, i64 0, !10, i64 8}
!15 = !{!14, !10, i64 8}
!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"

%struct.PT = type { double, double }
%class.anon.18 = type { ptr }
%class.anon.19 = type { ptr }
%"struct.std::pair.20" = type { double, double }

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

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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_Z16geometric_medianSt6vectorI2PTSaIS0_EE(ptr dead_on_unwind noalias writable sret(%struct.PT) align 8 %0, ptr noundef %1) local_unnamed_addr #2 {
  %3 = alloca %class.anon.18, align 8
  %4 = alloca %class.anon.19, align 8
  %5 = alloca %"struct.std::pair.20", align 8
  %6 = alloca %"struct.std::pair.20", align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #4
  store ptr %1, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #4
  store ptr %3, ptr %4, align 8, !tbaa !5
  %7 = getelementptr inbounds i8, ptr %5, i64 8
  %8 = getelementptr inbounds i8, ptr %6, i64 8
  br label %12

9:                                                ; preds = %12
  %10 = call { double, double } @"_ZZ16geometric_medianSt6vectorI2PTSaIS0_EEENK3$_1clEd"(ptr noundef nonnull align 8 dereferenceable(8) %4, double noundef %.0.)
  %11 = extractvalue { double, double } %10, 0
  call void @_ZN2PTC2Edd(ptr noundef nonnull align 8 dereferenceable(16) %0, double noundef %.0., double noundef %11)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #4
  ret void

12:                                               ; preds = %2, %12
  %.020 = phi double [ -1.000000e+05, %2 ], [ %.0., %12 ]
  %.01519 = phi double [ 1.000000e+05, %2 ], [ %..015, %12 ]
  %.01718 = phi i32 [ 0, %2 ], [ %26, %12 ]
  %13 = fsub double %.01519, %.020
  %14 = fdiv double %13, 3.000000e+00
  %15 = fadd double %.020, %14
  %16 = fsub double %.01519, %14
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %5) #4
  %17 = call { double, double } @"_ZZ16geometric_medianSt6vectorI2PTSaIS0_EEENK3$_1clEd"(ptr noundef nonnull align 8 dereferenceable(8) %4, double noundef %15)
  %18 = extractvalue { double, double } %17, 0
  store double %18, ptr %5, align 8
  %19 = extractvalue { double, double } %17, 1
  store double %19, ptr %7, align 8
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %6) #4
  %20 = call { double, double } @"_ZZ16geometric_medianSt6vectorI2PTSaIS0_EEENK3$_1clEd"(ptr noundef nonnull align 8 dereferenceable(8) %4, double noundef %16)
  %21 = extractvalue { double, double } %20, 0
  store double %21, ptr %6, align 8
  %22 = extractvalue { double, double } %20, 1
  store double %22, ptr %8, align 8
  %23 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt4pairIddEaSEOS0_(ptr noundef nonnull align 8 dereferenceable(16) %5, ptr noundef nonnull align 8 dereferenceable(16) %6) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %6) #4
  %24 = load double, ptr %7, align 8, !tbaa !9
  %25 = fcmp olt double %19, %24
  %..015 = select i1 %25, double %16, double %.01519
  %.0. = select i1 %25, double %.020, double %15
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %5) #4
  %26 = add nuw nsw i32 %.01718, 1
  %exitcond.not = icmp eq i32 %26, 60
  br i1 %exitcond.not, label %9, label %12, !llvm.loop !12
}

; Function Attrs: inlinehint mustprogress uwtable
declare hidden { double, double } @"_ZZ16geometric_medianSt6vectorI2PTSaIS0_EEENK3$_1clEd"(ptr noundef nonnull align 8 dereferenceable(8), double noundef) local_unnamed_addr #3 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt4pairIddEaSEOS0_(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #0 align 2

attributes #0 = { 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 nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 #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, !11, i64 8}
!10 = !{!"_ZTSSt4pairIddE", !11, i64 0, !11, i64 8}
!11 = !{!"double", !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,LCSSAPass,LICMPass,LoopRotatePass,LoopUnrollPass,SROAPass,SimplifyCFGPass