; LLVM IR from thepowersgang/mrustc :: src/hir/deserialise.ll (ZN15HirDeserialiser23deserialise_lifetimerefEv)

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

%"struct.HIR::LifetimeRef" = type { i32 }
%class.HirDeserialiser = type { %class.RcString, %"class.std::vector", ptr }
%class.RcString = type { ptr }
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<HIR::TypeRef, std::allocator<HIR::TypeRef>>::_Vector_impl" }
%"struct.std::_Vector_base<HIR::TypeRef, std::allocator<HIR::TypeRef>>::_Vector_impl" = type { %"struct.std::_Vector_base<HIR::TypeRef, std::allocator<HIR::TypeRef>>::_Vector_impl_data" }
%"struct.std::_Vector_base<HIR::TypeRef, std::allocator<HIR::TypeRef>>::_Vector_impl_data" = type { ptr, ptr, ptr }

; Function Attrs: mustprogress uwtable
define dso_local i32 @_ZN15HirDeserialiser23deserialise_lifetimerefEv(ptr noundef nonnull align 8 dereferenceable(40) %0) #0 align 2 {
  %2 = alloca %"struct.HIR::LifetimeRef", align 4
  %3 = alloca ptr, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  %4 = load ptr, ptr %3, align 8
  call void @_ZN3HIR11LifetimeRefC2Ev(ptr noundef nonnull align 4 dereferenceable(4) %2)
  %5 = getelementptr inbounds %class.HirDeserialiser, ptr %4, i32 0, i32 2
  %6 = load ptr, ptr %5, align 8, !tbaa !9
  %7 = call noundef i64 @_ZN3HIR9serialise6Reader10read_countEv(ptr noundef nonnull align 8 dereferenceable(96) %6)
  %8 = trunc i64 %7 to i32
  %9 = getelementptr inbounds %"struct.HIR::LifetimeRef", ptr %2, i32 0, i32 0
  store i32 %8, ptr %9, align 4, !tbaa !16
  %10 = getelementptr inbounds %"struct.HIR::LifetimeRef", ptr %2, i32 0, i32 0
  %11 = load i32, ptr %10, align 4
  ret i32 %11
}

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef i64 @_ZN3HIR9serialise6Reader10read_countEv(ptr noundef nonnull align 8 dereferenceable(96)) #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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !6, i64 32}
!10 = !{!"_ZTS15HirDeserialiser", !11, i64 0, !12, i64 8, !6, i64 32}
!11 = !{!"_ZTS8RcString", !6, i64 0}
!12 = !{!"_ZTSSt6vectorIN3HIR7TypeRefESaIS1_EE", !13, i64 0}
!13 = !{!"_ZTSSt12_Vector_baseIN3HIR7TypeRefESaIS1_EE", !14, i64 0}
!14 = !{!"_ZTSNSt12_Vector_baseIN3HIR7TypeRefESaIS1_EE12_Vector_implE", !15, i64 0}
!15 = !{!"_ZTSNSt12_Vector_baseIN3HIR7TypeRefESaIS1_EE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!16 = !{!17, !18, i64 0}
!17 = !{!"_ZTSN3HIR11LifetimeRefE", !18, i64 0}
!18 = !{!"int", !7, 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"

%"struct.HIR::LifetimeRef" = type { i32 }

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZN15HirDeserialiser23deserialise_lifetimerefEv(ptr nocapture noundef nonnull readonly align 8 dereferenceable(40) %0) local_unnamed_addr #0 align 2 {
  %2 = alloca %"struct.HIR::LifetimeRef", align 4
  call void @_ZN3HIR11LifetimeRefC2Ev(ptr noundef nonnull align 4 dereferenceable(4) %2)
  %3 = getelementptr inbounds i8, ptr %0, i64 32
  %4 = load ptr, ptr %3, align 8, !tbaa !5
  %5 = call noundef i64 @_ZN3HIR9serialise6Reader10read_countEv(ptr noundef nonnull align 8 dereferenceable(96) %4)
  %6 = trunc i64 %5 to i32
  ret i32 %6
}

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef i64 @_ZN3HIR9serialise6Reader10read_countEv(ptr noundef nonnull align 8 dereferenceable(96)) 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, !8, i64 32}
!6 = !{!"_ZTS15HirDeserialiser", !7, i64 0, !11, i64 8, !8, i64 32}
!7 = !{!"_ZTS8RcString", !8, i64 0}
!8 = !{!"any pointer", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C++ TBAA"}
!11 = !{!"_ZTSSt6vectorIN3HIR7TypeRefESaIS1_EE", !12, i64 0}
!12 = !{!"_ZTSSt12_Vector_baseIN3HIR7TypeRefESaIS1_EE", !13, i64 0}
!13 = !{!"_ZTSNSt12_Vector_baseIN3HIR7TypeRefESaIS1_EE12_Vector_implE", !14, i64 0}
!14 = !{!"_ZTSNSt12_Vector_baseIN3HIR7TypeRefESaIS1_EE17_Vector_impl_dataE", !8, i64 0, !8, i64 8, !8, i64 16}


; Effective O3 passes: DSEPass,EarlyCSEPass,GlobalOptPass,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass