; LLVM IR from ERGO-Code/HiGHS :: src/presolve (HPresolve)

; 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 uwtable
declare dso_local noundef i32 @_ZN8presolve9HPresolve19removeRowSingletonsERNS_19HighsPostsolveStackE(ptr noundef nonnull align 8 dereferenceable(1720), ptr noundef nonnull align 8 dereferenceable(224)) #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_ZN8presolve9HPresolve24removeDoubletonEquationsERNS_19HighsPostsolveStackE(ptr noundef nonnull align 8 dereferenceable(1720), ptr noundef nonnull align 8 dereferenceable(224)) #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZN8presolve9HPresolve16fastPresolveLoopERNS_19HighsPostsolveStackE(ptr noundef nonnull align 8 dereferenceable(1720) %0, ptr noundef nonnull align 8 dereferenceable(224) %1) #1 align 2 {
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  %12 = load ptr, ptr %4, align 8
  br label %13

13:                                               ; preds = %74, %2
  call void @_ZN8presolve9HPresolve23storeCurrentProblemSizeEv(ptr noundef nonnull align 8 dereferenceable(1720) %12)
  br label %14

14:                                               ; preds = %13
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #3
  %15 = load ptr, ptr %5, align 8, !tbaa !5
  %16 = call noundef i32 @_ZN8presolve9HPresolve19removeRowSingletonsERNS_19HighsPostsolveStackE(ptr noundef nonnull align 8 dereferenceable(1720) %12, ptr noundef nonnull align 8 dereferenceable(224) %15)
  store i32 %16, ptr %6, align 4, !tbaa !9
  %17 = load i32, ptr %6, align 4, !tbaa !9
  %18 = icmp ne i32 %17, 0
  br i1 %18, label %19, label %21

19:                                               ; preds = %14
  %20 = load i32, ptr %6, align 4, !tbaa !9
  store i32 %20, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %22

21:                                               ; preds = %14
  store i32 0, ptr %7, align 4
  br label %22

22:                                               ; preds = %21, %19
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  %23 = load i32, ptr %7, align 4
  switch i32 %23, label %80 [
    i32 0, label %24
    i32 1, label %78
  ]

24:                                               ; preds = %22
  br label %25

25:                                               ; preds = %24
  br label %26

26:                                               ; preds = %25
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #3
  %27 = load ptr, ptr %5, align 8, !tbaa !5
  %28 = call noundef i32 @_ZN8presolve9HPresolve19presolveChangedRowsERNS_19HighsPostsolveStackE(ptr noundef nonnull align 8 dereferenceable(1720) %12, ptr noundef nonnull align 8 dereferenceable(224) %27)
  store i32 %28, ptr %8, align 4, !tbaa !9
  %29 = load i32, ptr %8, align 4, !tbaa !9
  %30 = icmp ne i32 %29, 0
  br i1 %30, label %31, label %33

31:                                               ; preds = %26
  %32 = load i32, ptr %8, align 4, !tbaa !9
  store i32 %32, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %34

33:                                               ; preds = %26
  store i32 0, ptr %7, align 4
  br label %34

34:                                               ; preds = %33, %31
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  %35 = load i32, ptr %7, align 4
  switch i32 %35, label %80 [
    i32 0, label %36
    i32 1, label %78
  ]

36:                                               ; preds = %34
  br label %37

37:                                               ; preds = %36
  br label %38

38:                                               ; preds = %37
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #3
  %39 = load ptr, ptr %5, align 8, !tbaa !5
  %40 = call noundef i32 @_ZN8presolve9HPresolve24removeDoubletonEquationsERNS_19HighsPostsolveStackE(ptr noundef nonnull align 8 dereferenceable(1720) %12, ptr noundef nonnull align 8 dereferenceable(224) %39)
  store i32 %40, ptr %9, align 4, !tbaa !9
  %41 = load i32, ptr %9, align 4, !tbaa !9
  %42 = icmp ne i32 %41, 0
  br i1 %42, label %43, label %45

43:                                               ; preds = %38
  %44 = load i32, ptr %9, align 4, !tbaa !9
  store i32 %44, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %46

45:                                               ; preds = %38
  store i32 0, ptr %7, align 4
  br label %46

46:                                               ; preds = %45, %43
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #3
  %47 = load i32, ptr %7, align 4
  switch i32 %47, label %80 [
    i32 0, label %48
    i32 1, label %78
  ]

48:                                               ; preds = %46
  br label %49

49:                                               ; preds = %48
  br label %50

50:                                               ; preds = %49
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #3
  %51 = load ptr, ptr %5, align 8, !tbaa !5
  %52 = call noundef i32 @_ZN8presolve9HPresolve21presolveColSingletonsERNS_19HighsPostsolveStackE(ptr noundef nonnull align 8 dereferenceable(1720) %12, ptr noundef nonnull align 8 dereferenceable(224) %51)
  store i32 %52, ptr %10, align 4, !tbaa !9
  %53 = load i32, ptr %10, align 4, !tbaa !9
  %54 = icmp ne i32 %53, 0
  br i1 %54, label %55, label %57

55:                                               ; preds = %50
  %56 = load i32, ptr %10, align 4, !tbaa !9
  store i32 %56, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %58

57:                                               ; preds = %50
  store i32 0, ptr %7, align 4
  br label %58

58:                                               ; preds = %57, %55
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #3
  %59 = load i32, ptr %7, align 4
  switch i32 %59, label %80 [
    i32 0, label %60
    i32 1, label %78
  ]

60:                                               ; preds = %58
  br label %61

61:                                               ; preds = %60
  br label %62

62:                                               ; preds = %61
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #3
  %63 = load ptr, ptr %5, align 8, !tbaa !5
  %64 = call noundef i32 @_ZN8presolve9HPresolve19presolveChangedColsERNS_19HighsPostsolveStackE(ptr noundef nonnull align 8 dereferenceable(1720) %12, ptr noundef nonnull align 8 dereferenceable(224) %63)
  store i32 %64, ptr %11, align 4, !tbaa !9
  %65 = load i32, ptr %11, align 4, !tbaa !9
  %66 = icmp ne i32 %65, 0
  br i1 %66, label %67, label %69

67:                                               ; preds = %62
  %68 = load i32, ptr %11, align 4, !tbaa !9
  store i32 %68, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %70

69:                                               ; preds = %62
  store i32 0, ptr %7, align 4
  br label %70

70:                                               ; preds = %69, %67
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #3
  %71 = load i32, ptr %7, align 4
  switch i32 %71, label %80 [
    i32 0, label %72
    i32 1, label %78
  ]

72:                                               ; preds = %70
  br label %73

73:                                               ; preds = %72
  br label %74

74:                                               ; preds = %73
  %75 = call noundef double @_ZN8presolve9HPresolve20problemSizeReductionEv(ptr noundef nonnull align 8 dereferenceable(1720) %12)
  %76 = fcmp ogt double %75, 1.000000e-02
  br i1 %76, label %13, label %77, !llvm.loop !11

77:                                               ; preds = %74
  store i32 0, ptr %3, align 4
  br label %78

78:                                               ; preds = %77, %70, %58, %46, %34, %22
  %79 = load i32, ptr %3, align 4
  ret i32 %79

80:                                               ; preds = %70, %58, %46, %34, %22
  unreachable
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN8presolve9HPresolve23storeCurrentProblemSizeEv(ptr noundef nonnull align 8 dereferenceable(1720)) #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_ZN8presolve9HPresolve19presolveChangedRowsERNS_19HighsPostsolveStackE(ptr noundef nonnull align 8 dereferenceable(1720), ptr noundef nonnull align 8 dereferenceable(224)) #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_ZN8presolve9HPresolve21presolveColSingletonsERNS_19HighsPostsolveStackE(ptr noundef nonnull align 8 dereferenceable(1720), ptr noundef nonnull align 8 dereferenceable(224)) #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_ZN8presolve9HPresolve19presolveChangedColsERNS_19HighsPostsolveStackE(ptr noundef nonnull align 8 dereferenceable(1720), ptr noundef nonnull align 8 dereferenceable(224)) #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef double @_ZN8presolve9HPresolve20problemSizeReductionEv(ptr noundef nonnull align 8 dereferenceable(1720)) #1 align 2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 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 = !{!"_ZTSN8presolve9HPresolve6ResultE", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"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 uwtable
declare dso_local noundef i32 @_ZN8presolve9HPresolve19removeRowSingletonsERNS_19HighsPostsolveStackE(ptr noundef nonnull align 8 dereferenceable(1720), ptr noundef nonnull align 8 dereferenceable(224)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_ZN8presolve9HPresolve24removeDoubletonEquationsERNS_19HighsPostsolveStackE(ptr noundef nonnull align 8 dereferenceable(1720), ptr noundef nonnull align 8 dereferenceable(224)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZN8presolve9HPresolve16fastPresolveLoopERNS_19HighsPostsolveStackE(ptr noundef nonnull align 8 dereferenceable(1720) %0, ptr noundef nonnull align 8 dereferenceable(224) %1) local_unnamed_addr #0 align 2 {
  br label %3

3:                                                ; preds = %13, %2
  tail call void @_ZN8presolve9HPresolve23storeCurrentProblemSizeEv(ptr noundef nonnull align 8 dereferenceable(1720) %0)
  %4 = tail call noundef i32 @_ZN8presolve9HPresolve19removeRowSingletonsERNS_19HighsPostsolveStackE(ptr noundef nonnull align 8 dereferenceable(1720) %0, ptr noundef nonnull align 8 dereferenceable(224) %1)
  %.not.not = icmp eq i32 %4, 0
  br i1 %.not.not, label %5, label %16

5:                                                ; preds = %3
  %6 = tail call noundef i32 @_ZN8presolve9HPresolve19presolveChangedRowsERNS_19HighsPostsolveStackE(ptr noundef nonnull align 8 dereferenceable(1720) %0, ptr noundef nonnull align 8 dereferenceable(224) %1)
  %.not31.not = icmp eq i32 %6, 0
  br i1 %.not31.not, label %7, label %16

7:                                                ; preds = %5
  %8 = tail call noundef i32 @_ZN8presolve9HPresolve24removeDoubletonEquationsERNS_19HighsPostsolveStackE(ptr noundef nonnull align 8 dereferenceable(1720) %0, ptr noundef nonnull align 8 dereferenceable(224) %1)
  %.not32.not = icmp eq i32 %8, 0
  br i1 %.not32.not, label %9, label %16

9:                                                ; preds = %7
  %10 = tail call noundef i32 @_ZN8presolve9HPresolve21presolveColSingletonsERNS_19HighsPostsolveStackE(ptr noundef nonnull align 8 dereferenceable(1720) %0, ptr noundef nonnull align 8 dereferenceable(224) %1)
  %.not33.not = icmp eq i32 %10, 0
  br i1 %.not33.not, label %11, label %16

11:                                               ; preds = %9
  %12 = tail call noundef i32 @_ZN8presolve9HPresolve19presolveChangedColsERNS_19HighsPostsolveStackE(ptr noundef nonnull align 8 dereferenceable(1720) %0, ptr noundef nonnull align 8 dereferenceable(224) %1)
  %.not34.not = icmp eq i32 %12, 0
  br i1 %.not34.not, label %13, label %16

13:                                               ; preds = %11
  %14 = tail call noundef double @_ZN8presolve9HPresolve20problemSizeReductionEv(ptr noundef nonnull align 8 dereferenceable(1720) %0)
  %15 = fcmp ogt double %14, 1.000000e-02
  br i1 %15, label %3, label %16, !llvm.loop !5

16:                                               ; preds = %11, %9, %7, %5, %3, %13
  %.6 = phi i32 [ %4, %3 ], [ %6, %5 ], [ %8, %7 ], [ %10, %9 ], [ %12, %11 ], [ 0, %13 ]
  ret i32 %.6
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN8presolve9HPresolve23storeCurrentProblemSizeEv(ptr noundef nonnull align 8 dereferenceable(1720)) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_ZN8presolve9HPresolve19presolveChangedRowsERNS_19HighsPostsolveStackE(ptr noundef nonnull align 8 dereferenceable(1720), ptr noundef nonnull align 8 dereferenceable(224)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_ZN8presolve9HPresolve21presolveColSingletonsERNS_19HighsPostsolveStackE(ptr noundef nonnull align 8 dereferenceable(1720), ptr noundef nonnull align 8 dereferenceable(224)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_ZN8presolve9HPresolve19presolveChangedColsERNS_19HighsPostsolveStackE(ptr noundef nonnull align 8 dereferenceable(1720), ptr noundef nonnull align 8 dereferenceable(224)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef double @_ZN8presolve9HPresolve20problemSizeReductionEv(ptr noundef nonnull align 8 dereferenceable(1720)) local_unnamed_addr #0 align 2

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

!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 = distinct !{!5, !6}
!6 = !{!"llvm.loop.mustprogress"}


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