; LLVM IR from buresjan/optim_lbm :: nomad/src/Algos/TrialPointStats.ll (ZN9NOMAD_4_315TrialPointStats17updateParentStatsEv)

; 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.NOMAD_4_3::TrialPointStats" = type { ptr, %"class.std::vector", %"class.std::map", %"class.std::map", %"class.std::map", %"class.std::map", i64 }
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<NOMAD_4_3::EvalType, std::allocator<NOMAD_4_3::EvalType>>::_Vector_impl" }
%"struct.std::_Vector_base<NOMAD_4_3::EvalType, std::allocator<NOMAD_4_3::EvalType>>::_Vector_impl" = type { %"struct.std::_Vector_base<NOMAD_4_3::EvalType, std::allocator<NOMAD_4_3::EvalType>>::_Vector_impl_data" }
%"struct.std::_Vector_base<NOMAD_4_3::EvalType, std::allocator<NOMAD_4_3::EvalType>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.std::map" = type { %"class.std::_Rb_tree.6" }
%"class.std::_Rb_tree.6" = type { %"struct.std::_Rb_tree<NOMAD_4_3::EvalType, std::pair<const NOMAD_4_3::EvalType, unsigned long>, std::_Select1st<std::pair<const NOMAD_4_3::EvalType, unsigned long>>, std::less<NOMAD_4_3::EvalType>>::_Rb_tree_impl" }
%"struct.std::_Rb_tree<NOMAD_4_3::EvalType, std::pair<const NOMAD_4_3::EvalType, unsigned long>, std::_Select1st<std::pair<const NOMAD_4_3::EvalType, unsigned long>>, std::less<NOMAD_4_3::EvalType>>::_Rb_tree_impl" = type { [8 x i8], %"struct.std::_Rb_tree_header" }
%"struct.std::_Rb_tree_header" = type { %"struct.std::_Rb_tree_node_base", i64 }
%"struct.std::_Rb_tree_node_base" = type { i32, ptr, ptr, ptr }

@_ZTIN9NOMAD_4_34StepE = external constant ptr
@_ZTIN9NOMAD_4_314IterationUtilsE = external constant ptr
@_ZTIN9NOMAD_4_39AlgorithmE = external constant ptr

; 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: mustprogress uwtable
define dso_local void @_ZN9NOMAD_4_315TrialPointStats17updateParentStatsEv(ptr noundef nonnull align 8 dereferenceable(232) %0) #1 align 2 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  %6 = load ptr, ptr %2, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #5
  %7 = getelementptr inbounds %"class.NOMAD_4_3::TrialPointStats", ptr %6, i32 0, i32 0
  %8 = load ptr, ptr %7, align 8, !tbaa !9
  store ptr %8, ptr %3, align 8, !tbaa !5
  br label %9

9:                                                ; preds = %49, %1
  %10 = load ptr, ptr %3, align 8, !tbaa !5
  %11 = icmp ne ptr null, %10
  br i1 %11, label %12, label %52

12:                                               ; preds = %9
  %13 = load ptr, ptr %3, align 8, !tbaa !5
  %14 = icmp eq ptr %13, null
  br i1 %14, label %17, label %15

15:                                               ; preds = %12
  %16 = call ptr @__dynamic_cast(ptr %13, ptr @_ZTIN9NOMAD_4_34StepE, ptr @_ZTIN9NOMAD_4_314IterationUtilsE, i64 -2) #5
  br label %18

17:                                               ; preds = %12
  br label %18

18:                                               ; preds = %17, %15
  %19 = phi ptr [ %16, %15 ], [ null, %17 ]
  %20 = icmp ne ptr null, %19
  br i1 %20, label %21, label %30

21:                                               ; preds = %18
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #5
  %22 = load ptr, ptr %3, align 8, !tbaa !5
  %23 = icmp eq ptr %22, null
  br i1 %23, label %26, label %24

24:                                               ; preds = %21
  %25 = call ptr @__dynamic_cast(ptr %22, ptr @_ZTIN9NOMAD_4_34StepE, ptr @_ZTIN9NOMAD_4_314IterationUtilsE, i64 -2) #5
  br label %27

26:                                               ; preds = %21
  br label %27

27:                                               ; preds = %26, %24
  %28 = phi ptr [ %25, %24 ], [ null, %26 ]
  store ptr %28, ptr %4, align 8, !tbaa !5
  %29 = load ptr, ptr %4, align 8, !tbaa !5
  call void @_ZN9NOMAD_4_314IterationUtils11updateStatsERNS_15TrialPointStatsE(ptr noundef nonnull align 8 dereferenceable(328) %29, ptr noundef nonnull align 8 dereferenceable(232) %6)
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #5
  br label %52

30:                                               ; preds = %18
  %31 = load ptr, ptr %3, align 8, !tbaa !5
  %32 = icmp eq ptr %31, null
  br i1 %32, label %35, label %33

33:                                               ; preds = %30
  %34 = call ptr @__dynamic_cast(ptr %31, ptr @_ZTIN9NOMAD_4_34StepE, ptr @_ZTIN9NOMAD_4_39AlgorithmE, i64 0) #5
  br label %36

35:                                               ; preds = %30
  br label %36

36:                                               ; preds = %35, %33
  %37 = phi ptr [ %34, %33 ], [ null, %35 ]
  %38 = icmp ne ptr null, %37
  br i1 %38, label %39, label %48

39:                                               ; preds = %36
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #5
  %40 = load ptr, ptr %3, align 8, !tbaa !5
  %41 = icmp eq ptr %40, null
  br i1 %41, label %44, label %42

42:                                               ; preds = %39
  %43 = call ptr @__dynamic_cast(ptr %40, ptr @_ZTIN9NOMAD_4_34StepE, ptr @_ZTIN9NOMAD_4_39AlgorithmE, i64 0) #5
  br label %45

44:                                               ; preds = %39
  br label %45

45:                                               ; preds = %44, %42
  %46 = phi ptr [ %43, %42 ], [ null, %44 ]
  store ptr %46, ptr %5, align 8, !tbaa !5
  %47 = load ptr, ptr %5, align 8, !tbaa !5
  call void @_ZN9NOMAD_4_39Algorithm11updateStatsERNS_15TrialPointStatsE(ptr noundef nonnull align 8 dereferenceable(417) %47, ptr noundef nonnull align 8 dereferenceable(232) %6)
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #5
  br label %52

48:                                               ; preds = %36
  br label %49

49:                                               ; preds = %48
  %50 = load ptr, ptr %3, align 8, !tbaa !5
  %51 = call noundef ptr @_ZNK9NOMAD_4_34Step13getParentStepEv(ptr noundef nonnull align 8 dereferenceable(140) %50)
  store ptr %51, ptr %3, align 8, !tbaa !5
  br label %9, !llvm.loop !24

52:                                               ; preds = %45, %27, %9
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #5
  ret void
}

; Function Attrs: nounwind willreturn memory(read)
declare ptr @__dynamic_cast(ptr, ptr, ptr, i64) #2

declare void @_ZN9NOMAD_4_314IterationUtils11updateStatsERNS_15TrialPointStatsE(ptr noundef nonnull align 8 dereferenceable(328), ptr noundef nonnull align 8 dereferenceable(232)) #3

declare void @_ZN9NOMAD_4_39Algorithm11updateStatsERNS_15TrialPointStatsE(ptr noundef nonnull align 8 dereferenceable(417), ptr noundef nonnull align 8 dereferenceable(232)) #3

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZNK9NOMAD_4_34Step13getParentStepEv(ptr noundef nonnull align 8 dereferenceable(140)) #4 align 2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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" }
attributes #2 = { nounwind willreturn memory(read) }
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 = { 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 #5 = { 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, !6, i64 0}
!10 = !{!"_ZTSN9NOMAD_4_315TrialPointStatsE", !6, i64 0, !11, i64 8, !15, i64 32, !15, i64 80, !15, i64 128, !15, i64 176, !23, i64 224}
!11 = !{!"_ZTSSt6vectorIN9NOMAD_4_38EvalTypeESaIS1_EE", !12, i64 0}
!12 = !{!"_ZTSSt12_Vector_baseIN9NOMAD_4_38EvalTypeESaIS1_EE", !13, i64 0}
!13 = !{!"_ZTSNSt12_Vector_baseIN9NOMAD_4_38EvalTypeESaIS1_EE12_Vector_implE", !14, i64 0}
!14 = !{!"_ZTSNSt12_Vector_baseIN9NOMAD_4_38EvalTypeESaIS1_EE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!15 = !{!"_ZTSSt3mapIN9NOMAD_4_38EvalTypeEmSt4lessIS1_ESaISt4pairIKS1_mEEE", !16, i64 0}
!16 = !{!"_ZTSSt8_Rb_treeIN9NOMAD_4_38EvalTypeESt4pairIKS1_mESt10_Select1stIS4_ESt4lessIS1_ESaIS4_EE", !17, i64 0}
!17 = !{!"_ZTSNSt8_Rb_treeIN9NOMAD_4_38EvalTypeESt4pairIKS1_mESt10_Select1stIS4_ESt4lessIS1_ESaIS4_EE13_Rb_tree_implIS8_Lb1EEE", !18, i64 0, !20, i64 8}
!18 = !{!"_ZTSSt20_Rb_tree_key_compareISt4lessIN9NOMAD_4_38EvalTypeEEE", !19, i64 0}
!19 = !{!"_ZTSSt4lessIN9NOMAD_4_38EvalTypeEE"}
!20 = !{!"_ZTSSt15_Rb_tree_header", !21, i64 0, !23, i64 32}
!21 = !{!"_ZTSSt18_Rb_tree_node_base", !22, i64 0, !6, i64 8, !6, i64 16, !6, i64 24}
!22 = !{!"_ZTSSt14_Rb_tree_color", !7, i64 0}
!23 = !{!"long", !7, i64 0}
!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"

@_ZTIN9NOMAD_4_34StepE = external constant ptr
@_ZTIN9NOMAD_4_314IterationUtilsE = external constant ptr
@_ZTIN9NOMAD_4_39AlgorithmE = external constant ptr

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN9NOMAD_4_315TrialPointStats17updateParentStatsEv(ptr noundef nonnull align 8 dereferenceable(232) %0) local_unnamed_addr #0 align 2 {
  %2 = load ptr, ptr %0, align 8, !tbaa !5
  %.not13 = icmp eq ptr %2, null
  br i1 %.not13, label %.loopexit, label %.lr.ph

.lr.ph:                                           ; preds = %1, %8
  %.014 = phi ptr [ %9, %8 ], [ %2, %1 ]
  %3 = tail call ptr @__dynamic_cast(ptr nonnull %.014, ptr nonnull @_ZTIN9NOMAD_4_34StepE, ptr nonnull @_ZTIN9NOMAD_4_314IterationUtilsE, i64 -2) #4
  %.not9 = icmp eq ptr %3, null
  br i1 %.not9, label %5, label %4

4:                                                ; preds = %.lr.ph
  tail call void @_ZN9NOMAD_4_314IterationUtils11updateStatsERNS_15TrialPointStatsE(ptr noundef nonnull align 8 dereferenceable(328) %3, ptr noundef nonnull align 8 dereferenceable(232) %0)
  br label %.loopexit

5:                                                ; preds = %.lr.ph
  %6 = tail call ptr @__dynamic_cast(ptr nonnull %.014, ptr nonnull @_ZTIN9NOMAD_4_34StepE, ptr nonnull @_ZTIN9NOMAD_4_39AlgorithmE, i64 0) #4
  %.not10 = icmp eq ptr %6, null
  br i1 %.not10, label %8, label %7

7:                                                ; preds = %5
  tail call void @_ZN9NOMAD_4_39Algorithm11updateStatsERNS_15TrialPointStatsE(ptr noundef nonnull align 8 dereferenceable(417) %6, ptr noundef nonnull align 8 dereferenceable(232) %0)
  br label %.loopexit

8:                                                ; preds = %5
  %9 = tail call noundef ptr @_ZNK9NOMAD_4_34Step13getParentStepEv(ptr noundef nonnull align 8 dereferenceable(140) %.014)
  %.not = icmp eq ptr %9, null
  br i1 %.not, label %.loopexit, label %.lr.ph, !llvm.loop !23

.loopexit:                                        ; preds = %8, %1, %7, %4
  ret void
}

; Function Attrs: mustprogress nofree nounwind willreturn memory(read)
declare ptr @__dynamic_cast(ptr, ptr, ptr, i64) local_unnamed_addr #1

declare void @_ZN9NOMAD_4_314IterationUtils11updateStatsERNS_15TrialPointStatsE(ptr noundef nonnull align 8 dereferenceable(328), ptr noundef nonnull align 8 dereferenceable(232)) local_unnamed_addr #2

declare void @_ZN9NOMAD_4_39Algorithm11updateStatsERNS_15TrialPointStatsE(ptr noundef nonnull align 8 dereferenceable(417), ptr noundef nonnull align 8 dereferenceable(232)) local_unnamed_addr #2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZNK9NOMAD_4_34Step13getParentStepEv(ptr noundef nonnull align 8 dereferenceable(140)) local_unnamed_addr #3 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 nofree nounwind willreturn memory(read) }
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 = { 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 #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 = !{!"_ZTSN9NOMAD_4_315TrialPointStatsE", !7, i64 0, !10, i64 8, !14, i64 32, !14, i64 80, !14, i64 128, !14, i64 176, !22, i64 224}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"_ZTSSt6vectorIN9NOMAD_4_38EvalTypeESaIS1_EE", !11, i64 0}
!11 = !{!"_ZTSSt12_Vector_baseIN9NOMAD_4_38EvalTypeESaIS1_EE", !12, i64 0}
!12 = !{!"_ZTSNSt12_Vector_baseIN9NOMAD_4_38EvalTypeESaIS1_EE12_Vector_implE", !13, i64 0}
!13 = !{!"_ZTSNSt12_Vector_baseIN9NOMAD_4_38EvalTypeESaIS1_EE17_Vector_impl_dataE", !7, i64 0, !7, i64 8, !7, i64 16}
!14 = !{!"_ZTSSt3mapIN9NOMAD_4_38EvalTypeEmSt4lessIS1_ESaISt4pairIKS1_mEEE", !15, i64 0}
!15 = !{!"_ZTSSt8_Rb_treeIN9NOMAD_4_38EvalTypeESt4pairIKS1_mESt10_Select1stIS4_ESt4lessIS1_ESaIS4_EE", !16, i64 0}
!16 = !{!"_ZTSNSt8_Rb_treeIN9NOMAD_4_38EvalTypeESt4pairIKS1_mESt10_Select1stIS4_ESt4lessIS1_ESaIS4_EE13_Rb_tree_implIS8_Lb1EEE", !17, i64 0, !19, i64 8}
!17 = !{!"_ZTSSt20_Rb_tree_key_compareISt4lessIN9NOMAD_4_38EvalTypeEEE", !18, i64 0}
!18 = !{!"_ZTSSt4lessIN9NOMAD_4_38EvalTypeEE"}
!19 = !{!"_ZTSSt15_Rb_tree_header", !20, i64 0, !22, i64 32}
!20 = !{!"_ZTSSt18_Rb_tree_node_base", !21, i64 0, !7, i64 8, !7, i64 16, !7, i64 24}
!21 = !{!"_ZTSSt14_Rb_tree_color", !8, i64 0}
!22 = !{!"long", !8, i64 0}
!23 = distinct !{!23, !24}
!24 = !{!"llvm.loop.mustprogress"}


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