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

; 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.std::shared_ptr.65" = type { %"class.std::__shared_ptr.66" }
%"class.std::__shared_ptr.66" = type { ptr, %"class.std::__shared_count" }
%"class.std::__shared_count" = type { ptr }

@_ZTIN9NOMAD_4_34StepE = external dso_local constant { ptr, ptr }, align 8
@_ZTIN9NOMAD_4_39AlgorithmE = external constant ptr
@_ZTIN9NOMAD_4_313MegaIterationE = external constant ptr

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

declare i32 @__gxx_personality_v0(...)

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK9NOMAD_4_34Step13isAnAlgorithmEv(ptr noundef nonnull align 8 dereferenceable(140)) #1 align 2

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZNK9NOMAD_4_34Step23getMegaIterationBarrierEv(ptr dead_on_unwind noalias writable sret(%"class.std::shared_ptr.65") align 8 %0, ptr noundef nonnull align 8 dereferenceable(140) %1) #3 align 2 personality ptr @__gxx_personality_v0 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i1, align 1
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca ptr, align 8
  store ptr %0, ptr %3, align 8
  store ptr %1, ptr %4, align 8, !tbaa !5
  %11 = load ptr, ptr %4, align 8
  store i1 false, ptr %5, align 1
  call void @_ZNSt10shared_ptrIN9NOMAD_4_311BarrierBaseEEC2EDn(ptr noundef nonnull align 8 dereferenceable(16) %0, ptr null) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #4
  store ptr null, ptr %6, align 8, !tbaa !5
  %12 = call noundef zeroext i1 @_ZNK9NOMAD_4_34Step13isAnAlgorithmEv(ptr noundef nonnull align 8 dereferenceable(140) %11)
  br i1 %12, label %13, label %28

13:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #4
  %14 = icmp eq ptr %11, null
  br i1 %14, label %17, label %15

15:                                               ; preds = %13
  %16 = call ptr @__dynamic_cast(ptr %11, ptr @_ZTIN9NOMAD_4_34StepE, ptr @_ZTIN9NOMAD_4_39AlgorithmE, i64 0) #4
  br label %18

17:                                               ; preds = %13
  br label %18

18:                                               ; preds = %17, %15
  %19 = phi ptr [ %16, %15 ], [ null, %17 ]
  store ptr %19, ptr %7, align 8, !tbaa !5
  %20 = load ptr, ptr %7, align 8, !tbaa !5
  %21 = invoke noundef nonnull align 8 dereferenceable(16) ptr @_ZNK9NOMAD_4_39Algorithm19getRefMegaIterationEv(ptr noundef nonnull align 8 dereferenceable(417) %20)
          to label %22 unwind label %24

22:                                               ; preds = %18
  %23 = call noundef ptr @_ZNKSt12__shared_ptrIN9NOMAD_4_313MegaIterationELN9__gnu_cxx12_Lock_policyE2EE3getEv(ptr noundef nonnull align 8 dereferenceable(16) %21) #4
  store ptr %23, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #4
  br label %46

24:                                               ; preds = %18
  %25 = landingpad { ptr, i32 }
          cleanup
  %26 = extractvalue { ptr, i32 } %25, 0
  store ptr %26, ptr %8, align 8
  %27 = extractvalue { ptr, i32 } %25, 1
  store i32 %27, ptr %9, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #4
  br label %60

28:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #4
  %29 = icmp eq ptr %11, null
  br i1 %29, label %32, label %30

30:                                               ; preds = %28
  %31 = call ptr @__dynamic_cast(ptr %11, ptr @_ZTIN9NOMAD_4_34StepE, ptr @_ZTIN9NOMAD_4_313MegaIterationE, i64 0) #4
  br label %33

32:                                               ; preds = %28
  br label %33

33:                                               ; preds = %32, %30
  %34 = phi ptr [ %31, %30 ], [ null, %32 ]
  store ptr %34, ptr %10, align 8, !tbaa !5
  %35 = load ptr, ptr %10, align 8, !tbaa !5
  %36 = icmp eq ptr null, %35
  br i1 %36, label %37, label %44

37:                                               ; preds = %33
  %38 = invoke noundef ptr @_ZNK9NOMAD_4_34Step15getParentOfTypeIPNS_13MegaIterationEEET_b(ptr noundef nonnull align 8 dereferenceable(140) %11, i1 noundef zeroext true)
          to label %39 unwind label %40

39:                                               ; preds = %37
  store ptr %38, ptr %10, align 8, !tbaa !5
  br label %44

40:                                               ; preds = %37
  %41 = landingpad { ptr, i32 }
          cleanup
  %42 = extractvalue { ptr, i32 } %41, 0
  store ptr %42, ptr %8, align 8
  %43 = extractvalue { ptr, i32 } %41, 1
  store i32 %43, ptr %9, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #4
  br label %60

44:                                               ; preds = %39, %33
  %45 = load ptr, ptr %10, align 8, !tbaa !5
  store ptr %45, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #4
  br label %46

46:                                               ; preds = %44, %22
  %47 = load ptr, ptr %6, align 8, !tbaa !5
  %48 = icmp ne ptr null, %47
  br i1 %48, label %49, label %58

49:                                               ; preds = %46
  %50 = load ptr, ptr %6, align 8, !tbaa !5
  %51 = invoke noundef nonnull align 8 dereferenceable(16) ptr @_ZNK9NOMAD_4_313MegaIteration10getBarrierEv(ptr noundef nonnull align 8 dereferenceable(172) %50)
          to label %52 unwind label %54

52:                                               ; preds = %49
  %53 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt10shared_ptrIN9NOMAD_4_311BarrierBaseEEaSERKS2_(ptr noundef nonnull align 8 dereferenceable(16) %0, ptr noundef nonnull align 8 dereferenceable(16) %51) #4
  br label %58

54:                                               ; preds = %49
  %55 = landingpad { ptr, i32 }
          cleanup
  %56 = extractvalue { ptr, i32 } %55, 0
  store ptr %56, ptr %8, align 8
  %57 = extractvalue { ptr, i32 } %55, 1
  store i32 %57, ptr %9, align 4
  br label %60

58:                                               ; preds = %52, %46
  store i1 true, ptr %5, align 1
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #4
  %59 = load i1, ptr %5, align 1
  br i1 %59, label %62, label %61

60:                                               ; preds = %54, %40, %24
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #4
  call void @_ZNSt12__shared_ptrIN9NOMAD_4_311BarrierBaseELN9__gnu_cxx12_Lock_policyE2EED2Ev(ptr noundef nonnull align 8 dereferenceable(16) %0) #4
  br label %63

61:                                               ; preds = %58
  call void @_ZNSt12__shared_ptrIN9NOMAD_4_311BarrierBaseELN9__gnu_cxx12_Lock_policyE2EED2Ev(ptr noundef nonnull align 8 dereferenceable(16) %0) #4
  br label %62

62:                                               ; preds = %61, %58
  ret void

63:                                               ; preds = %60
  %64 = load ptr, ptr %8, align 8
  %65 = load i32, ptr %9, align 4
  %66 = insertvalue { ptr, i32 } poison, ptr %64, 0
  %67 = insertvalue { ptr, i32 } %66, i32 %65, 1
  resume { ptr, i32 } %67
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt10shared_ptrIN9NOMAD_4_311BarrierBaseEEC2EDn(ptr noundef nonnull align 8 dereferenceable(16), ptr) unnamed_addr #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(16) ptr @_ZNK9NOMAD_4_39Algorithm19getRefMegaIterationEv(ptr noundef nonnull align 8 dereferenceable(417)) #1 align 2

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZNK9NOMAD_4_34Step15getParentOfTypeIPNS_13MegaIterationEEET_b(ptr noundef nonnull align 8 dereferenceable(140), i1 noundef zeroext) #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(16) ptr @_ZNK9NOMAD_4_313MegaIteration10getBarrierEv(ptr noundef nonnull align 8 dereferenceable(172)) #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt10shared_ptrIN9NOMAD_4_311BarrierBaseEEaSERKS2_(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(16)) #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt12__shared_ptrIN9NOMAD_4_311BarrierBaseELN9__gnu_cxx12_Lock_policyE2EED2Ev(ptr noundef nonnull align 8 dereferenceable(16)) unnamed_addr #1 align 2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { nounwind willreturn memory(read) }
attributes #3 = { 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 #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, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}


; 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.std::shared_ptr.65" = type { %"class.std::__shared_ptr.66" }
%"class.std::__shared_ptr.66" = type { ptr, %"class.std::__shared_count" }
%"class.std::__shared_count" = type { ptr }

@_ZTIN9NOMAD_4_34StepE = external dso_local constant { ptr, ptr }, align 8
@_ZTIN9NOMAD_4_39AlgorithmE = external constant ptr
@_ZTIN9NOMAD_4_313MegaIterationE = external constant ptr

declare i32 @__gxx_personality_v0(...)

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

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZNK9NOMAD_4_34Step23getMegaIterationBarrierEv(ptr dead_on_unwind noalias nonnull writable sret(%"class.std::shared_ptr.65") align 8 %0, ptr noundef nonnull align 8 dereferenceable(140) %1) local_unnamed_addr #0 align 2 personality ptr @__gxx_personality_v0 {
  tail call void @_ZNSt10shared_ptrIN9NOMAD_4_311BarrierBaseEEC2EDn(ptr noundef nonnull align 8 dereferenceable(16) %0, ptr null) #2
  %3 = tail call noundef zeroext i1 @_ZNK9NOMAD_4_34Step13isAnAlgorithmEv(ptr noundef nonnull align 8 dereferenceable(140) %1)
  br i1 %3, label %4, label %8

4:                                                ; preds = %2
  %5 = tail call ptr @__dynamic_cast(ptr nonnull %1, ptr nonnull @_ZTIN9NOMAD_4_34StepE, ptr nonnull @_ZTIN9NOMAD_4_39AlgorithmE, i64 0) #2
  %6 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNK9NOMAD_4_39Algorithm19getRefMegaIterationEv(ptr noundef nonnull align 8 dereferenceable(417) %5)
  %7 = tail call noundef ptr @_ZNKSt12__shared_ptrIN9NOMAD_4_313MegaIterationELN9__gnu_cxx12_Lock_policyE2EE3getEv(ptr noundef nonnull align 8 dereferenceable(16) %6) #2
  br label %13

8:                                                ; preds = %2
  %9 = tail call ptr @__dynamic_cast(ptr nonnull %1, ptr nonnull @_ZTIN9NOMAD_4_34StepE, ptr nonnull @_ZTIN9NOMAD_4_313MegaIterationE, i64 0) #2
  %10 = icmp eq ptr %9, null
  br i1 %10, label %11, label %.thread

11:                                               ; preds = %8
  %12 = tail call noundef ptr @_ZNK9NOMAD_4_34Step15getParentOfTypeIPNS_13MegaIterationEEET_b(ptr noundef nonnull align 8 dereferenceable(140) %1, i1 noundef zeroext true)
  br label %13

13:                                               ; preds = %11, %4
  %.07 = phi ptr [ %7, %4 ], [ %12, %11 ]
  %.not = icmp eq ptr %.07, null
  br i1 %.not, label %16, label %.thread

.thread:                                          ; preds = %8, %13
  %.0711 = phi ptr [ %.07, %13 ], [ %9, %8 ]
  %14 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNK9NOMAD_4_313MegaIteration10getBarrierEv(ptr noundef nonnull align 8 dereferenceable(172) %.0711)
  %15 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt10shared_ptrIN9NOMAD_4_311BarrierBaseEEaSERKS2_(ptr noundef nonnull align 8 dereferenceable(16) %0, ptr noundef nonnull align 8 dereferenceable(16) %14) #2
  br label %16

16:                                               ; preds = %13, %.thread
  ret void
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt10shared_ptrIN9NOMAD_4_311BarrierBaseEEC2EDn(ptr noundef nonnull align 8 dereferenceable(16), ptr) unnamed_addr #0 align 2

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

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

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt10shared_ptrIN9NOMAD_4_311BarrierBaseEEaSERKS2_(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(16)) 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" }
attributes #1 = { mustprogress nofree nounwind willreturn memory(read) }
attributes #2 = { 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)"}


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