; LLVM IR from iksha-rudra/Computational-Geometry :: CGAlgorithms/CGAlgorithms (cgalgorithms)

; 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.Point = type { i32, i32 }

; 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 i64 @_ZN12CGAlgorithms9_findMinYESt6vectorI5PointSaIS1_EE(ptr noundef %0) #1 align 2 {
  %2 = alloca %class.Point, align 4
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  call void @_ZN5PointC1Eii(ptr noundef nonnull align 4 dereferenceable(8) %2, i32 noundef 2147483647, i32 noundef 2147483647)
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #4
  store i32 0, ptr %4, align 4, !tbaa !9
  br label %5

5:                                                ; preds = %49, %1
  %6 = load i32, ptr %4, align 4, !tbaa !9
  %7 = zext i32 %6 to i64
  %8 = call noundef i64 @_ZNKSt6vectorI5PointSaIS0_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %0) #4
  %9 = icmp ult i64 %7, %8
  br i1 %9, label %11, label %10

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

11:                                               ; preds = %5
  %12 = load i32, ptr %4, align 4, !tbaa !9
  %13 = zext i32 %12 to i64
  %14 = call noundef nonnull align 4 dereferenceable(8) ptr @_ZNSt6vectorI5PointSaIS0_EE2atEm(ptr noundef nonnull align 8 dereferenceable(24) %0, i64 noundef %13)
  %15 = call noundef i32 @_ZN5Point1yEv(ptr noundef nonnull align 4 dereferenceable(8) %14)
  %16 = call noundef i32 @_ZN5Point1yEv(ptr noundef nonnull align 4 dereferenceable(8) %2)
  %17 = icmp slt i32 %15, %16
  br i1 %17, label %18, label %27

18:                                               ; preds = %11
  %19 = load i32, ptr %4, align 4, !tbaa !9
  %20 = zext i32 %19 to i64
  %21 = call noundef nonnull align 4 dereferenceable(8) ptr @_ZNSt6vectorI5PointSaIS0_EE2atEm(ptr noundef nonnull align 8 dereferenceable(24) %0, i64 noundef %20)
  %22 = call noundef i32 @_ZN5Point1yEv(ptr noundef nonnull align 4 dereferenceable(8) %21)
  call void @_ZN5Point4setYEi(ptr noundef nonnull align 4 dereferenceable(8) %2, i32 noundef %22)
  %23 = load i32, ptr %4, align 4, !tbaa !9
  %24 = zext i32 %23 to i64
  %25 = call noundef nonnull align 4 dereferenceable(8) ptr @_ZNSt6vectorI5PointSaIS0_EE2atEm(ptr noundef nonnull align 8 dereferenceable(24) %0, i64 noundef %24)
  %26 = call noundef i32 @_ZN5Point1xEv(ptr noundef nonnull align 4 dereferenceable(8) %25)
  call void @_ZN5Point4setXEi(ptr noundef nonnull align 4 dereferenceable(8) %2, i32 noundef %26)
  br label %48

27:                                               ; preds = %11
  %28 = load i32, ptr %4, align 4, !tbaa !9
  %29 = zext i32 %28 to i64
  %30 = call noundef nonnull align 4 dereferenceable(8) ptr @_ZNSt6vectorI5PointSaIS0_EE2atEm(ptr noundef nonnull align 8 dereferenceable(24) %0, i64 noundef %29)
  %31 = call noundef i32 @_ZN5Point1yEv(ptr noundef nonnull align 4 dereferenceable(8) %30)
  %32 = call noundef i32 @_ZN5Point1yEv(ptr noundef nonnull align 4 dereferenceable(8) %2)
  %33 = icmp eq i32 %31, %32
  br i1 %33, label %34, label %47

34:                                               ; preds = %27
  %35 = load i32, ptr %4, align 4, !tbaa !9
  %36 = zext i32 %35 to i64
  %37 = call noundef nonnull align 4 dereferenceable(8) ptr @_ZNSt6vectorI5PointSaIS0_EE2atEm(ptr noundef nonnull align 8 dereferenceable(24) %0, i64 noundef %36)
  %38 = call noundef i32 @_ZN5Point1xEv(ptr noundef nonnull align 4 dereferenceable(8) %37)
  %39 = call noundef i32 @_ZN5Point1xEv(ptr noundef nonnull align 4 dereferenceable(8) %2)
  %40 = icmp slt i32 %38, %39
  br i1 %40, label %41, label %46

41:                                               ; preds = %34
  %42 = load i32, ptr %4, align 4, !tbaa !9
  %43 = zext i32 %42 to i64
  %44 = call noundef nonnull align 4 dereferenceable(8) ptr @_ZNSt6vectorI5PointSaIS0_EE2atEm(ptr noundef nonnull align 8 dereferenceable(24) %0, i64 noundef %43)
  %45 = call noundef i32 @_ZN5Point1xEv(ptr noundef nonnull align 4 dereferenceable(8) %44)
  call void @_ZN5Point4setXEi(ptr noundef nonnull align 4 dereferenceable(8) %2, i32 noundef %45)
  br label %46

46:                                               ; preds = %41, %34
  br label %47

47:                                               ; preds = %46, %27
  br label %48

48:                                               ; preds = %47, %18
  br label %49

49:                                               ; preds = %48
  %50 = load i32, ptr %4, align 4, !tbaa !9
  %51 = add i32 %50, 1
  store i32 %51, ptr %4, align 4, !tbaa !9
  br label %5, !llvm.loop !11

52:                                               ; preds = %10
  %53 = load i64, ptr %2, align 4
  ret i64 %53
}

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

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

declare noundef i32 @_ZN5Point1xEv(ptr noundef nonnull align 4 dereferenceable(8)) #3

declare noundef i32 @_ZN5Point1yEv(ptr noundef nonnull align 4 dereferenceable(8)) #3

declare void @_ZN5PointC1Eii(ptr noundef nonnull align 4 dereferenceable(8), i32 noundef, i32 noundef) unnamed_addr #3

declare void @_ZN5Point4setYEi(ptr noundef nonnull align 4 dereferenceable(8), i32 noundef) #3

declare void @_ZN5Point4setXEi(ptr noundef nonnull align 4 dereferenceable(8), i32 noundef) #3

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 = { 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 #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" }
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 = distinct !{!11, !12}
!12 = !{!"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"

%class.Point = type { i32, i32 }

; Function Attrs: mustprogress uwtable
define dso_local i64 @_ZN12CGAlgorithms9_findMinYESt6vectorI5PointSaIS1_EE(ptr noundef %0) local_unnamed_addr #0 align 2 {
  %2 = alloca %class.Point, align 8
  call void @_ZN5PointC1Eii(ptr noundef nonnull align 4 dereferenceable(8) %2, i32 noundef 2147483647, i32 noundef 2147483647)
  %3 = call noundef i64 @_ZNKSt6vectorI5PointSaIS0_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %0) #3
  %.not = icmp eq i64 %3, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph

._crit_edge:                                      ; preds = %23, %1
  %4 = load i64, ptr %2, align 8
  ret i64 %4

.lr.ph:                                           ; preds = %1, %23
  %5 = phi i64 [ %25, %23 ], [ 0, %1 ]
  %.09 = phi i32 [ %24, %23 ], [ 0, %1 ]
  %6 = call noundef nonnull align 4 dereferenceable(8) ptr @_ZNSt6vectorI5PointSaIS0_EE2atEm(ptr noundef nonnull align 8 dereferenceable(24) %0, i64 noundef %5)
  %7 = call noundef i32 @_ZN5Point1yEv(ptr noundef nonnull align 4 dereferenceable(8) %6)
  %8 = call noundef i32 @_ZN5Point1yEv(ptr noundef nonnull align 4 dereferenceable(8) %2)
  %9 = icmp slt i32 %7, %8
  %10 = call noundef nonnull align 4 dereferenceable(8) ptr @_ZNSt6vectorI5PointSaIS0_EE2atEm(ptr noundef nonnull align 8 dereferenceable(24) %0, i64 noundef %5)
  %11 = call noundef i32 @_ZN5Point1yEv(ptr noundef nonnull align 4 dereferenceable(8) %10)
  br i1 %9, label %12, label %13

12:                                               ; preds = %.lr.ph
  call void @_ZN5Point4setYEi(ptr noundef nonnull align 4 dereferenceable(8) %2, i32 noundef %11)
  br label %.sink.split

13:                                               ; preds = %.lr.ph
  %14 = call noundef i32 @_ZN5Point1yEv(ptr noundef nonnull align 4 dereferenceable(8) %2)
  %15 = icmp eq i32 %11, %14
  br i1 %15, label %16, label %23

16:                                               ; preds = %13
  %17 = call noundef nonnull align 4 dereferenceable(8) ptr @_ZNSt6vectorI5PointSaIS0_EE2atEm(ptr noundef nonnull align 8 dereferenceable(24) %0, i64 noundef %5)
  %18 = call noundef i32 @_ZN5Point1xEv(ptr noundef nonnull align 4 dereferenceable(8) %17)
  %19 = call noundef i32 @_ZN5Point1xEv(ptr noundef nonnull align 4 dereferenceable(8) %2)
  %20 = icmp slt i32 %18, %19
  br i1 %20, label %.sink.split, label %23

.sink.split:                                      ; preds = %16, %12
  %21 = call noundef nonnull align 4 dereferenceable(8) ptr @_ZNSt6vectorI5PointSaIS0_EE2atEm(ptr noundef nonnull align 8 dereferenceable(24) %0, i64 noundef %5)
  %22 = call noundef i32 @_ZN5Point1xEv(ptr noundef nonnull align 4 dereferenceable(8) %21)
  call void @_ZN5Point4setXEi(ptr noundef nonnull align 4 dereferenceable(8) %2, i32 noundef %22)
  br label %23

23:                                               ; preds = %.sink.split, %16, %13
  %24 = add i32 %.09, 1
  %25 = zext i32 %24 to i64
  %26 = call noundef i64 @_ZNKSt6vectorI5PointSaIS0_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %0) #3
  %27 = icmp ugt i64 %26, %25
  br i1 %27, label %.lr.ph, label %._crit_edge, !llvm.loop !5
}

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

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

declare noundef i32 @_ZN5Point1xEv(ptr noundef nonnull align 4 dereferenceable(8)) local_unnamed_addr #2

declare noundef i32 @_ZN5Point1yEv(ptr noundef nonnull align 4 dereferenceable(8)) local_unnamed_addr #2

declare void @_ZN5PointC1Eii(ptr noundef nonnull align 4 dereferenceable(8), i32 noundef, i32 noundef) unnamed_addr #2

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

declare void @_ZN5Point4setXEi(ptr noundef nonnull align 4 dereferenceable(8), i32 noundef) local_unnamed_addr #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 = { "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 = distinct !{!5, !6}
!6 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass