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

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

@.str.12 = external hidden unnamed_addr constant [72 x i8], align 1
@.str.18 = external hidden unnamed_addr constant [13 x i8], align 1
@__PRETTY_FUNCTION__._ZNK3ipx7Iterate13ScalingFactorEi = external hidden unnamed_addr constant [46 x i8], align 1
@.str.19 = external hidden unnamed_addr constant [13 x i8], align 1
@.str.20 = external hidden unnamed_addr constant [17 x i8], align 1
@.str.21 = external hidden unnamed_addr constant [8 x i8], align 1

; 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
declare dso_local noundef zeroext i1 @_ZSt8isfinited(double noundef) #1

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZNKSt8valarrayIdEixEm(ptr noundef nonnull align 8 dereferenceable(16), i64 noundef) #2 align 2

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK3ipx7Iterate7StateOfEi(ptr noundef nonnull align 8 dereferenceable(296), i32 noundef) #2 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef double @_ZNK3ipx7Iterate13ScalingFactorEi(ptr noundef nonnull align 8 dereferenceable(296) %0, i32 noundef %1) #4 align 2 {
  %3 = alloca double, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca double, align 8
  %7 = alloca double, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i32 %1, ptr %5, align 4, !tbaa !9
  %8 = load ptr, ptr %4, align 8
  %9 = load i32, ptr %5, align 4, !tbaa !9
  %10 = call noundef i32 @_ZNK3ipx7Iterate7StateOfEi(ptr noundef nonnull align 8 dereferenceable(296) %8, i32 noundef %9)
  switch i32 %10, label %13 [
    i32 0, label %11
    i32 1, label %12
  ]

11:                                               ; preds = %2
  store double 0.000000e+00, ptr %3, align 8
  br label %73

12:                                               ; preds = %2
  store double 0x7FF0000000000000, ptr %3, align 8
  br label %73

13:                                               ; preds = %2
  %14 = getelementptr inbounds %"class.ipx::Iterate", ptr %8, i32 0, i32 2
  %15 = load i32, ptr %5, align 4, !tbaa !9
  %16 = sext i32 %15 to i64
  %17 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNKSt8valarrayIdEixEm(ptr noundef nonnull align 8 dereferenceable(16) %14, i64 noundef %16) #6
  %18 = load double, ptr %17, align 8, !tbaa !11
  %19 = fcmp ogt double %18, 0.000000e+00
  br i1 %19, label %20, label %21

20:                                               ; preds = %13
  br label %23

21:                                               ; preds = %13
  call void @__assert_fail(ptr noundef @.str.18, ptr noundef @.str.12, i32 noundef 189, ptr noundef @__PRETTY_FUNCTION__._ZNK3ipx7Iterate13ScalingFactorEi) #7
  unreachable

22:                                               ; No predecessors!
  br label %23

23:                                               ; preds = %22, %20
  %24 = getelementptr inbounds %"class.ipx::Iterate", ptr %8, i32 0, i32 3
  %25 = load i32, ptr %5, align 4, !tbaa !9
  %26 = sext i32 %25 to i64
  %27 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNKSt8valarrayIdEixEm(ptr noundef nonnull align 8 dereferenceable(16) %24, i64 noundef %26) #6
  %28 = load double, ptr %27, align 8, !tbaa !11
  %29 = fcmp ogt double %28, 0.000000e+00
  br i1 %29, label %30, label %31

30:                                               ; preds = %23
  br label %33

31:                                               ; preds = %23
  call void @__assert_fail(ptr noundef @.str.19, ptr noundef @.str.12, i32 noundef 190, ptr noundef @__PRETTY_FUNCTION__._ZNK3ipx7Iterate13ScalingFactorEi) #7
  unreachable

32:                                               ; No predecessors!
  br label %33

33:                                               ; preds = %32, %30
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #6
  %34 = getelementptr inbounds %"class.ipx::Iterate", ptr %8, i32 0, i32 5
  %35 = load i32, ptr %5, align 4, !tbaa !9
  %36 = sext i32 %35 to i64
  %37 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNKSt8valarrayIdEixEm(ptr noundef nonnull align 8 dereferenceable(16) %34, i64 noundef %36) #6
  %38 = load double, ptr %37, align 8, !tbaa !11
  %39 = getelementptr inbounds %"class.ipx::Iterate", ptr %8, i32 0, i32 2
  %40 = load i32, ptr %5, align 4, !tbaa !9
  %41 = sext i32 %40 to i64
  %42 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNKSt8valarrayIdEixEm(ptr noundef nonnull align 8 dereferenceable(16) %39, i64 noundef %41) #6
  %43 = load double, ptr %42, align 8, !tbaa !11
  %44 = fdiv double %38, %43
  %45 = getelementptr inbounds %"class.ipx::Iterate", ptr %8, i32 0, i32 6
  %46 = load i32, ptr %5, align 4, !tbaa !9
  %47 = sext i32 %46 to i64
  %48 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNKSt8valarrayIdEixEm(ptr noundef nonnull align 8 dereferenceable(16) %45, i64 noundef %47) #6
  %49 = load double, ptr %48, align 8, !tbaa !11
  %50 = getelementptr inbounds %"class.ipx::Iterate", ptr %8, i32 0, i32 3
  %51 = load i32, ptr %5, align 4, !tbaa !9
  %52 = sext i32 %51 to i64
  %53 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNKSt8valarrayIdEixEm(ptr noundef nonnull align 8 dereferenceable(16) %50, i64 noundef %52) #6
  %54 = load double, ptr %53, align 8, !tbaa !11
  %55 = fdiv double %49, %54
  %56 = fadd double %44, %55
  store double %56, ptr %6, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #6
  %57 = load double, ptr %6, align 8, !tbaa !11
  %58 = call double @sqrt(double noundef %57) #6
  %59 = fdiv double 1.000000e+00, %58
  store double %59, ptr %7, align 8, !tbaa !11
  %60 = load double, ptr %7, align 8, !tbaa !11
  %61 = call noundef zeroext i1 @_ZSt8isfinited(double noundef %60)
  br i1 %61, label %62, label %63

62:                                               ; preds = %33
  br label %65

63:                                               ; preds = %33
  call void @__assert_fail(ptr noundef @.str.20, ptr noundef @.str.12, i32 noundef 193, ptr noundef @__PRETTY_FUNCTION__._ZNK3ipx7Iterate13ScalingFactorEi) #7
  unreachable

64:                                               ; No predecessors!
  br label %65

65:                                               ; preds = %64, %62
  %66 = load double, ptr %7, align 8, !tbaa !11
  %67 = fcmp ogt double %66, 0.000000e+00
  br i1 %67, label %68, label %69

68:                                               ; preds = %65
  br label %71

69:                                               ; preds = %65
  call void @__assert_fail(ptr noundef @.str.21, ptr noundef @.str.12, i32 noundef 194, ptr noundef @__PRETTY_FUNCTION__._ZNK3ipx7Iterate13ScalingFactorEi) #7
  unreachable

70:                                               ; No predecessors!
  br label %71

71:                                               ; preds = %70, %68
  %72 = load double, ptr %7, align 8, !tbaa !11
  store double %72, ptr %3, align 8
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #6
  br label %73

73:                                               ; preds = %71, %12, %11
  %74 = load double, ptr %3, align 8
  ret double %74
}

; Function Attrs: nounwind
declare double @sqrt(double noundef) #5

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 = { inlinehint 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 = { 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 #4 = { 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 #5 = { 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 #6 = { nounwind }
attributes #7 = { 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, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"double", !7, 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.12 = external hidden unnamed_addr constant [72 x i8], align 1
@.str.18 = external hidden unnamed_addr constant [13 x i8], align 1
@__PRETTY_FUNCTION__._ZNK3ipx7Iterate13ScalingFactorEi = external hidden unnamed_addr constant [46 x i8], align 1
@.str.19 = external hidden unnamed_addr constant [13 x i8], align 1
@.str.20 = external hidden unnamed_addr constant [17 x i8], align 1
@.str.21 = external hidden unnamed_addr constant [8 x i8], align 1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZSt8isfinited(double noundef) local_unnamed_addr #0

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

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK3ipx7Iterate7StateOfEi(ptr noundef nonnull align 8 dereferenceable(296), i32 noundef) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef double @_ZNK3ipx7Iterate13ScalingFactorEi(ptr noundef nonnull align 8 dereferenceable(296) %0, i32 noundef %1) local_unnamed_addr #0 align 2 {
  %3 = tail call noundef i32 @_ZNK3ipx7Iterate7StateOfEi(ptr noundef nonnull align 8 dereferenceable(296) %0, i32 noundef %1)
  switch i32 %3, label %5 [
    i32 0, label %43
    i32 1, label %4
  ]

4:                                                ; preds = %2
  br label %43

5:                                                ; preds = %2
  %6 = getelementptr inbounds i8, ptr %0, i64 24
  %7 = sext i32 %1 to i64
  %8 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNKSt8valarrayIdEixEm(ptr noundef nonnull align 8 dereferenceable(16) %6, i64 noundef %7) #4
  %9 = load double, ptr %8, align 8, !tbaa !5
  %10 = fcmp ogt double %9, 0.000000e+00
  br i1 %10, label %12, label %11

11:                                               ; preds = %5
  tail call void @__assert_fail(ptr noundef nonnull @.str.18, ptr noundef nonnull @.str.12, i32 noundef 189, ptr noundef nonnull @__PRETTY_FUNCTION__._ZNK3ipx7Iterate13ScalingFactorEi) #5
  unreachable

12:                                               ; preds = %5
  %13 = getelementptr inbounds i8, ptr %0, i64 40
  %14 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNKSt8valarrayIdEixEm(ptr noundef nonnull align 8 dereferenceable(16) %13, i64 noundef %7) #4
  %15 = load double, ptr %14, align 8, !tbaa !5
  %16 = fcmp ogt double %15, 0.000000e+00
  br i1 %16, label %18, label %17

17:                                               ; preds = %12
  tail call void @__assert_fail(ptr noundef nonnull @.str.19, ptr noundef nonnull @.str.12, i32 noundef 190, ptr noundef nonnull @__PRETTY_FUNCTION__._ZNK3ipx7Iterate13ScalingFactorEi) #5
  unreachable

18:                                               ; preds = %12
  %19 = getelementptr inbounds i8, ptr %0, i64 72
  %20 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNKSt8valarrayIdEixEm(ptr noundef nonnull align 8 dereferenceable(16) %19, i64 noundef %7) #4
  %21 = load double, ptr %20, align 8, !tbaa !5
  %22 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNKSt8valarrayIdEixEm(ptr noundef nonnull align 8 dereferenceable(16) %6, i64 noundef %7) #4
  %23 = load double, ptr %22, align 8, !tbaa !5
  %24 = getelementptr inbounds i8, ptr %0, i64 88
  %25 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNKSt8valarrayIdEixEm(ptr noundef nonnull align 8 dereferenceable(16) %24, i64 noundef %7) #4
  %26 = load double, ptr %25, align 8, !tbaa !5
  %27 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNKSt8valarrayIdEixEm(ptr noundef nonnull align 8 dereferenceable(16) %13, i64 noundef %7) #4
  %28 = load double, ptr %27, align 8, !tbaa !5
  %29 = insertelement <2 x double> poison, double %21, i64 0
  %30 = insertelement <2 x double> %29, double %26, i64 1
  %31 = insertelement <2 x double> poison, double %23, i64 0
  %32 = insertelement <2 x double> %31, double %28, i64 1
  %33 = fdiv <2 x double> %30, %32
  %shift = shufflevector <2 x double> %33, <2 x double> poison, <2 x i32> <i32 1, i32 poison>
  %34 = fadd <2 x double> %33, %shift
  %35 = extractelement <2 x double> %34, i64 0
  %36 = tail call double @sqrt(double noundef %35) #4
  %37 = fdiv double 1.000000e+00, %36
  %38 = tail call noundef zeroext i1 @_ZSt8isfinited(double noundef %37)
  br i1 %38, label %40, label %39

39:                                               ; preds = %18
  tail call void @__assert_fail(ptr noundef nonnull @.str.20, ptr noundef nonnull @.str.12, i32 noundef 193, ptr noundef nonnull @__PRETTY_FUNCTION__._ZNK3ipx7Iterate13ScalingFactorEi) #5
  unreachable

40:                                               ; preds = %18
  %41 = fcmp ogt double %37, 0.000000e+00
  br i1 %41, label %43, label %42

42:                                               ; preds = %40
  tail call void @__assert_fail(ptr noundef nonnull @.str.21, ptr noundef nonnull @.str.12, i32 noundef 194, ptr noundef nonnull @__PRETTY_FUNCTION__._ZNK3ipx7Iterate13ScalingFactorEi) #5
  unreachable

43:                                               ; preds = %40, %2, %4
  %.0 = phi double [ 0x7FF0000000000000, %4 ], [ 0.000000e+00, %2 ], [ %37, %40 ]
  ret double %.0
}

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare double @sqrt(double noundef) local_unnamed_addr #3

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 = { inlinehint 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 "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 = { mustprogress nofree nounwind willreturn memory(write) "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 #4 = { nounwind }
attributes #5 = { 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 = !{!"double", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,SLPVectorizerPass,SROAPass,SimplifyCFGPass,TailCallElimPass,VectorCombinePass