; LLVM IR from rahulyesantharao/b-epsilon-tree :: src/lru_cache/lru_cache.ll (ZN8LRUCache3PutEjPj)

; 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.LRUCache = type { i32, i32, ptr, %"class.std::unordered_map" }
%"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.LRUNode = type { i32, i32, ptr, ptr }

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_ZN13LRULinkedList13AddNodeToHeadEjj(ptr noundef nonnull align 8 dereferenceable(16), i32 noundef, i32 noundef) #0 align 2

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

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

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

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_ZN8LRUCache3GetEj(ptr noundef nonnull align 8 dereferenceable(72), i32 noundef) #0 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZN8LRUCache3PutEjPj(ptr noundef nonnull align 8 dereferenceable(72) %0, i32 noundef %1, ptr noundef %2) #0 align 2 {
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i32 %1, ptr %5, align 4, !tbaa !9
  store ptr %2, ptr %6, align 8, !tbaa !5
  %10 = load ptr, ptr %4, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  %11 = load i32, ptr %5, align 4, !tbaa !9
  %12 = call noundef i32 @_ZN8LRUCache3GetEj(ptr noundef nonnull align 8 dereferenceable(72) %10, i32 noundef %11)
  store i32 %12, ptr %7, align 4, !tbaa !9
  %13 = load i32, ptr %7, align 4, !tbaa !9
  %14 = getelementptr inbounds %class.LRUCache, ptr %10, i32 0, i32 0
  %15 = load i32, ptr %14, align 8, !tbaa !11
  %16 = icmp uge i32 %13, %15
  br i1 %16, label %17, label %63

17:                                               ; preds = %3
  %18 = getelementptr inbounds %class.LRUCache, ptr %10, i32 0, i32 1
  %19 = load i32, ptr %18, align 4, !tbaa !19
  %20 = getelementptr inbounds %class.LRUCache, ptr %10, i32 0, i32 0
  %21 = load i32, ptr %20, align 8, !tbaa !11
  %22 = icmp eq i32 %19, %21
  br i1 %22, label %23, label %47

23:                                               ; preds = %17
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  %24 = getelementptr inbounds %class.LRUCache, ptr %10, i32 0, i32 2
  %25 = load ptr, ptr %24, align 8, !tbaa !20
  %26 = call noundef ptr @_ZN13LRULinkedList11GetRearNodeEv(ptr noundef nonnull align 8 dereferenceable(16) %25)
  store ptr %26, ptr %8, align 8, !tbaa !5
  %27 = load ptr, ptr %8, align 8, !tbaa !5
  %28 = getelementptr inbounds %class.LRUNode, ptr %27, i32 0, i32 1
  %29 = load i32, ptr %28, align 4, !tbaa !21
  store i32 %29, ptr %7, align 4, !tbaa !9
  %30 = load ptr, ptr %6, align 8, !tbaa !5
  %31 = icmp ne ptr %30, null
  br i1 %31, label %32, label %37

32:                                               ; preds = %23
  %33 = load ptr, ptr %8, align 8, !tbaa !5
  %34 = getelementptr inbounds %class.LRUNode, ptr %33, i32 0, i32 0
  %35 = load i32, ptr %34, align 8, !tbaa !23
  %36 = load ptr, ptr %6, align 8, !tbaa !5
  store i32 %35, ptr %36, align 4, !tbaa !9
  br label %37

37:                                               ; preds = %32, %23
  %38 = getelementptr inbounds %class.LRUCache, ptr %10, i32 0, i32 3
  %39 = load ptr, ptr %8, align 8, !tbaa !5
  %40 = getelementptr inbounds %class.LRUNode, ptr %39, i32 0, i32 0
  %41 = call noundef i64 @_ZNSt13unordered_mapIjP7LRUNodeSt4hashIjESt8equal_toIjESaISt4pairIKjS1_EEE5eraseERS7_(ptr noundef nonnull align 8 dereferenceable(56) %38, ptr noundef nonnull align 4 dereferenceable(4) %40)
  %42 = getelementptr inbounds %class.LRUCache, ptr %10, i32 0, i32 2
  %43 = load ptr, ptr %42, align 8, !tbaa !20
  call void @_ZN13LRULinkedList14RemoveRearNodeEv(ptr noundef nonnull align 8 dereferenceable(16) %43)
  %44 = getelementptr inbounds %class.LRUCache, ptr %10, i32 0, i32 1
  %45 = load i32, ptr %44, align 4, !tbaa !19
  %46 = add nsw i32 %45, -1
  store i32 %46, ptr %44, align 4, !tbaa !19
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  br label %51

47:                                               ; preds = %17
  %48 = load ptr, ptr %6, align 8, !tbaa !5
  store i32 0, ptr %48, align 4, !tbaa !9
  %49 = getelementptr inbounds %class.LRUCache, ptr %10, i32 0, i32 1
  %50 = load i32, ptr %49, align 4, !tbaa !19
  store i32 %50, ptr %7, align 4, !tbaa !9
  br label %51

51:                                               ; preds = %47, %37
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #3
  %52 = getelementptr inbounds %class.LRUCache, ptr %10, i32 0, i32 2
  %53 = load ptr, ptr %52, align 8, !tbaa !20
  %54 = load i32, ptr %5, align 4, !tbaa !9
  %55 = load i32, ptr %7, align 4, !tbaa !9
  %56 = call noundef ptr @_ZN13LRULinkedList13AddNodeToHeadEjj(ptr noundef nonnull align 8 dereferenceable(16) %53, i32 noundef %54, i32 noundef %55)
  store ptr %56, ptr %9, align 8, !tbaa !5
  %57 = getelementptr inbounds %class.LRUCache, ptr %10, i32 0, i32 1
  %58 = load i32, ptr %57, align 4, !tbaa !19
  %59 = add nsw i32 %58, 1
  store i32 %59, ptr %57, align 4, !tbaa !19
  %60 = load ptr, ptr %9, align 8, !tbaa !5
  %61 = getelementptr inbounds %class.LRUCache, ptr %10, i32 0, i32 3
  %62 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt13unordered_mapIjP7LRUNodeSt4hashIjESt8equal_toIjESaISt4pairIKjS1_EEEixERS7_(ptr noundef nonnull align 8 dereferenceable(56) %61, ptr noundef nonnull align 4 dereferenceable(4) %5)
  store ptr %60, ptr %62, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #3
  br label %63

63:                                               ; preds = %51, %3
  %64 = load i32, ptr %7, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  ret i32 %64
}

; Function Attrs: mustprogress uwtable
declare dso_local noundef i64 @_ZNSt13unordered_mapIjP7LRUNodeSt4hashIjESt8equal_toIjESaISt4pairIKjS1_EEE5eraseERS7_(ptr noundef nonnull align 8 dereferenceable(56), ptr noundef nonnull align 4 dereferenceable(4)) #0 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt13unordered_mapIjP7LRUNodeSt4hashIjESt8equal_toIjESaISt4pairIKjS1_EEEixERS7_(ptr noundef nonnull align 8 dereferenceable(56), ptr noundef nonnull align 4 dereferenceable(4)) #0 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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !10, i64 0}
!12 = !{!"_ZTS8LRUCache", !10, i64 0, !10, i64 4, !6, i64 8, !13, i64 16}
!13 = !{!"_ZTSSt13unordered_mapIjP7LRUNodeSt4hashIjESt8equal_toIjESaISt4pairIKjS1_EEE", !14, i64 0}
!14 = !{!"_ZTSSt10_HashtableIjSt4pairIKjP7LRUNodeESaIS4_ENSt8__detail10_Select1stESt8equal_toIjESt4hashIjENS6_18_Mod_range_hashingENS6_20_Default_ranged_hashENS6_20_Prime_rehash_policyENS6_17_Hashtable_traitsILb0ELb0ELb1EEEE", !6, i64 0, !15, i64 8, !16, i64 16, !15, i64 24, !17, i64 32, !6, i64 48}
!15 = !{!"long", !7, i64 0}
!16 = !{!"_ZTSNSt8__detail15_Hash_node_baseE", !6, i64 0}
!17 = !{!"_ZTSNSt8__detail20_Prime_rehash_policyE", !18, i64 0, !15, i64 8}
!18 = !{!"float", !7, i64 0}
!19 = !{!12, !10, i64 4}
!20 = !{!12, !6, i64 8}
!21 = !{!22, !10, i64 4}
!22 = !{!"_ZTS7LRUNode", !10, i64 0, !10, i64 4, !6, i64 8, !6, i64 16}
!23 = !{!22, !10, 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 uwtable
declare dso_local noundef ptr @_ZN13LRULinkedList13AddNodeToHeadEjj(ptr noundef nonnull align 8 dereferenceable(16), i32 noundef, i32 noundef) local_unnamed_addr #0 align 2

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

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_ZN8LRUCache3GetEj(ptr noundef nonnull align 8 dereferenceable(72), i32 noundef) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZN8LRUCache3PutEjPj(ptr noundef nonnull align 8 dereferenceable(72) %0, i32 noundef %1, ptr noundef writeonly %2) local_unnamed_addr #0 align 2 {
  %4 = alloca i32, align 4
  store i32 %1, ptr %4, align 4, !tbaa !5
  %5 = tail call noundef i32 @_ZN8LRUCache3GetEj(ptr noundef nonnull align 8 dereferenceable(72) %0, i32 noundef %1)
  %6 = load i32, ptr %0, align 8, !tbaa !9
  %.not = icmp ult i32 %5, %6
  br i1 %.not, label %35, label %7

7:                                                ; preds = %3
  %8 = getelementptr inbounds i8, ptr %0, i64 4
  %9 = load i32, ptr %8, align 4, !tbaa !18
  %10 = icmp eq i32 %9, %6
  br i1 %10, label %11, label %25

11:                                               ; preds = %7
  %12 = getelementptr inbounds i8, ptr %0, i64 8
  %13 = load ptr, ptr %12, align 8, !tbaa !19
  %14 = tail call noundef ptr @_ZN13LRULinkedList11GetRearNodeEv(ptr noundef nonnull align 8 dereferenceable(16) %13)
  %15 = getelementptr inbounds i8, ptr %14, i64 4
  %16 = load i32, ptr %15, align 4, !tbaa !20
  %.not13 = icmp eq ptr %2, null
  br i1 %.not13, label %19, label %17

17:                                               ; preds = %11
  %18 = load i32, ptr %14, align 8, !tbaa !22
  store i32 %18, ptr %2, align 4, !tbaa !5
  br label %19

19:                                               ; preds = %17, %11
  %20 = getelementptr inbounds i8, ptr %0, i64 16
  %21 = tail call noundef i64 @_ZNSt13unordered_mapIjP7LRUNodeSt4hashIjESt8equal_toIjESaISt4pairIKjS1_EEE5eraseERS7_(ptr noundef nonnull align 8 dereferenceable(56) %20, ptr noundef nonnull align 4 dereferenceable(4) %14)
  %22 = load ptr, ptr %12, align 8, !tbaa !19
  tail call void @_ZN13LRULinkedList14RemoveRearNodeEv(ptr noundef nonnull align 8 dereferenceable(16) %22)
  %23 = load i32, ptr %8, align 4, !tbaa !18
  %24 = add nsw i32 %23, -1
  store i32 %24, ptr %8, align 4, !tbaa !18
  br label %27

25:                                               ; preds = %7
  store i32 0, ptr %2, align 4, !tbaa !5
  %26 = load i32, ptr %8, align 4, !tbaa !18
  br label %27

27:                                               ; preds = %25, %19
  %.0 = phi i32 [ %16, %19 ], [ %26, %25 ]
  %28 = getelementptr inbounds i8, ptr %0, i64 8
  %29 = load ptr, ptr %28, align 8, !tbaa !19
  %30 = tail call noundef ptr @_ZN13LRULinkedList13AddNodeToHeadEjj(ptr noundef nonnull align 8 dereferenceable(16) %29, i32 noundef %1, i32 noundef %.0)
  %31 = load i32, ptr %8, align 4, !tbaa !18
  %32 = add nsw i32 %31, 1
  store i32 %32, ptr %8, align 4, !tbaa !18
  %33 = getelementptr inbounds i8, ptr %0, i64 16
  %34 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt13unordered_mapIjP7LRUNodeSt4hashIjESt8equal_toIjESaISt4pairIKjS1_EEEixERS7_(ptr noundef nonnull align 8 dereferenceable(56) %33, ptr noundef nonnull align 4 dereferenceable(4) %4)
  store ptr %30, ptr %34, align 8, !tbaa !23
  br label %35

35:                                               ; preds = %27, %3
  %.1 = phi i32 [ %.0, %27 ], [ %5, %3 ]
  ret i32 %.1
}

; Function Attrs: mustprogress uwtable
declare dso_local noundef i64 @_ZNSt13unordered_mapIjP7LRUNodeSt4hashIjESt8equal_toIjESaISt4pairIKjS1_EEE5eraseERS7_(ptr noundef nonnull align 8 dereferenceable(56), ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt13unordered_mapIjP7LRUNodeSt4hashIjESt8equal_toIjESaISt4pairIKjS1_EEEixERS7_(ptr noundef nonnull align 8 dereferenceable(56), ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #0 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 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, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !6, i64 0}
!10 = !{!"_ZTS8LRUCache", !6, i64 0, !6, i64 4, !11, i64 8, !12, i64 16}
!11 = !{!"any pointer", !7, i64 0}
!12 = !{!"_ZTSSt13unordered_mapIjP7LRUNodeSt4hashIjESt8equal_toIjESaISt4pairIKjS1_EEE", !13, i64 0}
!13 = !{!"_ZTSSt10_HashtableIjSt4pairIKjP7LRUNodeESaIS4_ENSt8__detail10_Select1stESt8equal_toIjESt4hashIjENS6_18_Mod_range_hashingENS6_20_Default_ranged_hashENS6_20_Prime_rehash_policyENS6_17_Hashtable_traitsILb0ELb0ELb1EEEE", !11, i64 0, !14, i64 8, !15, i64 16, !14, i64 24, !16, i64 32, !11, i64 48}
!14 = !{!"long", !7, i64 0}
!15 = !{!"_ZTSNSt8__detail15_Hash_node_baseE", !11, i64 0}
!16 = !{!"_ZTSNSt8__detail20_Prime_rehash_policyE", !17, i64 0, !14, i64 8}
!17 = !{!"float", !7, i64 0}
!18 = !{!10, !6, i64 4}
!19 = !{!10, !11, i64 8}
!20 = !{!21, !6, i64 4}
!21 = !{!"_ZTS7LRUNode", !6, i64 0, !6, i64 4, !11, i64 8, !11, i64 16}
!22 = !{!21, !6, i64 0}
!23 = !{!11, !11, i64 0}


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