; LLVM IR from GPUOpen-LibrariesAndSDKs/TAN :: tan/common/fifo.ll (ZN4Fifo4ReadEPhm)

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

%union.pthread_mutex_t = type { %struct.__pthread_mutex_s }
%struct.__pthread_mutex_s = type { i32, i32, i32, i32, i32, i16, i16, %struct.__pthread_internal_list }
%struct.__pthread_internal_list = type { ptr, ptr }
%"class.std::lock_guard" = type { ptr }
%class.Fifo = type { i64, i64, i64, %"class.std::vector" }
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<unsigned char, std::allocator<unsigned char>>::_Vector_impl" }
%"struct.std::_Vector_base<unsigned char, std::allocator<unsigned char>>::_Vector_impl" = type { %"struct.std::_Vector_base<unsigned char, std::allocator<unsigned char>>::_Vector_impl_data" }
%"struct.std::_Vector_base<unsigned char, std::allocator<unsigned char>>::_Vector_impl_data" = type { ptr, ptr, ptr }

@mLockMutex = external dso_local global { %union.pthread_mutex_t }, align 8

; 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: 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) #1

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt10lock_guardISt5mutexEC2ERS0_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(40)) unnamed_addr #2 align 2

declare i32 @__gxx_personality_v0(...)

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZNKSt6vectorIhSaIhEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24)) #3 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 noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt6vectorIhSaIhEE5frontEv(ptr noundef nonnull align 8 dereferenceable(24)) #3 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZN4Fifo4ReadEPhm(ptr noundef nonnull align 8 dereferenceable(48) %0, ptr noundef %1, i64 noundef %2) #2 align 2 personality ptr @__gxx_personality_v0 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i64, align 8
  %7 = alloca %"class.std::lock_guard", align 8
  %8 = alloca i64, align 8
  %9 = alloca i64, align 8
  %10 = alloca i64, align 8
  %11 = alloca i64, align 8
  %12 = alloca i64, align 8
  %13 = alloca i32, align 4
  %14 = alloca i64, align 8
  %15 = alloca ptr, align 8
  %16 = alloca i32, align 4
  %17 = alloca i32, align 4
  %18 = alloca i64, align 8
  %19 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store i64 %2, ptr %6, align 8, !tbaa !9
  %20 = load ptr, ptr %4, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #5
  call void @_ZNSt10lock_guardISt5mutexEC2ERS0_(ptr noundef nonnull align 8 dereferenceable(8) %7, ptr noundef nonnull align 8 dereferenceable(40) @mLockMutex)
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #5
  %21 = getelementptr inbounds %class.Fifo, ptr %20, i32 0, i32 0
  %22 = load i64, ptr %21, align 8, !tbaa !11
  store i64 %22, ptr %8, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #5
  %23 = getelementptr inbounds %class.Fifo, ptr %20, i32 0, i32 1
  %24 = load i64, ptr %23, align 8, !tbaa !17
  store i64 %24, ptr %9, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #5
  %25 = getelementptr inbounds %class.Fifo, ptr %20, i32 0, i32 2
  %26 = load i64, ptr %25, align 8, !tbaa !18
  store i64 %26, ptr %10, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #5
  %27 = load i64, ptr %9, align 8, !tbaa !9
  %28 = load i64, ptr %10, align 8, !tbaa !9
  %29 = icmp eq i64 %27, %28
  br i1 %29, label %30, label %41

30:                                               ; preds = %3
  %31 = load i64, ptr %8, align 8, !tbaa !9
  %32 = icmp ne i64 %31, 0
  br i1 %32, label %33, label %38

33:                                               ; preds = %30
  %34 = getelementptr inbounds %class.Fifo, ptr %20, i32 0, i32 3
  %35 = call noundef i64 @_ZNKSt6vectorIhSaIhEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %34) #5
  %36 = load i64, ptr %9, align 8, !tbaa !9
  %37 = sub i64 %35, %36
  br label %39

38:                                               ; preds = %30
  br label %39

39:                                               ; preds = %38, %33
  %40 = phi i64 [ %37, %33 ], [ 0, %38 ]
  br label %63

41:                                               ; preds = %3
  %42 = load i64, ptr %9, align 8, !tbaa !9
  %43 = load i64, ptr %10, align 8, !tbaa !9
  %44 = icmp ugt i64 %42, %43
  br i1 %44, label %45, label %49

45:                                               ; preds = %41
  %46 = load i64, ptr %9, align 8, !tbaa !9
  %47 = load i64, ptr %10, align 8, !tbaa !9
  %48 = sub i64 %46, %47
  br label %61

49:                                               ; preds = %41
  %50 = load i64, ptr %9, align 8, !tbaa !9
  %51 = load i64, ptr %10, align 8, !tbaa !9
  %52 = icmp ult i64 %50, %51
  br i1 %52, label %53, label %58

53:                                               ; preds = %49
  %54 = getelementptr inbounds %class.Fifo, ptr %20, i32 0, i32 3
  %55 = call noundef i64 @_ZNKSt6vectorIhSaIhEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %54) #5
  %56 = load i64, ptr %10, align 8, !tbaa !9
  %57 = sub i64 %55, %56
  br label %59

58:                                               ; preds = %49
  br label %59

59:                                               ; preds = %58, %53
  %60 = phi i64 [ %57, %53 ], [ 0, %58 ]
  br label %61

61:                                               ; preds = %59, %45
  %62 = phi i64 [ %48, %45 ], [ %60, %59 ]
  br label %63

63:                                               ; preds = %61, %39
  %64 = phi i64 [ %40, %39 ], [ %62, %61 ]
  store i64 %64, ptr %11, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #5
  %65 = load i64, ptr %9, align 8, !tbaa !9
  %66 = load i64, ptr %10, align 8, !tbaa !9
  %67 = icmp ult i64 %65, %66
  br i1 %67, label %68, label %70

68:                                               ; preds = %63
  %69 = load i64, ptr %9, align 8, !tbaa !9
  br label %71

70:                                               ; preds = %63
  br label %71

71:                                               ; preds = %70, %68
  %72 = phi i64 [ %69, %68 ], [ 0, %70 ]
  store i64 %72, ptr %12, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #5
  store i32 0, ptr %13, align 4, !tbaa !19
  %73 = load i64, ptr %11, align 8, !tbaa !9
  %74 = icmp ne i64 %73, 0
  br i1 %74, label %75, label %108

75:                                               ; preds = %71
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #5
  %76 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3minImERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %11, ptr noundef nonnull align 8 dereferenceable(8) %6)
          to label %77 unwind label %86

77:                                               ; preds = %75
  %78 = load i64, ptr %76, align 8, !tbaa !9
  store i64 %78, ptr %14, align 8, !tbaa !9
  %79 = load i64, ptr %14, align 8, !tbaa !9
  %80 = getelementptr inbounds %class.Fifo, ptr %20, i32 0, i32 0
  %81 = load i64, ptr %80, align 8, !tbaa !11
  %82 = icmp ugt i64 %79, %81
  br i1 %82, label %83, label %90

83:                                               ; preds = %77
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #5
  store i32 0, ptr %17, align 4, !tbaa !19
  %84 = load i32, ptr %17, align 4, !tbaa !19
  %85 = add nsw i32 %84, 1
  store i32 %85, ptr %17, align 4, !tbaa !19
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #5
  br label %90

86:                                               ; preds = %75
  %87 = landingpad { ptr, i32 }
          cleanup
  %88 = extractvalue { ptr, i32 } %87, 0
  store ptr %88, ptr %15, align 8
  %89 = extractvalue { ptr, i32 } %87, 1
  store i32 %89, ptr %16, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #5
  br label %170

90:                                               ; preds = %83, %77
  %91 = load ptr, ptr %5, align 8, !tbaa !5
  %92 = getelementptr inbounds %class.Fifo, ptr %20, i32 0, i32 3
  %93 = call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt6vectorIhSaIhEE5frontEv(ptr noundef nonnull align 8 dereferenceable(24) %92) #5
  %94 = load i64, ptr %10, align 8, !tbaa !9
  %95 = getelementptr inbounds i8, ptr %93, i64 %94
  %96 = load i64, ptr %14, align 8, !tbaa !9
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %91, ptr align 1 %95, i64 %96, i1 false)
  %97 = load i64, ptr %14, align 8, !tbaa !9
  %98 = load i32, ptr %13, align 4, !tbaa !19
  %99 = sext i32 %98 to i64
  %100 = add i64 %99, %97
  %101 = trunc i64 %100 to i32
  store i32 %101, ptr %13, align 4, !tbaa !19
  %102 = load i64, ptr %14, align 8, !tbaa !9
  %103 = load i64, ptr %6, align 8, !tbaa !9
  %104 = sub i64 %103, %102
  store i64 %104, ptr %6, align 8, !tbaa !9
  %105 = load i64, ptr %14, align 8, !tbaa !9
  %106 = load i64, ptr %10, align 8, !tbaa !9
  %107 = add i64 %106, %105
  store i64 %107, ptr %10, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #5
  br label %108

108:                                              ; preds = %90, %71
  %109 = load i64, ptr %10, align 8, !tbaa !9
  %110 = getelementptr inbounds %class.Fifo, ptr %20, i32 0, i32 3
  %111 = call noundef i64 @_ZNKSt6vectorIhSaIhEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %110) #5
  %112 = icmp eq i64 %109, %111
  br i1 %112, label %113, label %118

113:                                              ; preds = %108
  %114 = load i64, ptr %9, align 8, !tbaa !9
  %115 = load i64, ptr %10, align 8, !tbaa !9
  %116 = icmp ult i64 %114, %115
  br i1 %116, label %117, label %118

117:                                              ; preds = %113
  store i64 0, ptr %10, align 8, !tbaa !9
  br label %118

118:                                              ; preds = %117, %113, %108
  %119 = load i64, ptr %6, align 8, !tbaa !9
  %120 = icmp ne i64 %119, 0
  br i1 %120, label %121, label %161

121:                                              ; preds = %118
  %122 = load i64, ptr %12, align 8, !tbaa !9
  %123 = icmp ne i64 %122, 0
  br i1 %123, label %124, label %161

124:                                              ; preds = %121
  call void @llvm.lifetime.start.p0(i64 8, ptr %18) #5
  %125 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3minImERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %12, ptr noundef nonnull align 8 dereferenceable(8) %6)
          to label %126 unwind label %138

126:                                              ; preds = %124
  %127 = load i64, ptr %125, align 8, !tbaa !9
  store i64 %127, ptr %18, align 8, !tbaa !9
  %128 = load i32, ptr %13, align 4, !tbaa !19
  %129 = sext i32 %128 to i64
  %130 = load i64, ptr %18, align 8, !tbaa !9
  %131 = add i64 %129, %130
  %132 = getelementptr inbounds %class.Fifo, ptr %20, i32 0, i32 0
  %133 = load i64, ptr %132, align 8, !tbaa !11
  %134 = icmp ugt i64 %131, %133
  br i1 %134, label %135, label %142

135:                                              ; preds = %126
  call void @llvm.lifetime.start.p0(i64 4, ptr %19) #5
  store i32 0, ptr %19, align 4, !tbaa !19
  %136 = load i32, ptr %19, align 4, !tbaa !19
  %137 = add nsw i32 %136, 1
  store i32 %137, ptr %19, align 4, !tbaa !19
  call void @llvm.lifetime.end.p0(i64 4, ptr %19) #5
  br label %142

138:                                              ; preds = %124
  %139 = landingpad { ptr, i32 }
          cleanup
  %140 = extractvalue { ptr, i32 } %139, 0
  store ptr %140, ptr %15, align 8
  %141 = extractvalue { ptr, i32 } %139, 1
  store i32 %141, ptr %16, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #5
  br label %170

142:                                              ; preds = %135, %126
  %143 = load ptr, ptr %5, align 8, !tbaa !5
  %144 = load i32, ptr %13, align 4, !tbaa !19
  %145 = sext i32 %144 to i64
  %146 = getelementptr inbounds i8, ptr %143, i64 %145
  %147 = getelementptr inbounds %class.Fifo, ptr %20, i32 0, i32 3
  %148 = call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt6vectorIhSaIhEE5frontEv(ptr noundef nonnull align 8 dereferenceable(24) %147) #5
  %149 = load i64, ptr %18, align 8, !tbaa !9
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %146, ptr align 1 %148, i64 %149, i1 false)
  %150 = load i64, ptr %18, align 8, !tbaa !9
  %151 = load i32, ptr %13, align 4, !tbaa !19
  %152 = sext i32 %151 to i64
  %153 = add i64 %152, %150
  %154 = trunc i64 %153 to i32
  store i32 %154, ptr %13, align 4, !tbaa !19
  %155 = load i64, ptr %18, align 8, !tbaa !9
  %156 = load i64, ptr %6, align 8, !tbaa !9
  %157 = sub i64 %156, %155
  store i64 %157, ptr %6, align 8, !tbaa !9
  %158 = load i64, ptr %18, align 8, !tbaa !9
  %159 = load i64, ptr %10, align 8, !tbaa !9
  %160 = add i64 %159, %158
  store i64 %160, ptr %10, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #5
  br label %161

161:                                              ; preds = %142, %121, %118
  %162 = load i64, ptr %10, align 8, !tbaa !9
  %163 = getelementptr inbounds %class.Fifo, ptr %20, i32 0, i32 2
  store i64 %162, ptr %163, align 8, !tbaa !18
  %164 = load i32, ptr %13, align 4, !tbaa !19
  %165 = sext i32 %164 to i64
  %166 = getelementptr inbounds %class.Fifo, ptr %20, i32 0, i32 0
  %167 = load i64, ptr %166, align 8, !tbaa !11
  %168 = sub i64 %167, %165
  store i64 %168, ptr %166, align 8, !tbaa !11
  %169 = load i32, ptr %13, align 4, !tbaa !19
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #5
  call void @_ZNSt10lock_guardISt5mutexED2Ev(ptr noundef nonnull align 8 dereferenceable(8) %7) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #5
  ret i32 %169

170:                                              ; preds = %138, %86
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #5
  call void @_ZNSt10lock_guardISt5mutexED2Ev(ptr noundef nonnull align 8 dereferenceable(8) %7) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #5
  br label %171

171:                                              ; preds = %170
  %172 = load ptr, ptr %15, align 8
  %173 = load i32, ptr %16, align 4
  %174 = insertvalue { ptr, i32 } poison, ptr %172, 0
  %175 = insertvalue { ptr, i32 } %174, i32 %173, 1
  resume { ptr, i32 } %175
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #3 = { 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 #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 = { 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 = !{!"_ZTS4Fifo", !10, i64 0, !10, i64 8, !10, i64 16, !13, i64 24}
!13 = !{!"_ZTSSt6vectorIhSaIhEE", !14, i64 0}
!14 = !{!"_ZTSSt12_Vector_baseIhSaIhEE", !15, i64 0}
!15 = !{!"_ZTSNSt12_Vector_baseIhSaIhEE12_Vector_implE", !16, i64 0}
!16 = !{!"_ZTSNSt12_Vector_baseIhSaIhEE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!17 = !{!12, !10, i64 8}
!18 = !{!12, !10, i64 16}
!19 = !{!20, !20, i64 0}
!20 = !{!"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"

%union.pthread_mutex_t = type { %struct.__pthread_mutex_s }
%struct.__pthread_mutex_s = type { i32, i32, i32, i32, i32, i16, i16, %struct.__pthread_internal_list }
%struct.__pthread_internal_list = type { ptr, ptr }
%"class.std::lock_guard" = type { ptr }

@mLockMutex = external dso_local global { %union.pthread_mutex_t }, align 8

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

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

; Function Attrs: mustprogress 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) #1

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt10lock_guardISt5mutexEC2ERS0_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(40)) unnamed_addr #2 align 2

declare i32 @__gxx_personality_v0(...)

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZNKSt6vectorIhSaIhEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #3 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 noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt6vectorIhSaIhEE5frontEv(ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #3 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZN4Fifo4ReadEPhm(ptr noundef nonnull align 8 dereferenceable(48) %0, ptr nocapture noundef writeonly %1, i64 noundef %2) local_unnamed_addr #2 align 2 personality ptr @__gxx_personality_v0 {
  %4 = alloca i64, align 8
  %5 = alloca %"class.std::lock_guard", align 8
  %6 = alloca i64, align 8
  %7 = alloca i64, align 8
  store i64 %2, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #5
  call void @_ZNSt10lock_guardISt5mutexEC2ERS0_(ptr noundef nonnull align 8 dereferenceable(8) %5, ptr noundef nonnull align 8 dereferenceable(40) @mLockMutex)
  %8 = load i64, ptr %0, align 8, !tbaa !9
  %9 = getelementptr inbounds i8, ptr %0, i64 8
  %10 = load i64, ptr %9, align 8, !tbaa !16
  %11 = getelementptr inbounds i8, ptr %0, i64 16
  %12 = load i64, ptr %11, align 8, !tbaa !17
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %6) #5
  %13 = icmp eq i64 %10, %12
  br i1 %13, label %14, label %19

14:                                               ; preds = %3
  %.not = icmp eq i64 %8, 0
  br i1 %.not, label %.thread, label %15

15:                                               ; preds = %14
  %16 = getelementptr inbounds i8, ptr %0, i64 24
  %17 = call noundef i64 @_ZNKSt6vectorIhSaIhEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %16) #5
  %18 = sub i64 %17, %10
  br label %31

19:                                               ; preds = %3
  %20 = icmp ugt i64 %10, %12
  br i1 %20, label %21, label %23

21:                                               ; preds = %19
  %22 = sub i64 %10, %12
  br label %31

23:                                               ; preds = %19
  %24 = icmp ult i64 %10, %12
  br i1 %24, label %25, label %.thread

25:                                               ; preds = %23
  %26 = getelementptr inbounds i8, ptr %0, i64 24
  %27 = call noundef i64 @_ZNKSt6vectorIhSaIhEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %26) #5
  %28 = sub i64 %27, %12
  br label %31

.thread:                                          ; preds = %14, %23
  store i64 0, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %7) #5
  %29 = icmp ult i64 %10, %12
  %30 = select i1 %29, i64 %10, i64 0
  store i64 %30, ptr %7, align 8, !tbaa !5
  br label %45

31:                                               ; preds = %21, %25, %15
  %32 = phi i64 [ %18, %15 ], [ %22, %21 ], [ %28, %25 ]
  store i64 %32, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %7) #5
  %33 = icmp ult i64 %10, %12
  %34 = select i1 %33, i64 %10, i64 0
  store i64 %34, ptr %7, align 8, !tbaa !5
  %.not47 = icmp eq i64 %32, 0
  br i1 %.not47, label %45, label %35

35:                                               ; preds = %31
  %36 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3minImERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %6, ptr noundef nonnull align 8 dereferenceable(8) %4)
  %37 = load i64, ptr %36, align 8, !tbaa !5
  %38 = getelementptr inbounds i8, ptr %0, i64 24
  %39 = call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt6vectorIhSaIhEE5frontEv(ptr noundef nonnull align 8 dereferenceable(24) %38) #5
  %40 = getelementptr inbounds i8, ptr %39, i64 %12
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %1, ptr nonnull align 1 %40, i64 %37, i1 false)
  %41 = trunc i64 %37 to i32
  %42 = load i64, ptr %4, align 8, !tbaa !5
  %43 = sub i64 %42, %37
  store i64 %43, ptr %4, align 8, !tbaa !5
  %44 = add i64 %37, %12
  br label %45

45:                                               ; preds = %.thread, %35, %31
  %46 = phi i64 [ %34, %35 ], [ %34, %31 ], [ %30, %.thread ]
  %.042 = phi i32 [ %41, %35 ], [ 0, %31 ], [ 0, %.thread ]
  %.0 = phi i64 [ %44, %35 ], [ %12, %31 ], [ %12, %.thread ]
  %47 = getelementptr inbounds i8, ptr %0, i64 24
  %48 = call noundef i64 @_ZNKSt6vectorIhSaIhEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %47) #5
  %49 = icmp eq i64 %.0, %48
  %50 = icmp ult i64 %10, %.0
  %51 = and i1 %50, %49
  %.1 = select i1 %51, i64 0, i64 %.0
  %52 = load i64, ptr %4, align 8, !tbaa !5
  %53 = icmp ne i64 %52, 0
  %54 = icmp ne i64 %46, 0
  %or.cond = and i1 %53, %54
  br i1 %or.cond, label %55, label %66

55:                                               ; preds = %45
  %56 = call 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) %4)
  %57 = load i64, ptr %56, align 8, !tbaa !5
  %58 = sext i32 %.042 to i64
  %59 = getelementptr inbounds i8, ptr %1, i64 %58
  %60 = call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt6vectorIhSaIhEE5frontEv(ptr noundef nonnull align 8 dereferenceable(24) %47) #5
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %59, ptr nonnull align 1 %60, i64 %57, i1 false)
  %61 = trunc i64 %57 to i32
  %62 = add i32 %.042, %61
  %63 = load i64, ptr %4, align 8, !tbaa !5
  %64 = sub i64 %63, %57
  store i64 %64, ptr %4, align 8, !tbaa !5
  %65 = add i64 %57, %.1
  br label %66

66:                                               ; preds = %55, %45
  %.143 = phi i32 [ %62, %55 ], [ %.042, %45 ]
  %.2 = phi i64 [ %65, %55 ], [ %.1, %45 ]
  store i64 %.2, ptr %11, align 8, !tbaa !17
  %67 = sext i32 %.143 to i64
  %68 = load i64, ptr %0, align 8, !tbaa !9
  %69 = sub i64 %68, %67
  store i64 %69, ptr %0, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %7) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %6) #5
  call void @_ZNSt10lock_guardISt5mutexED2Ev(ptr noundef nonnull align 8 dereferenceable(8) %5) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #5
  ret i32 %.143
}

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #3 = { 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 #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 = { 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 0}
!10 = !{!"_ZTS4Fifo", !6, i64 0, !6, i64 8, !6, i64 16, !11, i64 24}
!11 = !{!"_ZTSSt6vectorIhSaIhEE", !12, i64 0}
!12 = !{!"_ZTSSt12_Vector_baseIhSaIhEE", !13, i64 0}
!13 = !{!"_ZTSNSt12_Vector_baseIhSaIhEE12_Vector_implE", !14, i64 0}
!14 = !{!"_ZTSNSt12_Vector_baseIhSaIhEE17_Vector_impl_dataE", !15, i64 0, !15, i64 8, !15, i64 16}
!15 = !{!"any pointer", !7, i64 0}
!16 = !{!10, !6, i64 8}
!17 = !{!10, !6, i64 16}


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