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

; 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 uwtable
define dso_local noundef i32 @_ZN4Fifo5WriteEPKhm(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 i64, align 8
  %16 = alloca ptr, align 8
  %17 = alloca i32, align 4
  %18 = alloca i32, align 4
  %19 = alloca i64, align 8
  %20 = alloca i64, align 8
  %21 = alloca i32, align 4
  %22 = 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
  %23 = 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
  %24 = getelementptr inbounds %class.Fifo, ptr %23, i32 0, i32 0
  %25 = load i64, ptr %24, align 8, !tbaa !11
  store i64 %25, ptr %8, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #5
  %26 = getelementptr inbounds %class.Fifo, ptr %23, i32 0, i32 1
  %27 = load i64, ptr %26, align 8, !tbaa !17
  store i64 %27, ptr %9, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #5
  %28 = getelementptr inbounds %class.Fifo, ptr %23, i32 0, i32 2
  %29 = load i64, ptr %28, align 8, !tbaa !18
  store i64 %29, ptr %10, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #5
  %30 = load i64, ptr %9, align 8, !tbaa !9
  %31 = load i64, ptr %10, align 8, !tbaa !9
  %32 = icmp eq i64 %30, %31
  br i1 %32, label %33, label %46

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

38:                                               ; preds = %33
  br label %44

39:                                               ; preds = %33
  %40 = getelementptr inbounds %class.Fifo, ptr %23, i32 0, i32 3
  %41 = call noundef i64 @_ZNKSt6vectorIhSaIhEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %40) #5
  %42 = load i64, ptr %9, align 8, !tbaa !9
  %43 = sub i64 %41, %42
  br label %44

44:                                               ; preds = %39, %38
  %45 = phi i64 [ 0, %38 ], [ %43, %39 ]
  br label %61

46:                                               ; preds = %3
  %47 = load i64, ptr %9, align 8, !tbaa !9
  %48 = load i64, ptr %10, align 8, !tbaa !9
  %49 = icmp ugt i64 %47, %48
  br i1 %49, label %50, label %55

50:                                               ; preds = %46
  %51 = getelementptr inbounds %class.Fifo, ptr %23, i32 0, i32 3
  %52 = call noundef i64 @_ZNKSt6vectorIhSaIhEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %51) #5
  %53 = load i64, ptr %9, align 8, !tbaa !9
  %54 = sub i64 %52, %53
  br label %59

55:                                               ; preds = %46
  %56 = load i64, ptr %10, align 8, !tbaa !9
  %57 = load i64, ptr %9, align 8, !tbaa !9
  %58 = sub i64 %56, %57
  br label %59

59:                                               ; preds = %55, %50
  %60 = phi i64 [ %54, %50 ], [ %58, %55 ]
  br label %61

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

66:                                               ; preds = %61
  %67 = load i64, ptr %10, align 8, !tbaa !9
  br label %69

68:                                               ; preds = %61
  br label %69

69:                                               ; preds = %68, %66
  %70 = phi i64 [ %67, %66 ], [ 0, %68 ]
  store i64 %70, 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
  %71 = load i64, ptr %11, align 8, !tbaa !9
  %72 = icmp ne i64 %71, 0
  br i1 %72, label %73, label %109

73:                                               ; preds = %69
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #5
  %74 = load i64, ptr %6, align 8, !tbaa !9
  store i64 %74, ptr %15, align 8, !tbaa !9
  %75 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3minImERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %15, ptr noundef nonnull align 8 dereferenceable(8) %11)
          to label %76 unwind label %87

76:                                               ; preds = %73
  %77 = load i64, ptr %75, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #5
  store i64 %77, ptr %14, align 8, !tbaa !9
  %78 = load i64, ptr %8, align 8, !tbaa !9
  %79 = load i64, ptr %14, align 8, !tbaa !9
  %80 = add i64 %78, %79
  %81 = getelementptr inbounds %class.Fifo, ptr %23, i32 0, i32 3
  %82 = call noundef i64 @_ZNKSt6vectorIhSaIhEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %81) #5
  %83 = icmp ugt i64 %80, %82
  br i1 %83, label %84, label %91

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

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

91:                                               ; preds = %84, %76
  %92 = getelementptr inbounds %class.Fifo, ptr %23, 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 %9, align 8, !tbaa !9
  %95 = getelementptr inbounds i8, ptr %93, i64 %94
  %96 = load ptr, ptr %5, align 8, !tbaa !5
  %97 = load i64, ptr %14, align 8, !tbaa !9
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %95, ptr align 1 %96, i64 %97, i1 false)
  %98 = load i64, ptr %14, align 8, !tbaa !9
  %99 = load i64, ptr %6, align 8, !tbaa !9
  %100 = sub i64 %99, %98
  store i64 %100, ptr %6, align 8, !tbaa !9
  %101 = load i64, ptr %14, align 8, !tbaa !9
  %102 = load i32, ptr %13, align 4, !tbaa !19
  %103 = sext i32 %102 to i64
  %104 = add i64 %103, %101
  %105 = trunc i64 %104 to i32
  store i32 %105, ptr %13, align 4, !tbaa !19
  %106 = load i64, ptr %14, align 8, !tbaa !9
  %107 = load i64, ptr %9, align 8, !tbaa !9
  %108 = add i64 %107, %106
  store i64 %108, ptr %9, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #5
  br label %109

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

114:                                              ; preds = %109
  %115 = load i64, ptr %12, align 8, !tbaa !9
  %116 = icmp ne i64 %115, 0
  br i1 %116, label %117, label %118

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

118:                                              ; preds = %117, %114, %109
  %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 %19) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %20) #5
  %125 = load i64, ptr %6, align 8, !tbaa !9
  store i64 %125, ptr %20, align 8, !tbaa !9
  %126 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3minImERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %20, ptr noundef nonnull align 8 dereferenceable(8) %12)
          to label %127 unwind label %141

127:                                              ; preds = %124
  %128 = load i64, ptr %126, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %20) #5
  store i64 %128, ptr %19, align 8, !tbaa !9
  %129 = load i64, ptr %8, align 8, !tbaa !9
  %130 = load i32, ptr %13, align 4, !tbaa !19
  %131 = sext i32 %130 to i64
  %132 = add i64 %129, %131
  %133 = load i64, ptr %19, align 8, !tbaa !9
  %134 = add i64 %132, %133
  %135 = getelementptr inbounds %class.Fifo, ptr %23, i32 0, i32 3
  %136 = call noundef i64 @_ZNKSt6vectorIhSaIhEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %135) #5
  %137 = icmp ugt i64 %134, %136
  br i1 %137, label %138, label %145

138:                                              ; preds = %127
  call void @llvm.lifetime.start.p0(i64 4, ptr %21) #5
  store i32 0, ptr %21, align 4, !tbaa !19
  %139 = load i32, ptr %21, align 4, !tbaa !19
  %140 = add nsw i32 %139, 1
  store i32 %140, ptr %21, align 4, !tbaa !19
  call void @llvm.lifetime.end.p0(i64 4, ptr %21) #5
  br label %145

141:                                              ; preds = %124
  %142 = landingpad { ptr, i32 }
          cleanup
  %143 = extractvalue { ptr, i32 } %142, 0
  store ptr %143, ptr %16, align 8
  %144 = extractvalue { ptr, i32 } %142, 1
  store i32 %144, ptr %17, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %20) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %19) #5
  br label %188

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

161:                                              ; preds = %145, %121, %118
  %162 = load i64, ptr %9, align 8, !tbaa !9
  %163 = getelementptr inbounds %class.Fifo, ptr %23, i32 0, i32 3
  %164 = call noundef i64 @_ZNKSt6vectorIhSaIhEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %163) #5
  %165 = icmp eq i64 %162, %164
  br i1 %165, label %166, label %167

166:                                              ; preds = %161
  store i64 0, ptr %9, align 8, !tbaa !9
  br label %167

167:                                              ; preds = %166, %161
  %168 = load i64, ptr %9, align 8, !tbaa !9
  %169 = getelementptr inbounds %class.Fifo, ptr %23, i32 0, i32 1
  store i64 %168, ptr %169, align 8, !tbaa !17
  %170 = getelementptr inbounds %class.Fifo, ptr %23, i32 0, i32 0
  %171 = load i64, ptr %170, align 8, !tbaa !11
  %172 = load i32, ptr %13, align 4, !tbaa !19
  %173 = sext i32 %172 to i64
  %174 = add i64 %171, %173
  %175 = getelementptr inbounds %class.Fifo, ptr %23, i32 0, i32 3
  %176 = call noundef i64 @_ZNKSt6vectorIhSaIhEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %175) #5
  %177 = icmp ugt i64 %174, %176
  br i1 %177, label %178, label %181

178:                                              ; preds = %167
  call void @llvm.lifetime.start.p0(i64 4, ptr %22) #5
  store i32 0, ptr %22, align 4, !tbaa !19
  %179 = load i32, ptr %22, align 4, !tbaa !19
  %180 = add nsw i32 %179, 1
  store i32 %180, ptr %22, align 4, !tbaa !19
  call void @llvm.lifetime.end.p0(i64 4, ptr %22) #5
  br label %181

181:                                              ; preds = %178, %167
  %182 = load i32, ptr %13, align 4, !tbaa !19
  %183 = sext i32 %182 to i64
  %184 = getelementptr inbounds %class.Fifo, ptr %23, i32 0, i32 0
  %185 = load i64, ptr %184, align 8, !tbaa !11
  %186 = add i64 %185, %183
  store i64 %186, ptr %184, align 8, !tbaa !11
  %187 = 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 %187

188:                                              ; preds = %141, %87
  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 %189

189:                                              ; preds = %188
  %190 = load ptr, ptr %16, align 8
  %191 = load i32, ptr %17, align 4
  %192 = insertvalue { ptr, i32 } poison, ptr %190, 0
  %193 = insertvalue { ptr, i32 } %192, i32 %191, 1
  resume { ptr, i32 } %193
}

; 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

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 uwtable
define dso_local noundef i32 @_ZN4Fifo5WriteEPKhm(ptr noundef nonnull align 8 dereferenceable(48) %0, ptr nocapture noundef readonly %1, i64 noundef %2) local_unnamed_addr #2 align 2 personality ptr @__gxx_personality_v0 {
  %4 = alloca %"class.std::lock_guard", align 8
  %5 = alloca i64, align 8
  %6 = alloca i64, align 8
  %7 = alloca i64, align 8
  %8 = alloca i64, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #5
  call void @_ZNSt10lock_guardISt5mutexEC2ERS0_(ptr noundef nonnull align 8 dereferenceable(8) %4, ptr noundef nonnull align 8 dereferenceable(40) @mLockMutex)
  %9 = load i64, ptr %0, align 8, !tbaa !5
  %10 = getelementptr inbounds i8, ptr %0, i64 8
  %11 = load i64, ptr %10, align 8, !tbaa !15
  %12 = getelementptr inbounds i8, ptr %0, i64 16
  %13 = load i64, ptr %12, align 8, !tbaa !16
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #5
  %14 = icmp eq i64 %11, %13
  br i1 %14, label %15, label %19

15:                                               ; preds = %3
  %16 = getelementptr inbounds i8, ptr %0, i64 24
  %17 = call noundef i64 @_ZNKSt6vectorIhSaIhEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %16) #5
  %18 = icmp eq i64 %9, %17
  br i1 %18, label %.thread, label %.sink.split

.thread:                                          ; preds = %15
  store i64 0, ptr %5, align 8, !tbaa !17
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %6) #5
  store i64 0, ptr %6, align 8, !tbaa !17
  br label %38

19:                                               ; preds = %3
  %20 = icmp ugt i64 %11, %13
  br i1 %20, label %21, label %24

21:                                               ; preds = %19
  %22 = getelementptr inbounds i8, ptr %0, i64 24
  br label %.sink.split

.sink.split:                                      ; preds = %15, %21
  %.sink = phi ptr [ %22, %21 ], [ %16, %15 ]
  %23 = call noundef i64 @_ZNKSt6vectorIhSaIhEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %.sink) #5
  br label %24

24:                                               ; preds = %.sink.split, %19
  %.pn = phi i64 [ %13, %19 ], [ %23, %.sink.split ]
  %25 = sub i64 %.pn, %11
  store i64 %25, ptr %5, align 8, !tbaa !17
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %6) #5
  %26 = icmp ugt i64 %11, %13
  %27 = select i1 %26, i64 %13, i64 0
  store i64 %27, ptr %6, align 8, !tbaa !17
  %.not = icmp eq i64 %.pn, %11
  br i1 %.not, label %38, label %28

28:                                               ; preds = %24
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %7) #5
  store i64 %2, ptr %7, align 8, !tbaa !17
  %29 = 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) %5)
  %30 = load i64, ptr %29, align 8, !tbaa !17
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %7) #5
  %31 = getelementptr inbounds i8, ptr %0, i64 24
  %32 = call noundef i64 @_ZNKSt6vectorIhSaIhEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %31) #5
  %33 = call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt6vectorIhSaIhEE5frontEv(ptr noundef nonnull align 8 dereferenceable(24) %31) #5
  %34 = getelementptr inbounds i8, ptr %33, i64 %11
  call void @llvm.memcpy.p0.p0.i64(ptr nonnull align 1 %34, ptr align 1 %1, i64 %30, i1 false)
  %35 = sub i64 %2, %30
  %36 = trunc i64 %30 to i32
  %37 = add i64 %30, %11
  br label %38

38:                                               ; preds = %.thread, %28, %24
  %39 = phi i64 [ %27, %28 ], [ %27, %24 ], [ 0, %.thread ]
  %.050 = phi i32 [ %36, %28 ], [ 0, %24 ], [ 0, %.thread ]
  %.049 = phi i64 [ %37, %28 ], [ %11, %24 ], [ %11, %.thread ]
  %.0 = phi i64 [ %35, %28 ], [ %2, %24 ], [ %2, %.thread ]
  %40 = getelementptr inbounds i8, ptr %0, i64 24
  %41 = call noundef i64 @_ZNKSt6vectorIhSaIhEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %40) #5
  %42 = icmp eq i64 %.049, %41
  %43 = icmp ne i64 %39, 0
  %or.cond = and i1 %42, %43
  %spec.select = select i1 %or.cond, i64 0, i64 %.049
  %44 = icmp ne i64 %.0, 0
  %or.cond3 = and i1 %44, %43
  br i1 %or.cond3, label %45, label %53

45:                                               ; preds = %38
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %8) #5
  store i64 %.0, ptr %8, align 8, !tbaa !17
  %46 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3minImERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %8, ptr noundef nonnull align 8 dereferenceable(8) %6)
  %47 = load i64, ptr %46, align 8, !tbaa !17
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %8) #5
  %48 = call noundef i64 @_ZNKSt6vectorIhSaIhEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %40) #5
  %49 = call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt6vectorIhSaIhEE5frontEv(ptr noundef nonnull align 8 dereferenceable(24) %40) #5
  call void @llvm.memcpy.p0.p0.i64(ptr nonnull align 1 %49, ptr align 1 %1, i64 %47, i1 false)
  %50 = trunc i64 %47 to i32
  %51 = add i32 %.050, %50
  %52 = add i64 %47, %spec.select
  br label %53

53:                                               ; preds = %45, %38
  %.151 = phi i32 [ %51, %45 ], [ %.050, %38 ]
  %.2 = phi i64 [ %52, %45 ], [ %spec.select, %38 ]
  %54 = call noundef i64 @_ZNKSt6vectorIhSaIhEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %40) #5
  %55 = icmp eq i64 %.2, %54
  %spec.select55 = select i1 %55, i64 0, i64 %.2
  store i64 %spec.select55, ptr %10, align 8, !tbaa !15
  %56 = sext i32 %.151 to i64
  %57 = call noundef i64 @_ZNKSt6vectorIhSaIhEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %40) #5
  %58 = load i64, ptr %0, align 8, !tbaa !5
  %59 = add i64 %58, %56
  store i64 %59, ptr %0, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %6) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #5
  call void @_ZNSt10lock_guardISt5mutexED2Ev(ptr noundef nonnull align 8 dereferenceable(8) %4) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #5
  ret i32 %.151
}

; 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

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, !7, i64 0}
!6 = !{!"_ZTS4Fifo", !7, i64 0, !7, i64 8, !7, i64 16, !10, i64 24}
!7 = !{!"long", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"_ZTSSt6vectorIhSaIhEE", !11, i64 0}
!11 = !{!"_ZTSSt12_Vector_baseIhSaIhEE", !12, i64 0}
!12 = !{!"_ZTSNSt12_Vector_baseIhSaIhEE12_Vector_implE", !13, i64 0}
!13 = !{!"_ZTSNSt12_Vector_baseIhSaIhEE17_Vector_impl_dataE", !14, i64 0, !14, i64 8, !14, i64 16}
!14 = !{!"any pointer", !8, i64 0}
!15 = !{!6, !7, i64 8}
!16 = !{!6, !7, i64 16}
!17 = !{!7, !7, i64 0}


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