; LLVM IR from GPUOpen-LibrariesAndSDKs/TAN :: amf/public/common (IOCapsImpl)

; 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.amf::AMFIOCapsImpl::MemoryType" = type <{ i32, i8, [3 x i8] }>
%"class.amf::AMFIOCapsImpl" = type { %"class.amf::AMFInterfaceImpl", i32, i32, i32, i32, i32, i8, %"class.std::vector", %"class.std::vector.0" }
%"class.amf::AMFInterfaceImpl" = type { %"class.amf::AMFIOCaps", %"class.amf::AMFInterfaceBase" }
%"class.amf::AMFIOCaps" = type { %"class.amf::AMFInterface" }
%"class.amf::AMFInterface" = type { ptr }
%"class.amf::AMFInterfaceBase" = type { ptr, i64 }
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<amf::AMFIOCapsImpl::SurfaceFormat, std::allocator<amf::AMFIOCapsImpl::SurfaceFormat>>::_Vector_impl" }
%"struct.std::_Vector_base<amf::AMFIOCapsImpl::SurfaceFormat, std::allocator<amf::AMFIOCapsImpl::SurfaceFormat>>::_Vector_impl" = type { %"struct.std::_Vector_base<amf::AMFIOCapsImpl::SurfaceFormat, std::allocator<amf::AMFIOCapsImpl::SurfaceFormat>>::_Vector_impl_data" }
%"struct.std::_Vector_base<amf::AMFIOCapsImpl::SurfaceFormat, std::allocator<amf::AMFIOCapsImpl::SurfaceFormat>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.std::vector.0" = type { %"struct.std::_Vector_base.1" }
%"struct.std::_Vector_base.1" = type { %"struct.std::_Vector_base<amf::AMFIOCapsImpl::MemoryType, std::allocator<amf::AMFIOCapsImpl::MemoryType>>::_Vector_impl" }
%"struct.std::_Vector_base<amf::AMFIOCapsImpl::MemoryType, std::allocator<amf::AMFIOCapsImpl::MemoryType>>::_Vector_impl" = type { %"struct.std::_Vector_base<amf::AMFIOCapsImpl::MemoryType, std::allocator<amf::AMFIOCapsImpl::MemoryType>>::_Vector_impl_data" }
%"struct.std::_Vector_base<amf::AMFIOCapsImpl::MemoryType, std::allocator<amf::AMFIOCapsImpl::MemoryType>>::_Vector_impl_data" = type { ptr, ptr, ptr }

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN3amf13AMFIOCapsImpl19PopulateMemoryTypesEiPKNS_15AMF_MEMORY_TYPEEb(ptr noundef nonnull align 8 dereferenceable(96) %0, i32 noundef %1, ptr noundef %2, i1 noundef zeroext %3) #0 align 2 {
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca i8, align 1
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i8, align 1
  %12 = alloca i64, align 8
  %13 = alloca %"class.amf::AMFIOCapsImpl::MemoryType", align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store i32 %1, ptr %6, align 4, !tbaa !9
  store ptr %2, ptr %7, align 8, !tbaa !5
  %14 = zext i1 %3 to i8
  store i8 %14, ptr %8, align 1, !tbaa !11
  %15 = load ptr, ptr %5, align 8
  %16 = load ptr, ptr %7, align 8, !tbaa !5
  %17 = icmp ne ptr %16, null
  br i1 %17, label %18, label %64

18:                                               ; preds = %4
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #4
  store i32 0, ptr %9, align 4, !tbaa !9
  br label %19

19:                                               ; preds = %60, %18
  %20 = load i32, ptr %9, align 4, !tbaa !9
  %21 = load i32, ptr %6, align 4, !tbaa !9
  %22 = icmp slt i32 %20, %21
  br i1 %22, label %24, label %23

23:                                               ; preds = %19
  store i32 2, ptr %10, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  br label %63

24:                                               ; preds = %19
  call void @llvm.lifetime.start.p0(i64 1, ptr %11) #4
  store i8 0, ptr %11, align 1, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #4
  store i64 0, ptr %12, align 8, !tbaa !13
  br label %25

25:                                               ; preds = %44, %24
  %26 = load i64, ptr %12, align 8, !tbaa !13
  %27 = getelementptr inbounds %"class.amf::AMFIOCapsImpl", ptr %15, i32 0, i32 8
  %28 = call noundef i64 @_ZNKSt6vectorIN3amf13AMFIOCapsImpl10MemoryTypeESaIS2_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %27) #4
  %29 = icmp ult i64 %26, %28
  br i1 %29, label %31, label %30

30:                                               ; preds = %25
  store i32 5, ptr %10, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #4
  br label %47

31:                                               ; preds = %25
  %32 = getelementptr inbounds %"class.amf::AMFIOCapsImpl", ptr %15, i32 0, i32 8
  %33 = load i64, ptr %12, align 8, !tbaa !13
  %34 = call noundef nonnull align 4 dereferenceable(5) ptr @_ZNSt6vectorIN3amf13AMFIOCapsImpl10MemoryTypeESaIS2_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %32, i64 noundef %33) #4
  %35 = call noundef i32 @_ZNK3amf13AMFIOCapsImpl10MemoryType7GetTypeEv(ptr noundef nonnull align 4 dereferenceable(5) %34) #4
  %36 = load ptr, ptr %7, align 8, !tbaa !5
  %37 = load i32, ptr %9, align 4, !tbaa !9
  %38 = sext i32 %37 to i64
  %39 = getelementptr inbounds i32, ptr %36, i64 %38
  %40 = load i32, ptr %39, align 4, !tbaa !15
  %41 = icmp eq i32 %35, %40
  br i1 %41, label %42, label %43

42:                                               ; preds = %31
  store i8 1, ptr %11, align 1, !tbaa !11
  br label %43

43:                                               ; preds = %42, %31
  br label %44

44:                                               ; preds = %43
  %45 = load i64, ptr %12, align 8, !tbaa !13
  %46 = add i64 %45, 1
  store i64 %46, ptr %12, align 8, !tbaa !13
  br label %25, !llvm.loop !17

47:                                               ; preds = %30
  %48 = load i8, ptr %11, align 1, !tbaa !11, !range !19, !noundef !20
  %49 = trunc i8 %48 to i1
  br i1 %49, label %59, label %50

50:                                               ; preds = %47
  %51 = getelementptr inbounds %"class.amf::AMFIOCapsImpl", ptr %15, i32 0, i32 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #4
  %52 = load ptr, ptr %7, align 8, !tbaa !5
  %53 = load i32, ptr %9, align 4, !tbaa !9
  %54 = sext i32 %53 to i64
  %55 = getelementptr inbounds i32, ptr %52, i64 %54
  %56 = load i32, ptr %55, align 4, !tbaa !15
  %57 = load i8, ptr %8, align 1, !tbaa !11, !range !19, !noundef !20
  %58 = trunc i8 %57 to i1
  call void @_ZN3amf13AMFIOCapsImpl10MemoryTypeC1ENS_15AMF_MEMORY_TYPEEb(ptr noundef nonnull align 4 dereferenceable(5) %13, i32 noundef %56, i1 noundef zeroext %58)
  call void @_ZNSt6vectorIN3amf13AMFIOCapsImpl10MemoryTypeESaIS2_EE9push_backEOS2_(ptr noundef nonnull align 8 dereferenceable(24) %51, ptr noundef nonnull align 4 dereferenceable(5) %13)
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #4
  br label %59

59:                                               ; preds = %50, %47
  call void @llvm.lifetime.end.p0(i64 1, ptr %11) #4
  br label %60

60:                                               ; preds = %59
  %61 = load i32, ptr %9, align 4, !tbaa !9
  %62 = add nsw i32 %61, 1
  store i32 %62, ptr %9, align 4, !tbaa !9
  br label %19, !llvm.loop !21

63:                                               ; preds = %23
  br label %64

64:                                               ; preds = %63, %4
  ret void
}

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

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

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK3amf13AMFIOCapsImpl10MemoryType7GetTypeEv(ptr noundef nonnull align 4 dereferenceable(5)) #3 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt6vectorIN3amf13AMFIOCapsImpl10MemoryTypeESaIS2_EE9push_backEOS2_(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 4 dereferenceable(5)) #0 align 2

declare void @_ZN3amf13AMFIOCapsImpl10MemoryTypeC1ENS_15AMF_MEMORY_TYPEEb(ptr, i32, i1)

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 = { mustprogress nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { 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 = { 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 = !{!"int", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"bool", !7, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"long", !7, i64 0}
!15 = !{!16, !16, i64 0}
!16 = !{!"_ZTSN3amf15AMF_MEMORY_TYPEE", !7, i64 0}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}
!19 = !{i8 0, i8 2}
!20 = !{}
!21 = distinct !{!21, !18}


; 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.amf::AMFIOCapsImpl::MemoryType" = type <{ i32, i8, [3 x i8] }>

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN3amf13AMFIOCapsImpl19PopulateMemoryTypesEiPKNS_15AMF_MEMORY_TYPEEb(ptr noundef nonnull align 8 dereferenceable(96) %0, i32 noundef %1, ptr noundef readonly %2, i1 noundef zeroext %3) local_unnamed_addr #0 align 2 {
  %5 = alloca %"class.amf::AMFIOCapsImpl::MemoryType", align 4
  %.not = icmp ne ptr %2, null
  %6 = icmp sgt i32 %1, 0
  %or.cond = and i1 %.not, %6
  br i1 %or.cond, label %.preheader.lr.ph, label %.loopexit

.preheader.lr.ph:                                 ; preds = %4
  %7 = getelementptr inbounds i8, ptr %0, i64 72
  %wide.trip.count = zext nneg i32 %1 to i64
  br label %.preheader

.preheader:                                       ; preds = %.preheader.lr.ph, %20
  %indvars.iv = phi i64 [ 0, %.preheader.lr.ph ], [ %indvars.iv.next, %20 ]
  %8 = call noundef i64 @_ZNKSt6vectorIN3amf13AMFIOCapsImpl10MemoryTypeESaIS2_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %7) #4
  %.not21 = icmp eq i64 %8, 0
  br i1 %.not21, label %.critedge, label %.lr.ph

.lr.ph:                                           ; preds = %.preheader
  %9 = getelementptr inbounds i32, ptr %2, i64 %indvars.iv
  br label %10

._crit_edge:                                      ; preds = %10
  br i1 %spec.select, label %20, label %.critedge

10:                                               ; preds = %.lr.ph, %10
  %.018 = phi i64 [ 0, %.lr.ph ], [ %15, %10 ]
  %.01317 = phi i1 [ false, %.lr.ph ], [ %spec.select, %10 ]
  %11 = call noundef nonnull align 4 dereferenceable(5) ptr @_ZNSt6vectorIN3amf13AMFIOCapsImpl10MemoryTypeESaIS2_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %7, i64 noundef %.018) #4
  %12 = call noundef i32 @_ZNK3amf13AMFIOCapsImpl10MemoryType7GetTypeEv(ptr noundef nonnull align 4 dereferenceable(5) %11) #4
  %13 = load i32, ptr %9, align 4, !tbaa !5
  %14 = icmp eq i32 %12, %13
  %spec.select = select i1 %14, i1 true, i1 %.01317
  %15 = add nuw i64 %.018, 1
  %16 = call noundef i64 @_ZNKSt6vectorIN3amf13AMFIOCapsImpl10MemoryTypeESaIS2_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %7) #4
  %17 = icmp ult i64 %15, %16
  br i1 %17, label %10, label %._crit_edge, !llvm.loop !9

.critedge:                                        ; preds = %.preheader, %._crit_edge
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #4
  %18 = getelementptr inbounds i32, ptr %2, i64 %indvars.iv
  %19 = load i32, ptr %18, align 4, !tbaa !5
  call void @_ZN3amf13AMFIOCapsImpl10MemoryTypeC1ENS_15AMF_MEMORY_TYPEEb(ptr noundef nonnull align 4 dereferenceable(5) %5, i32 noundef %19, i1 noundef zeroext %3)
  call void @_ZNSt6vectorIN3amf13AMFIOCapsImpl10MemoryTypeESaIS2_EE9push_backEOS2_(ptr noundef nonnull align 8 dereferenceable(24) %7, ptr noundef nonnull align 4 dereferenceable(5) %5)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #4
  br label %20

20:                                               ; preds = %.critedge, %._crit_edge
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
  br i1 %exitcond.not, label %.loopexit, label %.preheader, !llvm.loop !11

.loopexit:                                        ; preds = %20, %4
  ret void
}

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

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

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK3amf13AMFIOCapsImpl10MemoryType7GetTypeEv(ptr noundef nonnull align 4 dereferenceable(5)) local_unnamed_addr #3 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt6vectorIN3amf13AMFIOCapsImpl10MemoryTypeESaIS2_EE9push_backEOS2_(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 4 dereferenceable(5)) local_unnamed_addr #0 align 2

declare void @_ZN3amf13AMFIOCapsImpl10MemoryTypeC1ENS_15AMF_MEMORY_TYPEEb(ptr, i32, i1) local_unnamed_addr

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 nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { 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 = { 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 = !{!"_ZTSN3amf15AMF_MEMORY_TYPEE", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10}


; Effective O3 passes: AggressiveInstCombinePass,CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopInstSimplifyPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass