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

; 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.HSet = type { i32, %"class.std::vector", i8, i8, i8, i8, ptr, i32, %"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 }

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN4HSet5setupEiibP8_IO_FILEbb(ptr noundef nonnull align 8 dereferenceable(80), i32 noundef, i32 noundef, i1 noundef zeroext, ptr noundef, i1 noundef zeroext, i1 noundef zeroext) #0 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZNK4HSet5debugEv(ptr noundef nonnull align 8 dereferenceable(80)) #0 align 2

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

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

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

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZN4HSet6removeEi(ptr noundef nonnull align 8 dereferenceable(80) %0, i32 noundef %1) #0 align 2 {
  %3 = alloca i1, align 1
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i32 %1, ptr %5, align 4, !tbaa !9
  %9 = load ptr, ptr %4, align 8
  %10 = getelementptr inbounds %class.HSet, ptr %9, i32 0, i32 2
  %11 = load i8, ptr %10, align 8, !tbaa !11, !range !18, !noundef !19
  %12 = trunc i8 %11 to i1
  br i1 %12, label %21, label %13

13:                                               ; preds = %2
  %14 = call noundef zeroext i1 @_ZN4HSet5setupEiibP8_IO_FILEbb(ptr noundef nonnull align 8 dereferenceable(80) %9, i32 noundef 1, i32 noundef 0, i1 noundef zeroext false, ptr noundef null, i1 noundef zeroext false, i1 noundef zeroext true)
  %15 = getelementptr inbounds %class.HSet, ptr %9, i32 0, i32 3
  %16 = load i8, ptr %15, align 1, !tbaa !20, !range !18, !noundef !19
  %17 = trunc i8 %16 to i1
  br i1 %17, label %18, label %20

18:                                               ; preds = %13
  %19 = call noundef zeroext i1 @_ZNK4HSet5debugEv(ptr noundef nonnull align 8 dereferenceable(80) %9)
  br label %20

20:                                               ; preds = %18, %13
  store i1 false, ptr %3, align 1
  br label %79

21:                                               ; preds = %2
  %22 = load i32, ptr %5, align 4, !tbaa !9
  %23 = icmp slt i32 %22, 0
  br i1 %23, label %24, label %25

24:                                               ; preds = %21
  store i1 false, ptr %3, align 1
  br label %79

25:                                               ; preds = %21
  %26 = load i32, ptr %5, align 4, !tbaa !9
  %27 = getelementptr inbounds %class.HSet, ptr %9, i32 0, i32 7
  %28 = load i32, ptr %27, align 8, !tbaa !21
  %29 = icmp sgt i32 %26, %28
  br i1 %29, label %30, label %31

30:                                               ; preds = %25
  store i1 false, ptr %3, align 1
  br label %79

31:                                               ; preds = %25
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #3
  %32 = getelementptr inbounds %class.HSet, ptr %9, i32 0, i32 8
  %33 = load i32, ptr %5, align 4, !tbaa !9
  %34 = sext i32 %33 to i64
  %35 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %32, i64 noundef %34) #3
  %36 = load i32, ptr %35, align 4, !tbaa !9
  store i32 %36, ptr %6, align 4, !tbaa !9
  %37 = load i32, ptr %6, align 4, !tbaa !9
  %38 = icmp eq i32 %37, -1
  br i1 %38, label %39, label %40

39:                                               ; preds = %31
  store i1 false, ptr %3, align 1
  store i32 1, ptr %7, align 4
  br label %78

40:                                               ; preds = %31
  %41 = getelementptr inbounds %class.HSet, ptr %9, i32 0, i32 8
  %42 = load i32, ptr %5, align 4, !tbaa !9
  %43 = sext i32 %42 to i64
  %44 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %41, i64 noundef %43) #3
  store i32 -1, ptr %44, align 4, !tbaa !9
  %45 = load i32, ptr %6, align 4, !tbaa !9
  %46 = getelementptr inbounds %class.HSet, ptr %9, i32 0, i32 0
  %47 = load i32, ptr %46, align 8, !tbaa !22
  %48 = sub nsw i32 %47, 1
  %49 = icmp slt i32 %45, %48
  br i1 %49, label %50, label %68

50:                                               ; preds = %40
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #3
  %51 = getelementptr inbounds %class.HSet, ptr %9, i32 0, i32 1
  %52 = getelementptr inbounds %class.HSet, ptr %9, i32 0, i32 0
  %53 = load i32, ptr %52, align 8, !tbaa !22
  %54 = sub nsw i32 %53, 1
  %55 = sext i32 %54 to i64
  %56 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %51, i64 noundef %55) #3
  %57 = load i32, ptr %56, align 4, !tbaa !9
  store i32 %57, ptr %8, align 4, !tbaa !9
  %58 = load i32, ptr %8, align 4, !tbaa !9
  %59 = getelementptr inbounds %class.HSet, ptr %9, i32 0, i32 1
  %60 = load i32, ptr %6, align 4, !tbaa !9
  %61 = sext i32 %60 to i64
  %62 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %59, i64 noundef %61) #3
  store i32 %58, ptr %62, align 4, !tbaa !9
  %63 = load i32, ptr %6, align 4, !tbaa !9
  %64 = getelementptr inbounds %class.HSet, ptr %9, i32 0, i32 8
  %65 = load i32, ptr %8, align 4, !tbaa !9
  %66 = sext i32 %65 to i64
  %67 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %64, i64 noundef %66) #3
  store i32 %63, ptr %67, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  br label %68

68:                                               ; preds = %50, %40
  %69 = getelementptr inbounds %class.HSet, ptr %9, i32 0, i32 0
  %70 = load i32, ptr %69, align 8, !tbaa !22
  %71 = add nsw i32 %70, -1
  store i32 %71, ptr %69, align 8, !tbaa !22
  %72 = getelementptr inbounds %class.HSet, ptr %9, i32 0, i32 3
  %73 = load i8, ptr %72, align 1, !tbaa !20, !range !18, !noundef !19
  %74 = trunc i8 %73 to i1
  br i1 %74, label %75, label %77

75:                                               ; preds = %68
  %76 = call noundef zeroext i1 @_ZNK4HSet5debugEv(ptr noundef nonnull align 8 dereferenceable(80) %9)
  br label %77

77:                                               ; preds = %75, %68
  store i1 true, ptr %3, align 1
  store i32 1, ptr %7, align 4
  br label %78

78:                                               ; preds = %77, %39
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  br label %79

79:                                               ; preds = %78, %30, %24, %20
  %80 = load i1, ptr %3, align 1
  ret i1 %80
}

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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 = !{!12, !17, i64 32}
!12 = !{!"_ZTS4HSet", !10, i64 0, !13, i64 8, !17, i64 32, !17, i64 33, !17, i64 34, !17, i64 35, !6, i64 40, !10, i64 48, !13, i64 56}
!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 = !{!"bool", !7, i64 0}
!18 = !{i8 0, i8 2}
!19 = !{}
!20 = !{!12, !17, i64 33}
!21 = !{!12, !10, i64 48}
!22 = !{!12, !10, 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"

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN4HSet5setupEiibP8_IO_FILEbb(ptr noundef nonnull align 8 dereferenceable(80), i32 noundef, i32 noundef, i1 noundef zeroext, ptr noundef, i1 noundef zeroext, i1 noundef zeroext) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZNK4HSet5debugEv(ptr noundef nonnull align 8 dereferenceable(80)) local_unnamed_addr #0 align 2

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

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZN4HSet6removeEi(ptr noundef nonnull align 8 dereferenceable(80) %0, i32 noundef %1) local_unnamed_addr #0 align 2 {
  %3 = getelementptr inbounds i8, ptr %0, i64 32
  %4 = load i8, ptr %3, align 8, !tbaa !5, !range !16, !noundef !17
  %5 = trunc nuw i8 %4 to i1
  br i1 %5, label %11, label %6

6:                                                ; preds = %2
  %7 = tail call noundef zeroext i1 @_ZN4HSet5setupEiibP8_IO_FILEbb(ptr noundef nonnull align 8 dereferenceable(80) %0, i32 noundef 1, i32 noundef 0, i1 noundef zeroext false, ptr noundef null, i1 noundef zeroext false, i1 noundef zeroext true)
  %8 = getelementptr inbounds i8, ptr %0, i64 33
  %9 = load i8, ptr %8, align 1, !tbaa !18, !range !16, !noundef !17
  %10 = trunc nuw i8 %9 to i1
  br i1 %10, label %.sink.split, label %40

11:                                               ; preds = %2
  %12 = icmp slt i32 %1, 0
  %13 = getelementptr inbounds i8, ptr %0, i64 48
  %14 = load i32, ptr %13, align 8
  %15 = icmp slt i32 %14, %1
  %or.cond = select i1 %12, i1 true, i1 %15
  br i1 %or.cond, label %40, label %16

16:                                               ; preds = %11
  %17 = getelementptr inbounds i8, ptr %0, i64 56
  %18 = zext nneg i32 %1 to i64
  %19 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %17, i64 noundef %18) #2
  %20 = load i32, ptr %19, align 4, !tbaa !19
  %.not = icmp eq i32 %20, -1
  br i1 %.not, label %40, label %21

21:                                               ; preds = %16
  %22 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %17, i64 noundef %18) #2
  store i32 -1, ptr %22, align 4, !tbaa !19
  %23 = load i32, ptr %0, align 8, !tbaa !20
  %24 = add nsw i32 %23, -1
  %25 = icmp slt i32 %20, %24
  br i1 %25, label %26, label %35

26:                                               ; preds = %21
  %27 = getelementptr inbounds i8, ptr %0, i64 8
  %28 = sext i32 %24 to i64
  %29 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %27, i64 noundef %28) #2
  %30 = load i32, ptr %29, align 4, !tbaa !19
  %31 = sext i32 %20 to i64
  %32 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %27, i64 noundef %31) #2
  store i32 %30, ptr %32, align 4, !tbaa !19
  %33 = sext i32 %30 to i64
  %34 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %17, i64 noundef %33) #2
  store i32 %20, ptr %34, align 4, !tbaa !19
  %.pre = load i32, ptr %0, align 8, !tbaa !20
  %.pre16 = add nsw i32 %.pre, -1
  br label %35

35:                                               ; preds = %26, %21
  %.pre-phi = phi i32 [ %.pre16, %26 ], [ %24, %21 ]
  store i32 %.pre-phi, ptr %0, align 8, !tbaa !20
  %36 = getelementptr inbounds i8, ptr %0, i64 33
  %37 = load i8, ptr %36, align 1, !tbaa !18, !range !16, !noundef !17
  %38 = trunc nuw i8 %37 to i1
  br i1 %38, label %.sink.split, label %40

.sink.split:                                      ; preds = %35, %6
  %39 = tail call noundef zeroext i1 @_ZNK4HSet5debugEv(ptr noundef nonnull align 8 dereferenceable(80) %0)
  br label %40

40:                                               ; preds = %.sink.split, %16, %35, %11, %6
  %.1 = phi i1 [ false, %6 ], [ false, %11 ], [ true, %35 ], [ false, %16 ], [ %5, %.sink.split ]
  ret i1 %.1
}

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 = { 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, !15, i64 32}
!6 = !{!"_ZTS4HSet", !7, i64 0, !10, i64 8, !15, i64 32, !15, i64 33, !15, i64 34, !15, i64 35, !14, i64 40, !7, i64 48, !10, i64 56}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"_ZTSSt6vectorIiSaIiEE", !11, i64 0}
!11 = !{!"_ZTSSt12_Vector_baseIiSaIiEE", !12, i64 0}
!12 = !{!"_ZTSNSt12_Vector_baseIiSaIiEE12_Vector_implE", !13, i64 0}
!13 = !{!"_ZTSNSt12_Vector_baseIiSaIiEE17_Vector_impl_dataE", !14, i64 0, !14, i64 8, !14, i64 16}
!14 = !{!"any pointer", !8, i64 0}
!15 = !{!"bool", !8, i64 0}
!16 = !{i8 0, i8 2}
!17 = !{}
!18 = !{!6, !15, i64 33}
!19 = !{!7, !7, i64 0}
!20 = !{!6, !7, i64 0}


; Effective O3 passes: BDCEPass,CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,SROAPass,SimplifyCFGPass,TailCallElimPass