; LLVM IR from ERGO-Code/HiGHS :: src/ipm/basiclu (lu_condest)

; 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: nounwind uwtable
define dso_local double @lu_condest(i32 noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %4, ptr noundef %5, i32 noundef %6, ptr noundef %7, ptr noundef %8, ptr noundef %9) #0 {
  %11 = alloca i32, align 4
  %12 = alloca ptr, align 8
  %13 = alloca ptr, align 8
  %14 = alloca ptr, align 8
  %15 = alloca ptr, align 8
  %16 = alloca ptr, align 8
  %17 = alloca i32, align 4
  %18 = alloca ptr, align 8
  %19 = alloca ptr, align 8
  %20 = alloca ptr, align 8
  %21 = alloca i32, align 4
  %22 = alloca i32, align 4
  %23 = alloca double, align 8
  %24 = alloca double, align 8
  %25 = alloca double, align 8
  store i32 %0, ptr %11, align 4, !tbaa !5
  store ptr %1, ptr %12, align 8, !tbaa !9
  store ptr %2, ptr %13, align 8, !tbaa !9
  store ptr %3, ptr %14, align 8, !tbaa !9
  store ptr %4, ptr %15, align 8, !tbaa !9
  store ptr %5, ptr %16, align 8, !tbaa !9
  store i32 %6, ptr %17, align 4, !tbaa !5
  store ptr %7, ptr %18, align 8, !tbaa !9
  store ptr %8, ptr %19, align 8, !tbaa !9
  store ptr %9, ptr %20, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %21) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %22) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %23) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %24) #3
  store double 0.000000e+00, ptr %23, align 8, !tbaa !11
  store i32 0, ptr %21, align 4, !tbaa !5
  br label %26

26:                                               ; preds = %71, %10
  %27 = load i32, ptr %21, align 4, !tbaa !5
  %28 = load i32, ptr %11, align 4, !tbaa !5
  %29 = icmp slt i32 %27, %28
  br i1 %29, label %30, label %74

30:                                               ; preds = %26
  call void @llvm.lifetime.start.p0(i64 8, ptr %25) #3
  %31 = load ptr, ptr %15, align 8, !tbaa !9
  %32 = icmp ne ptr %31, null
  br i1 %32, label %33, label %40

33:                                               ; preds = %30
  %34 = load ptr, ptr %15, align 8, !tbaa !9
  %35 = load i32, ptr %21, align 4, !tbaa !5
  %36 = sext i32 %35 to i64
  %37 = getelementptr inbounds double, ptr %34, i64 %36
  %38 = load double, ptr %37, align 8, !tbaa !11
  %39 = call double @llvm.fabs.f64(double %38)
  br label %41

40:                                               ; preds = %30
  br label %41

41:                                               ; preds = %40, %33
  %42 = phi double [ %39, %33 ], [ 1.000000e+00, %40 ]
  store double %42, ptr %25, align 8, !tbaa !11
  %43 = load ptr, ptr %12, align 8, !tbaa !9
  %44 = load i32, ptr %21, align 4, !tbaa !5
  %45 = sext i32 %44 to i64
  %46 = getelementptr inbounds i32, ptr %43, i64 %45
  %47 = load i32, ptr %46, align 4, !tbaa !5
  store i32 %47, ptr %22, align 4, !tbaa !5
  br label %48

48:                                               ; preds = %64, %41
  %49 = load ptr, ptr %13, align 8, !tbaa !9
  %50 = load i32, ptr %22, align 4, !tbaa !5
  %51 = sext i32 %50 to i64
  %52 = getelementptr inbounds i32, ptr %49, i64 %51
  %53 = load i32, ptr %52, align 4, !tbaa !5
  %54 = icmp sge i32 %53, 0
  br i1 %54, label %55, label %67

55:                                               ; preds = %48
  %56 = load ptr, ptr %14, align 8, !tbaa !9
  %57 = load i32, ptr %22, align 4, !tbaa !5
  %58 = sext i32 %57 to i64
  %59 = getelementptr inbounds double, ptr %56, i64 %58
  %60 = load double, ptr %59, align 8, !tbaa !11
  %61 = call double @llvm.fabs.f64(double %60)
  %62 = load double, ptr %25, align 8, !tbaa !11
  %63 = fadd double %62, %61
  store double %63, ptr %25, align 8, !tbaa !11
  br label %64

64:                                               ; preds = %55
  %65 = load i32, ptr %22, align 4, !tbaa !5
  %66 = add nsw i32 %65, 1
  store i32 %66, ptr %22, align 4, !tbaa !5
  br label %48, !llvm.loop !13

67:                                               ; preds = %48
  %68 = load double, ptr %23, align 8, !tbaa !11
  %69 = load double, ptr %25, align 8, !tbaa !11
  %70 = call double @llvm.maxnum.f64(double %68, double %69)
  store double %70, ptr %23, align 8, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 8, ptr %25) #3
  br label %71

71:                                               ; preds = %67
  %72 = load i32, ptr %21, align 4, !tbaa !5
  %73 = add nsw i32 %72, 1
  store i32 %73, ptr %21, align 4, !tbaa !5
  br label %26, !llvm.loop !15

74:                                               ; preds = %26
  %75 = load i32, ptr %11, align 4, !tbaa !5
  %76 = load ptr, ptr %12, align 8, !tbaa !9
  %77 = load ptr, ptr %13, align 8, !tbaa !9
  %78 = load ptr, ptr %14, align 8, !tbaa !9
  %79 = load ptr, ptr %15, align 8, !tbaa !9
  %80 = load ptr, ptr %16, align 8, !tbaa !9
  %81 = load i32, ptr %17, align 4, !tbaa !5
  %82 = load ptr, ptr %18, align 8, !tbaa !9
  %83 = call double @lu_normest(i32 noundef %75, ptr noundef %76, ptr noundef %77, ptr noundef %78, ptr noundef %79, ptr noundef %80, i32 noundef %81, ptr noundef %82)
  store double %83, ptr %24, align 8, !tbaa !11
  %84 = load ptr, ptr %19, align 8, !tbaa !9
  %85 = icmp ne ptr %84, null
  br i1 %85, label %86, label %89

86:                                               ; preds = %74
  %87 = load double, ptr %23, align 8, !tbaa !11
  %88 = load ptr, ptr %19, align 8, !tbaa !9
  store double %87, ptr %88, align 8, !tbaa !11
  br label %89

89:                                               ; preds = %86, %74
  %90 = load ptr, ptr %20, align 8, !tbaa !9
  %91 = icmp ne ptr %90, null
  br i1 %91, label %92, label %95

92:                                               ; preds = %89
  %93 = load double, ptr %24, align 8, !tbaa !11
  %94 = load ptr, ptr %20, align 8, !tbaa !9
  store double %93, ptr %94, align 8, !tbaa !11
  br label %95

95:                                               ; preds = %92, %89
  %96 = load double, ptr %23, align 8, !tbaa !11
  %97 = load double, ptr %24, align 8, !tbaa !11
  %98 = fmul double %96, %97
  call void @llvm.lifetime.end.p0(i64 8, ptr %24) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %23) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %22) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %21) #3
  ret double %98
}

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

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

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

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

; Function Attrs: nounwind uwtable
declare dso_local double @lu_normest(i32 noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, i32 noundef, ptr noundef) #0

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


; 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: nounwind uwtable
define dso_local double @lu_condest(i32 noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %4, ptr noundef %5, i32 noundef %6, ptr noundef %7, ptr noundef writeonly %8, ptr noundef writeonly %9) local_unnamed_addr #0 {
  %11 = icmp sgt i32 %0, 0
  br i1 %11, label %.lr.ph45, label %._crit_edge46

.lr.ph45:                                         ; preds = %10
  %.not39 = icmp eq ptr %4, null
  %wide.trip.count62 = zext nneg i32 %0 to i64
  br i1 %.not39, label %.lr.ph45.split.us, label %.lr.ph45.split

.lr.ph45.split.us:                                ; preds = %.lr.ph45, %._crit_edge.us
  %indvars.iv59 = phi i64 [ %indvars.iv.next60, %._crit_edge.us ], [ 0, %.lr.ph45 ]
  %.03242.us = phi double [ %18, %._crit_edge.us ], [ 0.000000e+00, %.lr.ph45 ]
  %12 = getelementptr inbounds i32, ptr %1, i64 %indvars.iv59
  %13 = load i32, ptr %12, align 4, !tbaa !5
  %14 = sext i32 %13 to i64
  %15 = getelementptr inbounds i32, ptr %2, i64 %14
  %16 = load i32, ptr %15, align 4, !tbaa !5
  %17 = icmp sgt i32 %16, -1
  br i1 %17, label %.lr.ph.us, label %._crit_edge.us

._crit_edge.us:                                   ; preds = %.lr.ph.us, %.lr.ph45.split.us
  %.0.lcssa.us = phi double [ 1.000000e+00, %.lr.ph45.split.us ], [ %22, %.lr.ph.us ]
  %18 = tail call double @llvm.maxnum.f64(double %.03242.us, double %.0.lcssa.us)
  %indvars.iv.next60 = add nuw nsw i64 %indvars.iv59, 1
  %exitcond63.not = icmp eq i64 %indvars.iv.next60, %wide.trip.count62
  br i1 %exitcond63.not, label %._crit_edge46, label %.lr.ph45.split.us, !llvm.loop !9

.lr.ph.us:                                        ; preds = %.lr.ph45.split.us, %.lr.ph.us
  %indvars.iv56 = phi i64 [ %indvars.iv.next57, %.lr.ph.us ], [ %14, %.lr.ph45.split.us ]
  %.041.us = phi double [ %22, %.lr.ph.us ], [ 1.000000e+00, %.lr.ph45.split.us ]
  %19 = getelementptr inbounds double, ptr %3, i64 %indvars.iv56
  %20 = load double, ptr %19, align 8, !tbaa !11
  %21 = tail call double @llvm.fabs.f64(double %20)
  %22 = fadd double %.041.us, %21
  %indvars.iv.next57 = add nsw i64 %indvars.iv56, 1
  %23 = getelementptr inbounds i32, ptr %2, i64 %indvars.iv.next57
  %24 = load i32, ptr %23, align 4, !tbaa !5
  %25 = icmp sgt i32 %24, -1
  br i1 %25, label %.lr.ph.us, label %._crit_edge.us, !llvm.loop !13

.lr.ph45.split:                                   ; preds = %.lr.ph45, %._crit_edge
  %indvars.iv53 = phi i64 [ %indvars.iv.next54, %._crit_edge ], [ 0, %.lr.ph45 ]
  %.03242 = phi double [ %42, %._crit_edge ], [ 0.000000e+00, %.lr.ph45 ]
  %26 = getelementptr inbounds double, ptr %4, i64 %indvars.iv53
  %27 = load double, ptr %26, align 8, !tbaa !11
  %28 = tail call double @llvm.fabs.f64(double %27)
  %29 = getelementptr inbounds i32, ptr %1, i64 %indvars.iv53
  %30 = load i32, ptr %29, align 4, !tbaa !5
  %31 = sext i32 %30 to i64
  %32 = getelementptr inbounds i32, ptr %2, i64 %31
  %33 = load i32, ptr %32, align 4, !tbaa !5
  %34 = icmp sgt i32 %33, -1
  br i1 %34, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %.lr.ph45.split, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ %31, %.lr.ph45.split ]
  %.041 = phi double [ %38, %.lr.ph ], [ %28, %.lr.ph45.split ]
  %35 = getelementptr inbounds double, ptr %3, i64 %indvars.iv
  %36 = load double, ptr %35, align 8, !tbaa !11
  %37 = tail call double @llvm.fabs.f64(double %36)
  %38 = fadd double %.041, %37
  %indvars.iv.next = add nsw i64 %indvars.iv, 1
  %39 = getelementptr inbounds i32, ptr %2, i64 %indvars.iv.next
  %40 = load i32, ptr %39, align 4, !tbaa !5
  %41 = icmp sgt i32 %40, -1
  br i1 %41, label %.lr.ph, label %._crit_edge, !llvm.loop !13

._crit_edge:                                      ; preds = %.lr.ph, %.lr.ph45.split
  %.0.lcssa = phi double [ %28, %.lr.ph45.split ], [ %38, %.lr.ph ]
  %42 = tail call double @llvm.maxnum.f64(double %.03242, double %.0.lcssa)
  %indvars.iv.next54 = add nuw nsw i64 %indvars.iv53, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next54, %wide.trip.count62
  br i1 %exitcond.not, label %._crit_edge46, label %.lr.ph45.split, !llvm.loop !9

._crit_edge46:                                    ; preds = %._crit_edge, %._crit_edge.us, %10
  %.032.lcssa = phi double [ 0.000000e+00, %10 ], [ %18, %._crit_edge.us ], [ %42, %._crit_edge ]
  %43 = tail call double @lu_normest(i32 noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %4, ptr noundef %5, i32 noundef %6, ptr noundef %7)
  %.not = icmp eq ptr %8, null
  br i1 %.not, label %45, label %44

44:                                               ; preds = %._crit_edge46
  store double %.032.lcssa, ptr %8, align 8, !tbaa !11
  br label %45

45:                                               ; preds = %44, %._crit_edge46
  %.not38 = icmp eq ptr %9, null
  br i1 %.not38, label %47, label %46

46:                                               ; preds = %45
  store double %43, ptr %9, align 8, !tbaa !11
  br label %47

47:                                               ; preds = %46, %45
  %48 = fmul double %.032.lcssa, %43
  ret double %48
}

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

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

; Function Attrs: nounwind uwtable
declare dso_local double @lu_normest(i32 noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #0

attributes #0 = { 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) }

!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/C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = !{!12, !12, i64 0}
!12 = !{!"double", !7, i64 0}
!13 = distinct !{!13, !10}


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