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

; 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.basiclu_object = type { ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, 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: nounwind uwtable
declare hidden i32 @isvalid(ptr noundef) #1

; Function Attrs: nounwind uwtable
declare hidden i32 @lu_realloc_obj(ptr noundef) #1

; Function Attrs: nounwind uwtable
declare hidden void @lu_clear_lhs(ptr noundef) #1

; Function Attrs: nounwind uwtable
define dso_local i32 @basiclu_obj_solve_for_update(ptr noundef %0, i32 noundef %1, ptr noundef %2, ptr noundef %3, i8 noundef signext %4, i32 noundef %5) #1 {
  %7 = alloca i32, align 4
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca i8, align 1
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  store ptr %0, ptr %8, align 8, !tbaa !5
  store i32 %1, ptr %9, align 4, !tbaa !9
  store ptr %2, ptr %10, align 8, !tbaa !5
  store ptr %3, ptr %11, align 8, !tbaa !5
  store i8 %4, ptr %12, align 1, !tbaa !11
  store i32 %5, ptr %13, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #3
  store i32 0, ptr %14, align 4, !tbaa !9
  %16 = load ptr, ptr %8, align 8, !tbaa !5
  %17 = call i32 @isvalid(ptr noundef %16)
  %18 = icmp ne i32 %17, 0
  br i1 %18, label %20, label %19

19:                                               ; preds = %6
  store i32 -8, ptr %7, align 4
  store i32 1, ptr %15, align 4
  br label %77

20:                                               ; preds = %6
  %21 = load ptr, ptr %8, align 8, !tbaa !5
  call void @lu_clear_lhs(ptr noundef %21)
  br label %22

22:                                               ; preds = %72, %20
  %23 = load i32, ptr %14, align 4, !tbaa !9
  %24 = icmp eq i32 %23, 0
  br i1 %24, label %25, label %75

25:                                               ; preds = %22
  %26 = load ptr, ptr %8, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.basiclu_object, ptr %26, i32 0, i32 0
  %28 = load ptr, ptr %27, align 8, !tbaa !12
  %29 = load ptr, ptr %8, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.basiclu_object, ptr %29, i32 0, i32 1
  %31 = load ptr, ptr %30, align 8, !tbaa !15
  %32 = load ptr, ptr %8, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.basiclu_object, ptr %32, i32 0, i32 2
  %34 = load ptr, ptr %33, align 8, !tbaa !16
  %35 = load ptr, ptr %8, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.basiclu_object, ptr %35, i32 0, i32 5
  %37 = load ptr, ptr %36, align 8, !tbaa !17
  %38 = load ptr, ptr %8, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.basiclu_object, ptr %38, i32 0, i32 3
  %40 = load ptr, ptr %39, align 8, !tbaa !18
  %41 = load ptr, ptr %8, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.basiclu_object, ptr %41, i32 0, i32 6
  %43 = load ptr, ptr %42, align 8, !tbaa !19
  %44 = load ptr, ptr %8, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.basiclu_object, ptr %44, i32 0, i32 4
  %46 = load ptr, ptr %45, align 8, !tbaa !20
  %47 = load ptr, ptr %8, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.basiclu_object, ptr %47, i32 0, i32 7
  %49 = load ptr, ptr %48, align 8, !tbaa !21
  %50 = load i32, ptr %9, align 4, !tbaa !9
  %51 = load ptr, ptr %10, align 8, !tbaa !5
  %52 = load ptr, ptr %11, align 8, !tbaa !5
  %53 = load i32, ptr %13, align 4, !tbaa !9
  %54 = icmp ne i32 %53, 0
  br i1 %54, label %55, label %58

55:                                               ; preds = %25
  %56 = load ptr, ptr %8, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct.basiclu_object, ptr %56, i32 0, i32 10
  br label %59

58:                                               ; preds = %25
  br label %59

59:                                               ; preds = %58, %55
  %60 = phi ptr [ %57, %55 ], [ null, %58 ]
  %61 = load ptr, ptr %8, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct.basiclu_object, ptr %61, i32 0, i32 9
  %63 = load ptr, ptr %62, align 8, !tbaa !22
  %64 = load ptr, ptr %8, align 8, !tbaa !5
  %65 = getelementptr inbounds %struct.basiclu_object, ptr %64, i32 0, i32 8
  %66 = load ptr, ptr %65, align 8, !tbaa !23
  %67 = load i8, ptr %12, align 1, !tbaa !11
  %68 = call i32 @basiclu_solve_for_update(ptr noundef %28, ptr noundef %31, ptr noundef %34, ptr noundef %37, ptr noundef %40, ptr noundef %43, ptr noundef %46, ptr noundef %49, i32 noundef %50, ptr noundef %51, ptr noundef %52, ptr noundef %60, ptr noundef %63, ptr noundef %66, i8 noundef signext %67)
  store i32 %68, ptr %14, align 4, !tbaa !9
  %69 = load i32, ptr %14, align 4, !tbaa !9
  %70 = icmp ne i32 %69, 1
  br i1 %70, label %71, label %72

71:                                               ; preds = %59
  br label %75

72:                                               ; preds = %59
  %73 = load ptr, ptr %8, align 8, !tbaa !5
  %74 = call i32 @lu_realloc_obj(ptr noundef %73)
  store i32 %74, ptr %14, align 4, !tbaa !9
  br label %22, !llvm.loop !24

75:                                               ; preds = %71, %22
  %76 = load i32, ptr %14, align 4, !tbaa !9
  store i32 %76, ptr %7, align 4
  store i32 1, ptr %15, align 4
  br label %77

77:                                               ; preds = %75, %19
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #3
  %78 = load i32, ptr %7, align 4
  ret i32 %78
}

declare i32 @basiclu_solve_for_update(ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, i32 noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, i8 noundef signext) #2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 = { "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/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!7, !7, i64 0}
!12 = !{!13, !6, i64 0}
!13 = !{!"basiclu_object", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !6, i64 56, !6, i64 64, !6, i64 72, !10, i64 80, !14, i64 88}
!14 = !{!"double", !7, i64 0}
!15 = !{!13, !6, i64 8}
!16 = !{!13, !6, i64 16}
!17 = !{!13, !6, i64 40}
!18 = !{!13, !6, i64 24}
!19 = !{!13, !6, i64 48}
!20 = !{!13, !6, i64 32}
!21 = !{!13, !6, i64 56}
!22 = !{!13, !6, i64 72}
!23 = !{!13, !6, i64 64}
!24 = distinct !{!24, !25}
!25 = !{!"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: nounwind uwtable
declare hidden i32 @isvalid(ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare hidden i32 @lu_realloc_obj(ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare hidden void @lu_clear_lhs(ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local i32 @basiclu_obj_solve_for_update(ptr noundef %0, i32 noundef %1, ptr noundef %2, ptr noundef %3, i8 noundef signext %4, i32 noundef %5) local_unnamed_addr #0 {
  %7 = tail call i32 @isvalid(ptr noundef %0)
  %.not = icmp eq i32 %7, 0
  br i1 %.not, label %.loopexit, label %8

8:                                                ; preds = %6
  tail call void @lu_clear_lhs(ptr noundef %0)
  %9 = getelementptr inbounds i8, ptr %0, i64 8
  %10 = getelementptr inbounds i8, ptr %0, i64 16
  %11 = getelementptr inbounds i8, ptr %0, i64 40
  %12 = getelementptr inbounds i8, ptr %0, i64 24
  %13 = getelementptr inbounds i8, ptr %0, i64 48
  %14 = getelementptr inbounds i8, ptr %0, i64 32
  %15 = getelementptr inbounds i8, ptr %0, i64 56
  %.not24 = icmp eq i32 %5, 0
  %16 = getelementptr inbounds i8, ptr %0, i64 80
  %17 = select i1 %.not24, ptr null, ptr %16
  %18 = getelementptr inbounds i8, ptr %0, i64 72
  %19 = getelementptr inbounds i8, ptr %0, i64 64
  br label %20

20:                                               ; preds = %8, %32
  %21 = load ptr, ptr %0, align 8, !tbaa !5
  %22 = load ptr, ptr %9, align 8, !tbaa !12
  %23 = load ptr, ptr %10, align 8, !tbaa !13
  %24 = load ptr, ptr %11, align 8, !tbaa !14
  %25 = load ptr, ptr %12, align 8, !tbaa !15
  %26 = load ptr, ptr %13, align 8, !tbaa !16
  %27 = load ptr, ptr %14, align 8, !tbaa !17
  %28 = load ptr, ptr %15, align 8, !tbaa !18
  %29 = load ptr, ptr %18, align 8, !tbaa !19
  %30 = load ptr, ptr %19, align 8, !tbaa !20
  %31 = tail call i32 @basiclu_solve_for_update(ptr noundef %21, ptr noundef %22, ptr noundef %23, ptr noundef %24, ptr noundef %25, ptr noundef %26, ptr noundef %27, ptr noundef %28, i32 noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %17, ptr noundef %29, ptr noundef %30, i8 noundef signext %4) #2
  %.not25 = icmp eq i32 %31, 1
  br i1 %.not25, label %32, label %.loopexit

32:                                               ; preds = %20
  %33 = tail call i32 @lu_realloc_obj(ptr noundef nonnull %0)
  %34 = icmp eq i32 %33, 0
  br i1 %34, label %20, label %.loopexit, !llvm.loop !21

.loopexit:                                        ; preds = %32, %20, %6
  %.022 = phi i32 [ -8, %6 ], [ %33, %32 ], [ %31, %20 ]
  ret i32 %.022
}

declare i32 @basiclu_solve_for_update(ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, i32 noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, i8 noundef signext) local_unnamed_addr #1

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 = { "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 = { 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, !7, i64 0}
!6 = !{!"basiclu_object", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !7, i64 32, !7, i64 40, !7, i64 48, !7, i64 56, !7, i64 64, !7, i64 72, !10, i64 80, !11, i64 88}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!"double", !8, i64 0}
!12 = !{!6, !7, i64 8}
!13 = !{!6, !7, i64 16}
!14 = !{!6, !7, i64 40}
!15 = !{!6, !7, i64 24}
!16 = !{!6, !7, i64 48}
!17 = !{!6, !7, i64 32}
!18 = !{!6, !7, i64 56}
!19 = !{!6, !7, i64 72}
!20 = !{!6, !7, i64 64}
!21 = distinct !{!21, !22}
!22 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass