; LLVM IR from ERGO-Code/HiGHS :: src/model/HighsHessianUtils.ll (Z13reportHessianRK15HighsLogOptionsiiPKiS3_PKd)

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

@.str.78 = external hidden unnamed_addr constant [34 x i8], align 1
@.str.79 = external hidden unnamed_addr constant [22 x i8], align 1
@.str.80 = external hidden unnamed_addr constant [20 x i8], align 1
@.str.81 = external hidden unnamed_addr constant [27 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

declare void @_Z12highsLogUserRK15HighsLogOptions12HighsLogTypePKcz(ptr noundef nonnull align 8 dereferenceable(89), i32 noundef, ptr noundef, ...) #1

; Function Attrs: mustprogress uwtable
define dso_local void @_Z13reportHessianRK15HighsLogOptionsiiPKiS3_PKd(ptr noundef nonnull align 8 dereferenceable(89) %0, i32 noundef %1, i32 noundef %2, ptr noundef %3, ptr noundef %4, ptr noundef %5) #2 {
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  %16 = alloca i32, align 4
  store ptr %0, ptr %7, align 8, !tbaa !5
  store i32 %1, ptr %8, align 4, !tbaa !9
  store i32 %2, ptr %9, align 4, !tbaa !9
  store ptr %3, ptr %10, align 8, !tbaa !5
  store ptr %4, ptr %11, align 8, !tbaa !5
  store ptr %5, ptr %12, align 8, !tbaa !5
  %17 = load i32, ptr %8, align 4, !tbaa !9
  %18 = icmp sle i32 %17, 0
  br i1 %18, label %19, label %20

19:                                               ; preds = %6
  br label %82

20:                                               ; preds = %6
  %21 = load ptr, ptr %7, align 8, !tbaa !5
  call void (ptr, i32, ptr, ...) @_Z12highsLogUserRK15HighsLogOptions12HighsLogTypePKcz(ptr noundef nonnull align 8 dereferenceable(89) %21, i32 noundef 1, ptr noundef @.str.78)
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #3
  store i32 0, ptr %13, align 4, !tbaa !9
  br label %22

22:                                               ; preds = %76, %20
  %23 = load i32, ptr %13, align 4, !tbaa !9
  %24 = load i32, ptr %8, align 4, !tbaa !9
  %25 = icmp slt i32 %23, %24
  br i1 %25, label %27, label %26

26:                                               ; preds = %22
  store i32 2, ptr %14, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #3
  br label %79

27:                                               ; preds = %22
  %28 = load ptr, ptr %7, align 8, !tbaa !5
  %29 = load i32, ptr %13, align 4, !tbaa !9
  %30 = load ptr, ptr %10, align 8, !tbaa !5
  %31 = load i32, ptr %13, align 4, !tbaa !9
  %32 = sext i32 %31 to i64
  %33 = getelementptr inbounds i32, ptr %30, i64 %32
  %34 = load i32, ptr %33, align 4, !tbaa !9
  call void (ptr, i32, ptr, ...) @_Z12highsLogUserRK15HighsLogOptions12HighsLogTypePKcz(ptr noundef nonnull align 8 dereferenceable(89) %28, i32 noundef 1, ptr noundef @.str.79, i32 noundef %29, i32 noundef %34)
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #3
  %35 = load i32, ptr %13, align 4, !tbaa !9
  %36 = load i32, ptr %8, align 4, !tbaa !9
  %37 = sub nsw i32 %36, 1
  %38 = icmp slt i32 %35, %37
  br i1 %38, label %39, label %46

39:                                               ; preds = %27
  %40 = load ptr, ptr %10, align 8, !tbaa !5
  %41 = load i32, ptr %13, align 4, !tbaa !9
  %42 = add nsw i32 %41, 1
  %43 = sext i32 %42 to i64
  %44 = getelementptr inbounds i32, ptr %40, i64 %43
  %45 = load i32, ptr %44, align 4, !tbaa !9
  br label %48

46:                                               ; preds = %27
  %47 = load i32, ptr %9, align 4, !tbaa !9
  br label %48

48:                                               ; preds = %46, %39
  %49 = phi i32 [ %45, %39 ], [ %47, %46 ]
  store i32 %49, ptr %15, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #3
  %50 = load ptr, ptr %10, align 8, !tbaa !5
  %51 = load i32, ptr %13, align 4, !tbaa !9
  %52 = sext i32 %51 to i64
  %53 = getelementptr inbounds i32, ptr %50, i64 %52
  %54 = load i32, ptr %53, align 4, !tbaa !9
  store i32 %54, ptr %16, align 4, !tbaa !9
  br label %55

55:                                               ; preds = %72, %48
  %56 = load i32, ptr %16, align 4, !tbaa !9
  %57 = load i32, ptr %15, align 4, !tbaa !9
  %58 = icmp slt i32 %56, %57
  br i1 %58, label %60, label %59

59:                                               ; preds = %55
  store i32 5, ptr %14, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #3
  br label %75

60:                                               ; preds = %55
  %61 = load ptr, ptr %7, align 8, !tbaa !5
  %62 = load ptr, ptr %11, align 8, !tbaa !5
  %63 = load i32, ptr %16, align 4, !tbaa !9
  %64 = sext i32 %63 to i64
  %65 = getelementptr inbounds i32, ptr %62, i64 %64
  %66 = load i32, ptr %65, align 4, !tbaa !9
  %67 = load ptr, ptr %12, align 8, !tbaa !5
  %68 = load i32, ptr %16, align 4, !tbaa !9
  %69 = sext i32 %68 to i64
  %70 = getelementptr inbounds double, ptr %67, i64 %69
  %71 = load double, ptr %70, align 8, !tbaa !11
  call void (ptr, i32, ptr, ...) @_Z12highsLogUserRK15HighsLogOptions12HighsLogTypePKcz(ptr noundef nonnull align 8 dereferenceable(89) %61, i32 noundef 1, ptr noundef @.str.80, i32 noundef %66, double noundef %71)
  br label %72

72:                                               ; preds = %60
  %73 = load i32, ptr %16, align 4, !tbaa !9
  %74 = add nsw i32 %73, 1
  store i32 %74, ptr %16, align 4, !tbaa !9
  br label %55, !llvm.loop !13

75:                                               ; preds = %59
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #3
  br label %76

76:                                               ; preds = %75
  %77 = load i32, ptr %13, align 4, !tbaa !9
  %78 = add nsw i32 %77, 1
  store i32 %78, ptr %13, align 4, !tbaa !9
  br label %22, !llvm.loop !15

79:                                               ; preds = %26
  %80 = load ptr, ptr %7, align 8, !tbaa !5
  %81 = load i32, ptr %9, align 4, !tbaa !9
  call void (ptr, i32, ptr, ...) @_Z12highsLogUserRK15HighsLogOptions12HighsLogTypePKcz(ptr noundef nonnull align 8 dereferenceable(89) %80, i32 noundef 1, ptr noundef @.str.81, i32 noundef %81)
  br label %82

82:                                               ; preds = %79, %19
  ret void
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 = { 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}
!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"

@.str.78 = external hidden unnamed_addr constant [34 x i8], align 1
@.str.79 = external hidden unnamed_addr constant [22 x i8], align 1
@.str.80 = external hidden unnamed_addr constant [20 x i8], align 1
@.str.81 = external hidden unnamed_addr constant [27 x i8], align 1

declare void @_Z12highsLogUserRK15HighsLogOptions12HighsLogTypePKcz(ptr noundef nonnull align 8 dereferenceable(89), i32 noundef, ptr noundef, ...) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
define dso_local void @_Z13reportHessianRK15HighsLogOptionsiiPKiS3_PKd(ptr noundef nonnull align 8 dereferenceable(89) %0, i32 noundef %1, i32 noundef %2, ptr nocapture noundef readonly %3, ptr nocapture noundef readonly %4, ptr nocapture noundef readonly %5) local_unnamed_addr #1 {
  %7 = icmp slt i32 %1, 1
  br i1 %7, label %29, label %8

8:                                                ; preds = %6
  tail call void (ptr, i32, ptr, ...) @_Z12highsLogUserRK15HighsLogOptions12HighsLogTypePKcz(ptr noundef nonnull align 8 dereferenceable(89) %0, i32 noundef 1, ptr noundef nonnull @.str.78)
  %9 = add nsw i32 %1, -1
  %10 = zext nneg i32 %9 to i64
  %wide.trip.count = zext nneg i32 %1 to i64
  br label %12

11:                                               ; preds = %._crit_edge
  tail call void (ptr, i32, ptr, ...) @_Z12highsLogUserRK15HighsLogOptions12HighsLogTypePKcz(ptr noundef nonnull align 8 dereferenceable(89) %0, i32 noundef 1, ptr noundef nonnull @.str.81, i32 noundef %2)
  br label %29

12:                                               ; preds = %8, %._crit_edge
  %indvars.iv30 = phi i64 [ 0, %8 ], [ %indvars.iv.next31, %._crit_edge ]
  %13 = getelementptr inbounds i32, ptr %3, i64 %indvars.iv30
  %14 = load i32, ptr %13, align 4, !tbaa !5
  %15 = trunc nuw nsw i64 %indvars.iv30 to i32
  tail call void (ptr, i32, ptr, ...) @_Z12highsLogUserRK15HighsLogOptions12HighsLogTypePKcz(ptr noundef nonnull align 8 dereferenceable(89) %0, i32 noundef 1, ptr noundef nonnull @.str.79, i32 noundef %15, i32 noundef %14)
  %16 = icmp ult i64 %indvars.iv30, %10
  br i1 %16, label %17, label %20

17:                                               ; preds = %12
  %18 = getelementptr inbounds i8, ptr %13, i64 4
  %19 = load i32, ptr %18, align 4, !tbaa !5
  br label %20

20:                                               ; preds = %12, %17
  %21 = phi i32 [ %19, %17 ], [ %2, %12 ]
  %22 = load i32, ptr %13, align 4, !tbaa !5
  %23 = icmp slt i32 %22, %21
  br i1 %23, label %.lr.ph.preheader, label %._crit_edge

.lr.ph.preheader:                                 ; preds = %20
  %24 = sext i32 %22 to i64
  br label %.lr.ph

._crit_edge:                                      ; preds = %.lr.ph, %20
  %indvars.iv.next31 = add nuw nsw i64 %indvars.iv30, 1
  %exitcond33.not = icmp eq i64 %indvars.iv.next31, %wide.trip.count
  br i1 %exitcond33.not, label %11, label %12, !llvm.loop !9

.lr.ph:                                           ; preds = %.lr.ph.preheader, %.lr.ph
  %indvars.iv = phi i64 [ %24, %.lr.ph.preheader ], [ %indvars.iv.next, %.lr.ph ]
  %25 = getelementptr inbounds i32, ptr %4, i64 %indvars.iv
  %26 = load i32, ptr %25, align 4, !tbaa !5
  %27 = getelementptr inbounds double, ptr %5, i64 %indvars.iv
  %28 = load double, ptr %27, align 8, !tbaa !11
  tail call void (ptr, i32, ptr, ...) @_Z12highsLogUserRK15HighsLogOptions12HighsLogTypePKcz(ptr noundef nonnull align 8 dereferenceable(89) %0, i32 noundef 1, ptr noundef nonnull @.str.80, i32 noundef %26, double noundef %28)
  %indvars.iv.next = add nsw i64 %indvars.iv, 1
  %lftr.wideiv = trunc i64 %indvars.iv.next to i32
  %exitcond.not = icmp eq i32 %21, %lftr.wideiv
  br i1 %exitcond.not, label %._crit_edge, label %.lr.ph, !llvm.loop !13

29:                                               ; preds = %6, %11
  ret void
}

attributes #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 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" }

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


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