; LLVM IR from Try/Tempest :: Engine/thirdparty/openal-soft/common/ringbuffer.ll (ZN10RingBuffer4readEPvm)

; 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::tuple.2" = type { %"struct.std::_Tuple_impl.3" }
%"struct.std::_Tuple_impl.3" = type { %"struct.std::_Tuple_impl.4", %"struct.std::_Head_base.6" }
%"struct.std::_Tuple_impl.4" = type { %"struct.std::_Head_base.5" }
%"struct.std::_Head_base.5" = type { i64 }
%"struct.std::_Head_base.6" = type { i64 }
%"class.al::span" = type { ptr, i64 }
%"class.al::ptr_wrapper" = type { ptr }
%struct.RingBuffer = type { %"struct.std::atomic", [56 x i8], %"struct.std::atomic", [56 x i8], i64, i64, i64, [8 x i8], %"struct.al::FlexArray", [16 x i8] }
%"struct.std::atomic" = type { %"struct.std::__atomic_base" }
%"struct.std::__atomic_base" = type { i64 }
%"struct.al::FlexArray" = type { %"struct.al::FlexArrayStorage" }
%"struct.al::FlexArrayStorage" = type { %"class.al::span" }

; 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: alwaysinline mustprogress nounwind uwtable
declare dso_local void @_ZNSt13__atomic_baseImE5storeEmSt12memory_order(ptr noundef nonnull align 8 dereferenceable(8), i64 noundef, i32 noundef) #1 align 2

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

; Function Attrs: noinline noreturn nounwind uwtable
declare hidden void @__clang_call_terminate(ptr noundef) #3

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef i64 @_ZN10RingBuffer4readEPvm(ptr noundef nonnull align 64 dereferenceable(176) %0, ptr noundef %1, i64 noundef %2) #2 align 2 personality ptr @__gxx_personality_v0 {
  %4 = alloca i64, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i64, align 8
  %8 = alloca i64, align 8
  %9 = alloca i64, align 8
  %10 = alloca i64, align 8
  %11 = alloca i32, align 4
  %12 = alloca i64, align 8
  %13 = alloca i64, align 8
  %14 = alloca i64, align 8
  %15 = alloca %"class.std::tuple.2", align 8
  %16 = alloca i64, align 8
  %17 = alloca i64, align 8
  %18 = alloca i64, align 8
  %19 = alloca ptr, align 8
  %20 = alloca ptr, align 8
  %21 = alloca %"class.al::span", align 8
  %22 = alloca %"class.al::ptr_wrapper", align 8
  %23 = alloca %"class.al::ptr_wrapper", align 8
  %24 = alloca %"class.al::ptr_wrapper", align 8
  %25 = alloca %"class.al::ptr_wrapper", align 8
  %26 = alloca %"class.al::ptr_wrapper", align 8
  %27 = alloca %"class.al::ptr_wrapper", align 8
  %28 = alloca %"class.al::ptr_wrapper", align 8
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store i64 %2, ptr %7, align 8, !tbaa !9
  %29 = load ptr, ptr %5, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #7
  %30 = getelementptr inbounds %struct.RingBuffer, ptr %29, i32 0, i32 0
  %31 = call noundef i64 @_ZNKSt13__atomic_baseImE4loadESt12memory_order(ptr noundef nonnull align 8 dereferenceable(8) %30, i32 noundef 2) #7
  store i64 %31, ptr %8, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #7
  %32 = getelementptr inbounds %struct.RingBuffer, ptr %29, i32 0, i32 2
  %33 = call noundef i64 @_ZNKSt13__atomic_baseImE4loadESt12memory_order(ptr noundef nonnull align 8 dereferenceable(8) %32, i32 noundef 0) #7
  store i64 %33, ptr %9, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #7
  %34 = load i64, ptr %8, align 8, !tbaa !9
  %35 = load i64, ptr %9, align 8, !tbaa !9
  %36 = sub i64 %34, %35
  store i64 %36, ptr %10, align 8, !tbaa !9
  %37 = load i64, ptr %10, align 8, !tbaa !9
  %38 = icmp eq i64 %37, 0
  br i1 %38, label %39, label %40

39:                                               ; preds = %3
  store i64 0, ptr %4, align 8
  store i32 1, ptr %11, align 4
  br label %131

40:                                               ; preds = %3
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #7
  %41 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3minImERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %7, ptr noundef nonnull align 8 dereferenceable(8) %10)
          to label %42 unwind label %133

42:                                               ; preds = %40
  %43 = load i64, ptr %41, align 8, !tbaa !9
  store i64 %43, ptr %12, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #7
  %44 = load i64, ptr %9, align 8, !tbaa !9
  %45 = getelementptr inbounds %struct.RingBuffer, ptr %29, i32 0, i32 5
  %46 = load i64, ptr %45, align 8, !tbaa !11
  %47 = and i64 %44, %46
  store i64 %47, ptr %13, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #7
  %48 = load i64, ptr %13, align 8, !tbaa !9
  %49 = load i64, ptr %12, align 8, !tbaa !9
  %50 = add i64 %48, %49
  store i64 %50, ptr %14, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 16, ptr %15) #7
  %51 = load i64, ptr %14, align 8, !tbaa !9
  %52 = getelementptr inbounds %struct.RingBuffer, ptr %29, i32 0, i32 5
  %53 = load i64, ptr %52, align 8, !tbaa !11
  %54 = add i64 %53, 1
  %55 = icmp ule i64 %51, %54
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #7
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #7
  call void @llvm.lifetime.start.p0(i64 8, ptr %18) #7
  br i1 %55, label %56, label %59

56:                                               ; preds = %42
  %57 = call noundef i64 @_Zli3_uzy(i64 noundef 0) #7
  store i64 %57, ptr %16, align 8, !tbaa !9
  invoke void @_ZSt10make_tupleIJRKmmEESt5tupleIJDpNSt25__strip_reference_wrapperINSt5decayIT_E4typeEE6__typeEEEDpOS5_(ptr dead_on_unwind writable sret(%"class.std::tuple.2") align 8 %15, ptr noundef nonnull align 8 dereferenceable(8) %12, ptr noundef nonnull align 8 dereferenceable(8) %16)
          to label %58 unwind label %133

58:                                               ; preds = %56
  br label %70

59:                                               ; preds = %42
  %60 = getelementptr inbounds %struct.RingBuffer, ptr %29, i32 0, i32 5
  %61 = load i64, ptr %60, align 8, !tbaa !11
  %62 = add i64 %61, 1
  %63 = load i64, ptr %13, align 8, !tbaa !9
  %64 = sub i64 %62, %63
  store i64 %64, ptr %17, align 8, !tbaa !9
  %65 = load i64, ptr %14, align 8, !tbaa !9
  %66 = getelementptr inbounds %struct.RingBuffer, ptr %29, i32 0, i32 5
  %67 = load i64, ptr %66, align 8, !tbaa !11
  %68 = and i64 %65, %67
  store i64 %68, ptr %18, align 8, !tbaa !9
  invoke void @_ZSt10make_tupleIJmmEESt5tupleIJDpNSt25__strip_reference_wrapperINSt5decayIT_E4typeEE6__typeEEEDpOS3_(ptr dead_on_unwind writable sret(%"class.std::tuple.2") align 8 %15, ptr noundef nonnull align 8 dereferenceable(8) %17, ptr noundef nonnull align 8 dereferenceable(8) %18)
          to label %69 unwind label %133

69:                                               ; preds = %59
  br label %70

70:                                               ; preds = %69, %58
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #7
  call void @llvm.lifetime.start.p0(i64 8, ptr %19) #7
  %71 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3getILm0EJmmEEOKNSt13tuple_elementIXT_ESt5tupleIJDpT0_EEE4typeEOKS4_(ptr noundef nonnull align 8 dereferenceable(16) %15) #7
  store ptr %71, ptr %19, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %20) #7
  %72 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3getILm1EJmmEEOKNSt13tuple_elementIXT_ESt5tupleIJDpT0_EEE4typeEOKS4_(ptr noundef nonnull align 8 dereferenceable(16) %15) #7
  store ptr %72, ptr %20, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 16, ptr %21) #7
  %73 = load ptr, ptr %6, align 8, !tbaa !5
  %74 = load i64, ptr %7, align 8, !tbaa !9
  %75 = getelementptr inbounds %struct.RingBuffer, ptr %29, i32 0, i32 6
  %76 = load i64, ptr %75, align 16, !tbaa !18
  %77 = mul i64 %74, %76
  invoke void @_ZN2al4spanISt4byteLm18446744073709551615EEC2IPS1_EET_m(ptr noundef nonnull align 8 dereferenceable(16) %21, ptr noundef %73, i64 noundef %77)
          to label %78 unwind label %133

78:                                               ; preds = %70
  call void @llvm.lifetime.start.p0(i64 8, ptr %22) #7
  call void @llvm.lifetime.start.p0(i64 8, ptr %24) #7
  %79 = getelementptr inbounds %struct.RingBuffer, ptr %29, i32 0, i32 8
  %80 = call ptr @_ZN2al9FlexArrayISt4byteLm16EE5beginEv(ptr noundef nonnull align 16 dereferenceable(16) %79) #7
  %81 = getelementptr inbounds %"class.al::ptr_wrapper", ptr %24, i32 0, i32 0
  store ptr %80, ptr %81, align 8
  %82 = load i64, ptr %13, align 8, !tbaa !9
  %83 = getelementptr inbounds %struct.RingBuffer, ptr %29, i32 0, i32 6
  %84 = load i64, ptr %83, align 16, !tbaa !18
  %85 = mul i64 %82, %84
  %86 = call ptr @_ZN2alplERKNS_11ptr_wrapperIPSt4byteEEl(ptr noundef nonnull align 8 dereferenceable(8) %24, i64 noundef %85) #7
  %87 = getelementptr inbounds %"class.al::ptr_wrapper", ptr %23, i32 0, i32 0
  store ptr %86, ptr %87, align 8
  %88 = load ptr, ptr %19, align 8, !tbaa !5
  %89 = load i64, ptr %88, align 8, !tbaa !9
  %90 = getelementptr inbounds %struct.RingBuffer, ptr %29, i32 0, i32 6
  %91 = load i64, ptr %90, align 16, !tbaa !18
  %92 = mul i64 %89, %91
  %93 = call ptr @_ZNK2al4spanISt4byteLm18446744073709551615EE5beginEv(ptr noundef nonnull align 8 dereferenceable(16) %21) #7
  %94 = getelementptr inbounds %"class.al::ptr_wrapper", ptr %25, i32 0, i32 0
  store ptr %93, ptr %94, align 8
  %95 = getelementptr inbounds %"class.al::ptr_wrapper", ptr %23, i32 0, i32 0
  %96 = load ptr, ptr %95, align 8
  %97 = getelementptr inbounds %"class.al::ptr_wrapper", ptr %25, i32 0, i32 0
  %98 = load ptr, ptr %97, align 8
  %99 = invoke ptr @_ZSt6copy_nIN2al11ptr_wrapperIPSt4byteEEmS4_ET1_T_T0_S5_(ptr %96, i64 noundef %92, ptr %98)
          to label %100 unwind label %133

100:                                              ; preds = %78
  %101 = getelementptr inbounds %"class.al::ptr_wrapper", ptr %22, i32 0, i32 0
  store ptr %99, ptr %101, align 8
  call void @llvm.lifetime.end.p0(i64 8, ptr %24) #7
  %102 = load ptr, ptr %20, align 8, !tbaa !5
  %103 = load i64, ptr %102, align 8, !tbaa !9
  %104 = icmp ugt i64 %103, 0
  br i1 %104, label %105, label %121

105:                                              ; preds = %100
  %106 = getelementptr inbounds %struct.RingBuffer, ptr %29, i32 0, i32 8
  %107 = call ptr @_ZN2al9FlexArrayISt4byteLm16EE5beginEv(ptr noundef nonnull align 16 dereferenceable(16) %106) #7
  %108 = getelementptr inbounds %"class.al::ptr_wrapper", ptr %26, i32 0, i32 0
  store ptr %107, ptr %108, align 8
  %109 = load ptr, ptr %20, align 8, !tbaa !5
  %110 = load i64, ptr %109, align 8, !tbaa !9
  %111 = getelementptr inbounds %struct.RingBuffer, ptr %29, i32 0, i32 6
  %112 = load i64, ptr %111, align 16, !tbaa !18
  %113 = mul i64 %110, %112
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %27, ptr align 8 %22, i64 8, i1 false), !tbaa.struct !19
  %114 = getelementptr inbounds %"class.al::ptr_wrapper", ptr %26, i32 0, i32 0
  %115 = load ptr, ptr %114, align 8
  %116 = getelementptr inbounds %"class.al::ptr_wrapper", ptr %27, i32 0, i32 0
  %117 = load ptr, ptr %116, align 8
  %118 = invoke ptr @_ZSt6copy_nIN2al11ptr_wrapperIPSt4byteEEmS4_ET1_T_T0_S5_(ptr %115, i64 noundef %113, ptr %117)
          to label %119 unwind label %133

119:                                              ; preds = %105
  %120 = getelementptr inbounds %"class.al::ptr_wrapper", ptr %28, i32 0, i32 0
  store ptr %118, ptr %120, align 8
  br label %121

121:                                              ; preds = %119, %100
  %122 = getelementptr inbounds %struct.RingBuffer, ptr %29, i32 0, i32 2
  %123 = load i64, ptr %9, align 8, !tbaa !9
  %124 = load ptr, ptr %19, align 8, !tbaa !5
  %125 = load i64, ptr %124, align 8, !tbaa !9
  %126 = add i64 %123, %125
  %127 = load ptr, ptr %20, align 8, !tbaa !5
  %128 = load i64, ptr %127, align 8, !tbaa !9
  %129 = add i64 %126, %128
  call void @_ZNSt13__atomic_baseImE5storeEmSt12memory_order(ptr noundef nonnull align 8 dereferenceable(8) %122, i64 noundef %129, i32 noundef 3) #7
  %130 = load i64, ptr %12, align 8, !tbaa !9
  store i64 %130, ptr %4, align 8
  store i32 1, ptr %11, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %22) #7
  call void @llvm.lifetime.end.p0(i64 16, ptr %21) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %20) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %19) #7
  call void @llvm.lifetime.end.p0(i64 16, ptr %15) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #7
  br label %131

131:                                              ; preds = %121, %39
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #7
  %132 = load i64, ptr %4, align 8
  ret i64 %132

133:                                              ; preds = %105, %78, %70, %59, %56, %40
  %134 = landingpad { ptr, i32 }
          catch ptr null
  %135 = extractvalue { ptr, i32 } %134, 0
  call void @__clang_call_terminate(ptr %135) #8
  unreachable
}

; Function Attrs: alwaysinline mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZNKSt13__atomic_baseImE4loadESt12memory_order(ptr noundef nonnull align 8 dereferenceable(8), i32 noundef) #1 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3minImERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) #4

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZSt10make_tupleIJRKmmEESt5tupleIJDpNSt25__strip_reference_wrapperINSt5decayIT_E4typeEE6__typeEEEDpOS5_(ptr dead_on_unwind noalias writable sret(%"class.std::tuple.2") align 8, ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) #2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_Zli3_uzy(i64 noundef) #2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZSt10make_tupleIJmmEESt5tupleIJDpNSt25__strip_reference_wrapperINSt5decayIT_E4typeEE6__typeEEEDpOS3_(ptr dead_on_unwind noalias writable sret(%"class.std::tuple.2") align 8, ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) #2

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

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

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local ptr @_ZSt6copy_nIN2al11ptr_wrapperIPSt4byteEEmS4_ET1_T_T0_S5_(ptr, i64 noundef, ptr) #5

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

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #6

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { alwaysinline 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 = { 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 = { noinline noreturn nounwind uwtable "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 = { inlinehint 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 #5 = { inlinehint 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 #6 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #7 = { nounwind }
attributes #8 = { 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 = !{!"long", !7, i64 0}
!11 = !{!12, !10, i64 136}
!12 = !{!"_ZTS10RingBuffer", !13, i64 0, !13, i64 64, !10, i64 128, !10, i64 136, !10, i64 144, !15, i64 160}
!13 = !{!"_ZTSSt6atomicImE", !14, i64 0}
!14 = !{!"_ZTSSt13__atomic_baseImE", !10, i64 0}
!15 = !{!"_ZTSN2al9FlexArrayISt4byteLm16EEE", !16, i64 0}
!16 = !{!"_ZTSN2al16FlexArrayStorageISt4byteLm16ELb1EEE", !17, i64 0}
!17 = !{!"_ZTSN2al4spanISt4byteLm18446744073709551615EEE", !6, i64 0, !10, i64 8}
!18 = !{!12, !10, i64 144}
!19 = !{i64 0, i64 8, !5}


; 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::tuple.2" = type { %"struct.std::_Tuple_impl.3" }
%"struct.std::_Tuple_impl.3" = type { %"struct.std::_Tuple_impl.4", %"struct.std::_Head_base.6" }
%"struct.std::_Tuple_impl.4" = type { %"struct.std::_Head_base.5" }
%"struct.std::_Head_base.5" = type { i64 }
%"struct.std::_Head_base.6" = type { i64 }
%"class.al::span" = type { ptr, i64 }
%"class.al::ptr_wrapper" = type { ptr }

; Function Attrs: mustprogress 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: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: alwaysinline mustprogress nounwind uwtable
declare dso_local void @_ZNSt13__atomic_baseImE5storeEmSt12memory_order(ptr noundef nonnull align 8 dereferenceable(8), i64 noundef, i32 noundef) local_unnamed_addr #1 align 2

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

; Function Attrs: noinline noreturn nounwind uwtable
declare hidden void @__clang_call_terminate(ptr noundef) local_unnamed_addr #3

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef i64 @_ZN10RingBuffer4readEPvm(ptr noundef nonnull align 64 dereferenceable(176) %0, ptr noundef %1, i64 noundef %2) local_unnamed_addr #2 align 2 personality ptr @__gxx_personality_v0 {
  %4 = alloca i64, align 8
  %5 = alloca i64, align 8
  %6 = alloca i64, align 8
  %7 = alloca %"class.std::tuple.2", align 8
  %8 = alloca i64, align 8
  %9 = alloca i64, align 8
  %10 = alloca i64, align 8
  %11 = alloca %"class.al::span", align 8
  %12 = alloca %"class.al::ptr_wrapper", align 8
  store i64 %2, ptr %4, align 8, !tbaa !5
  %13 = tail call noundef i64 @_ZNKSt13__atomic_baseImE4loadESt12memory_order(ptr noundef nonnull align 8 dereferenceable(8) %0, i32 noundef 2) #6
  %14 = getelementptr inbounds i8, ptr %0, i64 64
  %15 = tail call noundef i64 @_ZNKSt13__atomic_baseImE4loadESt12memory_order(ptr noundef nonnull align 8 dereferenceable(8) %14, i32 noundef 0) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #6
  %16 = sub i64 %13, %15
  store i64 %16, ptr %5, align 8, !tbaa !5
  %17 = icmp eq i64 %13, %15
  br i1 %17, label %62, label %18

18:                                               ; preds = %3
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %6) #6
  %19 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3minImERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %4, ptr noundef nonnull align 8 dereferenceable(8) %5)
  %20 = load i64, ptr %19, align 8, !tbaa !5
  store i64 %20, ptr %6, align 8, !tbaa !5
  %21 = getelementptr inbounds i8, ptr %0, i64 136
  %22 = load i64, ptr %21, align 8, !tbaa !9
  %23 = and i64 %22, %15
  %24 = add i64 %23, %20
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %7) #6
  %25 = add i64 %22, 1
  %.not = icmp ugt i64 %24, %25
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %8) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %9) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %10) #6
  br i1 %.not, label %28, label %26

26:                                               ; preds = %18
  %27 = call noundef i64 @_Zli3_uzy(i64 noundef 0) #6
  store i64 %27, ptr %8, align 8, !tbaa !5
  call void @_ZSt10make_tupleIJRKmmEESt5tupleIJDpNSt25__strip_reference_wrapperINSt5decayIT_E4typeEE6__typeEEEDpOS5_(ptr dead_on_unwind nonnull writable sret(%"class.std::tuple.2") align 8 %7, ptr noundef nonnull align 8 dereferenceable(8) %6, ptr noundef nonnull align 8 dereferenceable(8) %8)
  br label %31

28:                                               ; preds = %18
  %29 = sub i64 %25, %23
  store i64 %29, ptr %9, align 8, !tbaa !5
  %30 = and i64 %24, %22
  store i64 %30, ptr %10, align 8, !tbaa !5
  call void @_ZSt10make_tupleIJmmEESt5tupleIJDpNSt25__strip_reference_wrapperINSt5decayIT_E4typeEE6__typeEEEDpOS3_(ptr dead_on_unwind nonnull writable sret(%"class.std::tuple.2") align 8 %7, ptr noundef nonnull align 8 dereferenceable(8) %9, ptr noundef nonnull align 8 dereferenceable(8) %10)
  br label %31

31:                                               ; preds = %28, %26
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %10) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %9) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %8) #6
  %32 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3getILm0EJmmEEOKNSt13tuple_elementIXT_ESt5tupleIJDpT0_EEE4typeEOKS4_(ptr noundef nonnull align 8 dereferenceable(16) %7) #6
  %33 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3getILm1EJmmEEOKNSt13tuple_elementIXT_ESt5tupleIJDpT0_EEE4typeEOKS4_(ptr noundef nonnull align 8 dereferenceable(16) %7) #6
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %11) #6
  %34 = load i64, ptr %4, align 8, !tbaa !5
  %35 = getelementptr inbounds i8, ptr %0, i64 144
  %36 = load i64, ptr %35, align 16, !tbaa !17
  %37 = mul i64 %36, %34
  call void @_ZN2al4spanISt4byteLm18446744073709551615EEC2IPS1_EET_m(ptr noundef nonnull align 8 dereferenceable(16) %11, ptr noundef %1, i64 noundef %37)
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %12) #6
  %38 = getelementptr inbounds i8, ptr %0, i64 160
  %39 = call ptr @_ZN2al9FlexArrayISt4byteLm16EE5beginEv(ptr noundef nonnull align 16 dereferenceable(16) %38) #6
  store ptr %39, ptr %12, align 8
  %40 = load i64, ptr %35, align 16, !tbaa !17
  %41 = mul i64 %40, %23
  %42 = call ptr @_ZN2alplERKNS_11ptr_wrapperIPSt4byteEEl(ptr noundef nonnull align 8 dereferenceable(8) %12, i64 noundef %41) #6
  %43 = load i64, ptr %32, align 8, !tbaa !5
  %44 = load i64, ptr %35, align 16, !tbaa !17
  %45 = mul i64 %44, %43
  %46 = call ptr @_ZNK2al4spanISt4byteLm18446744073709551615EE5beginEv(ptr noundef nonnull align 8 dereferenceable(16) %11) #6
  %47 = invoke ptr @_ZSt6copy_nIN2al11ptr_wrapperIPSt4byteEEmS4_ET1_T_T0_S5_(ptr %42, i64 noundef %45, ptr %46)
          to label %48 unwind label %63

48:                                               ; preds = %31
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %12) #6
  %49 = load i64, ptr %33, align 8, !tbaa !5
  %.not22 = icmp eq i64 %49, 0
  br i1 %.not22, label %56, label %50

50:                                               ; preds = %48
  %51 = call ptr @_ZN2al9FlexArrayISt4byteLm16EE5beginEv(ptr noundef nonnull align 16 dereferenceable(16) %38) #6
  %52 = load i64, ptr %33, align 8, !tbaa !5
  %53 = load i64, ptr %35, align 16, !tbaa !17
  %54 = mul i64 %53, %52
  %55 = invoke ptr @_ZSt6copy_nIN2al11ptr_wrapperIPSt4byteEEmS4_ET1_T_T0_S5_(ptr %51, i64 noundef %54, ptr %47)
          to label %._crit_edge unwind label %63

._crit_edge:                                      ; preds = %50
  %.pre = load i64, ptr %33, align 8, !tbaa !5
  br label %56

56:                                               ; preds = %._crit_edge, %48
  %57 = phi i64 [ %.pre, %._crit_edge ], [ 0, %48 ]
  %58 = load i64, ptr %32, align 8, !tbaa !5
  %59 = add i64 %58, %15
  %60 = add i64 %59, %57
  call void @_ZNSt13__atomic_baseImE5storeEmSt12memory_order(ptr noundef nonnull align 8 dereferenceable(8) %14, i64 noundef %60, i32 noundef 3) #6
  %61 = load i64, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %11) #6
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %7) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %6) #6
  br label %62

62:                                               ; preds = %3, %56
  %.0 = phi i64 [ %61, %56 ], [ 0, %3 ]
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #6
  ret i64 %.0

63:                                               ; preds = %50, %31
  %64 = landingpad { ptr, i32 }
          catch ptr null
  %65 = extractvalue { ptr, i32 } %64, 0
  call void @__clang_call_terminate(ptr %65) #7
  unreachable
}

; Function Attrs: alwaysinline mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZNKSt13__atomic_baseImE4loadESt12memory_order(ptr noundef nonnull align 8 dereferenceable(8), i32 noundef) local_unnamed_addr #1 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3minImERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #4

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZSt10make_tupleIJRKmmEESt5tupleIJDpNSt25__strip_reference_wrapperINSt5decayIT_E4typeEE6__typeEEEDpOS5_(ptr dead_on_unwind noalias writable sret(%"class.std::tuple.2") align 8, ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_Zli3_uzy(i64 noundef) local_unnamed_addr #2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZSt10make_tupleIJmmEESt5tupleIJDpNSt25__strip_reference_wrapperINSt5decayIT_E4typeEE6__typeEEEDpOS3_(ptr dead_on_unwind noalias writable sret(%"class.std::tuple.2") align 8, ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #2

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

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

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local ptr @_ZSt6copy_nIN2al11ptr_wrapperIPSt4byteEEmS4_ET1_T_T0_S5_(ptr, i64 noundef, ptr) local_unnamed_addr #5

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

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

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { alwaysinline 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 = { 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 = { noinline noreturn nounwind uwtable "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 = { inlinehint 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 #5 = { inlinehint 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 #6 = { nounwind }
attributes #7 = { 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 = !{!"long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !6, i64 136}
!10 = !{!"_ZTS10RingBuffer", !11, i64 0, !11, i64 64, !6, i64 128, !6, i64 136, !6, i64 144, !13, i64 160}
!11 = !{!"_ZTSSt6atomicImE", !12, i64 0}
!12 = !{!"_ZTSSt13__atomic_baseImE", !6, i64 0}
!13 = !{!"_ZTSN2al9FlexArrayISt4byteLm16EEE", !14, i64 0}
!14 = !{!"_ZTSN2al16FlexArrayStorageISt4byteLm16ELb1EEE", !15, i64 0}
!15 = !{!"_ZTSN2al4spanISt4byteLm18446744073709551615EEE", !16, i64 0, !6, i64 8}
!16 = !{!"any pointer", !7, i64 0}
!17 = !{!10, !6, i64 144}


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