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

; 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_descriptor = type <{ i32, i32, i32, i32, i32, i32, i32, i8, [3 x i8], i8, i64, i64, i8, i32, i32, i32, i16, i16, i8, i8, i8, i8, i16, i16, i16, i16, i16, i16, i32, i32, i32, i8 }>

; Function Attrs: nounwind uwtable
define dso_local void @libxsmm_generator_gemm_sse_kloop_kernel(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, i32 noundef %4, i32 noundef %5, i32 noundef %6) #0 {
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  %16 = alloca i32, align 4
  %17 = alloca ptr, align 8
  %18 = alloca i32, align 4
  store ptr %0, ptr %8, align 8, !tbaa !5
  store ptr %1, ptr %9, align 8, !tbaa !5
  store ptr %2, ptr %10, align 8, !tbaa !5
  store ptr %3, ptr %11, align 8, !tbaa !5
  store i32 %4, ptr %12, align 4, !tbaa !9
  store i32 %5, ptr %13, align 4, !tbaa !9
  store i32 %6, ptr %14, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #3
  store i32 0, ptr %15, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #3
  store i32 1, ptr %16, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #3
  %19 = load ptr, ptr %11, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.libxsmm_gemm_descriptor, ptr %19, i32 0, i32 8
  %21 = getelementptr inbounds [3 x i8], ptr %20, i64 0, i64 0
  %22 = call i32 @LIBXSMM_GEMM_GETENUM_AB_COMMON_PREC(ptr noundef %21)
  %23 = icmp eq i32 12, %22
  br i1 %23, label %24, label %52

24:                                               ; preds = %7
  %25 = load ptr, ptr %11, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.libxsmm_gemm_descriptor, ptr %25, i32 0, i32 6
  %27 = load i32, ptr %26, align 1, !tbaa !11
  %28 = and i32 %27, 256
  %29 = icmp eq i32 %28, 0
  br i1 %29, label %30, label %36

30:                                               ; preds = %24
  %31 = load ptr, ptr %11, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.libxsmm_gemm_descriptor, ptr %31, i32 0, i32 6
  %33 = load i32, ptr %32, align 1, !tbaa !11
  %34 = and i32 %33, 512
  %35 = icmp eq i32 %34, 0
  br i1 %35, label %50, label %36

36:                                               ; preds = %30, %24
  %37 = load ptr, ptr %11, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.libxsmm_gemm_descriptor, ptr %37, i32 0, i32 6
  %39 = load i32, ptr %38, align 1, !tbaa !11
  %40 = and i32 %39, 256
  %41 = icmp ugt i32 %40, 0
  br i1 %41, label %42, label %48

42:                                               ; preds = %36
  %43 = load ptr, ptr %11, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.libxsmm_gemm_descriptor, ptr %43, i32 0, i32 6
  %45 = load i32, ptr %44, align 1, !tbaa !11
  %46 = and i32 %45, 512
  %47 = icmp ugt i32 %46, 0
  br label %48

48:                                               ; preds = %42, %36
  %49 = phi i1 [ false, %36 ], [ %47, %42 ]
  br label %50

50:                                               ; preds = %48, %30
  %51 = phi i1 [ true, %30 ], [ %49, %48 ]
  br label %52

52:                                               ; preds = %50, %7
  %53 = phi i1 [ false, %7 ], [ %51, %50 ]
  %54 = zext i1 %53 to i32
  store i32 %54, ptr %18, align 4, !tbaa !9
  %55 = load ptr, ptr %11, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct.libxsmm_gemm_descriptor, ptr %55, i32 0, i32 8
  %57 = getelementptr inbounds [3 x i8], ptr %56, i64 0, i64 0
  %58 = call i32 @LIBXSMM_GEMM_GETENUM_AB_COMMON_PREC(ptr noundef %57)
  %59 = icmp eq i32 2, %58
  br i1 %59, label %60, label %67

60:                                               ; preds = %52
  %61 = load ptr, ptr %11, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct.libxsmm_gemm_descriptor, ptr %61, i32 0, i32 6
  %63 = load i32, ptr %62, align 1, !tbaa !11
  %64 = and i32 %63, 2048
  %65 = icmp ugt i32 %64, 0
  br i1 %65, label %66, label %67

66:                                               ; preds = %60
  store ptr @libxsmm_generator_gemm_sse_microkernel_bf16_vnni_emu, ptr %17, align 8, !tbaa !5
  br label %93

67:                                               ; preds = %60, %52
  %68 = load i32, ptr %18, align 4, !tbaa !9
  %69 = icmp ne i32 %68, 0
  br i1 %69, label %70, label %77

70:                                               ; preds = %67
  %71 = load ptr, ptr %11, align 8, !tbaa !5
  %72 = getelementptr inbounds %struct.libxsmm_gemm_descriptor, ptr %71, i32 0, i32 6
  %73 = load i32, ptr %72, align 1, !tbaa !11
  %74 = and i32 %73, 2048
  %75 = icmp ugt i32 %74, 0
  br i1 %75, label %76, label %77

76:                                               ; preds = %70
  store ptr @libxsmm_generator_gemm_sse_microkernel_int8_uu_ss_vnni_emu, ptr %17, align 8, !tbaa !5
  br label %92

77:                                               ; preds = %70, %67
  %78 = load ptr, ptr %11, align 8, !tbaa !5
  %79 = getelementptr inbounds %struct.libxsmm_gemm_descriptor, ptr %78, i32 0, i32 8
  %80 = getelementptr inbounds [3 x i8], ptr %79, i64 0, i64 0
  %81 = call i32 @LIBXSMM_GEMM_GETENUM_AB_COMMON_PREC(ptr noundef %80)
  %82 = icmp eq i32 2, %81
  br i1 %82, label %83, label %90

83:                                               ; preds = %77
  %84 = load ptr, ptr %11, align 8, !tbaa !5
  %85 = getelementptr inbounds %struct.libxsmm_gemm_descriptor, ptr %84, i32 0, i32 6
  %86 = load i32, ptr %85, align 1, !tbaa !11
  %87 = and i32 %86, 2048
  %88 = icmp eq i32 %87, 0
  br i1 %88, label %89, label %90

89:                                               ; preds = %83
  store ptr @libxsmm_generator_gemm_sse_microkernel_bf16_flat_emu, ptr %17, align 8, !tbaa !5
  br label %91

90:                                               ; preds = %83, %77
  store ptr @libxsmm_generator_gemm_sse_microkernel, ptr %17, align 8, !tbaa !5
  br label %91

91:                                               ; preds = %90, %89
  br label %92

92:                                               ; preds = %91, %76
  br label %93

93:                                               ; preds = %92, %66
  %94 = load ptr, ptr %11, align 8, !tbaa !5
  %95 = getelementptr inbounds %struct.libxsmm_gemm_descriptor, ptr %94, i32 0, i32 6
  %96 = load i32, ptr %95, align 1, !tbaa !11
  %97 = and i32 %96, 2048
  %98 = icmp eq i32 %97, 2048
  br i1 %98, label %99, label %105

99:                                               ; preds = %93
  %100 = load ptr, ptr %11, align 8, !tbaa !5
  %101 = getelementptr inbounds %struct.libxsmm_gemm_descriptor, ptr %100, i32 0, i32 8
  %102 = getelementptr inbounds [3 x i8], ptr %101, i64 0, i64 0
  %103 = call i32 @LIBXSMM_GEMM_GETENUM_AB_COMMON_PREC(ptr noundef %102)
  %104 = call i32 @libxsmm_cpuid_dot_pack_factor(i32 noundef %103)
  store i32 %104, ptr %16, align 4, !tbaa !9
  br label %105

105:                                              ; preds = %99, %93
  store i32 0, ptr %15, align 4, !tbaa !9
  br label %106

106:                                              ; preds = %118, %105
  %107 = load i32, ptr %15, align 4, !tbaa !9
  %108 = load i32, ptr %14, align 4, !tbaa !9
  %109 = icmp ult i32 %107, %108
  br i1 %109, label %110, label %122

110:                                              ; preds = %106
  %111 = load ptr, ptr %17, align 8, !tbaa !5
  %112 = load ptr, ptr %8, align 8, !tbaa !5
  %113 = load ptr, ptr %9, align 8, !tbaa !5
  %114 = load ptr, ptr %10, align 8, !tbaa !5
  %115 = load ptr, ptr %11, align 8, !tbaa !5
  %116 = load i32, ptr %12, align 4, !tbaa !9
  %117 = load i32, ptr %13, align 4, !tbaa !9
  call void %111(ptr noundef %112, ptr noundef %113, ptr noundef %114, ptr noundef %115, i32 noundef %116, i32 noundef %117)
  br label %118

118:                                              ; preds = %110
  %119 = load i32, ptr %16, align 4, !tbaa !9
  %120 = load i32, ptr %15, align 4, !tbaa !9
  %121 = add i32 %120, %119
  store i32 %121, ptr %15, align 4, !tbaa !9
  br label %106, !llvm.loop !15

122:                                              ; preds = %106
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #3
  ret void
}

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

declare i32 @LIBXSMM_GEMM_GETENUM_AB_COMMON_PREC(ptr noundef) #2

; Function Attrs: nounwind uwtable
declare dso_local void @libxsmm_generator_gemm_sse_microkernel_bf16_vnni_emu(ptr noundef, ptr noundef, ptr noundef, ptr noundef, i32 noundef, i32 noundef) #0

; Function Attrs: nounwind uwtable
declare dso_local void @libxsmm_generator_gemm_sse_microkernel_int8_uu_ss_vnni_emu(ptr noundef, ptr noundef, ptr noundef, ptr noundef, i32 noundef, i32 noundef) #0

; Function Attrs: nounwind uwtable
declare dso_local void @libxsmm_generator_gemm_sse_microkernel_bf16_flat_emu(ptr noundef, ptr noundef, ptr noundef, ptr noundef, i32 noundef, i32 noundef) #0

; Function Attrs: nounwind uwtable
declare dso_local void @libxsmm_generator_gemm_sse_microkernel(ptr noundef, ptr noundef, ptr noundef, ptr noundef, i32 noundef, i32 noundef) #0

declare i32 @libxsmm_cpuid_dot_pack_factor(i32 noundef) #2

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

attributes #0 = { 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 #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !10, i64 24}
!12 = !{!"libxsmm_gemm_descriptor", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20, !10, i64 24, !7, i64 28, !7, i64 29, !7, i64 32, !13, i64 33, !13, i64 41, !7, i64 49, !10, i64 50, !10, i64 54, !10, i64 58, !14, i64 62, !14, i64 64, !7, i64 66, !7, i64 67, !7, i64 68, !7, i64 69, !14, i64 70, !14, i64 72, !14, i64 74, !14, i64 76, !14, i64 78, !14, i64 80, !10, i64 82, !10, i64 86, !10, i64 90, !7, i64 94}
!13 = !{!"long long", !7, i64 0}
!14 = !{!"short", !7, i64 0}
!15 = distinct !{!15, !16}
!16 = !{!"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"

; Function Attrs: nounwind uwtable
define dso_local void @libxsmm_generator_gemm_sse_kloop_kernel(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, i32 noundef %4, i32 noundef %5, i32 noundef %6) local_unnamed_addr #0 {
  %8 = getelementptr inbounds i8, ptr %3, i64 29
  %9 = tail call i32 @LIBXSMM_GEMM_GETENUM_AB_COMMON_PREC(ptr noundef nonnull %8) #2
  %10 = icmp eq i32 %9, 12
  br i1 %10, label %11, label %15

11:                                               ; preds = %7
  %12 = getelementptr inbounds i8, ptr %3, i64 24
  %13 = load i32, ptr %12, align 1, !tbaa !5
  %14 = and i32 %13, 768
  %or.cond = icmp eq i32 %14, 0
  %spec.select = icmp eq i32 %14, 768
  %spec.select41 = or i1 %or.cond, %spec.select
  br label %15

15:                                               ; preds = %11, %7
  %16 = phi i1 [ false, %7 ], [ %spec.select41, %11 ]
  %17 = tail call i32 @LIBXSMM_GEMM_GETENUM_AB_COMMON_PREC(ptr noundef nonnull %8) #2
  %18 = icmp eq i32 %17, 2
  br i1 %18, label %19, label %23

19:                                               ; preds = %15
  %20 = getelementptr inbounds i8, ptr %3, i64 24
  %21 = load i32, ptr %20, align 1, !tbaa !5
  %22 = and i32 %21, 2048
  %.not25 = icmp eq i32 %22, 0
  br i1 %.not25, label %23, label %.thread

23:                                               ; preds = %19, %15
  br i1 %16, label %24, label %28

24:                                               ; preds = %23
  %25 = getelementptr inbounds i8, ptr %3, i64 24
  %26 = load i32, ptr %25, align 1, !tbaa !5
  %27 = and i32 %26, 2048
  %.not26 = icmp eq i32 %27, 0
  br i1 %.not26, label %28, label %.thread

28:                                               ; preds = %24, %23
  %29 = tail call i32 @LIBXSMM_GEMM_GETENUM_AB_COMMON_PREC(ptr noundef nonnull %8) #2
  %30 = icmp eq i32 %29, 2
  %31 = getelementptr inbounds i8, ptr %3, i64 24
  %32 = load i32, ptr %31, align 1, !tbaa !5
  %33 = and i32 %32, 2048
  %34 = icmp eq i32 %33, 0
  %libxsmm_generator_gemm_sse_microkernel_bf16_flat_emu.libxsmm_generator_gemm_sse_microkernel = select i1 %30, ptr @libxsmm_generator_gemm_sse_microkernel_bf16_flat_emu, ptr @libxsmm_generator_gemm_sse_microkernel
  br i1 %34, label %.thread38, label %.thread

.thread:                                          ; preds = %28, %19, %24
  %.02336 = phi ptr [ @libxsmm_generator_gemm_sse_microkernel_bf16_vnni_emu, %19 ], [ @libxsmm_generator_gemm_sse_microkernel_int8_uu_ss_vnni_emu, %24 ], [ @libxsmm_generator_gemm_sse_microkernel, %28 ]
  %35 = tail call i32 @LIBXSMM_GEMM_GETENUM_AB_COMMON_PREC(ptr noundef nonnull %8) #2
  %36 = tail call i32 @libxsmm_cpuid_dot_pack_factor(i32 noundef %35) #2
  br label %.thread38

.thread38:                                        ; preds = %28, %.thread
  %.02337 = phi ptr [ %.02336, %.thread ], [ %libxsmm_generator_gemm_sse_microkernel_bf16_flat_emu.libxsmm_generator_gemm_sse_microkernel, %28 ]
  %.024 = phi i32 [ %36, %.thread ], [ 1, %28 ]
  %.not = icmp eq i32 %6, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %.thread38, %.lr.ph
  %.029 = phi i32 [ %37, %.lr.ph ], [ 0, %.thread38 ]
  tail call void %.02337(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, i32 noundef %4, i32 noundef %5) #2, !callees !12
  %37 = add i32 %.029, %.024
  %38 = icmp ult i32 %37, %6
  br i1 %38, label %.lr.ph, label %._crit_edge, !llvm.loop !13

._crit_edge:                                      ; preds = %.lr.ph, %.thread38
  ret void
}

declare i32 @LIBXSMM_GEMM_GETENUM_AB_COMMON_PREC(ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare dso_local void @libxsmm_generator_gemm_sse_microkernel_bf16_vnni_emu(ptr noundef, ptr noundef, ptr noundef, ptr noundef, i32 noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local void @libxsmm_generator_gemm_sse_microkernel_int8_uu_ss_vnni_emu(ptr noundef, ptr noundef, ptr noundef, ptr noundef, i32 noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local void @libxsmm_generator_gemm_sse_microkernel_bf16_flat_emu(ptr noundef, ptr noundef, ptr noundef, ptr noundef, i32 noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local void @libxsmm_generator_gemm_sse_microkernel(ptr noundef, ptr noundef, ptr noundef, ptr noundef, i32 noundef, i32 noundef) local_unnamed_addr #0

declare i32 @libxsmm_cpuid_dot_pack_factor(i32 noundef) local_unnamed_addr #1

attributes #0 = { 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 #1 = { "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 = { 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 24}
!6 = !{!"libxsmm_gemm_descriptor", !7, i64 0, !7, i64 4, !7, i64 8, !7, i64 12, !7, i64 16, !7, i64 20, !7, i64 24, !8, i64 28, !8, i64 29, !8, i64 32, !10, i64 33, !10, i64 41, !8, i64 49, !7, i64 50, !7, i64 54, !7, i64 58, !11, i64 62, !11, i64 64, !8, i64 66, !8, i64 67, !8, i64 68, !8, i64 69, !11, i64 70, !11, i64 72, !11, i64 74, !11, i64 76, !11, i64 78, !11, i64 80, !7, i64 82, !7, i64 86, !7, i64 90, !8, i64 94}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"long long", !8, i64 0}
!11 = !{!"short", !8, i64 0}
!12 = !{ptr @libxsmm_generator_gemm_sse_microkernel, ptr @libxsmm_generator_gemm_sse_microkernel_bf16_flat_emu, ptr @libxsmm_generator_gemm_sse_microkernel_bf16_vnni_emu, ptr @libxsmm_generator_gemm_sse_microkernel_int8_uu_ss_vnni_emu}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: BDCEPass,CalledValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass