; LLVM IR from ahr9n/psolving-paradigms :: 3.binary-search/Gym 103081C - Safe Distance.ll (Z2okv)

; 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.DSU = type { [1005 x i32], [1005 x i32], i32 }
%"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 { x86_fp80, x86_fp80 }

@dsu = external dso_local global %struct.DSU, align 4
@p = external dso_local global %"class.std::vector", align 8
@mid = external dso_local global x86_fp80, align 16
@dx = external dso_local global x86_fp80, align 16
@dy = external dso_local global x86_fp80, align 16
@n = external dso_local global i32, align 4

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

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN3DSU5mergeEii(ptr noundef nonnull align 4 dereferenceable(8044), i32 noundef, i32 noundef) #2 align 2

; 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 zeroext i1 @_Z2okv() #2 {
  %1 = alloca i1, align 1
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = load i32, ptr @n, align 4, !tbaa !5
  %6 = call noundef i32 @_ZN3DSU4findEi(ptr noundef nonnull align 4 dereferenceable(8044) @dsu, i32 noundef %5)
  %7 = load i32, ptr @n, align 4, !tbaa !5
  %8 = add nsw i32 %7, 1
  %9 = call noundef i32 @_ZN3DSU4findEi(ptr noundef nonnull align 4 dereferenceable(8044) @dsu, i32 noundef %8)
  %10 = icmp eq i32 %6, %9
  br i1 %10, label %11, label %12

11:                                               ; preds = %0
  store i1 false, ptr %1, align 1
  br label %93

12:                                               ; preds = %0
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #4
  store i32 0, ptr %2, align 4, !tbaa !5
  br label %13

13:                                               ; preds = %87, %12
  %14 = load i32, ptr %2, align 4, !tbaa !5
  %15 = load i32, ptr @n, align 4, !tbaa !5
  %16 = icmp slt i32 %14, %15
  br i1 %16, label %18, label %17

17:                                               ; preds = %13
  store i32 2, ptr %3, align 4
  br label %90

18:                                               ; preds = %13
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #4
  %19 = load i32, ptr %2, align 4, !tbaa !5
  %20 = add nsw i32 %19, 1
  store i32 %20, ptr %4, align 4, !tbaa !5
  br label %21

21:                                               ; preds = %81, %18
  %22 = load i32, ptr %4, align 4, !tbaa !5
  %23 = load i32, ptr @n, align 4, !tbaa !5
  %24 = icmp slt i32 %22, %23
  br i1 %24, label %26, label %25

25:                                               ; preds = %21
  store i32 5, ptr %3, align 4
  br label %84

26:                                               ; preds = %21
  %27 = load i32, ptr %2, align 4, !tbaa !5
  %28 = call noundef i32 @_ZN3DSU4findEi(ptr noundef nonnull align 4 dereferenceable(8044) @dsu, i32 noundef %27)
  %29 = load i32, ptr %4, align 4, !tbaa !5
  %30 = call noundef i32 @_ZN3DSU4findEi(ptr noundef nonnull align 4 dereferenceable(8044) @dsu, i32 noundef %29)
  %31 = icmp eq i32 %28, %30
  br i1 %31, label %32, label %33

32:                                               ; preds = %26
  br label %81

33:                                               ; preds = %26
  %34 = load i32, ptr %4, align 4, !tbaa !5
  %35 = sext i32 %34 to i64
  %36 = call noundef nonnull align 16 dereferenceable(32) ptr @_ZNSt6vectorI5pointSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) @p, i64 noundef %35) #4
  %37 = getelementptr inbounds %struct.point, ptr %36, i32 0, i32 0
  %38 = load x86_fp80, ptr %37, align 16, !tbaa !9
  %39 = load i32, ptr %2, align 4, !tbaa !5
  %40 = sext i32 %39 to i64
  %41 = call noundef nonnull align 16 dereferenceable(32) ptr @_ZNSt6vectorI5pointSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) @p, i64 noundef %40) #4
  %42 = getelementptr inbounds %struct.point, ptr %41, i32 0, i32 0
  %43 = load x86_fp80, ptr %42, align 16, !tbaa !9
  %44 = fsub x86_fp80 %38, %43
  store x86_fp80 %44, ptr @dx, align 16, !tbaa !12
  %45 = load i32, ptr %4, align 4, !tbaa !5
  %46 = sext i32 %45 to i64
  %47 = call noundef nonnull align 16 dereferenceable(32) ptr @_ZNSt6vectorI5pointSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) @p, i64 noundef %46) #4
  %48 = getelementptr inbounds %struct.point, ptr %47, i32 0, i32 1
  %49 = load x86_fp80, ptr %48, align 16, !tbaa !13
  %50 = load i32, ptr %2, align 4, !tbaa !5
  %51 = sext i32 %50 to i64
  %52 = call noundef nonnull align 16 dereferenceable(32) ptr @_ZNSt6vectorI5pointSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) @p, i64 noundef %51) #4
  %53 = getelementptr inbounds %struct.point, ptr %52, i32 0, i32 1
  %54 = load x86_fp80, ptr %53, align 16, !tbaa !13
  %55 = fsub x86_fp80 %49, %54
  store x86_fp80 %55, ptr @dy, align 16, !tbaa !12
  %56 = load x86_fp80, ptr @dx, align 16, !tbaa !12
  %57 = load x86_fp80, ptr @dx, align 16, !tbaa !12
  %58 = load x86_fp80, ptr @dy, align 16, !tbaa !12
  %59 = load x86_fp80, ptr @dy, align 16, !tbaa !12
  %60 = fmul x86_fp80 %58, %59
  %61 = call x86_fp80 @llvm.fmuladd.f80(x86_fp80 %56, x86_fp80 %57, x86_fp80 %60)
  %62 = load x86_fp80, ptr @mid, align 16, !tbaa !12
  %63 = fmul x86_fp80 0xK40008000000000000000, %62
  %64 = load x86_fp80, ptr @mid, align 16, !tbaa !12
  %65 = fmul x86_fp80 0xK40008000000000000000, %64
  %66 = fmul x86_fp80 %63, %65
  %67 = fcmp ole x86_fp80 %61, %66
  br i1 %67, label %68, label %80

68:                                               ; preds = %33
  %69 = load i32, ptr %2, align 4, !tbaa !5
  %70 = load i32, ptr %4, align 4, !tbaa !5
  %71 = call noundef zeroext i1 @_ZN3DSU5mergeEii(ptr noundef nonnull align 4 dereferenceable(8044) @dsu, i32 noundef %69, i32 noundef %70)
  %72 = load i32, ptr @n, align 4, !tbaa !5
  %73 = call noundef i32 @_ZN3DSU4findEi(ptr noundef nonnull align 4 dereferenceable(8044) @dsu, i32 noundef %72)
  %74 = load i32, ptr @n, align 4, !tbaa !5
  %75 = add nsw i32 %74, 1
  %76 = call noundef i32 @_ZN3DSU4findEi(ptr noundef nonnull align 4 dereferenceable(8044) @dsu, i32 noundef %75)
  %77 = icmp eq i32 %73, %76
  br i1 %77, label %78, label %79

78:                                               ; preds = %68
  store i1 false, ptr %1, align 1
  store i32 1, ptr %3, align 4
  br label %84

79:                                               ; preds = %68
  br label %80

80:                                               ; preds = %79, %33
  br label %81

81:                                               ; preds = %80, %32
  %82 = load i32, ptr %4, align 4, !tbaa !5
  %83 = add nsw i32 %82, 1
  store i32 %83, ptr %4, align 4, !tbaa !5
  br label %21, !llvm.loop !14

84:                                               ; preds = %78, %25
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #4
  %85 = load i32, ptr %3, align 4
  switch i32 %85, label %90 [
    i32 5, label %86
  ]

86:                                               ; preds = %84
  br label %87

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

90:                                               ; preds = %84, %17
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #4
  %91 = load i32, ptr %3, align 4
  switch i32 %91, label %95 [
    i32 2, label %92
    i32 1, label %93
  ]

92:                                               ; preds = %90
  store i1 true, ptr %1, align 1
  br label %93

93:                                               ; preds = %92, %90, %11
  %94 = load i1, ptr %1, align 1
  ret i1 %94

95:                                               ; preds = %90
  unreachable
}

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_ZN3DSU4findEi(ptr noundef nonnull align 4 dereferenceable(8044), i32 noundef) #2 align 2

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare x86_fp80 @llvm.fmuladd.f80(x86_fp80, x86_fp80, x86_fp80) #3

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !11, i64 0}
!10 = !{!"_ZTS5point", !11, i64 0, !11, i64 16}
!11 = !{!"long double", !7, i64 0}
!12 = !{!11, !11, i64 0}
!13 = !{!10, !11, i64 16}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}
!16 = distinct !{!16, !15}


; 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.DSU = type { [1005 x i32], [1005 x i32], i32 }
%"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 }

@dsu = external dso_local global %struct.DSU, align 4
@p = external dso_local global %"class.std::vector", align 8
@mid = external dso_local local_unnamed_addr global x86_fp80, align 16
@dx = external dso_local local_unnamed_addr global x86_fp80, align 16
@dy = external dso_local local_unnamed_addr global x86_fp80, align 16
@n = external dso_local local_unnamed_addr global i32, align 4

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN3DSU5mergeEii(ptr noundef nonnull align 4 dereferenceable(8044), i32 noundef, i32 noundef) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_Z2okv() local_unnamed_addr #1 {
  %1 = load i32, ptr @n, align 4, !tbaa !5
  %2 = tail call noundef i32 @_ZN3DSU4findEi(ptr noundef nonnull align 4 dereferenceable(8044) @dsu, i32 noundef %1)
  %3 = load i32, ptr @n, align 4, !tbaa !5
  %4 = add nsw i32 %3, 1
  %5 = tail call noundef i32 @_ZN3DSU4findEi(ptr noundef nonnull align 4 dereferenceable(8044) @dsu, i32 noundef %4)
  %6 = icmp eq i32 %2, %5
  br i1 %6, label %.thread, label %.preheader

.preheader:                                       ; preds = %0
  %7 = load i32, ptr @n, align 4, !tbaa !5
  %8 = icmp slt i32 %7, 1
  br i1 %8, label %.thread, label %.lr.ph25

.loopexit.loopexit:                               ; preds = %46
  %.pre = sext i32 %47 to i64
  br label %.loopexit

.loopexit:                                        ; preds = %.loopexit.loopexit, %.lr.ph25
  %.pre-phi = phi i64 [ %.pre, %.loopexit.loopexit ], [ %11, %.lr.ph25 ]
  %9 = phi i32 [ %47, %.loopexit.loopexit ], [ %10, %.lr.ph25 ]
  %.not33 = icmp slt i64 %indvars.iv.next31, %.pre-phi
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  br i1 %.not33, label %.lr.ph25, label %.thread

.lr.ph25:                                         ; preds = %.preheader, %.loopexit
  %10 = phi i32 [ %9, %.loopexit ], [ %7, %.preheader ]
  %indvars.iv30 = phi i64 [ %indvars.iv.next31, %.loopexit ], [ 0, %.preheader ]
  %indvars.iv = phi i64 [ %indvars.iv.next, %.loopexit ], [ 1, %.preheader ]
  %indvars.iv.next31 = add nuw nsw i64 %indvars.iv30, 1
  %11 = sext i32 %10 to i64
  %.not22 = icmp slt i64 %indvars.iv.next31, %11
  br i1 %.not22, label %.lr.ph, label %.loopexit

.lr.ph:                                           ; preds = %.lr.ph25
  %12 = trunc nuw nsw i64 %indvars.iv30 to i32
  br label %13

13:                                               ; preds = %.lr.ph, %46
  %indvars.iv27 = phi i64 [ %indvars.iv, %.lr.ph ], [ %indvars.iv.next28, %46 ]
  %14 = tail call noundef i32 @_ZN3DSU4findEi(ptr noundef nonnull align 4 dereferenceable(8044) @dsu, i32 noundef %12)
  %15 = trunc nuw nsw i64 %indvars.iv27 to i32
  %16 = tail call noundef i32 @_ZN3DSU4findEi(ptr noundef nonnull align 4 dereferenceable(8044) @dsu, i32 noundef %15)
  %17 = icmp eq i32 %14, %16
  br i1 %17, label %46, label %18

18:                                               ; preds = %13
  %19 = tail call noundef nonnull align 16 dereferenceable(32) ptr @_ZNSt6vectorI5pointSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) @p, i64 noundef %indvars.iv27) #3
  %20 = load x86_fp80, ptr %19, align 16, !tbaa !9
  %21 = tail call noundef nonnull align 16 dereferenceable(32) ptr @_ZNSt6vectorI5pointSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) @p, i64 noundef %indvars.iv30) #3
  %22 = load x86_fp80, ptr %21, align 16, !tbaa !9
  %23 = fsub x86_fp80 %20, %22
  store x86_fp80 %23, ptr @dx, align 16, !tbaa !12
  %24 = tail call noundef nonnull align 16 dereferenceable(32) ptr @_ZNSt6vectorI5pointSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) @p, i64 noundef %indvars.iv27) #3
  %25 = getelementptr inbounds i8, ptr %24, i64 16
  %26 = load x86_fp80, ptr %25, align 16, !tbaa !13
  %27 = tail call noundef nonnull align 16 dereferenceable(32) ptr @_ZNSt6vectorI5pointSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) @p, i64 noundef %indvars.iv30) #3
  %28 = getelementptr inbounds i8, ptr %27, i64 16
  %29 = load x86_fp80, ptr %28, align 16, !tbaa !13
  %30 = fsub x86_fp80 %26, %29
  store x86_fp80 %30, ptr @dy, align 16, !tbaa !12
  %31 = load x86_fp80, ptr @dx, align 16, !tbaa !12
  %32 = fmul x86_fp80 %30, %30
  %33 = tail call x86_fp80 @llvm.fmuladd.f80(x86_fp80 %31, x86_fp80 %31, x86_fp80 %32)
  %34 = load x86_fp80, ptr @mid, align 16, !tbaa !12
  %35 = fmul x86_fp80 %34, 0xK40008000000000000000
  %36 = fmul x86_fp80 %35, %35
  %37 = fcmp ugt x86_fp80 %33, %36
  br i1 %37, label %46, label %38

38:                                               ; preds = %18
  %39 = tail call noundef zeroext i1 @_ZN3DSU5mergeEii(ptr noundef nonnull align 4 dereferenceable(8044) @dsu, i32 noundef %12, i32 noundef %15)
  %40 = load i32, ptr @n, align 4, !tbaa !5
  %41 = tail call noundef i32 @_ZN3DSU4findEi(ptr noundef nonnull align 4 dereferenceable(8044) @dsu, i32 noundef %40)
  %42 = load i32, ptr @n, align 4, !tbaa !5
  %43 = add nsw i32 %42, 1
  %44 = tail call noundef i32 @_ZN3DSU4findEi(ptr noundef nonnull align 4 dereferenceable(8044) @dsu, i32 noundef %43)
  %45 = icmp eq i32 %41, %44
  br i1 %45, label %.thread, label %46

46:                                               ; preds = %18, %38, %13
  %indvars.iv.next28 = add nuw nsw i64 %indvars.iv27, 1
  %47 = load i32, ptr @n, align 4, !tbaa !5
  %48 = trunc nuw i64 %indvars.iv.next28 to i32
  %.not = icmp sgt i32 %47, %48
  br i1 %.not, label %13, label %.loopexit.loopexit, !llvm.loop !14

.thread:                                          ; preds = %.loopexit, %38, %.preheader, %0
  %.3 = phi i1 [ false, %0 ], [ true, %.preheader ], [ false, %38 ], [ true, %.loopexit ]
  ret i1 %.3
}

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_ZN3DSU4findEi(ptr noundef nonnull align 4 dereferenceable(8044), i32 noundef) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare x86_fp80 @llvm.fmuladd.f80(x86_fp80, x86_fp80, x86_fp80) #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 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 speculatable willreturn memory(none) }
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, !11, i64 0}
!10 = !{!"_ZTS5point", !11, i64 0, !11, i64 16}
!11 = !{!"long double", !7, i64 0}
!12 = !{!11, !11, i64 0}
!13 = !{!10, !11, i64 16}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}


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