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

; 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.8" = type { ptr, i64 }
%"class.al::ptr_wrapper.7" = type { ptr }
%"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" }
%"class.al::span" = type { ptr, i64 }

; 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: 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 ptr @_ZN2alplERKNS_11ptr_wrapperIPSt4byteEEl(ptr noundef nonnull align 8 dereferenceable(8), i64 noundef) #2

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

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef i64 @_ZN10RingBuffer5writeEPKvm(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.8", align 8
  %22 = alloca %"class.al::ptr_wrapper.7", 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.7", align 8
  %27 = alloca %"class.al::ptr_wrapper.7", align 8
  %28 = alloca %"class.al::ptr_wrapper", align 8
  %29 = 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
  %30 = load ptr, ptr %5, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #6
  %31 = getelementptr inbounds %struct.RingBuffer, ptr %30, i32 0, i32 0
  %32 = call noundef i64 @_ZNKSt13__atomic_baseImE4loadESt12memory_order(ptr noundef nonnull align 8 dereferenceable(8) %31, i32 noundef 0) #6
  store i64 %32, ptr %8, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #6
  %33 = getelementptr inbounds %struct.RingBuffer, ptr %30, i32 0, i32 2
  %34 = call noundef i64 @_ZNKSt13__atomic_baseImE4loadESt12memory_order(ptr noundef nonnull align 8 dereferenceable(8) %33, i32 noundef 2) #6
  store i64 %34, ptr %9, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #6
  %35 = getelementptr inbounds %struct.RingBuffer, ptr %30, i32 0, i32 4
  %36 = load i64, ptr %35, align 64, !tbaa !11
  %37 = load i64, ptr %8, align 8, !tbaa !9
  %38 = load i64, ptr %9, align 8, !tbaa !9
  %39 = sub i64 %37, %38
  %40 = sub i64 %36, %39
  store i64 %40, ptr %10, align 8, !tbaa !9
  %41 = load i64, ptr %10, align 8, !tbaa !9
  %42 = icmp eq i64 %41, 0
  br i1 %42, label %43, label %44

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

44:                                               ; preds = %3
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #6
  %45 = 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 %46 unwind label %146

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

60:                                               ; preds = %46
  %61 = call noundef i64 @_Zli3_uzy(i64 noundef 0) #6
  store i64 %61, 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 %62 unwind label %146

62:                                               ; preds = %60
  br label %74

63:                                               ; preds = %46
  %64 = getelementptr inbounds %struct.RingBuffer, ptr %30, i32 0, i32 5
  %65 = load i64, ptr %64, align 8, !tbaa !18
  %66 = add i64 %65, 1
  %67 = load i64, ptr %13, align 8, !tbaa !9
  %68 = sub i64 %66, %67
  store i64 %68, ptr %17, align 8, !tbaa !9
  %69 = load i64, ptr %14, align 8, !tbaa !9
  %70 = getelementptr inbounds %struct.RingBuffer, ptr %30, i32 0, i32 5
  %71 = load i64, ptr %70, align 8, !tbaa !18
  %72 = and i64 %69, %71
  store i64 %72, 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 %73 unwind label %146

73:                                               ; preds = %63
  br label %74

74:                                               ; preds = %73, %62
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %19) #6
  %75 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3getILm0EJmmEEOKNSt13tuple_elementIXT_ESt5tupleIJDpT0_EEE4typeEOKS4_(ptr noundef nonnull align 8 dereferenceable(16) %15) #6
  store ptr %75, ptr %19, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %20) #6
  %76 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3getILm1EJmmEEOKNSt13tuple_elementIXT_ESt5tupleIJDpT0_EEE4typeEOKS4_(ptr noundef nonnull align 8 dereferenceable(16) %15) #6
  store ptr %76, ptr %20, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 16, ptr %21) #6
  %77 = load ptr, ptr %6, align 8, !tbaa !5
  %78 = load i64, ptr %7, align 8, !tbaa !9
  %79 = getelementptr inbounds %struct.RingBuffer, ptr %30, i32 0, i32 6
  %80 = load i64, ptr %79, align 16, !tbaa !19
  %81 = mul i64 %78, %80
  invoke void @_ZN2al4spanIKSt4byteLm18446744073709551615EEC2IPS2_EET_m(ptr noundef nonnull align 8 dereferenceable(16) %21, ptr noundef %77, i64 noundef %81)
          to label %82 unwind label %146

82:                                               ; preds = %74
  %83 = call ptr @_ZNK2al4spanIKSt4byteLm18446744073709551615EE6cbeginEv(ptr noundef nonnull align 8 dereferenceable(16) %21) #6
  %84 = getelementptr inbounds %"class.al::ptr_wrapper.7", ptr %22, i32 0, i32 0
  store ptr %83, ptr %84, align 8
  %85 = load ptr, ptr %19, align 8, !tbaa !5
  %86 = load i64, ptr %85, align 8, !tbaa !9
  %87 = getelementptr inbounds %struct.RingBuffer, ptr %30, i32 0, i32 6
  %88 = load i64, ptr %87, align 16, !tbaa !19
  %89 = mul i64 %86, %88
  call void @llvm.lifetime.start.p0(i64 8, ptr %24) #6
  %90 = getelementptr inbounds %struct.RingBuffer, ptr %30, i32 0, i32 8
  %91 = call ptr @_ZN2al9FlexArrayISt4byteLm16EE5beginEv(ptr noundef nonnull align 16 dereferenceable(16) %90) #6
  %92 = getelementptr inbounds %"class.al::ptr_wrapper", ptr %24, i32 0, i32 0
  store ptr %91, ptr %92, align 8
  %93 = load i64, ptr %13, align 8, !tbaa !9
  %94 = getelementptr inbounds %struct.RingBuffer, ptr %30, i32 0, i32 6
  %95 = load i64, ptr %94, align 16, !tbaa !19
  %96 = mul i64 %93, %95
  %97 = call ptr @_ZN2alplERKNS_11ptr_wrapperIPSt4byteEEl(ptr noundef nonnull align 8 dereferenceable(8) %24, i64 noundef %96) #6
  %98 = getelementptr inbounds %"class.al::ptr_wrapper", ptr %23, i32 0, i32 0
  store ptr %97, ptr %98, align 8
  %99 = getelementptr inbounds %"class.al::ptr_wrapper.7", ptr %22, i32 0, i32 0
  %100 = load ptr, ptr %99, align 8
  %101 = getelementptr inbounds %"class.al::ptr_wrapper", ptr %23, i32 0, i32 0
  %102 = load ptr, ptr %101, align 8
  %103 = invoke ptr @_ZSt6copy_nIN2al11ptr_wrapperIPKSt4byteEEmNS1_IPS2_EEET1_T_T0_S8_(ptr %100, i64 noundef %89, ptr %102)
          to label %104 unwind label %146

104:                                              ; preds = %82
  %105 = getelementptr inbounds %"class.al::ptr_wrapper", ptr %25, i32 0, i32 0
  store ptr %103, ptr %105, align 8
  call void @llvm.lifetime.end.p0(i64 8, ptr %24) #6
  %106 = load ptr, ptr %20, align 8, !tbaa !5
  %107 = load i64, ptr %106, align 8, !tbaa !9
  %108 = icmp ugt i64 %107, 0
  br i1 %108, label %109, label %134

109:                                              ; preds = %104
  call void @llvm.lifetime.start.p0(i64 8, ptr %27) #6
  %110 = call ptr @_ZNK2al4spanIKSt4byteLm18446744073709551615EE6cbeginEv(ptr noundef nonnull align 8 dereferenceable(16) %21) #6
  %111 = getelementptr inbounds %"class.al::ptr_wrapper.7", ptr %27, i32 0, i32 0
  store ptr %110, ptr %111, align 8
  %112 = load ptr, ptr %19, align 8, !tbaa !5
  %113 = load i64, ptr %112, align 8, !tbaa !9
  %114 = getelementptr inbounds %struct.RingBuffer, ptr %30, i32 0, i32 6
  %115 = load i64, ptr %114, align 16, !tbaa !19
  %116 = mul i64 %113, %115
  %117 = call ptr @_ZN2alplERKNS_11ptr_wrapperIPKSt4byteEEl(ptr noundef nonnull align 8 dereferenceable(8) %27, i64 noundef %116) #6
  %118 = getelementptr inbounds %"class.al::ptr_wrapper.7", ptr %26, i32 0, i32 0
  store ptr %117, ptr %118, align 8
  %119 = load ptr, ptr %20, align 8, !tbaa !5
  %120 = load i64, ptr %119, align 8, !tbaa !9
  %121 = getelementptr inbounds %struct.RingBuffer, ptr %30, i32 0, i32 6
  %122 = load i64, ptr %121, align 16, !tbaa !19
  %123 = mul i64 %120, %122
  %124 = getelementptr inbounds %struct.RingBuffer, ptr %30, i32 0, i32 8
  %125 = call ptr @_ZN2al9FlexArrayISt4byteLm16EE5beginEv(ptr noundef nonnull align 16 dereferenceable(16) %124) #6
  %126 = getelementptr inbounds %"class.al::ptr_wrapper", ptr %28, i32 0, i32 0
  store ptr %125, ptr %126, align 8
  %127 = getelementptr inbounds %"class.al::ptr_wrapper.7", ptr %26, i32 0, i32 0
  %128 = load ptr, ptr %127, align 8
  %129 = getelementptr inbounds %"class.al::ptr_wrapper", ptr %28, i32 0, i32 0
  %130 = load ptr, ptr %129, align 8
  %131 = invoke ptr @_ZSt6copy_nIN2al11ptr_wrapperIPKSt4byteEEmNS1_IPS2_EEET1_T_T0_S8_(ptr %128, i64 noundef %123, ptr %130)
          to label %132 unwind label %146

132:                                              ; preds = %109
  %133 = getelementptr inbounds %"class.al::ptr_wrapper", ptr %29, i32 0, i32 0
  store ptr %131, ptr %133, align 8
  call void @llvm.lifetime.end.p0(i64 8, ptr %27) #6
  br label %134

134:                                              ; preds = %132, %104
  %135 = getelementptr inbounds %struct.RingBuffer, ptr %30, i32 0, i32 0
  %136 = load i64, ptr %8, align 8, !tbaa !9
  %137 = load ptr, ptr %19, align 8, !tbaa !5
  %138 = load i64, ptr %137, align 8, !tbaa !9
  %139 = add i64 %136, %138
  %140 = load ptr, ptr %20, align 8, !tbaa !5
  %141 = load i64, ptr %140, align 8, !tbaa !9
  %142 = add i64 %139, %141
  call void @_ZNSt13__atomic_baseImE5storeEmSt12memory_order(ptr noundef nonnull align 8 dereferenceable(8) %135, i64 noundef %142, i32 noundef 3) #6
  %143 = load i64, ptr %12, align 8, !tbaa !9
  store i64 %143, ptr %4, align 8
  store i32 1, ptr %11, align 4
  call void @llvm.lifetime.end.p0(i64 16, ptr %21) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %20) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %19) #6
  call void @llvm.lifetime.end.p0(i64 16, ptr %15) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #6
  br label %144

144:                                              ; preds = %134, %43
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #6
  %145 = load i64, ptr %4, align 8
  ret i64 %145

146:                                              ; preds = %109, %82, %74, %63, %60, %44
  %147 = landingpad { ptr, i32 }
          catch ptr null
  %148 = extractvalue { ptr, i32 } %147, 0
  call void @__clang_call_terminate(ptr %148) #7
  unreachable
}

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

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

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 = { 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 = !{!"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 128}
!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 136}
!19 = !{!12, !10, i64 144}


; 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.8" = type { ptr, i64 }
%"class.al::ptr_wrapper" = type { ptr }
%"class.al::ptr_wrapper.7" = 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: 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 ptr @_ZN2alplERKNS_11ptr_wrapperIPSt4byteEEl(ptr noundef nonnull align 8 dereferenceable(8), i64 noundef) local_unnamed_addr #2

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

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef i64 @_ZN10RingBuffer5writeEPKvm(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.8", align 8
  %12 = alloca %"class.al::ptr_wrapper", align 8
  %13 = alloca %"class.al::ptr_wrapper.7", align 8
  store i64 %2, ptr %4, align 8, !tbaa !5
  %14 = tail call noundef i64 @_ZNKSt13__atomic_baseImE4loadESt12memory_order(ptr noundef nonnull align 8 dereferenceable(8) %0, i32 noundef 0) #6
  %15 = getelementptr inbounds i8, ptr %0, i64 64
  %16 = tail call noundef i64 @_ZNKSt13__atomic_baseImE4loadESt12memory_order(ptr noundef nonnull align 8 dereferenceable(8) %15, i32 noundef 2) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #6
  %17 = getelementptr inbounds i8, ptr %0, i64 128
  %18 = load i64, ptr %17, align 64, !tbaa !9
  %.neg = sub i64 %16, %14
  %19 = add i64 %18, %.neg
  store i64 %19, ptr %5, align 8, !tbaa !5
  %20 = icmp eq i64 %19, 0
  br i1 %20, label %71, label %21

21:                                               ; preds = %3
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %6) #6
  %22 = 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)
  %23 = load i64, ptr %22, align 8, !tbaa !5
  store i64 %23, ptr %6, align 8, !tbaa !5
  %24 = getelementptr inbounds i8, ptr %0, i64 136
  %25 = load i64, ptr %24, align 8, !tbaa !17
  %26 = and i64 %25, %14
  %27 = add i64 %26, %23
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %7) #6
  %28 = add i64 %25, 1
  %.not = icmp ugt i64 %27, %28
  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 %31, label %29

29:                                               ; preds = %21
  %30 = call noundef i64 @_Zli3_uzy(i64 noundef 0) #6
  store i64 %30, 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 %34

31:                                               ; preds = %21
  %32 = sub i64 %28, %26
  store i64 %32, ptr %9, align 8, !tbaa !5
  %33 = and i64 %27, %25
  store i64 %33, 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 %34

34:                                               ; preds = %31, %29
  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
  %35 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3getILm0EJmmEEOKNSt13tuple_elementIXT_ESt5tupleIJDpT0_EEE4typeEOKS4_(ptr noundef nonnull align 8 dereferenceable(16) %7) #6
  %36 = 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
  %37 = load i64, ptr %4, align 8, !tbaa !5
  %38 = getelementptr inbounds i8, ptr %0, i64 144
  %39 = load i64, ptr %38, align 16, !tbaa !18
  %40 = mul i64 %39, %37
  call void @_ZN2al4spanIKSt4byteLm18446744073709551615EEC2IPS2_EET_m(ptr noundef nonnull align 8 dereferenceable(16) %11, ptr noundef %1, i64 noundef %40)
  %41 = call ptr @_ZNK2al4spanIKSt4byteLm18446744073709551615EE6cbeginEv(ptr noundef nonnull align 8 dereferenceable(16) %11) #6
  %42 = load i64, ptr %35, align 8, !tbaa !5
  %43 = load i64, ptr %38, align 16, !tbaa !18
  %44 = mul i64 %43, %42
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %12) #6
  %45 = getelementptr inbounds i8, ptr %0, i64 160
  %46 = call ptr @_ZN2al9FlexArrayISt4byteLm16EE5beginEv(ptr noundef nonnull align 16 dereferenceable(16) %45) #6
  store ptr %46, ptr %12, align 8
  %47 = load i64, ptr %38, align 16, !tbaa !18
  %48 = mul i64 %47, %26
  %49 = call ptr @_ZN2alplERKNS_11ptr_wrapperIPSt4byteEEl(ptr noundef nonnull align 8 dereferenceable(8) %12, i64 noundef %48) #6
  %50 = invoke ptr @_ZSt6copy_nIN2al11ptr_wrapperIPKSt4byteEEmNS1_IPS2_EEET1_T_T0_S8_(ptr %41, i64 noundef %44, ptr %49)
          to label %51 unwind label %72

51:                                               ; preds = %34
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %12) #6
  %52 = load i64, ptr %36, align 8, !tbaa !5
  %.not23 = icmp eq i64 %52, 0
  br i1 %.not23, label %65, label %53

53:                                               ; preds = %51
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %13) #6
  %54 = call ptr @_ZNK2al4spanIKSt4byteLm18446744073709551615EE6cbeginEv(ptr noundef nonnull align 8 dereferenceable(16) %11) #6
  store ptr %54, ptr %13, align 8
  %55 = load i64, ptr %35, align 8, !tbaa !5
  %56 = load i64, ptr %38, align 16, !tbaa !18
  %57 = mul i64 %56, %55
  %58 = call ptr @_ZN2alplERKNS_11ptr_wrapperIPKSt4byteEEl(ptr noundef nonnull align 8 dereferenceable(8) %13, i64 noundef %57) #6
  %59 = load i64, ptr %36, align 8, !tbaa !5
  %60 = load i64, ptr %38, align 16, !tbaa !18
  %61 = mul i64 %60, %59
  %62 = call ptr @_ZN2al9FlexArrayISt4byteLm16EE5beginEv(ptr noundef nonnull align 16 dereferenceable(16) %45) #6
  %63 = invoke ptr @_ZSt6copy_nIN2al11ptr_wrapperIPKSt4byteEEmNS1_IPS2_EEET1_T_T0_S8_(ptr %58, i64 noundef %61, ptr %62)
          to label %64 unwind label %72

64:                                               ; preds = %53
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %13) #6
  %.pre = load i64, ptr %36, align 8, !tbaa !5
  br label %65

65:                                               ; preds = %64, %51
  %66 = phi i64 [ %.pre, %64 ], [ 0, %51 ]
  %67 = load i64, ptr %35, align 8, !tbaa !5
  %68 = add i64 %67, %14
  %69 = add i64 %68, %66
  call void @_ZNSt13__atomic_baseImE5storeEmSt12memory_order(ptr noundef nonnull align 8 dereferenceable(8) %0, i64 noundef %69, i32 noundef 3) #6
  %70 = 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 %71

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

72:                                               ; preds = %53, %34
  %73 = landingpad { ptr, i32 }
          catch ptr null
  %74 = extractvalue { ptr, i32 } %73, 0
  call void @__clang_call_terminate(ptr %74) #7
  unreachable
}

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local ptr @_ZNK2al4spanIKSt4byteLm18446744073709551615EE6cbeginEv(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 128}
!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 136}
!18 = !{!10, !6, i64 144}


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