; LLVM IR from buresjan/optim_lbm :: nomad/src/Algos/Step.ll (ZN9NOMAD_4_34Step19updateParentSuccessEv)

; 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::Step" = type <{ ptr, ptr, i32, [4 x i8], %"class.std::shared_ptr", %"class.std::shared_ptr.5", %"class.std::shared_ptr.8", %"class.NOMAD_4_3::SuccessStats", i32, [4 x i8] }>
%"class.std::shared_ptr" = type { %"class.std::__shared_ptr" }
%"class.std::__shared_ptr" = type { ptr, %"class.std::__shared_count" }
%"class.std::__shared_count" = type { ptr }
%"class.std::shared_ptr.5" = type { %"class.std::__shared_ptr.6" }
%"class.std::__shared_ptr.6" = type { ptr, %"class.std::__shared_count" }
%"class.std::shared_ptr.8" = type { %"class.std::__shared_ptr.9" }
%"class.std::__shared_ptr.9" = type { ptr, %"class.std::__shared_count" }
%"class.NOMAD_4_3::SuccessStats" = type { %"class.std::map", i64, i64 }
%"class.std::map" = type { %"class.std::_Rb_tree.11" }
%"class.std::_Rb_tree.11" = type { %"struct.std::_Rb_tree<std::pair<NOMAD_4_3::StepType, NOMAD_4_3::SuccessType>, std::pair<const std::pair<NOMAD_4_3::StepType, NOMAD_4_3::SuccessType>, unsigned long>, std::_Select1st<std::pair<const std::pair<NOMAD_4_3::StepType, NOMAD_4_3::SuccessType>, unsigned long>>, std::less<std::pair<NOMAD_4_3::StepType, NOMAD_4_3::SuccessType>>>::_Rb_tree_impl" }
%"struct.std::_Rb_tree<std::pair<NOMAD_4_3::StepType, NOMAD_4_3::SuccessType>, std::pair<const std::pair<NOMAD_4_3::StepType, NOMAD_4_3::SuccessType>, unsigned long>, std::_Select1st<std::pair<const std::pair<NOMAD_4_3::StepType, NOMAD_4_3::SuccessType>, unsigned long>>, std::less<std::pair<NOMAD_4_3::StepType, NOMAD_4_3::SuccessType>>>::_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 }

; 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_34Step19updateParentSuccessEv(ptr noundef nonnull align 8 dereferenceable(140) %0) #1 align 2 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  %4 = load ptr, ptr %2, align 8
  %5 = getelementptr inbounds %"class.NOMAD_4_3::Step", ptr %4, i32 0, i32 1
  %6 = load ptr, ptr %5, align 8, !tbaa !9
  %7 = icmp eq ptr null, %6
  br i1 %7, label %8, label %9

8:                                                ; preds = %1
  br label %22

9:                                                ; preds = %1
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #3
  %10 = getelementptr inbounds %"class.NOMAD_4_3::Step", ptr %4, i32 0, i32 1
  %11 = load ptr, ptr %10, align 8, !tbaa !9
  store ptr %11, ptr %3, align 8, !tbaa !5
  %12 = getelementptr inbounds %"class.NOMAD_4_3::Step", ptr %4, i32 0, i32 8
  %13 = load i32, ptr %12, align 8, !tbaa !30
  %14 = load ptr, ptr %3, align 8, !tbaa !5
  %15 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNK9NOMAD_4_34Step14getSuccessTypeEv(ptr noundef nonnull align 8 dereferenceable(140) %14)
  %16 = load i32, ptr %15, align 4, !tbaa !31
  %17 = icmp sgt i32 %13, %16
  br i1 %17, label %18, label %21

18:                                               ; preds = %9
  %19 = load ptr, ptr %3, align 8, !tbaa !5
  %20 = getelementptr inbounds %"class.NOMAD_4_3::Step", ptr %4, i32 0, i32 8
  call void @_ZN9NOMAD_4_34Step14setSuccessTypeERKNS_11SuccessTypeE(ptr noundef nonnull align 8 dereferenceable(140) %19, ptr noundef nonnull align 4 dereferenceable(4) %20)
  br label %21

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

22:                                               ; preds = %21, %8
  ret void
}

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN9NOMAD_4_34Step14setSuccessTypeERKNS_11SuccessTypeE(ptr noundef nonnull align 8 dereferenceable(140), ptr noundef nonnull align 4 dereferenceable(4)) #2 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 = { 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, !6, i64 8}
!10 = !{!"_ZTSN9NOMAD_4_34StepE", !6, i64 8, !11, i64 16, !12, i64 24, !15, i64 40, !17, i64 56, !19, i64 72, !29, i64 136}
!11 = !{!"_ZTSN9NOMAD_4_38StepTypeE", !7, i64 0}
!12 = !{!"_ZTSSt10shared_ptrIN9NOMAD_4_314AllStopReasonsEE", !13, i64 0}
!13 = !{!"_ZTSSt12__shared_ptrIN9NOMAD_4_314AllStopReasonsELN9__gnu_cxx12_Lock_policyE2EE", !6, i64 0, !14, i64 8}
!14 = !{!"_ZTSSt14__shared_countILN9__gnu_cxx12_Lock_policyE2EE", !6, i64 0}
!15 = !{!"_ZTSSt10shared_ptrIN9NOMAD_4_313RunParametersEE", !16, i64 0}
!16 = !{!"_ZTSSt12__shared_ptrIN9NOMAD_4_313RunParametersELN9__gnu_cxx12_Lock_policyE2EE", !6, i64 0, !14, i64 8}
!17 = !{!"_ZTSSt10shared_ptrIN9NOMAD_4_312PbParametersEE", !18, i64 0}
!18 = !{!"_ZTSSt12__shared_ptrIN9NOMAD_4_312PbParametersELN9__gnu_cxx12_Lock_policyE2EE", !6, i64 0, !14, i64 8}
!19 = !{!"_ZTSN9NOMAD_4_312SuccessStatsE", !20, i64 0, !28, i64 48, !28, i64 56}
!20 = !{!"_ZTSSt3mapISt4pairIN9NOMAD_4_38StepTypeENS1_11SuccessTypeEEmSt4lessIS4_ESaIS0_IKS4_mEEE", !21, i64 0}
!21 = !{!"_ZTSSt8_Rb_treeISt4pairIN9NOMAD_4_38StepTypeENS1_11SuccessTypeEES0_IKS4_mESt10_Select1stIS6_ESt4lessIS4_ESaIS6_EE", !22, i64 0}
!22 = !{!"_ZTSNSt8_Rb_treeISt4pairIN9NOMAD_4_38StepTypeENS1_11SuccessTypeEES0_IKS4_mESt10_Select1stIS6_ESt4lessIS4_ESaIS6_EE13_Rb_tree_implISA_Lb1EEE", !23, i64 0, !25, i64 8}
!23 = !{!"_ZTSSt20_Rb_tree_key_compareISt4lessISt4pairIN9NOMAD_4_38StepTypeENS2_11SuccessTypeEEEE", !24, i64 0}
!24 = !{!"_ZTSSt4lessISt4pairIN9NOMAD_4_38StepTypeENS1_11SuccessTypeEEE"}
!25 = !{!"_ZTSSt15_Rb_tree_header", !26, i64 0, !28, i64 32}
!26 = !{!"_ZTSSt18_Rb_tree_node_base", !27, i64 0, !6, i64 8, !6, i64 16, !6, i64 24}
!27 = !{!"_ZTSSt14_Rb_tree_color", !7, i64 0}
!28 = !{!"long", !7, i64 0}
!29 = !{!"_ZTSN9NOMAD_4_311SuccessTypeE", !7, i64 0}
!30 = !{!10, !29, i64 136}
!31 = !{!29, !29, i64 0}


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

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN9NOMAD_4_34Step19updateParentSuccessEv(ptr noundef nonnull align 8 dereferenceable(140) %0) local_unnamed_addr #0 align 2 {
  %2 = getelementptr inbounds i8, ptr %0, i64 8
  %3 = load ptr, ptr %2, align 8, !tbaa !5
  %4 = icmp eq ptr %3, null
  br i1 %4, label %12, label %5

5:                                                ; preds = %1
  %6 = getelementptr inbounds i8, ptr %0, i64 136
  %7 = load i32, ptr %6, align 8, !tbaa !29
  %8 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNK9NOMAD_4_34Step14getSuccessTypeEv(ptr noundef nonnull align 8 dereferenceable(140) %3)
  %9 = load i32, ptr %8, align 4, !tbaa !30
  %10 = icmp sgt i32 %7, %9
  br i1 %10, label %11, label %12

11:                                               ; preds = %5
  tail call void @_ZN9NOMAD_4_34Step14setSuccessTypeERKNS_11SuccessTypeE(ptr noundef nonnull align 8 dereferenceable(140) %3, ptr noundef nonnull align 4 dereferenceable(4) %6)
  br label %12

12:                                               ; preds = %5, %11, %1
  ret void
}

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN9NOMAD_4_34Step14setSuccessTypeERKNS_11SuccessTypeE(ptr noundef nonnull align 8 dereferenceable(140), ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #0 align 2

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

!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 8}
!6 = !{!"_ZTSN9NOMAD_4_34StepE", !7, i64 8, !10, i64 16, !11, i64 24, !14, i64 40, !16, i64 56, !18, i64 72, !28, i64 136}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"_ZTSN9NOMAD_4_38StepTypeE", !8, i64 0}
!11 = !{!"_ZTSSt10shared_ptrIN9NOMAD_4_314AllStopReasonsEE", !12, i64 0}
!12 = !{!"_ZTSSt12__shared_ptrIN9NOMAD_4_314AllStopReasonsELN9__gnu_cxx12_Lock_policyE2EE", !7, i64 0, !13, i64 8}
!13 = !{!"_ZTSSt14__shared_countILN9__gnu_cxx12_Lock_policyE2EE", !7, i64 0}
!14 = !{!"_ZTSSt10shared_ptrIN9NOMAD_4_313RunParametersEE", !15, i64 0}
!15 = !{!"_ZTSSt12__shared_ptrIN9NOMAD_4_313RunParametersELN9__gnu_cxx12_Lock_policyE2EE", !7, i64 0, !13, i64 8}
!16 = !{!"_ZTSSt10shared_ptrIN9NOMAD_4_312PbParametersEE", !17, i64 0}
!17 = !{!"_ZTSSt12__shared_ptrIN9NOMAD_4_312PbParametersELN9__gnu_cxx12_Lock_policyE2EE", !7, i64 0, !13, i64 8}
!18 = !{!"_ZTSN9NOMAD_4_312SuccessStatsE", !19, i64 0, !27, i64 48, !27, i64 56}
!19 = !{!"_ZTSSt3mapISt4pairIN9NOMAD_4_38StepTypeENS1_11SuccessTypeEEmSt4lessIS4_ESaIS0_IKS4_mEEE", !20, i64 0}
!20 = !{!"_ZTSSt8_Rb_treeISt4pairIN9NOMAD_4_38StepTypeENS1_11SuccessTypeEES0_IKS4_mESt10_Select1stIS6_ESt4lessIS4_ESaIS6_EE", !21, i64 0}
!21 = !{!"_ZTSNSt8_Rb_treeISt4pairIN9NOMAD_4_38StepTypeENS1_11SuccessTypeEES0_IKS4_mESt10_Select1stIS6_ESt4lessIS4_ESaIS6_EE13_Rb_tree_implISA_Lb1EEE", !22, i64 0, !24, i64 8}
!22 = !{!"_ZTSSt20_Rb_tree_key_compareISt4lessISt4pairIN9NOMAD_4_38StepTypeENS2_11SuccessTypeEEEE", !23, i64 0}
!23 = !{!"_ZTSSt4lessISt4pairIN9NOMAD_4_38StepTypeENS1_11SuccessTypeEEE"}
!24 = !{!"_ZTSSt15_Rb_tree_header", !25, i64 0, !27, i64 32}
!25 = !{!"_ZTSSt18_Rb_tree_node_base", !26, i64 0, !7, i64 8, !7, i64 16, !7, i64 24}
!26 = !{!"_ZTSSt14_Rb_tree_color", !8, i64 0}
!27 = !{!"long", !8, i64 0}
!28 = !{!"_ZTSN9NOMAD_4_311SuccessTypeE", !8, i64 0}
!29 = !{!6, !28, i64 136}
!30 = !{!28, !28, i64 0}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass