; LLVM IR from ERGO-Code/HiGHS :: src/util/HighsSort.ll (Z15increasingSetOkRKSt6vectorIdSaIdEEddb)

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

; 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 nounwind uwtable
define dso_local noundef zeroext i1 @_Z15increasingSetOkRKSt6vectorIdSaIdEEddb(ptr noundef nonnull align 8 dereferenceable(24) %0, double noundef %1, double noundef %2, i1 noundef zeroext %3) #1 {
  %5 = alloca i1, align 1
  %6 = alloca ptr, align 8
  %7 = alloca double, align 8
  %8 = alloca double, align 8
  %9 = alloca i8, align 1
  %10 = alloca i32, align 4
  %11 = alloca i8, align 1
  %12 = alloca double, align 8
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca double, align 8
  store ptr %0, ptr %6, align 8, !tbaa !5
  store double %1, ptr %7, align 8, !tbaa !9
  store double %2, ptr %8, align 8, !tbaa !9
  %16 = zext i1 %3 to i8
  store i8 %16, ptr %9, align 1, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #2
  %17 = load ptr, ptr %6, align 8, !tbaa !5
  %18 = call noundef i64 @_ZNKSt6vectorIdSaIdEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %17) #2
  %19 = trunc i64 %18 to i32
  store i32 %19, ptr %10, align 4, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 1, ptr %11) #2
  %20 = load double, ptr %7, align 8, !tbaa !9
  %21 = load double, ptr %8, align 8, !tbaa !9
  %22 = fcmp ole double %20, %21
  %23 = zext i1 %22 to i8
  store i8 %23, ptr %11, align 1, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #2
  %24 = load i8, ptr %11, align 1, !tbaa !11, !range !15, !noundef !16
  %25 = trunc i8 %24 to i1
  br i1 %25, label %26, label %47

26:                                               ; preds = %4
  %27 = load i8, ptr %9, align 1, !tbaa !11, !range !15, !noundef !16
  %28 = trunc i8 %27 to i1
  br i1 %28, label %29, label %44

29:                                               ; preds = %26
  %30 = load double, ptr %7, align 8, !tbaa !9
  %31 = fcmp olt double %30, 0.000000e+00
  br i1 %31, label %32, label %35

32:                                               ; preds = %29
  %33 = load double, ptr %7, align 8, !tbaa !9
  %34 = fmul double 0x3FF000000000002D, %33
  store double %34, ptr %12, align 8, !tbaa !9
  br label %43

35:                                               ; preds = %29
  %36 = load double, ptr %7, align 8, !tbaa !9
  %37 = fcmp ogt double %36, 0.000000e+00
  br i1 %37, label %38, label %41

38:                                               ; preds = %35
  %39 = load double, ptr %7, align 8, !tbaa !9
  %40 = fmul double 0x3FEFFFFFFFFFFFA6, %39
  store double %40, ptr %12, align 8, !tbaa !9
  br label %42

41:                                               ; preds = %35
  store double 0xBD06849B86A12B9B, ptr %12, align 8, !tbaa !9
  br label %42

42:                                               ; preds = %41, %38
  br label %43

43:                                               ; preds = %42, %32
  br label %46

44:                                               ; preds = %26
  %45 = load double, ptr %7, align 8, !tbaa !9
  store double %45, ptr %12, align 8, !tbaa !9
  br label %46

46:                                               ; preds = %44, %43
  br label %48

47:                                               ; preds = %4
  store double 0xFFF0000000000000, ptr %12, align 8, !tbaa !9
  br label %48

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

49:                                               ; preds = %87, %48
  %50 = load i32, ptr %13, align 4, !tbaa !13
  %51 = load i32, ptr %10, align 4, !tbaa !13
  %52 = icmp slt i32 %50, %51
  br i1 %52, label %54, label %53

53:                                               ; preds = %49
  store i32 2, ptr %14, align 4
  br label %90

54:                                               ; preds = %49
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #2
  %55 = load ptr, ptr %6, align 8, !tbaa !5
  %56 = load i32, ptr %13, align 4, !tbaa !13
  %57 = sext i32 %56 to i64
  %58 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNKSt6vectorIdSaIdEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %55, i64 noundef %57) #2
  %59 = load double, ptr %58, align 8, !tbaa !9
  store double %59, ptr %15, align 8, !tbaa !9
  %60 = load i8, ptr %9, align 1, !tbaa !11, !range !15, !noundef !16
  %61 = trunc i8 %60 to i1
  br i1 %61, label %62, label %68

62:                                               ; preds = %54
  %63 = load double, ptr %15, align 8, !tbaa !9
  %64 = load double, ptr %12, align 8, !tbaa !9
  %65 = fcmp ole double %63, %64
  br i1 %65, label %66, label %67

66:                                               ; preds = %62
  store i1 false, ptr %5, align 1
  store i32 1, ptr %14, align 4
  br label %84

67:                                               ; preds = %62
  br label %74

68:                                               ; preds = %54
  %69 = load double, ptr %15, align 8, !tbaa !9
  %70 = load double, ptr %12, align 8, !tbaa !9
  %71 = fcmp olt double %69, %70
  br i1 %71, label %72, label %73

72:                                               ; preds = %68
  store i1 false, ptr %5, align 1
  store i32 1, ptr %14, align 4
  br label %84

73:                                               ; preds = %68
  br label %74

74:                                               ; preds = %73, %67
  %75 = load i8, ptr %11, align 1, !tbaa !11, !range !15, !noundef !16
  %76 = trunc i8 %75 to i1
  br i1 %76, label %77, label %82

77:                                               ; preds = %74
  %78 = load double, ptr %15, align 8, !tbaa !9
  %79 = load double, ptr %8, align 8, !tbaa !9
  %80 = fcmp ogt double %78, %79
  br i1 %80, label %81, label %82

81:                                               ; preds = %77
  store i1 false, ptr %5, align 1
  store i32 1, ptr %14, align 4
  br label %84

82:                                               ; preds = %77, %74
  %83 = load double, ptr %15, align 8, !tbaa !9
  store double %83, ptr %12, align 8, !tbaa !9
  store i32 0, ptr %14, align 4
  br label %84

84:                                               ; preds = %82, %81, %72, %66
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #2
  %85 = load i32, ptr %14, align 4
  switch i32 %85, label %90 [
    i32 0, label %86
  ]

86:                                               ; preds = %84
  br label %87

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

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

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

93:                                               ; preds = %92, %90
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #2
  call void @llvm.lifetime.end.p0(i64 1, ptr %11) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #2
  %94 = load i1, ptr %5, align 1
  ret i1 %94
}

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

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

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 = { 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 = !{!"bool", !7, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"int", !7, i64 0}
!15 = !{i8 0, i8 2}
!16 = !{}
!17 = distinct !{!17, !18}
!18 = !{!"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"

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef zeroext i1 @_Z15increasingSetOkRKSt6vectorIdSaIdEEddb(ptr noundef nonnull align 8 dereferenceable(24) %0, double noundef %1, double noundef %2, i1 noundef zeroext %3) local_unnamed_addr #0 {
  %5 = tail call noundef i64 @_ZNKSt6vectorIdSaIdEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %0) #1
  %6 = trunc i64 %5 to i32
  %7 = fcmp ole double %1, %2
  %brmerge.not = and i1 %7, %3
  %.mux = select i1 %7, double %1, double 0xFFF0000000000000
  br i1 %brmerge.not, label %8, label %16

8:                                                ; preds = %4
  %9 = fcmp olt double %1, 0.000000e+00
  br i1 %9, label %10, label %12

10:                                               ; preds = %8
  %11 = fmul double %1, 0x3FF000000000002D
  br label %16

12:                                               ; preds = %8
  %13 = fcmp ogt double %1, 0.000000e+00
  br i1 %13, label %14, label %16

14:                                               ; preds = %12
  %15 = fmul double %1, 0x3FEFFFFFFFFFFFA6
  br label %16

16:                                               ; preds = %4, %12, %14, %10
  %.030 = phi double [ %11, %10 ], [ %15, %14 ], [ 0xBD06849B86A12B9B, %12 ], [ %.mux, %4 ]
  %.not39 = icmp slt i32 %6, 1
  br i1 %.not39, label %.critedge, label %.lr.ph

.lr.ph:                                           ; preds = %16
  br i1 %3, label %.lr.ph.split.us, label %.lr.ph.split

.lr.ph.split.us:                                  ; preds = %.lr.ph
  br i1 %7, label %.lr.ph.split.us.split.preheader, label %.lr.ph.split.us.split.us

.lr.ph.split.us.split.preheader:                  ; preds = %.lr.ph.split.us
  %17 = and i64 %5, 2147483647
  %wide.trip.count84 = and i64 %5, 2147483647
  %18 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNKSt6vectorIdSaIdEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %0, i64 noundef 0) #1
  %19 = load double, ptr %18, align 8, !tbaa !5
  %20 = fcmp ole double %19, %.030
  %21 = fcmp ogt double %19, %2
  %or.cond96 = or i1 %20, %21
  br i1 %or.cond96, label %.critedge, label %.lr.ph98

.lr.ph.split.us.split.us:                         ; preds = %.lr.ph.split.us
  %22 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNKSt6vectorIdSaIdEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %0, i64 noundef 0) #1
  %23 = load double, ptr %22, align 8, !tbaa !5
  %24 = fcmp ugt double %23, %.030
  br i1 %24, label %.lr.ph65.preheader, label %.critedge

.lr.ph65.preheader:                               ; preds = %.lr.ph.split.us.split.us
  %25 = and i64 %5, 2147483647
  %26 = add i64 %5, 4294967295
  %wide.trip.count80 = and i64 %26, 4294967295
  br label %.lr.ph65

27:                                               ; preds = %.lr.ph65
  %28 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNKSt6vectorIdSaIdEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %0, i64 noundef %indvars.iv.next78) #1
  %29 = load double, ptr %28, align 8, !tbaa !5
  %30 = fcmp ugt double %29, %31
  br i1 %30, label %.lr.ph65, label %.critedge.loopexit86, !llvm.loop !9

.lr.ph65:                                         ; preds = %.lr.ph65.preheader, %27
  %indvars.iv77 = phi i64 [ 0, %.lr.ph65.preheader ], [ %indvars.iv.next78, %27 ]
  %31 = phi double [ %23, %.lr.ph65.preheader ], [ %29, %27 ]
  %indvars.iv.next78 = add nuw nsw i64 %indvars.iv77, 1
  %exitcond81 = icmp eq i64 %indvars.iv77, %wide.trip.count80
  br i1 %exitcond81, label %.critedge.loopexit86, label %27, !llvm.loop !9

.lr.ph.split.us.split:                            ; preds = %.lr.ph98
  %32 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNKSt6vectorIdSaIdEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %0, i64 noundef %indvars.iv.next83) #1
  %33 = load double, ptr %32, align 8, !tbaa !5
  %34 = fcmp ole double %33, %36
  %35 = fcmp ogt double %33, %2
  %or.cond = or i1 %34, %35
  br i1 %or.cond, label %.critedge.loopexit, label %.lr.ph98, !llvm.loop !9

.lr.ph98:                                         ; preds = %.lr.ph.split.us.split.preheader, %.lr.ph.split.us.split
  %36 = phi double [ %33, %.lr.ph.split.us.split ], [ %19, %.lr.ph.split.us.split.preheader ]
  %indvars.iv8297 = phi i64 [ %indvars.iv.next83, %.lr.ph.split.us.split ], [ 0, %.lr.ph.split.us.split.preheader ]
  %indvars.iv.next83 = add nuw nsw i64 %indvars.iv8297, 1
  %exitcond85 = icmp eq i64 %indvars.iv.next83, %wide.trip.count84
  br i1 %exitcond85, label %.critedge.loopexit, label %.lr.ph.split.us.split, !llvm.loop !9

.lr.ph.split:                                     ; preds = %.lr.ph
  br i1 %7, label %.lr.ph.split.split.preheader, label %.lr.ph.split.split.us

.lr.ph.split.split.preheader:                     ; preds = %.lr.ph.split
  %37 = and i64 %5, 2147483647
  %wide.trip.count75 = and i64 %5, 2147483647
  %38 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNKSt6vectorIdSaIdEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %0, i64 noundef 0) #1
  %39 = load double, ptr %38, align 8, !tbaa !5
  %40 = fcmp olt double %39, %.030
  %41 = fcmp ogt double %39, %2
  %or.cond7092 = or i1 %40, %41
  br i1 %or.cond7092, label %.critedge, label %.lr.ph94

.lr.ph.split.split.us:                            ; preds = %.lr.ph.split
  %42 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNKSt6vectorIdSaIdEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %0, i64 noundef 0) #1
  %43 = load double, ptr %42, align 8, !tbaa !5
  %44 = fcmp olt double %43, %.030
  br i1 %44, label %.critedge, label %.lr.ph60.preheader

.lr.ph60.preheader:                               ; preds = %.lr.ph.split.split.us
  %45 = and i64 %5, 2147483647
  %46 = add i64 %5, 4294967295
  %wide.trip.count = and i64 %46, 4294967295
  br label %.lr.ph60

47:                                               ; preds = %.lr.ph60
  %48 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNKSt6vectorIdSaIdEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %0, i64 noundef %indvars.iv.next) #1
  %49 = load double, ptr %48, align 8, !tbaa !5
  %50 = fcmp olt double %49, %51
  br i1 %50, label %.critedge.loopexit89, label %.lr.ph60, !llvm.loop !9

.lr.ph60:                                         ; preds = %.lr.ph60.preheader, %47
  %indvars.iv = phi i64 [ 0, %.lr.ph60.preheader ], [ %indvars.iv.next, %47 ]
  %51 = phi double [ %43, %.lr.ph60.preheader ], [ %49, %47 ]
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond = icmp eq i64 %indvars.iv, %wide.trip.count
  br i1 %exitcond, label %.critedge.loopexit89, label %47, !llvm.loop !9

.lr.ph94:                                         ; preds = %.lr.ph.split.split.preheader, %.lr.ph.split.split
  %52 = phi double [ %54, %.lr.ph.split.split ], [ %39, %.lr.ph.split.split.preheader ]
  %indvars.iv7393 = phi i64 [ %indvars.iv.next74, %.lr.ph.split.split ], [ 0, %.lr.ph.split.split.preheader ]
  %indvars.iv.next74 = add nuw nsw i64 %indvars.iv7393, 1
  %exitcond76 = icmp eq i64 %indvars.iv.next74, %wide.trip.count75
  br i1 %exitcond76, label %.critedge.loopexit101, label %.lr.ph.split.split, !llvm.loop !9

.lr.ph.split.split:                               ; preds = %.lr.ph94
  %53 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNKSt6vectorIdSaIdEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %0, i64 noundef %indvars.iv.next74) #1
  %54 = load double, ptr %53, align 8, !tbaa !5
  %55 = fcmp olt double %54, %52
  %56 = fcmp ogt double %54, %2
  %or.cond70 = or i1 %55, %56
  br i1 %or.cond70, label %.critedge.loopexit101, label %.lr.ph94, !llvm.loop !9

.critedge.loopexit86:                             ; preds = %27, %.lr.ph65
  %.not.us.us.le = icmp uge i64 %indvars.iv.next78, %25
  br label %.critedge

.critedge.loopexit89:                             ; preds = %47, %.lr.ph60
  %.not.us54.le = icmp uge i64 %indvars.iv.next, %45
  br label %.critedge

.critedge.loopexit:                               ; preds = %.lr.ph98, %.lr.ph.split.us.split
  %.not.us.le = icmp uge i64 %indvars.iv.next83, %17
  br label %.critedge

.critedge.loopexit101:                            ; preds = %.lr.ph94, %.lr.ph.split.split
  %.not.le = icmp uge i64 %indvars.iv.next74, %37
  br label %.critedge

.critedge:                                        ; preds = %.critedge.loopexit101, %.critedge.loopexit, %.lr.ph.split.split.preheader, %.lr.ph.split.us.split.preheader, %.critedge.loopexit89, %.critedge.loopexit86, %.lr.ph.split.us.split.us, %.lr.ph.split.split.us, %16
  %.not.lcssa = phi i1 [ true, %16 ], [ false, %.lr.ph.split.split.us ], [ false, %.lr.ph.split.us.split.us ], [ %.not.us.us.le, %.critedge.loopexit86 ], [ %.not.us54.le, %.critedge.loopexit89 ], [ false, %.lr.ph.split.us.split.preheader ], [ false, %.lr.ph.split.split.preheader ], [ %.not.us.le, %.critedge.loopexit ], [ %.not.le, %.critedge.loopexit101 ]
  ret i1 %.not.lcssa
}

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZNKSt6vectorIdSaIdEEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) 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 = { 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 = !{!"double", !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,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopInstSimplifyPass,LoopRotatePass,LoopSimplifyCFGPass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass