; LLVM IR from optframe/optframe :: demo/03_QuickstartTSP_VNS_BRKGA (mainTSP-fcore-brkga-part1)

; 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, %"class.optframe::Matrix" }
%"class.optframe::Matrix" = type { ptr, i32, i32, ptr }

; Function Attrs: mustprogress uwtable
define dso_local void @_Z9fevaluateN5nnptr8NNSharedI14ProblemContextEERKSt6vectorIiSaIiEE(ptr dead_on_unwind noalias writable sret(%"class.optframe::Evaluation") align 8 %0, ptr noundef %1, ptr noundef nonnull align 8 dereferenceable(24) %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
  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
  br label %9

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

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

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

35:                                               ; preds = %17
  %36 = load i32, ptr %8, align 4, !tbaa !9
  %37 = add nsw i32 %36, 1
  store i32 %37, ptr %8, align 4, !tbaa !9
  br label %9, !llvm.loop !14

38:                                               ; preds = %16
  %39 = call noundef ptr @_ZN5nnptr8NNSharedI14ProblemContextEptEv(ptr noundef nonnull align 8 dereferenceable(16) %1)
  %40 = getelementptr inbounds %class.ProblemContext, ptr %39, i32 0, i32 1
  %41 = load ptr, ptr %6, align 8, !tbaa !5
  %42 = call noundef ptr @_ZN5nnptr8NNSharedI14ProblemContextEptEv(ptr noundef nonnull align 8 dereferenceable(16) %1)
  %43 = getelementptr inbounds %class.ProblemContext, ptr %42, i32 0, i32 0
  %44 = load i32, ptr %43, align 8, !tbaa !11
  %45 = sub nsw i32 %44, 1
  %46 = sext i32 %45 to i64
  %47 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNKSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %41, i64 noundef %46) #3
  %48 = load i32, ptr %47, align 4, !tbaa !9
  %49 = load ptr, ptr %6, align 8, !tbaa !5
  %50 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNKSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %49, i64 noundef 0) #3
  %51 = load i32, ptr %50, align 4, !tbaa !9
  %52 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZN8optframe6MatrixIiEclEjj(ptr noundef nonnull align 8 dereferenceable(24) %40, i32 noundef %48, i32 noundef %51) #3
  %53 = load i32, ptr %52, align 4, !tbaa !9
  %54 = load i32, ptr %7, align 4, !tbaa !9
  %55 = add nsw i32 %54, %53
  store i32 %55, ptr %7, align 4, !tbaa !9
  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 %7) #3
  ret void
}

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

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

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

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

; 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
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, !13, i64 8}
!13 = !{!"_ZTSN8optframe6MatrixIiEE", !10, i64 8, !10, i64 12, !6, i64 16}
!14 = distinct !{!14, !15}
!15 = !{!"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"

%"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
define dso_local void @_Z9fevaluateN5nnptr8NNSharedI14ProblemContextEERKSt6vectorIiSaIiEE(ptr dead_on_unwind noalias writable sret(%"class.optframe::Evaluation") align 8 %0, ptr noundef nonnull %1, ptr noundef nonnull align 8 dereferenceable(24) %2) local_unnamed_addr #0 {
  %4 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %4) #3
  %5 = tail call noundef ptr @_ZN5nnptr8NNSharedI14ProblemContextEptEv(ptr noundef nonnull align 8 dereferenceable(16) %1)
  %6 = load i32, ptr %5, align 8, !tbaa !5
  %7 = icmp sgt i32 %6, 1
  br i1 %7, label %.lr.ph, label %._crit_edge

._crit_edge:                                      ; preds = %.lr.ph, %3
  %8 = phi i32 [ 0, %3 ], [ %30, %.lr.ph ]
  %9 = tail call noundef ptr @_ZN5nnptr8NNSharedI14ProblemContextEptEv(ptr noundef nonnull align 8 dereferenceable(16) %1)
  %10 = getelementptr inbounds i8, ptr %9, i64 8
  %11 = tail call noundef ptr @_ZN5nnptr8NNSharedI14ProblemContextEptEv(ptr noundef nonnull align 8 dereferenceable(16) %1)
  %12 = load i32, ptr %11, align 8, !tbaa !5
  %13 = add nsw i32 %12, -1
  %14 = sext i32 %13 to i64
  %15 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNKSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %2, i64 noundef %14) #3
  %16 = load i32, ptr %15, align 4, !tbaa !12
  %17 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNKSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %2, i64 noundef 0) #3
  %18 = load i32, ptr %17, align 4, !tbaa !12
  %19 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZN8optframe6MatrixIiEclEjj(ptr noundef nonnull align 8 dereferenceable(24) %10, i32 noundef %16, i32 noundef %18) #3
  %20 = load i32, ptr %19, align 4, !tbaa !12
  %21 = add nsw i32 %8, %20
  store i32 %21, ptr %4, align 4, !tbaa !12
  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

.lr.ph:                                           ; preds = %3, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 0, %3 ]
  %storemerge7 = phi i32 [ %30, %.lr.ph ], [ 0, %3 ]
  %22 = tail call noundef ptr @_ZN5nnptr8NNSharedI14ProblemContextEptEv(ptr noundef nonnull align 8 dereferenceable(16) %1)
  %23 = getelementptr inbounds i8, ptr %22, i64 8
  %24 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNKSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %2, i64 noundef %indvars.iv) #3
  %25 = load i32, ptr %24, align 4, !tbaa !12
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %26 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNKSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %2, i64 noundef %indvars.iv.next) #3
  %27 = load i32, ptr %26, align 4, !tbaa !12
  %28 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZN8optframe6MatrixIiEclEjj(ptr noundef nonnull align 8 dereferenceable(24) %23, i32 noundef %25, i32 noundef %27) #3
  %29 = load i32, ptr %28, align 4, !tbaa !12
  %30 = add nsw i32 %storemerge7, %29
  %31 = tail call noundef ptr @_ZN5nnptr8NNSharedI14ProblemContextEptEv(ptr noundef nonnull align 8 dereferenceable(16) %1)
  %32 = load i32, ptr %31, align 8, !tbaa !5
  %33 = add nsw i32 %32, -1
  %34 = sext i32 %33 to i64
  %35 = icmp slt i64 %indvars.iv.next, %34
  br i1 %35, label %.lr.ph, label %._crit_edge, !llvm.loop !13
}

; 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 uwtable
declare dso_local noundef ptr @_ZN5nnptr8NNSharedI14ProblemContextEptEv(ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #0 align 2

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

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

; 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
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, !7, i64 0}
!6 = !{!"_ZTS14ProblemContext", !7, i64 0, !10, i64 8}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"_ZTSN8optframe6MatrixIiEE", !7, i64 8, !7, i64 12, !11, i64 16}
!11 = !{!"any pointer", !8, i64 0}
!12 = !{!7, !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}


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