; 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::SurfaceFormat" = 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: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

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

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

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

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZNK3amf13AMFIOCapsImpl11GetFormatAtEiPNS_18AMF_SURFACE_FORMATEPb(ptr noundef nonnull align 8 dereferenceable(96) %0, i32 noundef %1, ptr noundef %2, ptr noundef %3) unnamed_addr #3 align 2 {
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca %"class.amf::AMFIOCapsImpl::SurfaceFormat", align 4
  store ptr %0, ptr %6, align 8, !tbaa !5
  store i32 %1, ptr %7, align 4, !tbaa !9
  store ptr %2, ptr %8, align 8, !tbaa !5
  store ptr %3, ptr %9, align 8, !tbaa !5
  %11 = load ptr, ptr %6, align 8
  %12 = load i32, ptr %7, align 4, !tbaa !9
  %13 = icmp sge i32 %12, 0
  br i1 %13, label %14, label %38

14:                                               ; preds = %4
  %15 = load i32, ptr %7, align 4, !tbaa !9
  %16 = getelementptr inbounds %"class.amf::AMFIOCapsImpl", ptr %11, i32 0, i32 7
  %17 = call noundef i64 @_ZNKSt6vectorIN3amf13AMFIOCapsImpl13SurfaceFormatESaIS2_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %16) #5
  %18 = trunc i64 %17 to i32
  %19 = icmp slt i32 %15, %18
  br i1 %19, label %20, label %38

20:                                               ; preds = %14
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #5
  %21 = getelementptr inbounds %"class.amf::AMFIOCapsImpl", ptr %11, i32 0, i32 7
  %22 = load i32, ptr %7, align 4, !tbaa !9
  %23 = sext i32 %22 to i64
  %24 = call noundef nonnull align 4 dereferenceable(5) ptr @_ZNKSt6vectorIN3amf13AMFIOCapsImpl13SurfaceFormatESaIS2_EE2atEm(ptr noundef nonnull align 8 dereferenceable(24) %21, i64 noundef %23)
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %10, ptr align 4 %24, i64 8, i1 false), !tbaa.struct !11
  %25 = load ptr, ptr %8, align 8, !tbaa !5
  %26 = icmp ne ptr %25, null
  br i1 %26, label %27, label %30

27:                                               ; preds = %20
  %28 = call noundef i32 @_ZNK3amf13AMFIOCapsImpl13SurfaceFormat9GetFormatEv(ptr noundef nonnull align 4 dereferenceable(5) %10) #5
  %29 = load ptr, ptr %8, align 8, !tbaa !5
  store i32 %28, ptr %29, align 4, !tbaa !12
  br label %30

30:                                               ; preds = %27, %20
  %31 = load ptr, ptr %9, align 8, !tbaa !5
  %32 = icmp ne ptr %31, null
  br i1 %32, label %33, label %37

33:                                               ; preds = %30
  %34 = call noundef zeroext i1 @_ZNK3amf13AMFIOCapsImpl13SurfaceFormat8IsNativeEv(ptr noundef nonnull align 4 dereferenceable(5) %10) #5
  %35 = load ptr, ptr %9, align 8, !tbaa !5
  %36 = zext i1 %34 to i8
  store i8 %36, ptr %35, align 1, !tbaa !14
  br label %37

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

38:                                               ; preds = %14, %4
  store i32 4, ptr %5, align 4
  br label %39

39:                                               ; preds = %38, %37
  %40 = load i32, ptr %5, align 4
  ret i32 %40
}

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

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK3amf13AMFIOCapsImpl13SurfaceFormat8IsNativeEv(ptr noundef nonnull align 4 dereferenceable(5)) #2 align 2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { 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 #3 = { 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 #4 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 = !{!"int", !7, i64 0}
!11 = !{i64 0, i64 4, !12, i64 4, i64 1, !14}
!12 = !{!13, !13, i64 0}
!13 = !{!"_ZTSN3amf18AMF_SURFACE_FORMATE", !7, i64 0}
!14 = !{!15, !15, i64 0}
!15 = !{!"bool", !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"

%"class.amf::AMFIOCapsImpl::SurfaceFormat" = type <{ i32, i8, [3 x i8] }>

; 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 nounwind uwtable
declare dso_local noundef i64 @_ZNKSt6vectorIN3amf13AMFIOCapsImpl13SurfaceFormatESaIS2_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #1 align 2

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

; 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 uwtable
define dso_local noundef range(i32 0, 5) i32 @_ZNK3amf13AMFIOCapsImpl11GetFormatAtEiPNS_18AMF_SURFACE_FORMATEPb(ptr noundef nonnull align 8 dereferenceable(96) %0, i32 noundef %1, ptr noundef writeonly %2, ptr noundef writeonly %3) unnamed_addr #3 align 2 {
  %5 = alloca %"class.amf::AMFIOCapsImpl::SurfaceFormat", align 8
  %6 = icmp sgt i32 %1, -1
  br i1 %6, label %7, label %23

7:                                                ; preds = %4
  %8 = getelementptr inbounds i8, ptr %0, i64 48
  %9 = tail call noundef i64 @_ZNKSt6vectorIN3amf13AMFIOCapsImpl13SurfaceFormatESaIS2_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %8) #4
  %10 = trunc i64 %9 to i32
  %11 = icmp sgt i32 %10, %1
  br i1 %11, label %12, label %23

12:                                               ; preds = %7
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #4
  %13 = zext nneg i32 %1 to i64
  %14 = tail call noundef nonnull align 4 dereferenceable(5) ptr @_ZNKSt6vectorIN3amf13AMFIOCapsImpl13SurfaceFormatESaIS2_EE2atEm(ptr noundef nonnull align 8 dereferenceable(24) %8, i64 noundef %13)
  %15 = load i64, ptr %14, align 4
  store i64 %15, ptr %5, align 8
  %.not = icmp eq ptr %2, null
  br i1 %.not, label %18, label %16

16:                                               ; preds = %12
  %17 = call noundef i32 @_ZNK3amf13AMFIOCapsImpl13SurfaceFormat9GetFormatEv(ptr noundef nonnull align 4 dereferenceable(5) %5) #4
  store i32 %17, ptr %2, align 4, !tbaa !5
  br label %18

18:                                               ; preds = %16, %12
  %.not11 = icmp eq ptr %3, null
  br i1 %.not11, label %22, label %19

19:                                               ; preds = %18
  %20 = call noundef zeroext i1 @_ZNK3amf13AMFIOCapsImpl13SurfaceFormat8IsNativeEv(ptr noundef nonnull align 4 dereferenceable(5) %5) #4
  %21 = zext i1 %20 to i8
  store i8 %21, ptr %3, align 1, !tbaa !9
  br label %22

22:                                               ; preds = %19, %18
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #4
  br label %23

23:                                               ; preds = %4, %7, %22
  %.0 = phi i32 [ 0, %22 ], [ 4, %7 ], [ 4, %4 ]
  ret i32 %.0
}

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK3amf13AMFIOCapsImpl13SurfaceFormat8IsNativeEv(ptr noundef nonnull align 4 dereferenceable(5)) local_unnamed_addr #2 align 2

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { 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 #3 = { 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 #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 = !{!"_ZTSN3amf18AMF_SURFACE_FORMATE", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"bool", !7, i64 0}


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