; LLVM IR from ERGO-Code/HiGHS :: src/interfaces (highs_c_api)

; 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.HighsLinearObjective = type <{ double, double, %"class.std::vector", double, double, i32, [4 x i8] }>
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<double, std::allocator<double>>::_Vector_impl" }
%"struct.std::_Vector_base<double, std::allocator<double>>::_Vector_impl" = type { %"struct.std::_Vector_base<double, std::allocator<double>>::_Vector_impl_data" }
%"struct.std::_Vector_base<double, std::allocator<double>>::_Vector_impl_data" = type { ptr, ptr, ptr }

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

declare i32 @__gxx_personality_v0(...)

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZN20HighsLinearObjectiveC2Ev(ptr noundef nonnull align 8 dereferenceable(60)) unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local i32 @Highs_getNumCol(ptr noundef) #2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt6vectorIdSaIdEE9push_backERKd(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 8 dereferenceable(8)) #2 align 2

declare noundef i32 @_ZN5Highs18addLinearObjectiveERK20HighsLinearObjectivei(ptr noundef nonnull align 8 dereferenceable(20928), ptr noundef nonnull align 8 dereferenceable(60), i32 noundef) #3

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZN20HighsLinearObjectiveD2Ev(ptr noundef nonnull align 8 dereferenceable(60)) unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local i32 @Highs_addLinearObjective(ptr noundef %0, double noundef %1, double noundef %2, ptr noundef %3, double noundef %4, double noundef %5, i32 noundef %6) #2 personality ptr @__gxx_personality_v0 {
  %8 = alloca ptr, align 8
  %9 = alloca double, align 8
  %10 = alloca double, align 8
  %11 = alloca ptr, align 8
  %12 = alloca double, align 8
  %13 = alloca double, align 8
  %14 = alloca i32, align 4
  %15 = alloca %struct.HighsLinearObjective, align 8
  %16 = alloca i32, align 4
  %17 = alloca ptr, align 8
  %18 = alloca i32, align 4
  %19 = alloca i32, align 4
  store ptr %0, ptr %8, align 8, !tbaa !5
  store double %1, ptr %9, align 8, !tbaa !9
  store double %2, ptr %10, align 8, !tbaa !9
  store ptr %3, ptr %11, align 8, !tbaa !5
  store double %4, ptr %12, align 8, !tbaa !9
  store double %5, ptr %13, align 8, !tbaa !9
  store i32 %6, ptr %14, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 64, ptr %15) #4
  call void @_ZN20HighsLinearObjectiveC2Ev(ptr noundef nonnull align 8 dereferenceable(60) %15) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #4
  %20 = load ptr, ptr %8, align 8, !tbaa !5
  %21 = invoke i32 @Highs_getNumCol(ptr noundef %20)
          to label %22 unwind label %32

22:                                               ; preds = %7
  store i32 %21, ptr %16, align 4, !tbaa !11
  %23 = load double, ptr %9, align 8, !tbaa !9
  %24 = getelementptr inbounds %struct.HighsLinearObjective, ptr %15, i32 0, i32 0
  store double %23, ptr %24, align 8, !tbaa !13
  %25 = load double, ptr %10, align 8, !tbaa !9
  %26 = getelementptr inbounds %struct.HighsLinearObjective, ptr %15, i32 0, i32 1
  store double %25, ptr %26, align 8, !tbaa !19
  call void @llvm.lifetime.start.p0(i64 4, ptr %19) #4
  store i32 0, ptr %19, align 4, !tbaa !11
  br label %27

27:                                               ; preds = %43, %22
  %28 = load i32, ptr %19, align 4, !tbaa !11
  %29 = load i32, ptr %16, align 4, !tbaa !11
  %30 = icmp slt i32 %28, %29
  br i1 %30, label %36, label %31

31:                                               ; preds = %27
  call void @llvm.lifetime.end.p0(i64 4, ptr %19) #4
  br label %50

32:                                               ; preds = %50, %7
  %33 = landingpad { ptr, i32 }
          cleanup
  %34 = extractvalue { ptr, i32 } %33, 0
  store ptr %34, ptr %17, align 8
  %35 = extractvalue { ptr, i32 } %33, 1
  store i32 %35, ptr %18, align 4
  br label %62

36:                                               ; preds = %27
  %37 = getelementptr inbounds %struct.HighsLinearObjective, ptr %15, i32 0, i32 2
  %38 = load ptr, ptr %11, align 8, !tbaa !5
  %39 = load i32, ptr %19, align 4, !tbaa !11
  %40 = sext i32 %39 to i64
  %41 = getelementptr inbounds double, ptr %38, i64 %40
  invoke void @_ZNSt6vectorIdSaIdEE9push_backERKd(ptr noundef nonnull align 8 dereferenceable(24) %37, ptr noundef nonnull align 8 dereferenceable(8) %41)
          to label %42 unwind label %46

42:                                               ; preds = %36
  br label %43

43:                                               ; preds = %42
  %44 = load i32, ptr %19, align 4, !tbaa !11
  %45 = add nsw i32 %44, 1
  store i32 %45, ptr %19, align 4, !tbaa !11
  br label %27, !llvm.loop !20

46:                                               ; preds = %36
  %47 = landingpad { ptr, i32 }
          cleanup
  %48 = extractvalue { ptr, i32 } %47, 0
  store ptr %48, ptr %17, align 8
  %49 = extractvalue { ptr, i32 } %47, 1
  store i32 %49, ptr %18, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %19) #4
  br label %62

50:                                               ; preds = %31
  %51 = load double, ptr %12, align 8, !tbaa !9
  %52 = getelementptr inbounds %struct.HighsLinearObjective, ptr %15, i32 0, i32 3
  store double %51, ptr %52, align 8, !tbaa !22
  %53 = load double, ptr %13, align 8, !tbaa !9
  %54 = getelementptr inbounds %struct.HighsLinearObjective, ptr %15, i32 0, i32 4
  store double %53, ptr %54, align 8, !tbaa !23
  %55 = load i32, ptr %14, align 4, !tbaa !11
  %56 = getelementptr inbounds %struct.HighsLinearObjective, ptr %15, i32 0, i32 5
  store i32 %55, ptr %56, align 8, !tbaa !24
  %57 = load double, ptr %9, align 8, !tbaa !9
  %58 = getelementptr inbounds %struct.HighsLinearObjective, ptr %15, i32 0, i32 0
  store double %57, ptr %58, align 8, !tbaa !13
  %59 = load ptr, ptr %8, align 8, !tbaa !5
  %60 = invoke noundef i32 @_ZN5Highs18addLinearObjectiveERK20HighsLinearObjectivei(ptr noundef nonnull align 8 dereferenceable(20928) %59, ptr noundef nonnull align 8 dereferenceable(60) %15, i32 noundef -1)
          to label %61 unwind label %32

61:                                               ; preds = %50
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #4
  call void @_ZN20HighsLinearObjectiveD2Ev(ptr noundef nonnull align 8 dereferenceable(60) %15) #4
  call void @llvm.lifetime.end.p0(i64 64, ptr %15) #4
  ret i32 %60

62:                                               ; preds = %46, %32
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #4
  call void @_ZN20HighsLinearObjectiveD2Ev(ptr noundef nonnull align 8 dereferenceable(60) %15) #4
  call void @llvm.lifetime.end.p0(i64 64, ptr %15) #4
  br label %63

63:                                               ; preds = %62
  %64 = load ptr, ptr %17, align 8
  %65 = load i32, ptr %18, align 4
  %66 = insertvalue { ptr, i32 } poison, ptr %64, 0
  %67 = insertvalue { ptr, i32 } %66, i32 %65, 1
  resume { ptr, i32 } %67
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 #3 = { "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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"double", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!14, !10, i64 0}
!14 = !{!"_ZTS20HighsLinearObjective", !10, i64 0, !10, i64 8, !15, i64 16, !10, i64 40, !10, i64 48, !12, i64 56}
!15 = !{!"_ZTSSt6vectorIdSaIdEE", !16, i64 0}
!16 = !{!"_ZTSSt12_Vector_baseIdSaIdEE", !17, i64 0}
!17 = !{!"_ZTSNSt12_Vector_baseIdSaIdEE12_Vector_implE", !18, i64 0}
!18 = !{!"_ZTSNSt12_Vector_baseIdSaIdEE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!19 = !{!14, !10, i64 8}
!20 = distinct !{!20, !21}
!21 = !{!"llvm.loop.mustprogress"}
!22 = !{!14, !10, i64 40}
!23 = !{!14, !10, i64 48}
!24 = !{!14, !12, i64 56}


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

%struct.HighsLinearObjective = type <{ double, double, %"class.std::vector", double, double, i32, [4 x i8] }>
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<double, std::allocator<double>>::_Vector_impl" }
%"struct.std::_Vector_base<double, std::allocator<double>>::_Vector_impl" = type { %"struct.std::_Vector_base<double, std::allocator<double>>::_Vector_impl_data" }
%"struct.std::_Vector_base<double, std::allocator<double>>::_Vector_impl_data" = type { ptr, ptr, ptr }

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

declare i32 @__gxx_personality_v0(...)

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZN20HighsLinearObjectiveC2Ev(ptr noundef nonnull align 8 dereferenceable(60)) unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local i32 @Highs_getNumCol(ptr noundef) local_unnamed_addr #2

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

declare noundef i32 @_ZN5Highs18addLinearObjectiveERK20HighsLinearObjectivei(ptr noundef nonnull align 8 dereferenceable(20928), ptr noundef nonnull align 8 dereferenceable(60), i32 noundef) local_unnamed_addr #3

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZN20HighsLinearObjectiveD2Ev(ptr noundef nonnull align 8 dereferenceable(60)) unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @Highs_addLinearObjective(ptr noundef %0, double noundef %1, double noundef %2, ptr noundef %3, double noundef %4, double noundef %5, i32 noundef %6) local_unnamed_addr #2 personality ptr @__gxx_personality_v0 {
  %8 = alloca %struct.HighsLinearObjective, align 8
  call void @llvm.lifetime.start.p0(i64 64, ptr nonnull %8) #4
  call void @_ZN20HighsLinearObjectiveC2Ev(ptr noundef nonnull align 8 dereferenceable(60) %8) #4
  %9 = invoke i32 @Highs_getNumCol(ptr noundef %0)
          to label %10 unwind label %18

10:                                               ; preds = %7
  store double %1, ptr %8, align 8, !tbaa !5
  %11 = getelementptr inbounds i8, ptr %8, i64 8
  store double %2, ptr %11, align 8, !tbaa !16
  %12 = icmp sgt i32 %9, 0
  br i1 %12, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %10
  %13 = getelementptr inbounds i8, ptr %8, i64 16
  %wide.trip.count = zext nneg i32 %9 to i64
  br label %20

._crit_edge:                                      ; preds = %22, %10
  %14 = getelementptr inbounds i8, ptr %8, i64 40
  store double %4, ptr %14, align 8, !tbaa !17
  %15 = getelementptr inbounds i8, ptr %8, i64 48
  store double %5, ptr %15, align 8, !tbaa !18
  %16 = getelementptr inbounds i8, ptr %8, i64 56
  store i32 %6, ptr %16, align 8, !tbaa !19
  store double %1, ptr %8, align 8, !tbaa !5
  %17 = invoke noundef i32 @_ZN5Highs18addLinearObjectiveERK20HighsLinearObjectivei(ptr noundef nonnull align 8 dereferenceable(20928) %0, ptr noundef nonnull align 8 dereferenceable(60) %8, i32 noundef -1)
          to label %25 unwind label %18

18:                                               ; preds = %._crit_edge, %7
  %19 = landingpad { ptr, i32 }
          cleanup
  br label %26

20:                                               ; preds = %.lr.ph, %22
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %22 ]
  %21 = getelementptr inbounds double, ptr %3, i64 %indvars.iv
  invoke void @_ZNSt6vectorIdSaIdEE9push_backERKd(ptr noundef nonnull align 8 dereferenceable(24) %13, ptr noundef nonnull align 8 dereferenceable(8) %21)
          to label %22 unwind label %23

22:                                               ; preds = %20
  %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 %20, !llvm.loop !20

23:                                               ; preds = %20
  %24 = landingpad { ptr, i32 }
          cleanup
  br label %26

25:                                               ; preds = %._crit_edge
  call void @_ZN20HighsLinearObjectiveD2Ev(ptr noundef nonnull align 8 dereferenceable(60) %8) #4
  call void @llvm.lifetime.end.p0(i64 64, ptr nonnull %8) #4
  ret i32 %17

26:                                               ; preds = %23, %18
  %.pn = phi { ptr, i32 } [ %24, %23 ], [ %19, %18 ]
  call void @_ZN20HighsLinearObjectiveD2Ev(ptr noundef nonnull align 8 dereferenceable(60) %8) #4
  call void @llvm.lifetime.end.p0(i64 64, ptr nonnull %8) #4
  resume { ptr, i32 } %.pn
}

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 #3 = { "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, !7, i64 0}
!6 = !{!"_ZTS20HighsLinearObjective", !7, i64 0, !7, i64 8, !10, i64 16, !7, i64 40, !7, i64 48, !15, i64 56}
!7 = !{!"double", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"_ZTSSt6vectorIdSaIdEE", !11, i64 0}
!11 = !{!"_ZTSSt12_Vector_baseIdSaIdEE", !12, i64 0}
!12 = !{!"_ZTSNSt12_Vector_baseIdSaIdEE12_Vector_implE", !13, i64 0}
!13 = !{!"_ZTSNSt12_Vector_baseIdSaIdEE17_Vector_impl_dataE", !14, i64 0, !14, i64 8, !14, i64 16}
!14 = !{!"any pointer", !8, i64 0}
!15 = !{!"int", !8, i64 0}
!16 = !{!6, !7, i64 8}
!17 = !{!6, !7, i64 40}
!18 = !{!6, !7, i64 48}
!19 = !{!6, !15, i64 56}
!20 = distinct !{!20, !21}
!21 = !{!"llvm.loop.mustprogress"}


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