; LLVM IR from dynexcoin/Dynex :: src/WalletLegacy (WalletUserTransactionsCache)

; 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::WalletUserTransactionsCache" = type { %"class.std::vector", %"class.std::vector.4", %"class.DynexCN::WalletUnconfirmedTransactions", %"class.std::unordered_map.31" }
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<DynexCN::WalletLegacyTransaction, std::allocator<DynexCN::WalletLegacyTransaction>>::_Vector_impl" }
%"struct.std::_Vector_base<DynexCN::WalletLegacyTransaction, std::allocator<DynexCN::WalletLegacyTransaction>>::_Vector_impl" = type { %"struct.std::_Vector_base<DynexCN::WalletLegacyTransaction, std::allocator<DynexCN::WalletLegacyTransaction>>::_Vector_impl_data" }
%"struct.std::_Vector_base<DynexCN::WalletLegacyTransaction, std::allocator<DynexCN::WalletLegacyTransaction>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.std::vector.4" = type { %"struct.std::_Vector_base.5" }
%"struct.std::_Vector_base.5" = type { %"struct.std::_Vector_base<DynexCN::WalletLegacyTransfer, std::allocator<DynexCN::WalletLegacyTransfer>>::_Vector_impl" }
%"struct.std::_Vector_base<DynexCN::WalletLegacyTransfer, std::allocator<DynexCN::WalletLegacyTransfer>>::_Vector_impl" = type { %"struct.std::_Vector_base<DynexCN::WalletLegacyTransfer, std::allocator<DynexCN::WalletLegacyTransfer>>::_Vector_impl_data" }
%"struct.std::_Vector_base<DynexCN::WalletLegacyTransfer, std::allocator<DynexCN::WalletLegacyTransfer>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.DynexCN::WalletUnconfirmedTransactions" = type { %"class.std::unordered_map", %"class.std::unordered_set", i64 }
%"class.std::unordered_map" = type { %"class.std::_Hashtable" }
%"class.std::_Hashtable" = type { ptr, i64, %"struct.std::__detail::_Hash_node_base", i64, %"struct.std::__detail::_Prime_rehash_policy", ptr }
%"struct.std::__detail::_Hash_node_base" = type { ptr }
%"struct.std::__detail::_Prime_rehash_policy" = type { float, i64 }
%"class.std::unordered_set" = type { %"class.std::_Hashtable.14" }
%"class.std::_Hashtable.14" = type { ptr, i64, %"struct.std::__detail::_Hash_node_base", i64, %"struct.std::__detail::_Prime_rehash_policy", ptr }
%"class.std::unordered_map.31" = type { %"class.std::_Hashtable.32" }
%"class.std::_Hashtable.32" = type { ptr, i64, %"struct.std::__detail::_Hash_node_base", i64, %"struct.std::__detail::_Prime_rehash_policy", ptr }
%"struct.DynexCN::WalletLegacyTransaction" = type <{ i64, i64, i64, i64, i64, i64, %"struct.Crypto::Hash", %"class.boost::optional", i8, [2 x i8], i32, i64, %"class.std::__cxx11::basic_string", i8, [7 x i8] }>
%"struct.Crypto::Hash" = type { [32 x i8] }
%"class.boost::optional" = type { %"class.boost::optional_detail::optional_base" }
%"class.boost::optional_detail::optional_base" = type { i8, %"class.boost::optional_detail::aligned_storage" }
%"class.boost::optional_detail::aligned_storage" = type { %"union.boost::optional_detail::aligned_storage<Crypto::SecretKey>::dummy_u" }
%"union.boost::optional_detail::aligned_storage<Crypto::SecretKey>::dummy_u" = type { [32 x i8] }
%"class.std::__cxx11::basic_string" = type { %"struct.std::__cxx11::basic_string<char>::_Alloc_hider", i64, %union.anon }
%"struct.std::__cxx11::basic_string<char>::_Alloc_hider" = type { ptr }
%union.anon = type { i64, [8 x i8] }

; 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
declare dso_local noundef i64 @_ZNKSt6vectorIN7DynexCN23WalletLegacyTransactionESaIS1_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24)) #1 align 2

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef i64 @_ZNK7DynexCN27WalletUserTransactionsCache27findTransactionByTransferIdEm(ptr noundef nonnull align 8 dereferenceable(224) %0, i64 noundef %1) #1 align 2 {
  %3 = alloca i64, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i64, align 8
  %6 = alloca i64, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i64 %1, ptr %5, align 8, !tbaa !9
  %9 = load ptr, ptr %4, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #2
  store i64 0, ptr %6, align 8, !tbaa !9
  br label %10

10:                                               ; preds = %50, %2
  %11 = load i64, ptr %6, align 8, !tbaa !9
  %12 = getelementptr inbounds %"class.DynexCN::WalletUserTransactionsCache", ptr %9, i32 0, i32 0
  %13 = call noundef i64 @_ZNKSt6vectorIN7DynexCN23WalletLegacyTransactionESaIS1_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %12) #2
  %14 = icmp ult i64 %11, %13
  br i1 %14, label %15, label %53

15:                                               ; preds = %10
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #2
  %16 = getelementptr inbounds %"class.DynexCN::WalletUserTransactionsCache", ptr %9, i32 0, i32 0
  %17 = load i64, ptr %6, align 8, !tbaa !9
  %18 = call noundef nonnull align 8 dereferenceable(161) ptr @_ZNKSt6vectorIN7DynexCN23WalletLegacyTransactionESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %16, i64 noundef %17) #2
  store ptr %18, ptr %7, align 8, !tbaa !5
  %19 = load ptr, ptr %7, align 8, !tbaa !5
  %20 = getelementptr inbounds %"struct.DynexCN::WalletLegacyTransaction", ptr %19, i32 0, i32 0
  %21 = load i64, ptr %20, align 8, !tbaa !11
  %22 = icmp eq i64 %21, -1
  br i1 %22, label %28, label %23

23:                                               ; preds = %15
  %24 = load ptr, ptr %7, align 8, !tbaa !5
  %25 = getelementptr inbounds %"struct.DynexCN::WalletLegacyTransaction", ptr %24, i32 0, i32 1
  %26 = load i64, ptr %25, align 8, !tbaa !22
  %27 = icmp eq i64 %26, 0
  br i1 %27, label %28, label %29

28:                                               ; preds = %23, %15
  store i32 4, ptr %8, align 4
  br label %47

29:                                               ; preds = %23
  %30 = load i64, ptr %5, align 8, !tbaa !9
  %31 = load ptr, ptr %7, align 8, !tbaa !5
  %32 = getelementptr inbounds %"struct.DynexCN::WalletLegacyTransaction", ptr %31, i32 0, i32 0
  %33 = load i64, ptr %32, align 8, !tbaa !11
  %34 = icmp uge i64 %30, %33
  br i1 %34, label %35, label %46

35:                                               ; preds = %29
  %36 = load i64, ptr %5, align 8, !tbaa !9
  %37 = load ptr, ptr %7, align 8, !tbaa !5
  %38 = getelementptr inbounds %"struct.DynexCN::WalletLegacyTransaction", ptr %37, i32 0, i32 0
  %39 = load i64, ptr %38, align 8, !tbaa !11
  %40 = load ptr, ptr %7, align 8, !tbaa !5
  %41 = getelementptr inbounds %"struct.DynexCN::WalletLegacyTransaction", ptr %40, i32 0, i32 1
  %42 = load i64, ptr %41, align 8, !tbaa !22
  %43 = add i64 %39, %42
  %44 = icmp ult i64 %36, %43
  br i1 %44, label %45, label %46

45:                                               ; preds = %35
  store i32 2, ptr %8, align 4
  br label %47

46:                                               ; preds = %35, %29
  store i32 0, ptr %8, align 4
  br label %47

47:                                               ; preds = %46, %45, %28
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #2
  %48 = load i32, ptr %8, align 4
  switch i32 %48, label %63 [
    i32 0, label %49
    i32 4, label %50
    i32 2, label %53
  ]

49:                                               ; preds = %47
  br label %50

50:                                               ; preds = %49, %47
  %51 = load i64, ptr %6, align 8, !tbaa !9
  %52 = add i64 %51, 1
  store i64 %52, ptr %6, align 8, !tbaa !9
  br label %10, !llvm.loop !23

53:                                               ; preds = %47, %10
  %54 = load i64, ptr %6, align 8, !tbaa !9
  %55 = getelementptr inbounds %"class.DynexCN::WalletUserTransactionsCache", ptr %9, i32 0, i32 0
  %56 = call noundef i64 @_ZNKSt6vectorIN7DynexCN23WalletLegacyTransactionESaIS1_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %55) #2
  %57 = icmp eq i64 %54, %56
  br i1 %57, label %58, label %59

58:                                               ; preds = %53
  store i64 -1, ptr %3, align 8
  store i32 1, ptr %8, align 4
  br label %61

59:                                               ; preds = %53
  %60 = load i64, ptr %6, align 8, !tbaa !9
  store i64 %60, ptr %3, align 8
  store i32 1, ptr %8, align 4
  br label %61

61:                                               ; preds = %59, %58
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #2
  %62 = load i64, ptr %3, align 8
  ret i64 %62

63:                                               ; preds = %47
  unreachable
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(161) ptr @_ZNKSt6vectorIN7DynexCN23WalletLegacyTransactionESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) #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 }

!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 = !{!"long", !7, i64 0}
!11 = !{!12, !10, i64 0}
!12 = !{!"_ZTSN7DynexCN23WalletLegacyTransactionE", !10, i64 0, !10, i64 8, !10, i64 16, !10, i64 24, !10, i64 32, !10, i64 40, !13, i64 48, !14, i64 80, !16, i64 113, !18, i64 116, !10, i64 120, !19, i64 128, !21, i64 160}
!13 = !{!"_ZTSN6Crypto4HashE", !7, i64 0}
!14 = !{!"_ZTSN5boost8optionalIN6Crypto9SecretKeyEEE", !15, i64 0}
!15 = !{!"_ZTSN5boost15optional_detail13optional_baseIN6Crypto9SecretKeyEEE", !16, i64 0, !17, i64 1}
!16 = !{!"bool", !7, i64 0}
!17 = !{!"_ZTSN5boost15optional_detail15aligned_storageIN6Crypto9SecretKeyEEE", !7, i64 0}
!18 = !{!"int", !7, i64 0}
!19 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE", !20, i64 0, !10, i64 8, !7, i64 16}
!20 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_Alloc_hiderE", !6, i64 0}
!21 = !{!"_ZTSN7DynexCN28WalletLegacyTransactionStateE", !7, i64 0}
!22 = !{!12, !10, i64 8}
!23 = distinct !{!23, !24}
!24 = !{!"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"

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef i64 @_ZNK7DynexCN27WalletUserTransactionsCache27findTransactionByTransferIdEm(ptr noundef nonnull align 8 dereferenceable(224) %0, i64 noundef %1) local_unnamed_addr #0 align 2 {
  %3 = tail call noundef i64 @_ZNKSt6vectorIN7DynexCN23WalletLegacyTransactionESaIS1_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %0) #1
  %.not26 = icmp eq i64 %3, 0
  br i1 %.not26, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %2, %.thread
  %.01523 = phi i64 [ %14, %.thread ], [ 0, %2 ]
  %4 = tail call noundef nonnull align 8 dereferenceable(161) ptr @_ZNKSt6vectorIN7DynexCN23WalletLegacyTransactionESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %0, i64 noundef %.01523) #1
  %5 = load i64, ptr %4, align 8, !tbaa !5
  %6 = icmp eq i64 %5, -1
  br i1 %6, label %.thread, label %7

7:                                                ; preds = %.lr.ph
  %8 = getelementptr inbounds i8, ptr %4, i64 8
  %9 = load i64, ptr %8, align 8, !tbaa !20
  %10 = icmp eq i64 %9, 0
  br i1 %10, label %.thread, label %11

11:                                               ; preds = %7
  %.not = icmp ule i64 %5, %1
  %12 = add i64 %9, %5
  %13 = icmp ugt i64 %12, %1
  %or.cond = and i1 %.not, %13
  br i1 %or.cond, label %._crit_edge, label %.thread

.thread:                                          ; preds = %.lr.ph, %7, %11
  %14 = add nuw i64 %.01523, 1
  %15 = tail call noundef i64 @_ZNKSt6vectorIN7DynexCN23WalletLegacyTransactionESaIS1_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %0) #1
  %16 = icmp ult i64 %14, %15
  br i1 %16, label %.lr.ph, label %._crit_edge, !llvm.loop !21

._crit_edge:                                      ; preds = %.thread, %11, %2
  %.015.lcssa = phi i64 [ 0, %2 ], [ %.01523, %11 ], [ %14, %.thread ]
  %17 = tail call noundef i64 @_ZNKSt6vectorIN7DynexCN23WalletLegacyTransactionESaIS1_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %0) #1
  %18 = icmp eq i64 %.015.lcssa, %17
  %..015 = select i1 %18, i64 -1, i64 %.015.lcssa
  ret i64 %..015
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(161) ptr @_ZNKSt6vectorIN7DynexCN23WalletLegacyTransactionESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) 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 = { 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 = !{!"_ZTSN7DynexCN23WalletLegacyTransactionE", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !7, i64 32, !7, i64 40, !10, i64 48, !11, i64 80, !13, i64 113, !15, i64 116, !7, i64 120, !16, i64 128, !19, i64 160}
!7 = !{!"long", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"_ZTSN6Crypto4HashE", !8, i64 0}
!11 = !{!"_ZTSN5boost8optionalIN6Crypto9SecretKeyEEE", !12, i64 0}
!12 = !{!"_ZTSN5boost15optional_detail13optional_baseIN6Crypto9SecretKeyEEE", !13, i64 0, !14, i64 1}
!13 = !{!"bool", !8, i64 0}
!14 = !{!"_ZTSN5boost15optional_detail15aligned_storageIN6Crypto9SecretKeyEEE", !8, i64 0}
!15 = !{!"int", !8, i64 0}
!16 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE", !17, i64 0, !7, i64 8, !8, i64 16}
!17 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_Alloc_hiderE", !18, i64 0}
!18 = !{!"any pointer", !8, i64 0}
!19 = !{!"_ZTSN7DynexCN28WalletLegacyTransactionStateE", !8, i64 0}
!20 = !{!6, !7, i64 8}
!21 = distinct !{!21, !22}
!22 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass