; LLVM IR from optframe/optframe :: demo/02_QuickstartKP_SA (mainKP-fcore-ex)

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

%"class.optframe::Evaluation" = type <{ %"class.optframe::Component.base", [3 x i8], i32, i32, i32, i8, i8, [6 x i8] }>
%"class.optframe::Component.base" = type <{ ptr, ptr, ptr, i32, i8, i8, i8, i8, i8 }>
%class.ProblemContext = type { i32, i32, %"class.std::vector.3", %"class.std::vector.3" }
%"class.std::vector.3" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl" }
%"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl" = type { %"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl_data" }
%"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl_data" = type { ptr, ptr, ptr }

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_ZN5nnptr8NNSharedI14ProblemContextEptEv(ptr noundef nonnull align 8 dereferenceable(16)) #0 align 2

; 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 willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: mustprogress uwtable
define dso_local void @_Z9fevaluateN5nnptr8NNSharedI14ProblemContextEERKSt6vectorIbSaIbEE(ptr dead_on_unwind noalias writable sret(%"class.optframe::Evaluation") align 8 %0, ptr noundef %1, ptr noundef nonnull align 8 dereferenceable(40) %2) #0 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  store ptr %0, ptr %4, align 8
  store ptr %1, ptr %5, align 8, !tbaa !5
  store ptr %2, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  store i32 0, ptr %7, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #3
  store i32 0, ptr %8, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #3
  store i32 0, ptr %9, align 4, !tbaa !9
  br label %10

10:                                               ; preds = %40, %3
  %11 = load i32, ptr %9, align 4, !tbaa !9
  %12 = call noundef ptr @_ZN5nnptr8NNSharedI14ProblemContextEptEv(ptr noundef nonnull align 8 dereferenceable(16) %1)
  %13 = getelementptr inbounds %class.ProblemContext, ptr %12, i32 0, i32 0
  %14 = load i32, ptr %13, align 8, !tbaa !11
  %15 = icmp slt i32 %11, %14
  br i1 %15, label %17, label %16

16:                                               ; preds = %10
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #3
  br label %43

17:                                               ; preds = %10
  %18 = load ptr, ptr %6, align 8, !tbaa !5
  %19 = load i32, ptr %9, align 4, !tbaa !9
  %20 = sext i32 %19 to i64
  %21 = call noundef zeroext i1 @_ZNKSt6vectorIbSaIbEEixEm(ptr noundef nonnull align 8 dereferenceable(40) %18, i64 noundef %20)
  br i1 %21, label %22, label %39

22:                                               ; preds = %17
  %23 = call noundef ptr @_ZN5nnptr8NNSharedI14ProblemContextEptEv(ptr noundef nonnull align 8 dereferenceable(16) %1)
  %24 = getelementptr inbounds %class.ProblemContext, ptr %23, i32 0, i32 2
  %25 = load i32, ptr %9, align 4, !tbaa !9
  %26 = sext i32 %25 to i64
  %27 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %24, i64 noundef %26) #3
  %28 = load i32, ptr %27, align 4, !tbaa !9
  %29 = load i32, ptr %7, align 4, !tbaa !9
  %30 = add nsw i32 %29, %28
  store i32 %30, ptr %7, align 4, !tbaa !9
  %31 = call noundef ptr @_ZN5nnptr8NNSharedI14ProblemContextEptEv(ptr noundef nonnull align 8 dereferenceable(16) %1)
  %32 = getelementptr inbounds %class.ProblemContext, ptr %31, i32 0, i32 3
  %33 = load i32, ptr %9, align 4, !tbaa !9
  %34 = sext i32 %33 to i64
  %35 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %32, i64 noundef %34) #3
  %36 = load i32, ptr %35, align 4, !tbaa !9
  %37 = load i32, ptr %8, align 4, !tbaa !9
  %38 = add nsw i32 %37, %36
  store i32 %38, ptr %8, align 4, !tbaa !9
  br label %39

39:                                               ; preds = %22, %17
  br label %40

40:                                               ; preds = %39
  %41 = load i32, ptr %9, align 4, !tbaa !9
  %42 = add nsw i32 %41, 1
  store i32 %42, ptr %9, align 4, !tbaa !9
  br label %10, !llvm.loop !17

43:                                               ; preds = %16
  %44 = load i32, ptr %8, align 4, !tbaa !9
  %45 = call noundef ptr @_ZN5nnptr8NNSharedI14ProblemContextEptEv(ptr noundef nonnull align 8 dereferenceable(16) %1)
  %46 = getelementptr inbounds %class.ProblemContext, ptr %45, i32 0, i32 1
  %47 = load i32, ptr %46, align 4, !tbaa !19
  %48 = icmp sge i32 %44, %47
  br i1 %48, label %49, label %58

49:                                               ; preds = %43
  %50 = load i32, ptr %8, align 4, !tbaa !9
  %51 = call noundef ptr @_ZN5nnptr8NNSharedI14ProblemContextEptEv(ptr noundef nonnull align 8 dereferenceable(16) %1)
  %52 = getelementptr inbounds %class.ProblemContext, ptr %51, i32 0, i32 1
  %53 = load i32, ptr %52, align 4, !tbaa !19
  %54 = sub nsw i32 %50, %53
  %55 = mul nsw i32 1000000, %54
  %56 = load i32, ptr %7, align 4, !tbaa !9
  %57 = sub nsw i32 %56, %55
  store i32 %57, ptr %7, align 4, !tbaa !9
  br label %58

58:                                               ; preds = %49, %43
  call void @_ZN8optframe10EvaluationIiEC2ERKi(ptr noundef nonnull align 8 dereferenceable(56) %0, ptr noundef nonnull align 4 dereferenceable(4) %7)
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  ret void
}

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZNKSt6vectorIbSaIbEEixEm(ptr noundef nonnull align 8 dereferenceable(40), i64 noundef) #0 align 2

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN8optframe10EvaluationIiEC2ERKi(ptr noundef nonnull align 8 dereferenceable(56), ptr noundef nonnull align 4 dereferenceable(4)) unnamed_addr #0 align 2

attributes #0 = { 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 #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #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, !10, i64 0}
!12 = !{!"_ZTS14ProblemContext", !10, i64 0, !10, i64 4, !13, i64 8, !13, i64 32}
!13 = !{!"_ZTSSt6vectorIiSaIiEE", !14, i64 0}
!14 = !{!"_ZTSSt12_Vector_baseIiSaIiEE", !15, i64 0}
!15 = !{!"_ZTSNSt12_Vector_baseIiSaIiEE12_Vector_implE", !16, i64 0}
!16 = !{!"_ZTSNSt12_Vector_baseIiSaIiEE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}
!19 = !{!12, !10, i64 4}


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

%"class.optframe::Evaluation" = type <{ %"class.optframe::Component.base", [3 x i8], i32, i32, i32, i8, i8, [6 x i8] }>
%"class.optframe::Component.base" = type <{ ptr, ptr, ptr, i32, i8, i8, i8, i8, i8 }>

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_ZN5nnptr8NNSharedI14ProblemContextEptEv(ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #0 align 2

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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_Z9fevaluateN5nnptr8NNSharedI14ProblemContextEERKSt6vectorIbSaIbEE(ptr dead_on_unwind noalias writable sret(%"class.optframe::Evaluation") align 8 %0, ptr noundef nonnull %1, ptr noundef nonnull align 8 dereferenceable(40) %2) local_unnamed_addr #0 {
  %4 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %4) #3
  store i32 0, ptr %4, align 4, !tbaa !5
  %5 = tail call noundef ptr @_ZN5nnptr8NNSharedI14ProblemContextEptEv(ptr noundef nonnull align 8 dereferenceable(16) %1)
  %6 = load i32, ptr %5, align 8, !tbaa !9
  %7 = icmp sgt i32 %6, 0
  br i1 %7, label %.lr.ph, label %._crit_edge

._crit_edge:                                      ; preds = %25, %3
  %8 = phi i32 [ 0, %3 ], [ %26, %25 ]
  %.08.lcssa = phi i32 [ 0, %3 ], [ %.1, %25 ]
  %9 = tail call noundef ptr @_ZN5nnptr8NNSharedI14ProblemContextEptEv(ptr noundef nonnull align 8 dereferenceable(16) %1)
  %10 = getelementptr inbounds i8, ptr %9, i64 4
  %11 = load i32, ptr %10, align 4, !tbaa !16
  %.not = icmp slt i32 %.08.lcssa, %11
  br i1 %.not, label %37, label %31

.lr.ph:                                           ; preds = %3, %25
  %indvars.iv = phi i64 [ %indvars.iv.next, %25 ], [ 0, %3 ]
  %.089 = phi i32 [ %.1, %25 ], [ 0, %3 ]
  %12 = phi i32 [ %26, %25 ], [ 0, %3 ]
  %13 = tail call noundef zeroext i1 @_ZNKSt6vectorIbSaIbEEixEm(ptr noundef nonnull align 8 dereferenceable(40) %2, i64 noundef %indvars.iv)
  br i1 %13, label %14, label %25

14:                                               ; preds = %.lr.ph
  %15 = tail call noundef ptr @_ZN5nnptr8NNSharedI14ProblemContextEptEv(ptr noundef nonnull align 8 dereferenceable(16) %1)
  %16 = getelementptr inbounds i8, ptr %15, i64 8
  %17 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %16, i64 noundef %indvars.iv) #3
  %18 = load i32, ptr %17, align 4, !tbaa !5
  %19 = add nsw i32 %12, %18
  store i32 %19, ptr %4, align 4, !tbaa !5
  %20 = tail call noundef ptr @_ZN5nnptr8NNSharedI14ProblemContextEptEv(ptr noundef nonnull align 8 dereferenceable(16) %1)
  %21 = getelementptr inbounds i8, ptr %20, i64 32
  %22 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %21, i64 noundef %indvars.iv) #3
  %23 = load i32, ptr %22, align 4, !tbaa !5
  %24 = add nsw i32 %23, %.089
  br label %25

25:                                               ; preds = %.lr.ph, %14
  %26 = phi i32 [ %19, %14 ], [ %12, %.lr.ph ]
  %.1 = phi i32 [ %24, %14 ], [ %.089, %.lr.ph ]
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %27 = tail call noundef ptr @_ZN5nnptr8NNSharedI14ProblemContextEptEv(ptr noundef nonnull align 8 dereferenceable(16) %1)
  %28 = load i32, ptr %27, align 8, !tbaa !9
  %29 = sext i32 %28 to i64
  %30 = icmp slt i64 %indvars.iv.next, %29
  br i1 %30, label %.lr.ph, label %._crit_edge, !llvm.loop !17

31:                                               ; preds = %._crit_edge
  %32 = tail call noundef ptr @_ZN5nnptr8NNSharedI14ProblemContextEptEv(ptr noundef nonnull align 8 dereferenceable(16) %1)
  %33 = getelementptr inbounds i8, ptr %32, i64 4
  %34 = load i32, ptr %33, align 4, !tbaa !16
  %35 = sub nsw i32 %.08.lcssa, %34
  %.neg = mul i32 %35, -1000000
  %36 = add i32 %.neg, %8
  store i32 %36, ptr %4, align 4, !tbaa !5
  br label %37

37:                                               ; preds = %31, %._crit_edge
  call void @_ZN8optframe10EvaluationIiEC2ERKi(ptr noundef nonnull align 8 dereferenceable(56) %0, ptr noundef nonnull align 4 dereferenceable(4) %4)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %4) #3
  ret void
}

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZNKSt6vectorIbSaIbEEixEm(ptr noundef nonnull align 8 dereferenceable(40), i64 noundef) local_unnamed_addr #0 align 2

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN8optframe10EvaluationIiEC2ERKi(ptr noundef nonnull align 8 dereferenceable(56), ptr noundef nonnull align 4 dereferenceable(4)) unnamed_addr #0 align 2

attributes #0 = { 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 #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #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++ TBAA"}
!9 = !{!10, !6, i64 0}
!10 = !{!"_ZTS14ProblemContext", !6, i64 0, !6, i64 4, !11, i64 8, !11, i64 32}
!11 = !{!"_ZTSSt6vectorIiSaIiEE", !12, i64 0}
!12 = !{!"_ZTSSt12_Vector_baseIiSaIiEE", !13, i64 0}
!13 = !{!"_ZTSNSt12_Vector_baseIiSaIiEE12_Vector_implE", !14, i64 0}
!14 = !{!"_ZTSNSt12_Vector_baseIiSaIiEE17_Vector_impl_dataE", !15, i64 0, !15, i64 8, !15, i64 16}
!15 = !{!"any pointer", !7, i64 0}
!16 = !{!10, !6, i64 4}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}


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