; LLVM IR from libxsmm/libxsmm :: src (libxsmm_fsspmdm)

; 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"

%struct.libxsmm_gemm_param = type { %struct.libxsmm_matrix_op_arg, %struct.libxsmm_matrix_arg, %struct.libxsmm_matrix_arg, %struct.libxsmm_matrix_arg }
%struct.libxsmm_matrix_op_arg = type { ptr, ptr, ptr, ptr }
%struct.libxsmm_matrix_arg = type { ptr, ptr, ptr, ptr, ptr, ptr }
%struct.libxsmm_fsspmdm = type { i32, i32, i32, i32, i32, i32, ptr, i32, ptr }

@.str.2 = external hidden unnamed_addr constant [71 x i8], align 1
@.str.21 = external hidden unnamed_addr constant [21 x i8], align 1
@__PRETTY_FUNCTION__.libxsmm_fsspmdm_execute = external hidden unnamed_addr constant [76 x i8], align 1

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

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #1

declare zeroext i8 @libxsmm_typesize(i32 noundef) #2

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

; Function Attrs: nounwind uwtable
define dso_local void @libxsmm_fsspmdm_execute(ptr noundef %0, ptr noundef %1, ptr noundef %2) #3 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca %struct.libxsmm_gemm_param, align 8
  %8 = alloca i8, align 1
  %9 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store ptr %2, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 176, ptr %7) #4
  %10 = load ptr, ptr %4, align 8, !tbaa !5
  %11 = icmp ne ptr null, %10
  br i1 %11, label %12, label %13

12:                                               ; preds = %3
  br label %14

13:                                               ; preds = %3
  call void @__assert_fail(ptr noundef @.str.21, ptr noundef @.str.2, i32 noundef 496, ptr noundef @__PRETTY_FUNCTION__.libxsmm_fsspmdm_execute) #5
  unreachable

14:                                               ; preds = %12
  %15 = load ptr, ptr %4, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct.libxsmm_fsspmdm, ptr %15, i32 0, i32 8
  %17 = load ptr, ptr %16, align 8, !tbaa !9
  %18 = icmp eq ptr null, %17
  br i1 %18, label %19, label %31

19:                                               ; preds = %14
  %20 = getelementptr inbounds %struct.libxsmm_gemm_param, ptr %7, i32 0, i32 1
  %21 = getelementptr inbounds %struct.libxsmm_matrix_arg, ptr %20, i32 0, i32 0
  store ptr null, ptr %21, align 8, !tbaa !12
  %22 = load ptr, ptr %5, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.libxsmm_gemm_param, ptr %7, i32 0, i32 2
  %24 = getelementptr inbounds %struct.libxsmm_matrix_arg, ptr %23, i32 0, i32 0
  store ptr %22, ptr %24, align 8, !tbaa !16
  %25 = load ptr, ptr %6, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.libxsmm_gemm_param, ptr %7, i32 0, i32 3
  %27 = getelementptr inbounds %struct.libxsmm_matrix_arg, ptr %26, i32 0, i32 0
  store ptr %25, ptr %27, align 8, !tbaa !17
  %28 = load ptr, ptr %4, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.libxsmm_fsspmdm, ptr %28, i32 0, i32 6
  %30 = load ptr, ptr %29, align 8, !tbaa !18
  call void %30(ptr noundef %7)
  br label %76

31:                                               ; preds = %14
  call void @llvm.lifetime.start.p0(i64 1, ptr %8) #4
  %32 = load ptr, ptr %4, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.libxsmm_fsspmdm, ptr %32, i32 0, i32 7
  %34 = load i32, ptr %33, align 8, !tbaa !19
  %35 = call zeroext i8 @libxsmm_typesize(i32 noundef %34)
  store i8 %35, ptr %8, align 1, !tbaa !20
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #4
  %36 = load ptr, ptr %4, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.libxsmm_fsspmdm, ptr %36, i32 0, i32 8
  %38 = load ptr, ptr %37, align 8, !tbaa !9
  %39 = getelementptr inbounds %struct.libxsmm_gemm_param, ptr %7, i32 0, i32 2
  %40 = getelementptr inbounds %struct.libxsmm_matrix_arg, ptr %39, i32 0, i32 0
  store ptr %38, ptr %40, align 8, !tbaa !16
  store i32 0, ptr %9, align 4, !tbaa !21
  br label %41

41:                                               ; preds = %69, %31
  %42 = load i32, ptr %9, align 4, !tbaa !21
  %43 = load ptr, ptr %4, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.libxsmm_fsspmdm, ptr %43, i32 0, i32 1
  %45 = load i32, ptr %44, align 4, !tbaa !22
  %46 = icmp slt i32 %42, %45
  br i1 %46, label %47, label %75

47:                                               ; preds = %41
  %48 = load ptr, ptr %5, align 8, !tbaa !5
  %49 = load i32, ptr %9, align 4, !tbaa !21
  %50 = load i8, ptr %8, align 1, !tbaa !20
  %51 = zext i8 %50 to i32
  %52 = mul nsw i32 %49, %51
  %53 = sext i32 %52 to i64
  %54 = getelementptr inbounds i8, ptr %48, i64 %53
  %55 = getelementptr inbounds %struct.libxsmm_gemm_param, ptr %7, i32 0, i32 1
  %56 = getelementptr inbounds %struct.libxsmm_matrix_arg, ptr %55, i32 0, i32 0
  store ptr %54, ptr %56, align 8, !tbaa !12
  %57 = load ptr, ptr %6, align 8, !tbaa !5
  %58 = load i32, ptr %9, align 4, !tbaa !21
  %59 = load i8, ptr %8, align 1, !tbaa !20
  %60 = zext i8 %59 to i32
  %61 = mul nsw i32 %58, %60
  %62 = sext i32 %61 to i64
  %63 = getelementptr inbounds i8, ptr %57, i64 %62
  %64 = getelementptr inbounds %struct.libxsmm_gemm_param, ptr %7, i32 0, i32 3
  %65 = getelementptr inbounds %struct.libxsmm_matrix_arg, ptr %64, i32 0, i32 0
  store ptr %63, ptr %65, align 8, !tbaa !17
  %66 = load ptr, ptr %4, align 8, !tbaa !5
  %67 = getelementptr inbounds %struct.libxsmm_fsspmdm, ptr %66, i32 0, i32 6
  %68 = load ptr, ptr %67, align 8, !tbaa !18
  call void %68(ptr noundef %7)
  br label %69

69:                                               ; preds = %47
  %70 = load ptr, ptr %4, align 8, !tbaa !5
  %71 = getelementptr inbounds %struct.libxsmm_fsspmdm, ptr %70, i32 0, i32 5
  %72 = load i32, ptr %71, align 4, !tbaa !23
  %73 = load i32, ptr %9, align 4, !tbaa !21
  %74 = add nsw i32 %73, %72
  store i32 %74, ptr %9, align 4, !tbaa !21
  br label %41, !llvm.loop !24

75:                                               ; preds = %41
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 1, ptr %8) #4
  br label %76

76:                                               ; preds = %75, %19
  call void @llvm.lifetime.end.p0(i64 176, ptr %7) #4
  ret void
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { noreturn nounwind "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 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 }
attributes #5 = { noreturn 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/C++ TBAA"}
!9 = !{!10, !6, i64 40}
!10 = !{!"libxsmm_fsspmdm", !11, i64 0, !11, i64 4, !11, i64 8, !11, i64 12, !11, i64 16, !11, i64 20, !6, i64 24, !11, i64 32, !6, i64 40}
!11 = !{!"int", !7, i64 0}
!12 = !{!13, !6, i64 32}
!13 = !{!"libxsmm_gemm_param", !14, i64 0, !15, i64 32, !15, i64 80, !15, i64 128}
!14 = !{!"libxsmm_matrix_op_arg", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24}
!15 = !{!"libxsmm_matrix_arg", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40}
!16 = !{!13, !6, i64 80}
!17 = !{!13, !6, i64 128}
!18 = !{!10, !6, i64 24}
!19 = !{!10, !11, i64 32}
!20 = !{!7, !7, i64 0}
!21 = !{!11, !11, i64 0}
!22 = !{!10, !11, i64 4}
!23 = !{!10, !11, i64 20}
!24 = distinct !{!24, !25}
!25 = !{!"llvm.loop.mustprogress"}


; 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"

%struct.libxsmm_gemm_param = type { %struct.libxsmm_matrix_op_arg, %struct.libxsmm_matrix_arg, %struct.libxsmm_matrix_arg, %struct.libxsmm_matrix_arg }
%struct.libxsmm_matrix_op_arg = type { ptr, ptr, ptr, ptr }
%struct.libxsmm_matrix_arg = type { ptr, ptr, ptr, ptr, ptr, ptr }

@.str.2 = external hidden unnamed_addr constant [71 x i8], align 1
@.str.21 = external hidden unnamed_addr constant [21 x i8], align 1
@__PRETTY_FUNCTION__.libxsmm_fsspmdm_execute = external hidden unnamed_addr constant [76 x i8], align 1

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

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #1

declare zeroext i8 @libxsmm_typesize(i32 noundef) local_unnamed_addr #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: nounwind uwtable
define dso_local void @libxsmm_fsspmdm_execute(ptr noundef readonly %0, ptr noundef %1, ptr noundef %2) local_unnamed_addr #3 {
  %4 = alloca %struct.libxsmm_gemm_param, align 8
  call void @llvm.lifetime.start.p0(i64 176, ptr nonnull %4) #4
  %.not = icmp eq ptr %0, null
  br i1 %.not, label %5, label %6

5:                                                ; preds = %3
  tail call void @__assert_fail(ptr noundef nonnull @.str.21, ptr noundef nonnull @.str.2, i32 noundef 496, ptr noundef nonnull @__PRETTY_FUNCTION__.libxsmm_fsspmdm_execute) #5
  unreachable

6:                                                ; preds = %3
  %7 = getelementptr inbounds i8, ptr %0, i64 40
  %8 = load ptr, ptr %7, align 8, !tbaa !5
  %9 = icmp eq ptr %8, null
  br i1 %9, label %10, label %16

10:                                               ; preds = %6
  %11 = getelementptr inbounds i8, ptr %4, i64 32
  store ptr null, ptr %11, align 8, !tbaa !11
  %12 = getelementptr inbounds i8, ptr %4, i64 80
  store ptr %1, ptr %12, align 8, !tbaa !15
  %13 = getelementptr inbounds i8, ptr %4, i64 128
  store ptr %2, ptr %13, align 8, !tbaa !16
  %14 = getelementptr inbounds i8, ptr %0, i64 24
  %15 = load ptr, ptr %14, align 8, !tbaa !17
  call void %15(ptr noundef nonnull %4) #4
  br label %.loopexit

16:                                               ; preds = %6
  %17 = getelementptr inbounds i8, ptr %0, i64 32
  %18 = load i32, ptr %17, align 8, !tbaa !18
  %19 = tail call zeroext i8 @libxsmm_typesize(i32 noundef %18) #4
  %20 = load ptr, ptr %7, align 8, !tbaa !5
  %21 = getelementptr inbounds i8, ptr %4, i64 80
  store ptr %20, ptr %21, align 8, !tbaa !15
  %22 = getelementptr inbounds i8, ptr %0, i64 4
  %23 = load i32, ptr %22, align 4, !tbaa !19
  %24 = icmp sgt i32 %23, 0
  br i1 %24, label %.lr.ph, label %.loopexit

.lr.ph:                                           ; preds = %16
  %25 = zext i8 %19 to i32
  %26 = getelementptr inbounds i8, ptr %4, i64 32
  %27 = getelementptr inbounds i8, ptr %4, i64 128
  %28 = getelementptr inbounds i8, ptr %0, i64 24
  %29 = getelementptr inbounds i8, ptr %0, i64 20
  br label %30

30:                                               ; preds = %.lr.ph, %30
  %.018 = phi i32 [ 0, %.lr.ph ], [ %37, %30 ]
  %31 = mul nsw i32 %.018, %25
  %32 = sext i32 %31 to i64
  %33 = getelementptr inbounds i8, ptr %1, i64 %32
  store ptr %33, ptr %26, align 8, !tbaa !11
  %34 = getelementptr inbounds i8, ptr %2, i64 %32
  store ptr %34, ptr %27, align 8, !tbaa !16
  %35 = load ptr, ptr %28, align 8, !tbaa !17
  call void %35(ptr noundef nonnull %4) #4
  %36 = load i32, ptr %29, align 4, !tbaa !20
  %37 = add nsw i32 %36, %.018
  %38 = load i32, ptr %22, align 4, !tbaa !19
  %39 = icmp slt i32 %37, %38
  br i1 %39, label %30, label %.loopexit, !llvm.loop !21

.loopexit:                                        ; preds = %30, %16, %10
  call void @llvm.lifetime.end.p0(i64 176, ptr nonnull %4) #4
  ret void
}

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { noreturn nounwind "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 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 }
attributes #5 = { noreturn 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, !10, i64 40}
!6 = !{!"libxsmm_fsspmdm", !7, i64 0, !7, i64 4, !7, i64 8, !7, i64 12, !7, i64 16, !7, i64 20, !10, i64 24, !7, i64 32, !10, i64 40}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!12, !10, i64 32}
!12 = !{!"libxsmm_gemm_param", !13, i64 0, !14, i64 32, !14, i64 80, !14, i64 128}
!13 = !{!"libxsmm_matrix_op_arg", !10, i64 0, !10, i64 8, !10, i64 16, !10, i64 24}
!14 = !{!"libxsmm_matrix_arg", !10, i64 0, !10, i64 8, !10, i64 16, !10, i64 24, !10, i64 32, !10, i64 40}
!15 = !{!12, !10, i64 80}
!16 = !{!12, !10, i64 128}
!17 = !{!6, !10, i64 24}
!18 = !{!6, !7, i64 32}
!19 = !{!6, !7, i64 4}
!20 = !{!6, !7, i64 20}
!21 = distinct !{!21, !22}
!22 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass