; LLVM IR from ERGO-Code/HiGHS :: src/simplex (HSimplexDebug)

; 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.std::pair" = type { i32, double }

; 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
define dso_local void @_Z23debugDualChuzcFailNormsiRKSt6vectorISt4pairIidESaIS1_EERdiPKdS6_(i32 noundef %0, ptr noundef nonnull align 8 dereferenceable(24) %1, ptr noundef nonnull align 8 dereferenceable(8) %2, i32 noundef %3, ptr noundef %4, ptr noundef nonnull align 8 dereferenceable(8) %5) #1 {
  %7 = alloca i32, align 4
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca i32, align 4
  %14 = alloca double, align 8
  %15 = alloca i32, align 4
  %16 = alloca double, align 8
  store i32 %0, ptr %7, align 4, !tbaa !5
  store ptr %1, ptr %8, align 8, !tbaa !9
  store ptr %2, ptr %9, align 8, !tbaa !9
  store i32 %3, ptr %10, align 4, !tbaa !5
  store ptr %4, ptr %11, align 8, !tbaa !9
  store ptr %5, ptr %12, align 8, !tbaa !9
  %17 = load ptr, ptr %9, align 8, !tbaa !9
  store double 0.000000e+00, ptr %17, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #4
  store i32 0, ptr %13, align 4, !tbaa !5
  br label %18

18:                                               ; preds = %35, %6
  %19 = load i32, ptr %13, align 4, !tbaa !5
  %20 = load i32, ptr %7, align 4, !tbaa !5
  %21 = icmp slt i32 %19, %20
  br i1 %21, label %23, label %22

22:                                               ; preds = %18
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #4
  br label %38

23:                                               ; preds = %18
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #4
  %24 = load ptr, ptr %8, align 8, !tbaa !9
  %25 = load i32, ptr %13, align 4, !tbaa !5
  %26 = sext i32 %25 to i64
  %27 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNKSt6vectorISt4pairIidESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %24, i64 noundef %26) #4
  %28 = getelementptr inbounds %"struct.std::pair", ptr %27, i32 0, i32 1
  %29 = load double, ptr %28, align 8, !tbaa !13
  store double %29, ptr %14, align 8, !tbaa !11
  %30 = load double, ptr %14, align 8, !tbaa !11
  %31 = load double, ptr %14, align 8, !tbaa !11
  %32 = load ptr, ptr %9, align 8, !tbaa !9
  %33 = load double, ptr %32, align 8, !tbaa !11
  %34 = call double @llvm.fmuladd.f64(double %30, double %31, double %33)
  store double %34, ptr %32, align 8, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #4
  br label %35

35:                                               ; preds = %23
  %36 = load i32, ptr %13, align 4, !tbaa !5
  %37 = add nsw i32 %36, 1
  store i32 %37, ptr %13, align 4, !tbaa !5
  br label %18, !llvm.loop !15

38:                                               ; preds = %22
  %39 = load ptr, ptr %9, align 8, !tbaa !9
  %40 = load double, ptr %39, align 8, !tbaa !11
  %41 = call double @sqrt(double noundef %40) #4
  %42 = load ptr, ptr %9, align 8, !tbaa !9
  store double %41, ptr %42, align 8, !tbaa !11
  %43 = load ptr, ptr %12, align 8, !tbaa !9
  store double 0.000000e+00, ptr %43, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #4
  store i32 0, ptr %15, align 4, !tbaa !5
  br label %44

44:                                               ; preds = %60, %38
  %45 = load i32, ptr %15, align 4, !tbaa !5
  %46 = load i32, ptr %10, align 4, !tbaa !5
  %47 = icmp slt i32 %45, %46
  br i1 %47, label %49, label %48

48:                                               ; preds = %44
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #4
  br label %63

49:                                               ; preds = %44
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #4
  %50 = load ptr, ptr %11, align 8, !tbaa !9
  %51 = load i32, ptr %15, align 4, !tbaa !5
  %52 = sext i32 %51 to i64
  %53 = getelementptr inbounds double, ptr %50, i64 %52
  %54 = load double, ptr %53, align 8, !tbaa !11
  store double %54, ptr %16, align 8, !tbaa !11
  %55 = load double, ptr %16, align 8, !tbaa !11
  %56 = load double, ptr %16, align 8, !tbaa !11
  %57 = load ptr, ptr %12, align 8, !tbaa !9
  %58 = load double, ptr %57, align 8, !tbaa !11
  %59 = call double @llvm.fmuladd.f64(double %55, double %56, double %58)
  store double %59, ptr %57, align 8, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #4
  br label %60

60:                                               ; preds = %49
  %61 = load i32, ptr %15, align 4, !tbaa !5
  %62 = add nsw i32 %61, 1
  store i32 %62, ptr %15, align 4, !tbaa !5
  br label %44, !llvm.loop !17

63:                                               ; preds = %48
  %64 = load ptr, ptr %12, align 8, !tbaa !9
  %65 = load double, ptr %64, align 8, !tbaa !11
  %66 = call double @sqrt(double noundef %65) #4
  %67 = load ptr, ptr %12, align 8, !tbaa !9
  store double %66, ptr %67, align 8, !tbaa !11
  ret void
}

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

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #2

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

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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #3 = { 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 = { 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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"double", !7, i64 0}
!13 = !{!14, !12, i64 8}
!14 = !{!"_ZTSSt4pairIidE", !6, i64 0, !12, i64 8}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}
!17 = distinct !{!17, !16}


; 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 nounwind uwtable
define dso_local void @_Z23debugDualChuzcFailNormsiRKSt6vectorISt4pairIidESaIS1_EERdiPKdS6_(i32 noundef %0, ptr noundef nonnull align 8 dereferenceable(24) %1, ptr nocapture noundef nonnull align 8 dereferenceable(8) %2, i32 noundef %3, ptr nocapture noundef readonly %4, ptr nocapture noundef nonnull writeonly align 8 dereferenceable(8) %5) local_unnamed_addr #0 {
  store double 0.000000e+00, ptr %2, align 8, !tbaa !5
  %7 = icmp sgt i32 %0, 0
  br i1 %7, label %.lr.ph.preheader, label %._crit_edge

.lr.ph.preheader:                                 ; preds = %6
  %wide.trip.count = zext nneg i32 %0 to i64
  br label %.lr.ph

._crit_edge:                                      ; preds = %.lr.ph, %6
  %8 = phi double [ 0.000000e+00, %6 ], [ %16, %.lr.ph ]
  %9 = tail call double @sqrt(double noundef %8) #3
  store double %9, ptr %2, align 8, !tbaa !5
  store double 0.000000e+00, ptr %5, align 8, !tbaa !5
  %10 = icmp sgt i32 %3, 0
  br i1 %10, label %.lr.ph25.preheader, label %._crit_edge26

.lr.ph25.preheader:                               ; preds = %._crit_edge
  %wide.trip.count31 = zext nneg i32 %3 to i64
  %xtraiter = and i64 %wide.trip.count31, 3
  %11 = icmp ult i32 %3, 4
  br i1 %11, label %._crit_edge26.loopexit.unr-lcssa, label %.lr.ph25.preheader.new

.lr.ph25.preheader.new:                           ; preds = %.lr.ph25.preheader
  %unroll_iter = and i64 %wide.trip.count31, 2147483644
  br label %.lr.ph25

.lr.ph:                                           ; preds = %.lr.ph.preheader, %.lr.ph
  %indvars.iv = phi i64 [ 0, %.lr.ph.preheader ], [ %indvars.iv.next, %.lr.ph ]
  %12 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNKSt6vectorISt4pairIidESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %1, i64 noundef %indvars.iv) #3
  %13 = getelementptr inbounds i8, ptr %12, i64 8
  %14 = load double, ptr %13, align 8, !tbaa !9
  %15 = load double, ptr %2, align 8, !tbaa !5
  %16 = tail call double @llvm.fmuladd.f64(double %14, double %14, double %15)
  store double %16, ptr %2, align 8, !tbaa !5
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
  br i1 %exitcond.not, label %._crit_edge, label %.lr.ph, !llvm.loop !12

._crit_edge26.loopexit.unr-lcssa:                 ; preds = %.lr.ph25, %.lr.ph25.preheader
  %.lcssa.ph = phi double [ poison, %.lr.ph25.preheader ], [ %35, %.lr.ph25 ]
  %indvars.iv28.unr = phi i64 [ 0, %.lr.ph25.preheader ], [ %indvars.iv.next29.3, %.lr.ph25 ]
  %.unr = phi double [ 0.000000e+00, %.lr.ph25.preheader ], [ %35, %.lr.ph25 ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %._crit_edge26, label %.lr.ph25.epil

.lr.ph25.epil:                                    ; preds = %._crit_edge26.loopexit.unr-lcssa, %.lr.ph25.epil
  %indvars.iv28.epil = phi i64 [ %indvars.iv.next29.epil, %.lr.ph25.epil ], [ %indvars.iv28.unr, %._crit_edge26.loopexit.unr-lcssa ]
  %17 = phi double [ %20, %.lr.ph25.epil ], [ %.unr, %._crit_edge26.loopexit.unr-lcssa ]
  %epil.iter = phi i64 [ %epil.iter.next, %.lr.ph25.epil ], [ 0, %._crit_edge26.loopexit.unr-lcssa ]
  %18 = getelementptr inbounds double, ptr %4, i64 %indvars.iv28.epil
  %19 = load double, ptr %18, align 8, !tbaa !5
  %20 = tail call double @llvm.fmuladd.f64(double %19, double %19, double %17)
  store double %20, ptr %5, align 8, !tbaa !5
  %indvars.iv.next29.epil = add nuw nsw i64 %indvars.iv28.epil, 1
  %epil.iter.next = add i64 %epil.iter, 1
  %epil.iter.cmp.not = icmp eq i64 %epil.iter.next, %xtraiter
  br i1 %epil.iter.cmp.not, label %._crit_edge26, label %.lr.ph25.epil, !llvm.loop !14

._crit_edge26:                                    ; preds = %._crit_edge26.loopexit.unr-lcssa, %.lr.ph25.epil, %._crit_edge
  %21 = phi double [ 0.000000e+00, %._crit_edge ], [ %.lcssa.ph, %._crit_edge26.loopexit.unr-lcssa ], [ %20, %.lr.ph25.epil ]
  %22 = tail call double @sqrt(double noundef %21) #3
  store double %22, ptr %5, align 8, !tbaa !5
  ret void

.lr.ph25:                                         ; preds = %.lr.ph25, %.lr.ph25.preheader.new
  %indvars.iv28 = phi i64 [ 0, %.lr.ph25.preheader.new ], [ %indvars.iv.next29.3, %.lr.ph25 ]
  %23 = phi double [ 0.000000e+00, %.lr.ph25.preheader.new ], [ %35, %.lr.ph25 ]
  %niter = phi i64 [ 0, %.lr.ph25.preheader.new ], [ %niter.next.3, %.lr.ph25 ]
  %24 = getelementptr inbounds double, ptr %4, i64 %indvars.iv28
  %25 = load double, ptr %24, align 8, !tbaa !5
  %26 = tail call double @llvm.fmuladd.f64(double %25, double %25, double %23)
  store double %26, ptr %5, align 8, !tbaa !5
  %indvars.iv.next29 = or disjoint i64 %indvars.iv28, 1
  %27 = getelementptr inbounds double, ptr %4, i64 %indvars.iv.next29
  %28 = load double, ptr %27, align 8, !tbaa !5
  %29 = tail call double @llvm.fmuladd.f64(double %28, double %28, double %26)
  store double %29, ptr %5, align 8, !tbaa !5
  %indvars.iv.next29.1 = or disjoint i64 %indvars.iv28, 2
  %30 = getelementptr inbounds double, ptr %4, i64 %indvars.iv.next29.1
  %31 = load double, ptr %30, align 8, !tbaa !5
  %32 = tail call double @llvm.fmuladd.f64(double %31, double %31, double %29)
  store double %32, ptr %5, align 8, !tbaa !5
  %indvars.iv.next29.2 = or disjoint i64 %indvars.iv28, 3
  %33 = getelementptr inbounds double, ptr %4, i64 %indvars.iv.next29.2
  %34 = load double, ptr %33, align 8, !tbaa !5
  %35 = tail call double @llvm.fmuladd.f64(double %34, double %34, double %32)
  store double %35, ptr %5, align 8, !tbaa !5
  %indvars.iv.next29.3 = add nuw nsw i64 %indvars.iv28, 4
  %niter.next.3 = add i64 %niter, 4
  %niter.ncmp.3 = icmp eq i64 %niter.next.3, %unroll_iter
  br i1 %niter.ncmp.3, label %._crit_edge26.loopexit.unr-lcssa, label %.lr.ph25, !llvm.loop !16
}

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

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #1

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

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 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #2 = { 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 #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 = !{!"double", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !6, i64 8}
!10 = !{!"_ZTSSt4pairIidE", !11, i64 0, !6, i64 8}
!11 = !{!"int", !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.unroll.disable"}
!16 = distinct !{!16, !13}


; Effective O3 passes: GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass