; LLVM IR from dynexcoin/Dynex :: src/BlockchainExplorer (BlockchainExplorer)

; 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.DynexCN::BlockchainExplorer::PoolUpdateGuard" = type { %"struct.std::atomic" }
%"struct.std::atomic" = type { i32 }

@.str = external hidden unnamed_addr constant [6 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [95 x i8], align 1
@__PRETTY_FUNCTION__._ZN7DynexCN18BlockchainExplorer15PoolUpdateGuard11beginUpdateEv = external hidden unnamed_addr constant [65 x i8], align 1

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

9:                                                ; preds = %23, %1
  %10 = load i32, ptr %4, align 4, !tbaa !9
  switch i32 %10, label %22 [
    i32 0, label %11
    i32 1, label %16
    i32 2, label %21
  ]

11:                                               ; preds = %9
  %12 = getelementptr inbounds %"class.DynexCN::BlockchainExplorer::PoolUpdateGuard", ptr %6, i32 0, i32 0
  %13 = call noundef zeroext i1 @_ZNSt6atomicIN7DynexCN18BlockchainExplorer15PoolUpdateGuard5StateEE21compare_exchange_weakERS3_S3_St12memory_order(ptr noundef nonnull align 4 dereferenceable(4) %12, ptr noundef nonnull align 4 dereferenceable(4) %4, i32 noundef 1, i32 noundef 5) #3
  br i1 %13, label %14, label %15

14:                                               ; preds = %11
  store i1 true, ptr %2, align 1
  store i32 1, ptr %5, align 4
  br label %24

15:                                               ; preds = %11
  br label %23

16:                                               ; preds = %9
  %17 = getelementptr inbounds %"class.DynexCN::BlockchainExplorer::PoolUpdateGuard", ptr %6, i32 0, i32 0
  %18 = call noundef zeroext i1 @_ZNSt6atomicIN7DynexCN18BlockchainExplorer15PoolUpdateGuard5StateEE21compare_exchange_weakERS3_S3_St12memory_order(ptr noundef nonnull align 4 dereferenceable(4) %17, ptr noundef nonnull align 4 dereferenceable(4) %4, i32 noundef 2, i32 noundef 5) #3
  br i1 %18, label %19, label %20

19:                                               ; preds = %16
  store i1 false, ptr %2, align 1
  store i32 1, ptr %5, align 4
  br label %24

20:                                               ; preds = %16
  br label %23

21:                                               ; preds = %9
  store i1 false, ptr %2, align 1
  store i32 1, ptr %5, align 4
  br label %24

22:                                               ; preds = %9
  call void @__assert_fail(ptr noundef @.str, ptr noundef @.str.4, i32 noundef 125, ptr noundef @__PRETTY_FUNCTION__._ZN7DynexCN18BlockchainExplorer15PoolUpdateGuard11beginUpdateEv) #4
  unreachable

23:                                               ; preds = %20, %15
  br label %9, !llvm.loop !11

24:                                               ; preds = %21, %19, %14
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #3
  %25 = load i1, ptr %2, align 1
  ret i1 %25
}

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNSt6atomicIN7DynexCN18BlockchainExplorer15PoolUpdateGuard5StateEE21compare_exchange_weakERS3_S3_St12memory_order(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4), i32 noundef, i32 noundef) #1 align 2

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #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 = { noreturn nounwind "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 }
attributes #4 = { noreturn 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 = !{!"_ZTSN7DynexCN18BlockchainExplorer15PoolUpdateGuard5StateE", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"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"

@.str = external hidden unnamed_addr constant [6 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [95 x i8], align 1
@__PRETTY_FUNCTION__._ZN7DynexCN18BlockchainExplorer15PoolUpdateGuard11beginUpdateEv = external hidden unnamed_addr constant [65 x i8], align 1

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

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef zeroext i1 @_ZN7DynexCN18BlockchainExplorer15PoolUpdateGuard11beginUpdateEv(ptr noundef nonnull align 4 dereferenceable(4) %0) local_unnamed_addr #1 align 2 {
  %2 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #3
  %3 = tail call noundef i32 @_ZNKSt6atomicIN7DynexCN18BlockchainExplorer15PoolUpdateGuard5StateEE4loadESt12memory_order(ptr noundef nonnull align 4 dereferenceable(4) %0, i32 noundef 5) #3
  store i32 %3, ptr %2, align 4, !tbaa !5
  br label %4

4:                                                ; preds = %11, %1
  %5 = phi i32 [ %.pr, %11 ], [ %3, %1 ]
  switch i32 %5, label %10 [
    i32 0, label %6
    i32 1, label %8
    i32 2, label %12
  ]

6:                                                ; preds = %4
  %7 = call noundef zeroext i1 @_ZNSt6atomicIN7DynexCN18BlockchainExplorer15PoolUpdateGuard5StateEE21compare_exchange_weakERS3_S3_St12memory_order(ptr noundef nonnull align 4 dereferenceable(4) %0, ptr noundef nonnull align 4 dereferenceable(4) %2, i32 noundef 1, i32 noundef 5) #3
  br i1 %7, label %12, label %11

8:                                                ; preds = %4
  %9 = call noundef zeroext i1 @_ZNSt6atomicIN7DynexCN18BlockchainExplorer15PoolUpdateGuard5StateEE21compare_exchange_weakERS3_S3_St12memory_order(ptr noundef nonnull align 4 dereferenceable(4) %0, ptr noundef nonnull align 4 dereferenceable(4) %2, i32 noundef 2, i32 noundef 5) #3
  br i1 %9, label %12, label %11

10:                                               ; preds = %4
  call void @__assert_fail(ptr noundef nonnull @.str, ptr noundef nonnull @.str.4, i32 noundef 125, ptr noundef nonnull @__PRETTY_FUNCTION__._ZN7DynexCN18BlockchainExplorer15PoolUpdateGuard11beginUpdateEv) #4
  unreachable

11:                                               ; preds = %8, %6
  %.pr = load i32, ptr %2, align 4, !tbaa !5
  br label %4, !llvm.loop !9

12:                                               ; preds = %4, %8, %6
  %.0 = phi i1 [ true, %6 ], [ false, %8 ], [ false, %4 ]
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #3
  ret i1 %.0
}

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNSt6atomicIN7DynexCN18BlockchainExplorer15PoolUpdateGuard5StateEE21compare_exchange_weakERS3_S3_St12memory_order(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4), i32 noundef, i32 noundef) local_unnamed_addr #1 align 2

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #2

attributes #0 = { mustprogress 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 = { noreturn nounwind "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 }
attributes #4 = { noreturn 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 = !{!"_ZTSN7DynexCN18BlockchainExplorer15PoolUpdateGuard5StateE", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}


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