; LLVM IR from ERGO-Code/HiGHS :: src/ipm/ipx/iterate.ll (ZNK3ipx7Iterate17term_crit_reachedEv)

; 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.ipx::Iterate" = type { ptr, %"class.std::valarray", %"class.std::valarray", %"class.std::valarray", %"class.std::valarray", %"class.std::valarray", %"class.std::valarray", %"class.std::vector", %"class.std::valarray", %"class.std::valarray", %"class.std::valarray", %"class.std::valarray", double, double, double, double, double, double, double, double, double, i8, i8, double, double, double }
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<ipx::Iterate::StateDetail, std::allocator<ipx::Iterate::StateDetail>>::_Vector_impl" }
%"struct.std::_Vector_base<ipx::Iterate::StateDetail, std::allocator<ipx::Iterate::StateDetail>>::_Vector_impl" = type { %"struct.std::_Vector_base<ipx::Iterate::StateDetail, std::allocator<ipx::Iterate::StateDetail>>::_Vector_impl_data" }
%"struct.std::_Vector_base<ipx::Iterate::StateDetail, std::allocator<ipx::Iterate::StateDetail>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.std::valarray" = type { i64, ptr }

; 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 zeroext i1 @_ZNK3ipx7Iterate8feasibleEv(ptr noundef nonnull align 8 dereferenceable(296)) #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef double @_ZNK3ipx5Model11norm_boundsEv(ptr noundef nonnull align 8 dereferenceable(704)) #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef double @_ZNK3ipx5Model6norm_cEv(ptr noundef nonnull align 8 dereferenceable(704)) #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZNK3ipx7Iterate7optimalEv(ptr noundef nonnull align 8 dereferenceable(296)) #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZNK3ipx7Iterate17term_crit_reachedEv(ptr noundef nonnull align 8 dereferenceable(296) %0) #1 align 2 {
  %2 = alloca i1, align 1
  %3 = alloca ptr, align 8
  %4 = alloca double, align 8
  %5 = alloca double, align 8
  %6 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  %7 = load ptr, ptr %3, align 8
  %8 = call noundef zeroext i1 @_ZNK3ipx7Iterate8feasibleEv(ptr noundef nonnull align 8 dereferenceable(296) %7)
  br i1 %8, label %9, label %41

9:                                                ; preds = %1
  %10 = call noundef zeroext i1 @_ZNK3ipx7Iterate7optimalEv(ptr noundef nonnull align 8 dereferenceable(296) %7)
  br i1 %10, label %11, label %41

11:                                               ; preds = %9
  %12 = getelementptr inbounds %"class.ipx::Iterate", ptr %7, i32 0, i32 25
  %13 = load double, ptr %12, align 8, !tbaa !9
  %14 = fcmp ole double %13, 0.000000e+00
  br i1 %14, label %15, label %16

15:                                               ; preds = %11
  store i1 true, ptr %2, align 1
  br label %42

16:                                               ; preds = %11
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #3
  call void @_ZNK3ipx7Iterate21ResidualsFromDroppingEPdS1_(ptr noundef nonnull align 8 dereferenceable(296) %7, ptr noundef %4, ptr noundef %5)
  %17 = load double, ptr %4, align 8, !tbaa !19
  %18 = getelementptr inbounds %"class.ipx::Iterate", ptr %7, i32 0, i32 25
  %19 = load double, ptr %18, align 8, !tbaa !9
  %20 = getelementptr inbounds %"class.ipx::Iterate", ptr %7, i32 0, i32 0
  %21 = load ptr, ptr %20, align 8, !tbaa !20
  %22 = call noundef double @_ZNK3ipx5Model11norm_boundsEv(ptr noundef nonnull align 8 dereferenceable(704) %21)
  %23 = fadd double 1.000000e+00, %22
  %24 = fmul double %19, %23
  %25 = fcmp ole double %17, %24
  br i1 %25, label %26, label %37

26:                                               ; preds = %16
  %27 = load double, ptr %5, align 8, !tbaa !19
  %28 = getelementptr inbounds %"class.ipx::Iterate", ptr %7, i32 0, i32 25
  %29 = load double, ptr %28, align 8, !tbaa !9
  %30 = getelementptr inbounds %"class.ipx::Iterate", ptr %7, i32 0, i32 0
  %31 = load ptr, ptr %30, align 8, !tbaa !20
  %32 = call noundef double @_ZNK3ipx5Model6norm_cEv(ptr noundef nonnull align 8 dereferenceable(704) %31)
  %33 = fadd double 1.000000e+00, %32
  %34 = fmul double %29, %33
  %35 = fcmp ole double %27, %34
  br i1 %35, label %36, label %37

36:                                               ; preds = %26
  store i1 true, ptr %2, align 1
  store i32 1, ptr %6, align 4
  br label %38

37:                                               ; preds = %26, %16
  store i32 0, ptr %6, align 4
  br label %38

38:                                               ; preds = %37, %36
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #3
  %39 = load i32, ptr %6, align 4
  switch i32 %39, label %44 [
    i32 0, label %40
    i32 1, label %42
  ]

40:                                               ; preds = %38
  br label %41

41:                                               ; preds = %40, %9, %1
  store i1 false, ptr %2, align 1
  br label %42

42:                                               ; preds = %41, %38, %15
  %43 = load i1, ptr %2, align 1
  ret i1 %43

44:                                               ; preds = %38
  unreachable
}

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNK3ipx7Iterate21ResidualsFromDroppingEPdS1_(ptr noundef nonnull align 8 dereferenceable(296), ptr noundef, ptr noundef) #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, !17, i64 288}
!10 = !{!"_ZTSN3ipx7IterateE", !6, i64 0, !11, i64 8, !11, i64 24, !11, i64 40, !11, i64 56, !11, i64 72, !11, i64 88, !13, i64 104, !11, i64 128, !11, i64 144, !11, i64 160, !11, i64 176, !17, i64 192, !17, i64 200, !17, i64 208, !17, i64 216, !17, i64 224, !17, i64 232, !17, i64 240, !17, i64 248, !17, i64 256, !18, i64 264, !18, i64 265, !17, i64 272, !17, i64 280, !17, i64 288}
!11 = !{!"_ZTSSt8valarrayIdE", !12, i64 0, !6, i64 8}
!12 = !{!"long", !7, i64 0}
!13 = !{!"_ZTSSt6vectorIN3ipx7Iterate11StateDetailESaIS2_EE", !14, i64 0}
!14 = !{!"_ZTSSt12_Vector_baseIN3ipx7Iterate11StateDetailESaIS2_EE", !15, i64 0}
!15 = !{!"_ZTSNSt12_Vector_baseIN3ipx7Iterate11StateDetailESaIS2_EE12_Vector_implE", !16, i64 0}
!16 = !{!"_ZTSNSt12_Vector_baseIN3ipx7Iterate11StateDetailESaIS2_EE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!17 = !{!"double", !7, i64 0}
!18 = !{!"bool", !7, i64 0}
!19 = !{!17, !17, i64 0}
!20 = !{!10, !6, 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 nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: mustprogress 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 zeroext i1 @_ZNK3ipx7Iterate8feasibleEv(ptr noundef nonnull align 8 dereferenceable(296)) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef double @_ZNK3ipx5Model11norm_boundsEv(ptr noundef nonnull align 8 dereferenceable(704)) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef double @_ZNK3ipx5Model6norm_cEv(ptr noundef nonnull align 8 dereferenceable(704)) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZNK3ipx7Iterate7optimalEv(ptr noundef nonnull align 8 dereferenceable(296)) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZNK3ipx7Iterate17term_crit_reachedEv(ptr noundef nonnull align 8 dereferenceable(296) %0) local_unnamed_addr #1 align 2 {
  %2 = alloca double, align 8
  %3 = alloca double, align 8
  %4 = tail call noundef zeroext i1 @_ZNK3ipx7Iterate8feasibleEv(ptr noundef nonnull align 8 dereferenceable(296) %0)
  br i1 %4, label %5, label %28

5:                                                ; preds = %1
  %6 = tail call noundef zeroext i1 @_ZNK3ipx7Iterate7optimalEv(ptr noundef nonnull align 8 dereferenceable(296) %0)
  br i1 %6, label %7, label %28

7:                                                ; preds = %5
  %8 = getelementptr inbounds i8, ptr %0, i64 288
  %9 = load double, ptr %8, align 8, !tbaa !5
  %10 = fcmp ugt double %9, 0.000000e+00
  br i1 %10, label %11, label %28

11:                                               ; preds = %7
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #3
  call void @_ZNK3ipx7Iterate21ResidualsFromDroppingEPdS1_(ptr noundef nonnull align 8 dereferenceable(296) %0, ptr noundef nonnull %2, ptr noundef nonnull %3)
  %12 = load double, ptr %2, align 8, !tbaa !18
  %13 = load double, ptr %8, align 8, !tbaa !5
  %14 = load ptr, ptr %0, align 8, !tbaa !19
  %15 = call noundef double @_ZNK3ipx5Model11norm_boundsEv(ptr noundef nonnull align 8 dereferenceable(704) %14)
  %16 = fadd double %15, 1.000000e+00
  %17 = fmul double %13, %16
  %18 = fcmp ugt double %12, %17
  br i1 %18, label %.thread, label %19

19:                                               ; preds = %11
  %20 = load double, ptr %3, align 8, !tbaa !18
  %21 = load double, ptr %8, align 8, !tbaa !5
  %22 = load ptr, ptr %0, align 8, !tbaa !19
  %23 = call noundef double @_ZNK3ipx5Model6norm_cEv(ptr noundef nonnull align 8 dereferenceable(704) %22)
  %24 = fadd double %23, 1.000000e+00
  %25 = fmul double %21, %24
  %26 = fcmp ugt double %20, %25
  br i1 %26, label %.thread, label %27

.thread:                                          ; preds = %11, %19
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #3
  br label %28

27:                                               ; preds = %19
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #3
  br label %28

28:                                               ; preds = %1, %5, %.thread, %27, %7
  %.1 = phi i1 [ true, %27 ], [ true, %7 ], [ false, %.thread ], [ false, %5 ], [ false, %1 ]
  ret i1 %.1
}

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNK3ipx7Iterate21ResidualsFromDroppingEPdS1_(ptr noundef nonnull align 8 dereferenceable(296), ptr noundef, ptr noundef) local_unnamed_addr #1 align 2

attributes #0 = { mustprogress 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, !16, i64 288}
!6 = !{!"_ZTSN3ipx7IterateE", !7, i64 0, !10, i64 8, !10, i64 24, !10, i64 40, !10, i64 56, !10, i64 72, !10, i64 88, !12, i64 104, !10, i64 128, !10, i64 144, !10, i64 160, !10, i64 176, !16, i64 192, !16, i64 200, !16, i64 208, !16, i64 216, !16, i64 224, !16, i64 232, !16, i64 240, !16, i64 248, !16, i64 256, !17, i64 264, !17, i64 265, !16, i64 272, !16, i64 280, !16, i64 288}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"_ZTSSt8valarrayIdE", !11, i64 0, !7, i64 8}
!11 = !{!"long", !8, i64 0}
!12 = !{!"_ZTSSt6vectorIN3ipx7Iterate11StateDetailESaIS2_EE", !13, i64 0}
!13 = !{!"_ZTSSt12_Vector_baseIN3ipx7Iterate11StateDetailESaIS2_EE", !14, i64 0}
!14 = !{!"_ZTSNSt12_Vector_baseIN3ipx7Iterate11StateDetailESaIS2_EE12_Vector_implE", !15, i64 0}
!15 = !{!"_ZTSNSt12_Vector_baseIN3ipx7Iterate11StateDetailESaIS2_EE17_Vector_impl_dataE", !7, i64 0, !7, i64 8, !7, i64 16}
!16 = !{!"double", !8, i64 0}
!17 = !{!"bool", !8, i64 0}
!18 = !{!16, !16, i64 0}
!19 = !{!6, !7, i64 0}


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