; LLVM IR from openxla/xla :: xla/service/gpu/kernels (cutlass_gemm_kernel_f32xf32_to_f32)

; 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.xla::gpu::kernel::gemm_universal::Adaptor" = type { i8 }
%"struct.xla::gpu::kernel::gemm_universal::Arguments" = type { i32, i32, i32, i32, i32, ptr, ptr, ptr, ptr, %"struct.xla::gpu::kernel::gemm_universal::DynamicSliceArguments" }
%"struct.xla::gpu::kernel::gemm_universal::DynamicSliceArguments" = type { ptr }

; 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: mustprogress uwtable
define dso_local i64 @xla_cutlass_kernel_workspace_size(i32 noundef %0, i32 noundef %1, i32 noundef %2) #1 {
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca %"class.xla::gpu::kernel::gemm_universal::Adaptor", align 1
  %8 = alloca %"struct.xla::gpu::kernel::gemm_universal::Arguments", align 8
  store i32 %0, ptr %4, align 4, !tbaa !5
  store i32 %1, ptr %5, align 4, !tbaa !5
  store i32 %2, ptr %6, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 1, ptr %7) #3
  call void @llvm.lifetime.start.p0(i64 64, ptr %8) #3
  %9 = getelementptr inbounds %"struct.xla::gpu::kernel::gemm_universal::Arguments", ptr %8, i32 0, i32 0
  store i32 0, ptr %9, align 8, !tbaa !9
  %10 = getelementptr inbounds %"struct.xla::gpu::kernel::gemm_universal::Arguments", ptr %8, i32 0, i32 1
  store i32 1, ptr %10, align 4, !tbaa !14
  %11 = getelementptr inbounds %"struct.xla::gpu::kernel::gemm_universal::Arguments", ptr %8, i32 0, i32 2
  %12 = load i32, ptr %4, align 4, !tbaa !5
  store i32 %12, ptr %11, align 8, !tbaa !15
  %13 = getelementptr inbounds %"struct.xla::gpu::kernel::gemm_universal::Arguments", ptr %8, i32 0, i32 3
  %14 = load i32, ptr %5, align 4, !tbaa !5
  store i32 %14, ptr %13, align 4, !tbaa !16
  %15 = getelementptr inbounds %"struct.xla::gpu::kernel::gemm_universal::Arguments", ptr %8, i32 0, i32 4
  %16 = load i32, ptr %6, align 4, !tbaa !5
  store i32 %16, ptr %15, align 8, !tbaa !17
  %17 = getelementptr inbounds %"struct.xla::gpu::kernel::gemm_universal::Arguments", ptr %8, i32 0, i32 5
  store ptr null, ptr %17, align 8, !tbaa !18
  %18 = getelementptr inbounds %"struct.xla::gpu::kernel::gemm_universal::Arguments", ptr %8, i32 0, i32 6
  store ptr null, ptr %18, align 8, !tbaa !19
  %19 = getelementptr inbounds %"struct.xla::gpu::kernel::gemm_universal::Arguments", ptr %8, i32 0, i32 7
  store ptr null, ptr %19, align 8, !tbaa !20
  %20 = getelementptr inbounds %"struct.xla::gpu::kernel::gemm_universal::Arguments", ptr %8, i32 0, i32 8
  store ptr null, ptr %20, align 8, !tbaa !21
  %21 = getelementptr inbounds %"struct.xla::gpu::kernel::gemm_universal::Arguments", ptr %8, i32 0, i32 9
  %22 = getelementptr inbounds %"struct.xla::gpu::kernel::gemm_universal::DynamicSliceArguments", ptr %21, i32 0, i32 0
  store ptr null, ptr %22, align 8, !tbaa !22
  %23 = call noundef i64 @_ZNK3xla3gpu6kernel14gemm_universal7AdaptorINS2_12F32xF32ToF32ILNS2_4ArchE0EEEE13WorkspaceSizeERKNS2_9ArgumentsE(ptr noundef nonnull align 1 dereferenceable(1) %7, ptr noundef nonnull align 8 dereferenceable(64) %8)
  call void @llvm.lifetime.end.p0(i64 64, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 1, ptr %7) #3
  ret i64 %23
}

declare noundef i64 @_ZNK3xla3gpu6kernel14gemm_universal7AdaptorINS2_12F32xF32ToF32ILNS2_4ArchE0EEEE13WorkspaceSizeERKNS2_9ArgumentsE(ptr noundef nonnull align 1 dereferenceable(1), ptr noundef nonnull align 8 dereferenceable(64)) #2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { "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 = { 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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !11, i64 0}
!10 = !{!"_ZTSN3xla3gpu6kernel14gemm_universal9ArgumentsE", !11, i64 0, !6, i64 4, !6, i64 8, !6, i64 12, !6, i64 16, !12, i64 24, !12, i64 32, !12, i64 40, !12, i64 48, !13, i64 56}
!11 = !{!"_ZTSN3xla3gpu6kernel14gemm_universal8GemmModeE", !7, i64 0}
!12 = !{!"any pointer", !7, i64 0}
!13 = !{!"_ZTSN3xla3gpu6kernel14gemm_universal21DynamicSliceArgumentsE", !12, i64 0}
!14 = !{!10, !6, i64 4}
!15 = !{!10, !6, i64 8}
!16 = !{!10, !6, i64 12}
!17 = !{!10, !6, i64 16}
!18 = !{!10, !12, i64 24}
!19 = !{!10, !12, i64 32}
!20 = !{!10, !12, i64 40}
!21 = !{!10, !12, i64 48}
!22 = !{!13, !12, 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.xla::gpu::kernel::gemm_universal::Adaptor" = type { i8 }
%"struct.xla::gpu::kernel::gemm_universal::Arguments" = type { i32, i32, i32, i32, i32, ptr, ptr, ptr, ptr, %"struct.xla::gpu::kernel::gemm_universal::DynamicSliceArguments" }
%"struct.xla::gpu::kernel::gemm_universal::DynamicSliceArguments" = type { ptr }

; 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 uwtable
define dso_local noundef i64 @xla_cutlass_kernel_workspace_size(i32 noundef %0, i32 noundef %1, i32 noundef %2) local_unnamed_addr #1 {
  %4 = alloca %"class.xla::gpu::kernel::gemm_universal::Adaptor", align 1
  %5 = alloca %"struct.xla::gpu::kernel::gemm_universal::Arguments", align 8
  call void @llvm.lifetime.start.p0(i64 1, ptr nonnull %4) #4
  call void @llvm.lifetime.start.p0(i64 64, ptr nonnull %5) #4
  store i32 0, ptr %5, align 8, !tbaa !5
  %6 = getelementptr inbounds i8, ptr %5, i64 4
  store i32 1, ptr %6, align 4, !tbaa !13
  %7 = getelementptr inbounds i8, ptr %5, i64 8
  store i32 %0, ptr %7, align 8, !tbaa !14
  %8 = getelementptr inbounds i8, ptr %5, i64 12
  store i32 %1, ptr %8, align 4, !tbaa !15
  %9 = getelementptr inbounds i8, ptr %5, i64 16
  store i32 %2, ptr %9, align 8, !tbaa !16
  %10 = getelementptr inbounds i8, ptr %5, i64 24
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(40) %10, i8 0, i64 40, i1 false)
  %11 = call noundef i64 @_ZNK3xla3gpu6kernel14gemm_universal7AdaptorINS2_12F32xF32ToF32ILNS2_4ArchE0EEEE13WorkspaceSizeERKNS2_9ArgumentsE(ptr noundef nonnull align 1 dereferenceable(1) %4, ptr noundef nonnull align 8 dereferenceable(64) %5)
  call void @llvm.lifetime.end.p0(i64 64, ptr nonnull %5) #4
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %4) #4
  ret i64 %11
}

declare noundef i64 @_ZNK3xla3gpu6kernel14gemm_universal7AdaptorINS2_12F32xF32ToF32ILNS2_4ArchE0EEEE13WorkspaceSizeERKNS2_9ArgumentsE(ptr noundef nonnull align 1 dereferenceable(1), ptr noundef nonnull align 8 dereferenceable(64)) local_unnamed_addr #2

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #3

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { "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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
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, !7, i64 0}
!6 = !{!"_ZTSN3xla3gpu6kernel14gemm_universal9ArgumentsE", !7, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !10, i64 16, !11, i64 24, !11, i64 32, !11, i64 40, !11, i64 48, !12, i64 56}
!7 = !{!"_ZTSN3xla3gpu6kernel14gemm_universal8GemmModeE", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!"any pointer", !8, i64 0}
!12 = !{!"_ZTSN3xla3gpu6kernel14gemm_universal21DynamicSliceArgumentsE", !11, i64 0}
!13 = !{!6, !10, i64 4}
!14 = !{!6, !10, i64 8}
!15 = !{!6, !10, i64 12}
!16 = !{!6, !10, i64 16}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,MemCpyOptPass,PostOrderFunctionAttrsPass,SROAPass