; LLVM IR from GPUOpen-LibrariesAndSDKs/TAN :: amf/public/common/DataStreamMemory.ll (ZN3amf23AMFDataStreamMemoryImpl5WriteEPKvmPm)

; 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::__cxx11::basic_string" = type { %"struct.std::__cxx11::basic_string<wchar_t, std::char_traits<wchar_t>, amf::amf_allocator<wchar_t>>::_Alloc_hider", i64, %union.anon }
%"struct.std::__cxx11::basic_string<wchar_t, std::char_traits<wchar_t>, amf::amf_allocator<wchar_t>>::_Alloc_hider" = type { ptr }
%union.anon = type { i64, [8 x i8] }
%"class.amf::AMFDataStreamMemoryImpl" = type { %"class.amf::AMFInterfaceImpl", ptr, i64, i64, i64 }
%"class.amf::AMFInterfaceImpl" = type { %"class.amf::AMFDataStream", %"class.amf::AMFInterfaceBase" }
%"class.amf::AMFDataStream" = type { %"class.amf::AMFInterface" }
%"class.amf::AMFInterface" = type { ptr }
%"class.amf::AMFInterfaceBase" = type { ptr, i64 }

@.str = external hidden unnamed_addr constant [14 x i32], align 4
@.str.2 = external hidden unnamed_addr constant [101 x i32], align 4
@.str.3 = external hidden unnamed_addr constant [24 x i32], align 4
@.str.6 = external hidden unnamed_addr constant [22 x i32], align 4
@.str.7 = external hidden unnamed_addr constant [23 x i32], align 4
@.str.8 = external hidden unnamed_addr constant [34 x i32], align 4

declare i32 @__gxx_personality_v0(...)

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_ZN3amf23AMFDataStreamMemoryImpl7ReallocEm(ptr noundef nonnull align 8 dereferenceable(56), i64 noundef) #0 align 2

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

; 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) #2

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZN3amf18AMFCheckExpressionEi(i32 noundef) #3

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZStplIwSt11char_traitsIwEN3amf13amf_allocatorIwEEENSt7__cxx1112basic_stringIT_T0_T1_EEOSA_SB_(ptr dead_on_unwind noalias writable sret(%"class.std::__cxx11::basic_string") align 8, ptr noundef nonnull align 8 dereferenceable(32), ptr noundef nonnull align 8 dereferenceable(32)) #4

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN3amf15AMFFormatAssertB5cxx11Ei(ptr dead_on_unwind noalias writable sret(%"class.std::__cxx11::basic_string") align 8, i32 noundef) #4

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN3amf15__FormatMessageB5cxx11EiPKwS1_z(ptr dead_on_unwind noalias writable sret(%"class.std::__cxx11::basic_string") align 8, i32 noundef, ptr noundef, ptr noundef, ...) #4

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

declare void @AMFTraceW(ptr noundef, i32 noundef, i32 noundef, ptr noundef, i32 noundef, ptr noundef, ...) #6

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

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZN3amf23AMFDataStreamMemoryImpl5WriteEPKvmPm(ptr noundef nonnull align 8 dereferenceable(56) %0, ptr noundef %1, i64 noundef %2, ptr noundef %3) unnamed_addr #0 align 2 personality ptr @__gxx_personality_v0 {
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i64, align 8
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  %11 = alloca %"class.std::__cxx11::basic_string", align 8
  %12 = alloca %"class.std::__cxx11::basic_string", align 8
  %13 = alloca %"class.std::__cxx11::basic_string", align 8
  %14 = alloca ptr, align 8
  %15 = alloca i32, align 4
  %16 = alloca i32, align 4
  %17 = alloca i32, align 4
  %18 = alloca %"class.std::__cxx11::basic_string", align 8
  %19 = alloca %"class.std::__cxx11::basic_string", align 8
  %20 = alloca %"class.std::__cxx11::basic_string", align 8
  %21 = alloca i64, align 8
  store ptr %0, ptr %6, align 8, !tbaa !5
  store ptr %1, ptr %7, align 8, !tbaa !5
  store i64 %2, ptr %8, align 8, !tbaa !9
  store ptr %3, ptr %9, align 8, !tbaa !5
  %22 = load ptr, ptr %6, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #7
  %23 = load ptr, ptr %7, align 8, !tbaa !5
  %24 = icmp ne ptr %23, null
  %25 = zext i1 %24 to i32
  store i32 %25, ptr %10, align 4, !tbaa !11
  %26 = load i32, ptr %10, align 4, !tbaa !11
  %27 = call noundef zeroext i1 @_ZN3amf18AMFCheckExpressionEi(i32 noundef %26)
  br i1 %27, label %48, label %28

28:                                               ; preds = %4
  call void @llvm.lifetime.start.p0(i64 32, ptr %11) #7
  call void @llvm.lifetime.start.p0(i64 32, ptr %12) #7
  %29 = load i32, ptr %10, align 4, !tbaa !11
  call void @_ZN3amf15AMFFormatAssertB5cxx11Ei(ptr dead_on_unwind writable sret(%"class.std::__cxx11::basic_string") align 8 %12, i32 noundef %29)
  call void @llvm.lifetime.start.p0(i64 32, ptr %13) #7
  invoke void (ptr, i32, ptr, ptr, ...) @_ZN3amf15__FormatMessageB5cxx11EiPKwS1_z(ptr dead_on_unwind writable sret(%"class.std::__cxx11::basic_string") align 8 %13, i32 noundef 0, ptr noundef @.str, ptr noundef @.str.6)
          to label %30 unwind label %34

30:                                               ; preds = %28
  invoke void @_ZStplIwSt11char_traitsIwEN3amf13amf_allocatorIwEEENSt7__cxx1112basic_stringIT_T0_T1_EEOSA_SB_(ptr dead_on_unwind writable sret(%"class.std::__cxx11::basic_string") align 8 %11, ptr noundef nonnull align 8 dereferenceable(32) %12, ptr noundef nonnull align 8 dereferenceable(32) %13)
          to label %31 unwind label %38

31:                                               ; preds = %30
  call void @_ZNSt7__cxx1112basic_stringIwSt11char_traitsIwEN3amf13amf_allocatorIwEEED2Ev(ptr noundef nonnull align 8 dereferenceable(32) %13) #7
  call void @llvm.lifetime.end.p0(i64 32, ptr %13) #7
  call void @_ZNSt7__cxx1112basic_stringIwSt11char_traitsIwEN3amf13amf_allocatorIwEEED2Ev(ptr noundef nonnull align 8 dereferenceable(32) %12) #7
  call void @llvm.lifetime.end.p0(i64 32, ptr %12) #7
  %32 = call noundef ptr @_ZNKSt7__cxx1112basic_stringIwSt11char_traitsIwEN3amf13amf_allocatorIwEEE5c_strEv(ptr noundef nonnull align 8 dereferenceable(32) %11) #7
  invoke void (ptr, i32, i32, ptr, i32, ptr, ...) @AMFTraceW(ptr noundef @.str.2, i32 noundef 112, i32 noundef 0, ptr noundef @.str.3, i32 noundef 0, ptr noundef %32)
          to label %33 unwind label %43

33:                                               ; preds = %31
  store i32 7, ptr %5, align 4
  store i32 1, ptr %16, align 4
  call void @_ZNSt7__cxx1112basic_stringIwSt11char_traitsIwEN3amf13amf_allocatorIwEEED2Ev(ptr noundef nonnull align 8 dereferenceable(32) %11) #7
  call void @llvm.lifetime.end.p0(i64 32, ptr %11) #7
  br label %49

34:                                               ; preds = %28
  %35 = landingpad { ptr, i32 }
          cleanup
  %36 = extractvalue { ptr, i32 } %35, 0
  store ptr %36, ptr %14, align 8
  %37 = extractvalue { ptr, i32 } %35, 1
  store i32 %37, ptr %15, align 4
  br label %42

38:                                               ; preds = %30
  %39 = landingpad { ptr, i32 }
          cleanup
  %40 = extractvalue { ptr, i32 } %39, 0
  store ptr %40, ptr %14, align 8
  %41 = extractvalue { ptr, i32 } %39, 1
  store i32 %41, ptr %15, align 4
  call void @_ZNSt7__cxx1112basic_stringIwSt11char_traitsIwEN3amf13amf_allocatorIwEEED2Ev(ptr noundef nonnull align 8 dereferenceable(32) %13) #7
  br label %42

42:                                               ; preds = %38, %34
  call void @llvm.lifetime.end.p0(i64 32, ptr %13) #7
  call void @_ZNSt7__cxx1112basic_stringIwSt11char_traitsIwEN3amf13amf_allocatorIwEEED2Ev(ptr noundef nonnull align 8 dereferenceable(32) %12) #7
  call void @llvm.lifetime.end.p0(i64 32, ptr %12) #7
  br label %47

43:                                               ; preds = %31
  %44 = landingpad { ptr, i32 }
          cleanup
  %45 = extractvalue { ptr, i32 } %44, 0
  store ptr %45, ptr %14, align 8
  %46 = extractvalue { ptr, i32 } %44, 1
  store i32 %46, ptr %15, align 4
  call void @_ZNSt7__cxx1112basic_stringIwSt11char_traitsIwEN3amf13amf_allocatorIwEEED2Ev(ptr noundef nonnull align 8 dereferenceable(32) %11) #7
  br label %47

47:                                               ; preds = %43, %42
  call void @llvm.lifetime.end.p0(i64 32, ptr %11) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #7
  br label %120

48:                                               ; preds = %4
  store i32 0, ptr %16, align 4
  br label %49

49:                                               ; preds = %48, %33
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #7
  %50 = load i32, ptr %16, align 4
  switch i32 %50, label %125 [
    i32 0, label %51
    i32 1, label %118
  ]

51:                                               ; preds = %49
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #7
  %52 = getelementptr inbounds %"class.amf::AMFDataStreamMemoryImpl", ptr %22, i32 0, i32 4
  %53 = load i64, ptr %52, align 8, !tbaa !13
  %54 = load i64, ptr %8, align 8, !tbaa !9
  %55 = add i64 %53, %54
  %56 = call noundef i32 @_ZN3amf23AMFDataStreamMemoryImpl7ReallocEm(ptr noundef nonnull align 8 dereferenceable(56) %22, i64 noundef %55)
  store i32 %56, ptr %17, align 4, !tbaa !19
  %57 = load i32, ptr %17, align 4, !tbaa !19
  %58 = call noundef zeroext i1 @_ZN3amf13AMFResultIsOKE10AMF_RESULT(i32 noundef %57)
  br i1 %58, label %80, label %59

59:                                               ; preds = %51
  call void @llvm.lifetime.start.p0(i64 32, ptr %18) #7
  call void @llvm.lifetime.start.p0(i64 32, ptr %19) #7
  %60 = load i32, ptr %17, align 4, !tbaa !19
  call void @_ZN3amf15AMFFormatResultB5cxx11E10AMF_RESULT(ptr dead_on_unwind writable sret(%"class.std::__cxx11::basic_string") align 8 %19, i32 noundef %60)
  call void @llvm.lifetime.start.p0(i64 32, ptr %20) #7
  invoke void (ptr, i32, ptr, ptr, ...) @_ZN3amf15__FormatMessageB5cxx11EiPKwS1_z(ptr dead_on_unwind writable sret(%"class.std::__cxx11::basic_string") align 8 %20, i32 noundef 0, ptr noundef @.str.7, ptr noundef @.str.8)
          to label %61 unwind label %66

61:                                               ; preds = %59
  invoke void @_ZStplIwSt11char_traitsIwEN3amf13amf_allocatorIwEEENSt7__cxx1112basic_stringIT_T0_T1_EEOSA_SB_(ptr dead_on_unwind writable sret(%"class.std::__cxx11::basic_string") align 8 %18, ptr noundef nonnull align 8 dereferenceable(32) %19, ptr noundef nonnull align 8 dereferenceable(32) %20)
          to label %62 unwind label %70

62:                                               ; preds = %61
  call void @_ZNSt7__cxx1112basic_stringIwSt11char_traitsIwEN3amf13amf_allocatorIwEEED2Ev(ptr noundef nonnull align 8 dereferenceable(32) %20) #7
  call void @llvm.lifetime.end.p0(i64 32, ptr %20) #7
  call void @_ZNSt7__cxx1112basic_stringIwSt11char_traitsIwEN3amf13amf_allocatorIwEEED2Ev(ptr noundef nonnull align 8 dereferenceable(32) %19) #7
  call void @llvm.lifetime.end.p0(i64 32, ptr %19) #7
  %63 = call noundef ptr @_ZNKSt7__cxx1112basic_stringIwSt11char_traitsIwEN3amf13amf_allocatorIwEEE5c_strEv(ptr noundef nonnull align 8 dereferenceable(32) %18) #7
  invoke void (ptr, i32, i32, ptr, i32, ptr, ...) @AMFTraceW(ptr noundef @.str.2, i32 noundef 113, i32 noundef 0, ptr noundef @.str.3, i32 noundef 0, ptr noundef %63)
          to label %64 unwind label %75

64:                                               ; preds = %62
  %65 = load i32, ptr %17, align 4, !tbaa !19
  store i32 %65, ptr %5, align 4
  store i32 1, ptr %16, align 4
  call void @_ZNSt7__cxx1112basic_stringIwSt11char_traitsIwEN3amf13amf_allocatorIwEEED2Ev(ptr noundef nonnull align 8 dereferenceable(32) %18) #7
  call void @llvm.lifetime.end.p0(i64 32, ptr %18) #7
  br label %81

66:                                               ; preds = %59
  %67 = landingpad { ptr, i32 }
          cleanup
  %68 = extractvalue { ptr, i32 } %67, 0
  store ptr %68, ptr %14, align 8
  %69 = extractvalue { ptr, i32 } %67, 1
  store i32 %69, ptr %15, align 4
  br label %74

70:                                               ; preds = %61
  %71 = landingpad { ptr, i32 }
          cleanup
  %72 = extractvalue { ptr, i32 } %71, 0
  store ptr %72, ptr %14, align 8
  %73 = extractvalue { ptr, i32 } %71, 1
  store i32 %73, ptr %15, align 4
  call void @_ZNSt7__cxx1112basic_stringIwSt11char_traitsIwEN3amf13amf_allocatorIwEEED2Ev(ptr noundef nonnull align 8 dereferenceable(32) %20) #7
  br label %74

74:                                               ; preds = %70, %66
  call void @llvm.lifetime.end.p0(i64 32, ptr %20) #7
  call void @_ZNSt7__cxx1112basic_stringIwSt11char_traitsIwEN3amf13amf_allocatorIwEEED2Ev(ptr noundef nonnull align 8 dereferenceable(32) %19) #7
  call void @llvm.lifetime.end.p0(i64 32, ptr %19) #7
  br label %79

75:                                               ; preds = %62
  %76 = landingpad { ptr, i32 }
          cleanup
  %77 = extractvalue { ptr, i32 } %76, 0
  store ptr %77, ptr %14, align 8
  %78 = extractvalue { ptr, i32 } %76, 1
  store i32 %78, ptr %15, align 4
  call void @_ZNSt7__cxx1112basic_stringIwSt11char_traitsIwEN3amf13amf_allocatorIwEEED2Ev(ptr noundef nonnull align 8 dereferenceable(32) %18) #7
  br label %79

79:                                               ; preds = %75, %74
  call void @llvm.lifetime.end.p0(i64 32, ptr %18) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #7
  br label %120

80:                                               ; preds = %51
  store i32 0, ptr %16, align 4
  br label %81

81:                                               ; preds = %80, %64
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #7
  %82 = load i32, ptr %16, align 4
  switch i32 %82, label %125 [
    i32 0, label %83
    i32 1, label %118
  ]

83:                                               ; preds = %81
  call void @llvm.lifetime.start.p0(i64 8, ptr %21) #7
  %84 = load i64, ptr %8, align 8, !tbaa !9
  %85 = getelementptr inbounds %"class.amf::AMFDataStreamMemoryImpl", ptr %22, i32 0, i32 2
  %86 = load i64, ptr %85, align 8, !tbaa !21
  %87 = getelementptr inbounds %"class.amf::AMFDataStreamMemoryImpl", ptr %22, i32 0, i32 4
  %88 = load i64, ptr %87, align 8, !tbaa !13
  %89 = sub i64 %86, %88
  %90 = icmp ult i64 %84, %89
  br i1 %90, label %91, label %93

91:                                               ; preds = %83
  %92 = load i64, ptr %8, align 8, !tbaa !9
  br label %99

93:                                               ; preds = %83
  %94 = getelementptr inbounds %"class.amf::AMFDataStreamMemoryImpl", ptr %22, i32 0, i32 2
  %95 = load i64, ptr %94, align 8, !tbaa !21
  %96 = getelementptr inbounds %"class.amf::AMFDataStreamMemoryImpl", ptr %22, i32 0, i32 4
  %97 = load i64, ptr %96, align 8, !tbaa !13
  %98 = sub i64 %95, %97
  br label %99

99:                                               ; preds = %93, %91
  %100 = phi i64 [ %92, %91 ], [ %98, %93 ]
  store i64 %100, ptr %21, align 8, !tbaa !9
  %101 = getelementptr inbounds %"class.amf::AMFDataStreamMemoryImpl", ptr %22, i32 0, i32 1
  %102 = load ptr, ptr %101, align 8, !tbaa !22
  %103 = getelementptr inbounds %"class.amf::AMFDataStreamMemoryImpl", ptr %22, i32 0, i32 4
  %104 = load i64, ptr %103, align 8, !tbaa !13
  %105 = getelementptr inbounds i8, ptr %102, i64 %104
  %106 = load ptr, ptr %7, align 8, !tbaa !5
  %107 = load i64, ptr %21, align 8, !tbaa !9
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %105, ptr align 1 %106, i64 %107, i1 false)
  %108 = load i64, ptr %21, align 8, !tbaa !9
  %109 = getelementptr inbounds %"class.amf::AMFDataStreamMemoryImpl", ptr %22, i32 0, i32 4
  %110 = load i64, ptr %109, align 8, !tbaa !13
  %111 = add i64 %110, %108
  store i64 %111, ptr %109, align 8, !tbaa !13
  %112 = load ptr, ptr %9, align 8, !tbaa !5
  %113 = icmp ne ptr %112, null
  br i1 %113, label %114, label %117

114:                                              ; preds = %99
  %115 = load i64, ptr %21, align 8, !tbaa !9
  %116 = load ptr, ptr %9, align 8, !tbaa !5
  store i64 %115, ptr %116, align 8, !tbaa !9
  br label %117

117:                                              ; preds = %114, %99
  store i32 0, ptr %5, align 4
  store i32 1, ptr %16, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %21) #7
  br label %118

118:                                              ; preds = %117, %81, %49
  %119 = load i32, ptr %5, align 4
  ret i32 %119

120:                                              ; preds = %79, %47
  %121 = load ptr, ptr %14, align 8
  %122 = load i32, ptr %15, align 4
  %123 = insertvalue { ptr, i32 } poison, ptr %121, 0
  %124 = insertvalue { ptr, i32 } %123, i32 %122, 1
  resume { ptr, i32 } %124

125:                                              ; preds = %81, %49
  unreachable
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZN3amf13AMFResultIsOKE10AMF_RESULT(i32 noundef) #3

declare void @_ZN3amf15AMFFormatResultB5cxx11E10AMF_RESULT(ptr dead_on_unwind writable sret(%"class.std::__cxx11::basic_string") align 8, i32 noundef) #6

attributes #0 = { mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { 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 #4 = { 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 #5 = { 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 #6 = { "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 #7 = { 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, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!14, !10, i64 48}
!14 = !{!"_ZTSN3amf23AMFDataStreamMemoryImplE", !15, i64 0, !6, i64 24, !10, i64 32, !10, i64 40, !10, i64 48}
!15 = !{!"_ZTSN3amf16AMFInterfaceImplINS_13AMFDataStreamEiiiEE", !16, i64 0, !18, i64 8}
!16 = !{!"_ZTSN3amf13AMFDataStreamE", !17, i64 0}
!17 = !{!"_ZTSN3amf12AMFInterfaceE"}
!18 = !{!"_ZTSN3amf16AMFInterfaceBaseE", !10, i64 8}
!19 = !{!20, !20, i64 0}
!20 = !{!"_ZTS10AMF_RESULT", !7, i64 0}
!21 = !{!14, !10, i64 32}
!22 = !{!14, !6, i64 24}


; 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::__cxx11::basic_string" = type { %"struct.std::__cxx11::basic_string<wchar_t, std::char_traits<wchar_t>, amf::amf_allocator<wchar_t>>::_Alloc_hider", i64, %union.anon }
%"struct.std::__cxx11::basic_string<wchar_t, std::char_traits<wchar_t>, amf::amf_allocator<wchar_t>>::_Alloc_hider" = type { ptr }
%union.anon = type { i64, [8 x i8] }

@.str = external hidden unnamed_addr constant [14 x i32], align 4
@.str.2 = external hidden unnamed_addr constant [101 x i32], align 4
@.str.3 = external hidden unnamed_addr constant [24 x i32], align 4
@.str.6 = external hidden unnamed_addr constant [22 x i32], align 4
@.str.7 = external hidden unnamed_addr constant [23 x i32], align 4
@.str.8 = external hidden unnamed_addr constant [34 x i32], align 4

declare i32 @__gxx_personality_v0(...)

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_ZN3amf23AMFDataStreamMemoryImpl7ReallocEm(ptr noundef nonnull align 8 dereferenceable(56), i64 noundef) local_unnamed_addr #0 align 2

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

; 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) #2

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZN3amf18AMFCheckExpressionEi(i32 noundef) local_unnamed_addr #3

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZStplIwSt11char_traitsIwEN3amf13amf_allocatorIwEEENSt7__cxx1112basic_stringIT_T0_T1_EEOSA_SB_(ptr dead_on_unwind noalias writable sret(%"class.std::__cxx11::basic_string") align 8, ptr noundef nonnull align 8 dereferenceable(32), ptr noundef nonnull align 8 dereferenceable(32)) local_unnamed_addr #4

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN3amf15AMFFormatAssertB5cxx11Ei(ptr dead_on_unwind noalias writable sret(%"class.std::__cxx11::basic_string") align 8, i32 noundef) local_unnamed_addr #4

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN3amf15__FormatMessageB5cxx11EiPKwS1_z(ptr dead_on_unwind noalias writable sret(%"class.std::__cxx11::basic_string") align 8, i32 noundef, ptr noundef, ptr noundef, ...) local_unnamed_addr #4

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

declare void @AMFTraceW(ptr noundef, i32 noundef, i32 noundef, ptr noundef, i32 noundef, ptr noundef, ...) local_unnamed_addr #6

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

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZN3amf23AMFDataStreamMemoryImpl5WriteEPKvmPm(ptr noundef nonnull align 8 dereferenceable(56) %0, ptr noundef readonly %1, i64 noundef %2, ptr noundef writeonly %3) unnamed_addr #0 align 2 personality ptr @__gxx_personality_v0 {
  %5 = alloca %"class.std::__cxx11::basic_string", align 8
  %6 = alloca %"class.std::__cxx11::basic_string", align 8
  %7 = alloca %"class.std::__cxx11::basic_string", align 8
  %8 = alloca %"class.std::__cxx11::basic_string", align 8
  %9 = alloca %"class.std::__cxx11::basic_string", align 8
  %10 = alloca %"class.std::__cxx11::basic_string", align 8
  %11 = icmp ne ptr %1, null
  %12 = zext i1 %11 to i32
  %13 = tail call noundef zeroext i1 @_ZN3amf18AMFCheckExpressionEi(i32 noundef %12)
  br i1 %13, label %27, label %14

14:                                               ; preds = %4
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %5) #8
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %6) #8
  call void @_ZN3amf15AMFFormatAssertB5cxx11Ei(ptr dead_on_unwind nonnull writable sret(%"class.std::__cxx11::basic_string") align 8 %6, i32 noundef %12)
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %7) #8
  invoke void (ptr, i32, ptr, ptr, ...) @_ZN3amf15__FormatMessageB5cxx11EiPKwS1_z(ptr dead_on_unwind nonnull writable sret(%"class.std::__cxx11::basic_string") align 8 %7, i32 noundef 0, ptr noundef nonnull @.str, ptr noundef nonnull @.str.6)
          to label %15 unwind label %18

15:                                               ; preds = %14
  invoke void @_ZStplIwSt11char_traitsIwEN3amf13amf_allocatorIwEEENSt7__cxx1112basic_stringIT_T0_T1_EEOSA_SB_(ptr dead_on_unwind nonnull writable sret(%"class.std::__cxx11::basic_string") align 8 %5, ptr noundef nonnull align 8 dereferenceable(32) %6, ptr noundef nonnull align 8 dereferenceable(32) %7)
          to label %16 unwind label %20

16:                                               ; preds = %15
  call void @_ZNSt7__cxx1112basic_stringIwSt11char_traitsIwEN3amf13amf_allocatorIwEEED2Ev(ptr noundef nonnull align 8 dereferenceable(32) %7) #8
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %7) #8
  call void @_ZNSt7__cxx1112basic_stringIwSt11char_traitsIwEN3amf13amf_allocatorIwEEED2Ev(ptr noundef nonnull align 8 dereferenceable(32) %6) #8
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %6) #8
  %17 = call noundef ptr @_ZNKSt7__cxx1112basic_stringIwSt11char_traitsIwEN3amf13amf_allocatorIwEEE5c_strEv(ptr noundef nonnull align 8 dereferenceable(32) %5) #8
  invoke void (ptr, i32, i32, ptr, i32, ptr, ...) @AMFTraceW(ptr noundef nonnull @.str.2, i32 noundef 112, i32 noundef 0, ptr noundef nonnull @.str.3, i32 noundef 0, ptr noundef %17)
          to label %26 unwind label %23

18:                                               ; preds = %14
  %19 = landingpad { ptr, i32 }
          cleanup
  br label %22

20:                                               ; preds = %15
  %21 = landingpad { ptr, i32 }
          cleanup
  call void @_ZNSt7__cxx1112basic_stringIwSt11char_traitsIwEN3amf13amf_allocatorIwEEED2Ev(ptr noundef nonnull align 8 dereferenceable(32) %7) #8
  br label %22

22:                                               ; preds = %20, %18
  %.pn = phi { ptr, i32 } [ %21, %20 ], [ %19, %18 ]
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %7) #8
  call void @_ZNSt7__cxx1112basic_stringIwSt11char_traitsIwEN3amf13amf_allocatorIwEEED2Ev(ptr noundef nonnull align 8 dereferenceable(32) %6) #8
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %6) #8
  br label %25

23:                                               ; preds = %16
  %24 = landingpad { ptr, i32 }
          cleanup
  call void @_ZNSt7__cxx1112basic_stringIwSt11char_traitsIwEN3amf13amf_allocatorIwEEED2Ev(ptr noundef nonnull align 8 dereferenceable(32) %5) #8
  br label %25

25:                                               ; preds = %23, %22
  %.pn33 = phi { ptr, i32 } [ %24, %23 ], [ %.pn, %22 ]
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %5) #8
  br label %58

26:                                               ; preds = %16
  call void @_ZNSt7__cxx1112basic_stringIwSt11char_traitsIwEN3amf13amf_allocatorIwEEED2Ev(ptr noundef nonnull align 8 dereferenceable(32) %5) #8
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %5) #8
  br label %57

27:                                               ; preds = %4
  %28 = getelementptr inbounds i8, ptr %0, i64 48
  %29 = load i64, ptr %28, align 8, !tbaa !5
  %30 = add i64 %29, %2
  %31 = tail call noundef i32 @_ZN3amf23AMFDataStreamMemoryImpl7ReallocEm(ptr noundef nonnull align 8 dereferenceable(56) %0, i64 noundef %30)
  %32 = tail call noundef zeroext i1 @_ZN3amf13AMFResultIsOKE10AMF_RESULT(i32 noundef %31)
  br i1 %32, label %46, label %33

33:                                               ; preds = %27
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %8) #8
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %9) #8
  call void @_ZN3amf15AMFFormatResultB5cxx11E10AMF_RESULT(ptr dead_on_unwind nonnull writable sret(%"class.std::__cxx11::basic_string") align 8 %9, i32 noundef %31)
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %10) #8
  invoke void (ptr, i32, ptr, ptr, ...) @_ZN3amf15__FormatMessageB5cxx11EiPKwS1_z(ptr dead_on_unwind nonnull writable sret(%"class.std::__cxx11::basic_string") align 8 %10, i32 noundef 0, ptr noundef nonnull @.str.7, ptr noundef nonnull @.str.8)
          to label %34 unwind label %37

34:                                               ; preds = %33
  invoke void @_ZStplIwSt11char_traitsIwEN3amf13amf_allocatorIwEEENSt7__cxx1112basic_stringIT_T0_T1_EEOSA_SB_(ptr dead_on_unwind nonnull writable sret(%"class.std::__cxx11::basic_string") align 8 %8, ptr noundef nonnull align 8 dereferenceable(32) %9, ptr noundef nonnull align 8 dereferenceable(32) %10)
          to label %35 unwind label %39

35:                                               ; preds = %34
  call void @_ZNSt7__cxx1112basic_stringIwSt11char_traitsIwEN3amf13amf_allocatorIwEEED2Ev(ptr noundef nonnull align 8 dereferenceable(32) %10) #8
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %10) #8
  call void @_ZNSt7__cxx1112basic_stringIwSt11char_traitsIwEN3amf13amf_allocatorIwEEED2Ev(ptr noundef nonnull align 8 dereferenceable(32) %9) #8
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %9) #8
  %36 = call noundef ptr @_ZNKSt7__cxx1112basic_stringIwSt11char_traitsIwEN3amf13amf_allocatorIwEEE5c_strEv(ptr noundef nonnull align 8 dereferenceable(32) %8) #8
  invoke void (ptr, i32, i32, ptr, i32, ptr, ...) @AMFTraceW(ptr noundef nonnull @.str.2, i32 noundef 113, i32 noundef 0, ptr noundef nonnull @.str.3, i32 noundef 0, ptr noundef %36)
          to label %45 unwind label %42

37:                                               ; preds = %33
  %38 = landingpad { ptr, i32 }
          cleanup
  br label %41

39:                                               ; preds = %34
  %40 = landingpad { ptr, i32 }
          cleanup
  call void @_ZNSt7__cxx1112basic_stringIwSt11char_traitsIwEN3amf13amf_allocatorIwEEED2Ev(ptr noundef nonnull align 8 dereferenceable(32) %10) #8
  br label %41

41:                                               ; preds = %39, %37
  %.pn35 = phi { ptr, i32 } [ %40, %39 ], [ %38, %37 ]
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %10) #8
  call void @_ZNSt7__cxx1112basic_stringIwSt11char_traitsIwEN3amf13amf_allocatorIwEEED2Ev(ptr noundef nonnull align 8 dereferenceable(32) %9) #8
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %9) #8
  br label %44

42:                                               ; preds = %35
  %43 = landingpad { ptr, i32 }
          cleanup
  call void @_ZNSt7__cxx1112basic_stringIwSt11char_traitsIwEN3amf13amf_allocatorIwEEED2Ev(ptr noundef nonnull align 8 dereferenceable(32) %8) #8
  br label %44

44:                                               ; preds = %42, %41
  %.pn37 = phi { ptr, i32 } [ %43, %42 ], [ %.pn35, %41 ]
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %8) #8
  br label %58

45:                                               ; preds = %35
  call void @_ZNSt7__cxx1112basic_stringIwSt11char_traitsIwEN3amf13amf_allocatorIwEEED2Ev(ptr noundef nonnull align 8 dereferenceable(32) %8) #8
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %8) #8
  br label %57

46:                                               ; preds = %27
  %47 = getelementptr inbounds i8, ptr %0, i64 32
  %48 = load i64, ptr %47, align 8, !tbaa !15
  %49 = load i64, ptr %28, align 8, !tbaa !5
  %50 = sub i64 %48, %49
  %. = tail call i64 @llvm.umin.i64(i64 %50, i64 %2)
  %51 = getelementptr inbounds i8, ptr %0, i64 24
  %52 = load ptr, ptr %51, align 8, !tbaa !16
  %53 = getelementptr inbounds i8, ptr %52, i64 %49
  tail call void @llvm.memcpy.p0.p0.i64(ptr align 1 %53, ptr align 1 %1, i64 %., i1 false)
  %54 = load i64, ptr %28, align 8, !tbaa !5
  %55 = add i64 %54, %.
  store i64 %55, ptr %28, align 8, !tbaa !5
  %.not = icmp eq ptr %3, null
  br i1 %.not, label %57, label %56

56:                                               ; preds = %46
  store i64 %., ptr %3, align 8, !tbaa !17
  br label %57

57:                                               ; preds = %45, %26, %46, %56
  %.2 = phi i32 [ 7, %26 ], [ %31, %45 ], [ 0, %56 ], [ 0, %46 ]
  ret i32 %.2

58:                                               ; preds = %44, %25
  %.pn37.pn = phi { ptr, i32 } [ %.pn37, %44 ], [ %.pn33, %25 ]
  resume { ptr, i32 } %.pn37.pn
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZN3amf13AMFResultIsOKE10AMF_RESULT(i32 noundef) local_unnamed_addr #3

declare void @_ZN3amf15AMFFormatResultB5cxx11E10AMF_RESULT(ptr dead_on_unwind writable sret(%"class.std::__cxx11::basic_string") align 8, i32 noundef) local_unnamed_addr #6

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i64 @llvm.umin.i64(i64, i64) #7

attributes #0 = { mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { 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 #4 = { 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 #5 = { 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 #6 = { "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 #7 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #8 = { 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, !11, i64 48}
!6 = !{!"_ZTSN3amf23AMFDataStreamMemoryImplE", !7, i64 0, !14, i64 24, !11, i64 32, !11, i64 40, !11, i64 48}
!7 = !{!"_ZTSN3amf16AMFInterfaceImplINS_13AMFDataStreamEiiiEE", !8, i64 0, !10, i64 8}
!8 = !{!"_ZTSN3amf13AMFDataStreamE", !9, i64 0}
!9 = !{!"_ZTSN3amf12AMFInterfaceE"}
!10 = !{!"_ZTSN3amf16AMFInterfaceBaseE", !11, i64 8}
!11 = !{!"long", !12, i64 0}
!12 = !{!"omnipotent char", !13, i64 0}
!13 = !{!"Simple C++ TBAA"}
!14 = !{!"any pointer", !12, i64 0}
!15 = !{!6, !11, i64 32}
!16 = !{!6, !14, i64 24}
!17 = !{!11, !11, i64 0}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass