; LLVM IR from ADJA/algos :: Geometry (ConvexHull)

; 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.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<point, std::allocator<point>>::_Vector_impl" }
%"struct.std::_Vector_base<point, std::allocator<point>>::_Vector_impl" = type { %"struct.std::_Vector_base<point, std::allocator<point>>::_Vector_impl_data" }
%"struct.std::_Vector_base<point, std::allocator<point>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%struct.point = type { double, double }

@n = external dso_local global i32, align 4
@p = external dso_local global %"class.std::vector", align 8
@hull = external dso_local global %"class.std::vector", align 8
@ans = external dso_local global double, align 8
@.str = external hidden unnamed_addr constant [10 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [2 x i8], align 1
@stdin = external global ptr, align 8
@.str.5 = external hidden unnamed_addr constant [11 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [2 x i8], align 1
@stdout = external global ptr, align 8
@.str.7 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [6 x i8], align 1

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z13setConvexHullSt6vectorI5pointSaIS0_EERS2_(ptr noundef, ptr noundef nonnull align 8 dereferenceable(24)) #1

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

; 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 void @_ZNSt6vectorI5pointSaIS0_EE9push_backERKS0_(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 8 dereferenceable(16)) #1 align 2

declare i32 @__gxx_personality_v0(...)

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef double @_Z12getPerimeterSt6vectorI5pointSaIS0_EE(ptr noundef) #0

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #3 personality ptr @__gxx_personality_v0 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca %struct.point, align 8
  %4 = alloca %"class.std::vector", align 8
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca %"class.std::vector", align 8
  store i32 0, ptr %1, align 4
  %8 = load ptr, ptr @stdin, align 8, !tbaa !5
  %9 = call ptr @freopen(ptr noundef @.str, ptr noundef @.str.4, ptr noundef %8)
  %10 = load ptr, ptr @stdout, align 8, !tbaa !5
  %11 = call ptr @freopen(ptr noundef @.str.5, ptr noundef @.str.6, ptr noundef %10)
  %12 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.7, ptr noundef @n)
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #5
  store i32 1, ptr %2, align 4, !tbaa !9
  br label %13

13:                                               ; preds = %22, %0
  %14 = load i32, ptr %2, align 4, !tbaa !9
  %15 = load i32, ptr @n, align 4, !tbaa !9
  %16 = icmp sle i32 %14, %15
  br i1 %16, label %18, label %17

17:                                               ; preds = %13
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #5
  br label %25

18:                                               ; preds = %13
  call void @llvm.lifetime.start.p0(i64 16, ptr %3) #5
  %19 = getelementptr inbounds %struct.point, ptr %3, i32 0, i32 0
  %20 = getelementptr inbounds %struct.point, ptr %3, i32 0, i32 1
  %21 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.8, ptr noundef %19, ptr noundef %20)
  call void @_ZNSt6vectorI5pointSaIS0_EE9push_backERKS0_(ptr noundef nonnull align 8 dereferenceable(24) @p, ptr noundef nonnull align 8 dereferenceable(16) %3)
  call void @llvm.lifetime.end.p0(i64 16, ptr %3) #5
  br label %22

22:                                               ; preds = %18
  %23 = load i32, ptr %2, align 4, !tbaa !9
  %24 = add nsw i32 %23, 1
  store i32 %24, ptr %2, align 4, !tbaa !9
  br label %13, !llvm.loop !11

25:                                               ; preds = %17
  call void @_ZNSt6vectorI5pointSaIS0_EEC2ERKS2_(ptr noundef nonnull align 8 dereferenceable(24) %4, ptr noundef nonnull align 8 dereferenceable(24) @p)
  invoke void @_Z13setConvexHullSt6vectorI5pointSaIS0_EERS2_(ptr noundef %4, ptr noundef nonnull align 8 dereferenceable(24) @hull)
          to label %26 unwind label %30

26:                                               ; preds = %25
  call void @_ZNSt6vectorI5pointSaIS0_EED2Ev(ptr noundef nonnull align 8 dereferenceable(24) %4) #5
  call void @_ZNSt6vectorI5pointSaIS0_EEC2ERKS2_(ptr noundef nonnull align 8 dereferenceable(24) %7, ptr noundef nonnull align 8 dereferenceable(24) @hull)
  %27 = call noundef double @_Z12getPerimeterSt6vectorI5pointSaIS0_EE(ptr noundef %7)
  store double %27, ptr @ans, align 8, !tbaa !13
  call void @_ZNSt6vectorI5pointSaIS0_EED2Ev(ptr noundef nonnull align 8 dereferenceable(24) %7) #5
  %28 = load double, ptr @ans, align 8, !tbaa !13
  %29 = call i32 (ptr, ...) @printf(ptr noundef @.str.9, double noundef %28)
  ret i32 0

30:                                               ; preds = %25
  %31 = landingpad { ptr, i32 }
          cleanup
  %32 = extractvalue { ptr, i32 } %31, 0
  store ptr %32, ptr %5, align 8
  %33 = extractvalue { ptr, i32 } %31, 1
  store i32 %33, ptr %6, align 4
  call void @_ZNSt6vectorI5pointSaIS0_EED2Ev(ptr noundef nonnull align 8 dereferenceable(24) %4) #5
  br label %34

34:                                               ; preds = %30
  %35 = load ptr, ptr %5, align 8
  %36 = load i32, ptr %6, align 4
  %37 = insertvalue { ptr, i32 } poison, ptr %35, 0
  %38 = insertvalue { ptr, i32 } %37, i32 %36, 1
  resume { ptr, i32 } %38
}

declare ptr @freopen(ptr noundef, ptr noundef, ptr noundef) #4

declare i32 @__isoc99_scanf(ptr noundef, ...) #4

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

declare i32 @printf(ptr noundef, ...) #4

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 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 = { mustprogress norecurse 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 = { "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 #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 = !{!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"}
!13 = !{!14, !14, i64 0}
!14 = !{!"double", !7, i64 0}


; 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.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<point, std::allocator<point>>::_Vector_impl" }
%"struct.std::_Vector_base<point, std::allocator<point>>::_Vector_impl" = type { %"struct.std::_Vector_base<point, std::allocator<point>>::_Vector_impl_data" }
%"struct.std::_Vector_base<point, std::allocator<point>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%struct.point = type { double, double }

@n = external dso_local global i32, align 4
@p = external dso_local global %"class.std::vector", align 8
@hull = external dso_local global %"class.std::vector", align 8
@ans = external dso_local local_unnamed_addr global double, align 8
@.str = external hidden unnamed_addr constant [10 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [2 x i8], align 1
@stdin = external local_unnamed_addr global ptr, align 8
@.str.5 = external hidden unnamed_addr constant [11 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [2 x i8], align 1
@stdout = external local_unnamed_addr global ptr, align 8
@.str.7 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [6 x i8], align 1

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z13setConvexHullSt6vectorI5pointSaIS0_EERS2_(ptr noundef, ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #1

; 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 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 void @_ZNSt6vectorI5pointSaIS0_EE9push_backERKS0_(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #1 align 2

declare i32 @__gxx_personality_v0(...)

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef double @_Z12getPerimeterSt6vectorI5pointSaIS0_EE(ptr noundef) local_unnamed_addr #0

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #3 personality ptr @__gxx_personality_v0 {
  %1 = alloca %struct.point, align 8
  %2 = alloca %"class.std::vector", align 8
  %3 = alloca %"class.std::vector", align 8
  %4 = load ptr, ptr @stdin, align 8, !tbaa !5
  %5 = tail call ptr @freopen(ptr noundef nonnull @.str, ptr noundef nonnull @.str.4, ptr noundef %4)
  %6 = load ptr, ptr @stdout, align 8, !tbaa !5
  %7 = tail call ptr @freopen(ptr noundef nonnull @.str.5, ptr noundef nonnull @.str.6, ptr noundef %6)
  %8 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.7, ptr noundef nonnull @n)
  %9 = load i32, ptr @n, align 4, !tbaa !9
  %.not3 = icmp slt i32 %9, 1
  br i1 %.not3, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %0
  %10 = getelementptr inbounds i8, ptr %1, i64 8
  br label %11

._crit_edge:                                      ; preds = %11, %0
  call void @_ZNSt6vectorI5pointSaIS0_EEC2ERKS2_(ptr noundef nonnull align 8 dereferenceable(24) %2, ptr noundef nonnull align 8 dereferenceable(24) @p)
  invoke void @_Z13setConvexHullSt6vectorI5pointSaIS0_EERS2_(ptr noundef nonnull %2, ptr noundef nonnull align 8 dereferenceable(24) @hull)
          to label %15 unwind label %19

11:                                               ; preds = %.lr.ph, %11
  %.04 = phi i32 [ 1, %.lr.ph ], [ %13, %11 ]
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %1) #6
  %12 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.8, ptr noundef nonnull %1, ptr noundef nonnull %10)
  call void @_ZNSt6vectorI5pointSaIS0_EE9push_backERKS0_(ptr noundef nonnull align 8 dereferenceable(24) @p, ptr noundef nonnull align 8 dereferenceable(16) %1)
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %1) #6
  %13 = add nuw nsw i32 %.04, 1
  %14 = load i32, ptr @n, align 4, !tbaa !9
  %.not.not = icmp slt i32 %.04, %14
  br i1 %.not.not, label %11, label %._crit_edge, !llvm.loop !11

15:                                               ; preds = %._crit_edge
  call void @_ZNSt6vectorI5pointSaIS0_EED2Ev(ptr noundef nonnull align 8 dereferenceable(24) %2) #6
  call void @_ZNSt6vectorI5pointSaIS0_EEC2ERKS2_(ptr noundef nonnull align 8 dereferenceable(24) %3, ptr noundef nonnull align 8 dereferenceable(24) @hull)
  %16 = call noundef double @_Z12getPerimeterSt6vectorI5pointSaIS0_EE(ptr noundef nonnull %3)
  store double %16, ptr @ans, align 8, !tbaa !13
  call void @_ZNSt6vectorI5pointSaIS0_EED2Ev(ptr noundef nonnull align 8 dereferenceable(24) %3) #6
  %17 = load double, ptr @ans, align 8, !tbaa !13
  %18 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.9, double noundef %17)
  ret i32 0

19:                                               ; preds = %._crit_edge
  %20 = landingpad { ptr, i32 }
          cleanup
  call void @_ZNSt6vectorI5pointSaIS0_EED2Ev(ptr noundef nonnull align 8 dereferenceable(24) %2) #6
  resume { ptr, i32 } %20
}

declare ptr @freopen(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #4

; Function Attrs: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #5

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

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #5

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 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 norecurse 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 = { "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 #5 = { nofree nounwind "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 #6 = { 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"}
!13 = !{!14, !14, i64 0}
!14 = !{!"double", !7, i64 0}


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