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

; 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.HighsIndexCollection = type { i32, i8, i32, i32, i8, i32, %"class.std::vector", i8, %"class.std::vector" }
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl" }
%"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl" = type { %"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl_data" }
%"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl_data" = type { ptr, ptr, ptr }

@.str.52 = external hidden unnamed_addr constant [73 x i8], align 1
@.str.67 = external hidden unnamed_addr constant [7 x i8], align 1
@__PRETTY_FUNCTION__._Z6limitsRK20HighsIndexCollectionRiS2_ = external hidden unnamed_addr constant [66 x i8], align 1

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #0

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_Z6limitsRK20HighsIndexCollectionRiS2_(ptr noundef nonnull align 8 dereferenceable(80) %0, ptr noundef nonnull align 4 dereferenceable(4) %1, ptr noundef nonnull align 4 dereferenceable(4) %2) #1 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store ptr %2, ptr %6, align 8, !tbaa !5
  %7 = load ptr, ptr %4, align 8, !tbaa !5
  %8 = getelementptr inbounds %struct.HighsIndexCollection, ptr %7, i32 0, i32 1
  %9 = load i8, ptr %8, align 4, !tbaa !9, !range !17, !noundef !18
  %10 = trunc i8 %9 to i1
  br i1 %10, label %11, label %20

11:                                               ; preds = %3
  %12 = load ptr, ptr %4, align 8, !tbaa !5
  %13 = getelementptr inbounds %struct.HighsIndexCollection, ptr %12, i32 0, i32 2
  %14 = load i32, ptr %13, align 8, !tbaa !19
  %15 = load ptr, ptr %5, align 8, !tbaa !5
  store i32 %14, ptr %15, align 4, !tbaa !20
  %16 = load ptr, ptr %4, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct.HighsIndexCollection, ptr %16, i32 0, i32 3
  %18 = load i32, ptr %17, align 4, !tbaa !21
  %19 = load ptr, ptr %6, align 8, !tbaa !5
  store i32 %18, ptr %19, align 4, !tbaa !20
  br label %47

20:                                               ; preds = %3
  %21 = load ptr, ptr %4, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.HighsIndexCollection, ptr %21, i32 0, i32 4
  %23 = load i8, ptr %22, align 8, !tbaa !22, !range !17, !noundef !18
  %24 = trunc i8 %23 to i1
  br i1 %24, label %25, label %32

25:                                               ; preds = %20
  %26 = load ptr, ptr %5, align 8, !tbaa !5
  store i32 0, ptr %26, align 4, !tbaa !20
  %27 = load ptr, ptr %4, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.HighsIndexCollection, ptr %27, i32 0, i32 5
  %29 = load i32, ptr %28, align 4, !tbaa !23
  %30 = sub nsw i32 %29, 1
  %31 = load ptr, ptr %6, align 8, !tbaa !5
  store i32 %30, ptr %31, align 4, !tbaa !20
  br label %46

32:                                               ; preds = %20
  %33 = load ptr, ptr %4, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.HighsIndexCollection, ptr %33, i32 0, i32 7
  %35 = load i8, ptr %34, align 8, !tbaa !24, !range !17, !noundef !18
  %36 = trunc i8 %35 to i1
  br i1 %36, label %37, label %44

37:                                               ; preds = %32
  %38 = load ptr, ptr %5, align 8, !tbaa !5
  store i32 0, ptr %38, align 4, !tbaa !20
  %39 = load ptr, ptr %4, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.HighsIndexCollection, ptr %39, i32 0, i32 0
  %41 = load i32, ptr %40, align 8, !tbaa !25
  %42 = sub nsw i32 %41, 1
  %43 = load ptr, ptr %6, align 8, !tbaa !5
  store i32 %42, ptr %43, align 4, !tbaa !20
  br label %45

44:                                               ; preds = %32
  call void @__assert_fail(ptr noundef @.str.67, ptr noundef @.str.52, i32 noundef 188, ptr noundef @__PRETTY_FUNCTION__._Z6limitsRK20HighsIndexCollectionRiS2_) #2
  unreachable

45:                                               ; preds = %37
  br label %46

46:                                               ; preds = %45, %25
  br label %47

47:                                               ; preds = %46, %11
  ret void
}

attributes #0 = { noreturn 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 #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 = { noreturn 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, !12, i64 4}
!10 = !{!"_ZTS20HighsIndexCollection", !11, i64 0, !12, i64 4, !11, i64 8, !11, i64 12, !12, i64 16, !11, i64 20, !13, i64 24, !12, i64 48, !13, i64 56}
!11 = !{!"int", !7, i64 0}
!12 = !{!"bool", !7, i64 0}
!13 = !{!"_ZTSSt6vectorIiSaIiEE", !14, i64 0}
!14 = !{!"_ZTSSt12_Vector_baseIiSaIiEE", !15, i64 0}
!15 = !{!"_ZTSNSt12_Vector_baseIiSaIiEE12_Vector_implE", !16, i64 0}
!16 = !{!"_ZTSNSt12_Vector_baseIiSaIiEE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!17 = !{i8 0, i8 2}
!18 = !{}
!19 = !{!10, !11, i64 8}
!20 = !{!11, !11, i64 0}
!21 = !{!10, !11, i64 12}
!22 = !{!10, !12, i64 16}
!23 = !{!10, !11, i64 20}
!24 = !{!10, !12, i64 48}
!25 = !{!10, !11, 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"

@.str.52 = external hidden unnamed_addr constant [73 x i8], align 1
@.str.67 = external hidden unnamed_addr constant [7 x i8], align 1
@__PRETTY_FUNCTION__._Z6limitsRK20HighsIndexCollectionRiS2_ = external hidden unnamed_addr constant [66 x i8], align 1

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_Z6limitsRK20HighsIndexCollectionRiS2_(ptr nocapture noundef nonnull readonly align 8 dereferenceable(80) %0, ptr nocapture noundef nonnull writeonly align 4 dereferenceable(4) %1, ptr nocapture noundef nonnull writeonly align 4 dereferenceable(4) %2) local_unnamed_addr #1 {
  %4 = getelementptr inbounds i8, ptr %0, i64 4
  %5 = load i8, ptr %4, align 4, !tbaa !5, !range !16, !noundef !17
  %6 = trunc nuw i8 %5 to i1
  br i1 %6, label %7, label %12

7:                                                ; preds = %3
  %8 = getelementptr inbounds i8, ptr %0, i64 8
  %9 = load i32, ptr %8, align 8, !tbaa !18
  store i32 %9, ptr %1, align 4, !tbaa !19
  %10 = getelementptr inbounds i8, ptr %0, i64 12
  %11 = load i32, ptr %10, align 4, !tbaa !20
  br label %28

12:                                               ; preds = %3
  %13 = getelementptr inbounds i8, ptr %0, i64 16
  %14 = load i8, ptr %13, align 8, !tbaa !21, !range !16, !noundef !17
  %15 = trunc nuw i8 %14 to i1
  br i1 %15, label %16, label %20

16:                                               ; preds = %12
  store i32 0, ptr %1, align 4, !tbaa !19
  %17 = getelementptr inbounds i8, ptr %0, i64 20
  %18 = load i32, ptr %17, align 4, !tbaa !22
  %19 = add nsw i32 %18, -1
  br label %28

20:                                               ; preds = %12
  %21 = getelementptr inbounds i8, ptr %0, i64 48
  %22 = load i8, ptr %21, align 8, !tbaa !23, !range !16, !noundef !17
  %23 = trunc nuw i8 %22 to i1
  br i1 %23, label %24, label %27

24:                                               ; preds = %20
  store i32 0, ptr %1, align 4, !tbaa !19
  %25 = load i32, ptr %0, align 8, !tbaa !24
  %26 = add nsw i32 %25, -1
  br label %28

27:                                               ; preds = %20
  tail call void @__assert_fail(ptr noundef nonnull @.str.67, ptr noundef nonnull @.str.52, i32 noundef 188, ptr noundef nonnull @__PRETTY_FUNCTION__._Z6limitsRK20HighsIndexCollectionRiS2_) #2
  unreachable

28:                                               ; preds = %16, %24, %7
  %.sink = phi i32 [ %19, %16 ], [ %26, %24 ], [ %11, %7 ]
  store i32 %.sink, ptr %2, align 4, !tbaa !19
  ret void
}

attributes #0 = { noreturn 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 #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 = { noreturn 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, !10, i64 4}
!6 = !{!"_ZTS20HighsIndexCollection", !7, i64 0, !10, i64 4, !7, i64 8, !7, i64 12, !10, i64 16, !7, i64 20, !11, i64 24, !10, i64 48, !11, i64 56}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"bool", !8, i64 0}
!11 = !{!"_ZTSSt6vectorIiSaIiEE", !12, i64 0}
!12 = !{!"_ZTSSt12_Vector_baseIiSaIiEE", !13, i64 0}
!13 = !{!"_ZTSNSt12_Vector_baseIiSaIiEE12_Vector_implE", !14, i64 0}
!14 = !{!"_ZTSNSt12_Vector_baseIiSaIiEE17_Vector_impl_dataE", !15, i64 0, !15, i64 8, !15, i64 16}
!15 = !{!"any pointer", !8, i64 0}
!16 = !{i8 0, i8 2}
!17 = !{}
!18 = !{!6, !7, i64 8}
!19 = !{!7, !7, i64 0}
!20 = !{!6, !7, i64 12}
!21 = !{!6, !10, i64 16}
!22 = !{!6, !7, i64 20}
!23 = !{!6, !10, i64 48}
!24 = !{!6, !7, i64 0}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass