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

; 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_shape = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32 }
%struct.libxsmm_gemm_batch_reduce_config = type { i32, i32, i32, i8 }
%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
declare dso_local ptr @libxsmm_gemm_descriptor_init(ptr noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef) #0

; 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: nounwind uwtable
define dso_local ptr @libxsmm_gemm_descriptor_init_brgemm(ptr noundef %0, ptr noundef byval(%struct.libxsmm_gemm_shape) align 8 %1, i32 noundef %2, i32 noundef %3, i64 %4, i64 %5) #0 {
  %7 = alloca ptr, align 8
  %8 = alloca %struct.libxsmm_gemm_batch_reduce_config, align 4
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca ptr, align 8
  %14 = alloca i32, align 4
  %15 = getelementptr inbounds { i64, i64 }, ptr %8, i32 0, i32 0
  store i64 %4, ptr %15, align 4
  %16 = getelementptr inbounds { i64, i64 }, ptr %8, i32 0, i32 1
  store i64 %5, ptr %16, align 4
  store ptr %0, ptr %9, align 8, !tbaa !5
  store i32 %2, ptr %10, align 4, !tbaa !9
  store i32 %3, ptr %11, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #2
  %17 = load i32, ptr %10, align 4, !tbaa !9
  store i32 %17, ptr %12, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #2
  store ptr null, ptr %13, align 8, !tbaa !5
  %18 = load i32, ptr %12, align 4, !tbaa !9
  %19 = and i32 64, %18
  %20 = icmp ne i32 %19, 0
  br i1 %20, label %21, label %25

21:                                               ; preds = %6
  %22 = load i32, ptr %12, align 4, !tbaa !9
  %23 = and i32 128, %22
  %24 = icmp eq i32 %23, 0
  br i1 %24, label %33, label %25

25:                                               ; preds = %21, %6
  %26 = load i32, ptr %12, align 4, !tbaa !9
  %27 = and i32 64, %26
  %28 = icmp eq i32 %27, 0
  br i1 %28, label %29, label %34

29:                                               ; preds = %25
  %30 = load i32, ptr %12, align 4, !tbaa !9
  %31 = and i32 128, %30
  %32 = icmp ne i32 %31, 0
  br i1 %32, label %33, label %34

33:                                               ; preds = %29, %21
  store ptr null, ptr %7, align 8
  store i32 1, ptr %14, align 4
  br label %139

34:                                               ; preds = %29, %25
  %35 = load i32, ptr %12, align 4, !tbaa !9
  %36 = or i32 %35, 16384
  store i32 %36, ptr %12, align 4, !tbaa !9
  %37 = getelementptr inbounds %struct.libxsmm_gemm_batch_reduce_config, ptr %8, i32 0, i32 0
  %38 = load i32, ptr %37, align 4, !tbaa !11
  %39 = icmp eq i32 %38, 1
  br i1 %39, label %40, label %43

40:                                               ; preds = %34
  %41 = load i32, ptr %12, align 4, !tbaa !9
  %42 = or i32 %41, 65536
  store i32 %42, ptr %12, align 4, !tbaa !9
  br label %60

43:                                               ; preds = %34
  %44 = getelementptr inbounds %struct.libxsmm_gemm_batch_reduce_config, ptr %8, i32 0, i32 0
  %45 = load i32, ptr %44, align 4, !tbaa !11
  %46 = icmp eq i32 %45, 2
  br i1 %46, label %47, label %50

47:                                               ; preds = %43
  %48 = load i32, ptr %12, align 4, !tbaa !9
  %49 = or i32 %48, 131072
  store i32 %49, ptr %12, align 4, !tbaa !9
  br label %59

50:                                               ; preds = %43
  %51 = getelementptr inbounds %struct.libxsmm_gemm_batch_reduce_config, ptr %8, i32 0, i32 0
  %52 = load i32, ptr %51, align 4, !tbaa !11
  %53 = icmp eq i32 %52, 4
  br i1 %53, label %54, label %57

54:                                               ; preds = %50
  %55 = load i32, ptr %12, align 4, !tbaa !9
  %56 = or i32 %55, 262144
  store i32 %56, ptr %12, align 4, !tbaa !9
  br label %58

57:                                               ; preds = %50
  br label %58

58:                                               ; preds = %57, %54
  br label %59

59:                                               ; preds = %58, %47
  br label %60

60:                                               ; preds = %59, %40
  %61 = load ptr, ptr %9, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct.libxsmm_gemm_shape, ptr %1, i32 0, i32 6
  %63 = load i32, ptr %62, align 8, !tbaa !13
  %64 = getelementptr inbounds %struct.libxsmm_gemm_shape, ptr %1, i32 0, i32 7
  %65 = load i32, ptr %64, align 4, !tbaa !15
  %66 = getelementptr inbounds %struct.libxsmm_gemm_shape, ptr %1, i32 0, i32 9
  %67 = load i32, ptr %66, align 4, !tbaa !16
  %68 = getelementptr inbounds %struct.libxsmm_gemm_shape, ptr %1, i32 0, i32 8
  %69 = load i32, ptr %68, align 8, !tbaa !17
  %70 = getelementptr inbounds %struct.libxsmm_gemm_shape, ptr %1, i32 0, i32 0
  %71 = load i32, ptr %70, align 8, !tbaa !18
  %72 = getelementptr inbounds %struct.libxsmm_gemm_shape, ptr %1, i32 0, i32 1
  %73 = load i32, ptr %72, align 4, !tbaa !19
  %74 = getelementptr inbounds %struct.libxsmm_gemm_shape, ptr %1, i32 0, i32 2
  %75 = load i32, ptr %74, align 8, !tbaa !20
  %76 = getelementptr inbounds %struct.libxsmm_gemm_shape, ptr %1, i32 0, i32 3
  %77 = load i32, ptr %76, align 4, !tbaa !21
  %78 = getelementptr inbounds %struct.libxsmm_gemm_shape, ptr %1, i32 0, i32 4
  %79 = load i32, ptr %78, align 8, !tbaa !22
  %80 = getelementptr inbounds %struct.libxsmm_gemm_shape, ptr %1, i32 0, i32 5
  %81 = load i32, ptr %80, align 4, !tbaa !23
  %82 = load i32, ptr %12, align 4, !tbaa !9
  %83 = load i32, ptr %11, align 4, !tbaa !9
  %84 = call ptr @libxsmm_gemm_descriptor_init(ptr noundef %61, i32 noundef %63, i32 noundef %65, i32 noundef %67, i32 noundef %69, i32 noundef %71, i32 noundef %73, i32 noundef %75, i32 noundef %77, i32 noundef %79, i32 noundef %81, i32 noundef %82, i32 noundef %83)
  store ptr %84, ptr %13, align 8, !tbaa !5
  %85 = getelementptr inbounds %struct.libxsmm_gemm_batch_reduce_config, ptr %8, i32 0, i32 0
  %86 = load i32, ptr %85, align 4, !tbaa !11
  %87 = icmp ne i32 %86, 0
  br i1 %87, label %88, label %137

88:                                               ; preds = %60
  %89 = getelementptr inbounds %struct.libxsmm_gemm_batch_reduce_config, ptr %8, i32 0, i32 0
  %90 = load i32, ptr %89, align 4, !tbaa !11
  %91 = icmp eq i32 %90, 4
  br i1 %91, label %92, label %103

92:                                               ; preds = %88
  %93 = getelementptr inbounds %struct.libxsmm_gemm_batch_reduce_config, ptr %8, i32 0, i32 1
  %94 = load i32, ptr %93, align 4, !tbaa !24
  %95 = sext i32 %94 to i64
  %96 = load ptr, ptr %13, align 8, !tbaa !5
  %97 = getelementptr inbounds %struct.libxsmm_gemm_descriptor, ptr %96, i32 0, i32 10
  store i64 %95, ptr %97, align 1, !tbaa !25
  %98 = getelementptr inbounds %struct.libxsmm_gemm_batch_reduce_config, ptr %8, i32 0, i32 2
  %99 = load i32, ptr %98, align 4, !tbaa !29
  %100 = sext i32 %99 to i64
  %101 = load ptr, ptr %13, align 8, !tbaa !5
  %102 = getelementptr inbounds %struct.libxsmm_gemm_descriptor, ptr %101, i32 0, i32 11
  store i64 %100, ptr %102, align 1, !tbaa !30
  br label %108

103:                                              ; preds = %88
  %104 = load ptr, ptr %13, align 8, !tbaa !5
  %105 = getelementptr inbounds %struct.libxsmm_gemm_descriptor, ptr %104, i32 0, i32 10
  store i64 0, ptr %105, align 1, !tbaa !25
  %106 = load ptr, ptr %13, align 8, !tbaa !5
  %107 = getelementptr inbounds %struct.libxsmm_gemm_descriptor, ptr %106, i32 0, i32 11
  store i64 0, ptr %107, align 1, !tbaa !30
  br label %108

108:                                              ; preds = %103, %92
  %109 = getelementptr inbounds %struct.libxsmm_gemm_batch_reduce_config, ptr %8, i32 0, i32 3
  %110 = load i8, ptr %109, align 4, !tbaa !31
  %111 = zext i8 %110 to i32
  %112 = icmp ne i32 %111, 0
  br i1 %112, label %113, label %133

113:                                              ; preds = %108
  %114 = getelementptr inbounds %struct.libxsmm_gemm_batch_reduce_config, ptr %8, i32 0, i32 3
  %115 = load i8, ptr %114, align 4, !tbaa !31
  %116 = zext i8 %115 to i32
  %117 = icmp slt i32 %116, 255
  br i1 %117, label %118, label %127

118:                                              ; preds = %113
  %119 = getelementptr inbounds %struct.libxsmm_gemm_batch_reduce_config, ptr %8, i32 0, i32 3
  %120 = load i8, ptr %119, align 4, !tbaa !31
  %121 = zext i8 %120 to i32
  %122 = icmp sgt i32 %121, 0
  br i1 %122, label %123, label %127

123:                                              ; preds = %118
  %124 = getelementptr inbounds %struct.libxsmm_gemm_batch_reduce_config, ptr %8, i32 0, i32 3
  %125 = load i8, ptr %124, align 4, !tbaa !31
  %126 = zext i8 %125 to i32
  br label %128

127:                                              ; preds = %118, %113
  br label %128

128:                                              ; preds = %127, %123
  %129 = phi i32 [ %126, %123 ], [ 0, %127 ]
  %130 = trunc i32 %129 to i8
  %131 = load ptr, ptr %13, align 8, !tbaa !5
  %132 = getelementptr inbounds %struct.libxsmm_gemm_descriptor, ptr %131, i32 0, i32 12
  store i8 %130, ptr %132, align 1, !tbaa !32
  br label %136

133:                                              ; preds = %108
  %134 = load ptr, ptr %13, align 8, !tbaa !5
  %135 = getelementptr inbounds %struct.libxsmm_gemm_descriptor, ptr %134, i32 0, i32 12
  store i8 0, ptr %135, align 1, !tbaa !32
  br label %136

136:                                              ; preds = %133, %128
  br label %137

137:                                              ; preds = %136, %60
  %138 = load ptr, ptr %13, align 8, !tbaa !5
  store ptr %138, ptr %7, align 8
  store i32 1, ptr %14, align 4
  br label %139

139:                                              ; preds = %137, %33
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #2
  %140 = load ptr, ptr %7, align 8
  ret ptr %140
}

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 = { 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 0}
!12 = !{!"libxsmm_gemm_batch_reduce_config", !10, i64 0, !10, i64 4, !10, i64 8, !7, i64 12}
!13 = !{!14, !10, i64 24}
!14 = !{!"libxsmm_gemm_shape", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20, !10, i64 24, !10, i64 28, !10, i64 32, !10, i64 36}
!15 = !{!14, !10, i64 28}
!16 = !{!14, !10, i64 36}
!17 = !{!14, !10, i64 32}
!18 = !{!14, !10, i64 0}
!19 = !{!14, !10, i64 4}
!20 = !{!14, !10, i64 8}
!21 = !{!14, !10, i64 12}
!22 = !{!14, !10, i64 16}
!23 = !{!14, !10, i64 20}
!24 = !{!12, !10, i64 4}
!25 = !{!26, !27, i64 33}
!26 = !{!"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, !27, i64 33, !27, i64 41, !7, i64 49, !10, i64 50, !10, i64 54, !10, i64 58, !28, i64 62, !28, i64 64, !7, i64 66, !7, i64 67, !7, i64 68, !7, i64 69, !28, i64 70, !28, i64 72, !28, i64 74, !28, i64 76, !28, i64 78, !28, i64 80, !10, i64 82, !10, i64 86, !10, i64 90, !7, i64 94}
!27 = !{!"long long", !7, i64 0}
!28 = !{!"short", !7, i64 0}
!29 = !{!12, !10, i64 8}
!30 = !{!26, !27, i64 41}
!31 = !{!12, !7, i64 12}
!32 = !{!26, !7, i64 49}


; 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_shape = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32 }

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

; Function Attrs: nounwind uwtable
define dso_local ptr @libxsmm_gemm_descriptor_init_brgemm(ptr noundef %0, ptr nocapture noundef readonly byval(%struct.libxsmm_gemm_shape) align 8 %1, i32 noundef %2, i32 noundef %3, i64 %4, i64 %5) local_unnamed_addr #0 {
  %.sroa.0.0.extract.trunc = trunc i64 %4 to i32
  %.sroa.9.8.extract.shift = lshr i64 %5, 32
  %.sroa.9.8.extract.trunc = trunc nuw i64 %.sroa.9.8.extract.shift to i32
  %7 = trunc i32 %2 to i8
  %trunc = and i8 %7, -64
  switch i8 %trunc, label %8 [
    i8 -128, label %48
    i8 64, label %48
  ]

8:                                                ; preds = %6
  %9 = or i32 %2, 16384
  switch i32 %.sroa.0.0.extract.trunc, label %16 [
    i32 1, label %10
    i32 2, label %12
    i32 4, label %14
  ]

10:                                               ; preds = %8
  %11 = or i32 %2, 81920
  br label %16

12:                                               ; preds = %8
  %13 = or i32 %2, 147456
  br label %16

14:                                               ; preds = %8
  %15 = or i32 %2, 278528
  br label %16

16:                                               ; preds = %8, %12, %14, %10
  %.0 = phi i32 [ %11, %10 ], [ %13, %12 ], [ %15, %14 ], [ %9, %8 ]
  %17 = getelementptr inbounds i8, ptr %1, i64 24
  %18 = load i32, ptr %17, align 8, !tbaa !5
  %19 = getelementptr inbounds i8, ptr %1, i64 28
  %20 = load i32, ptr %19, align 4, !tbaa !10
  %21 = getelementptr inbounds i8, ptr %1, i64 36
  %22 = load i32, ptr %21, align 4, !tbaa !11
  %23 = getelementptr inbounds i8, ptr %1, i64 32
  %24 = load i32, ptr %23, align 8, !tbaa !12
  %25 = load i32, ptr %1, align 8, !tbaa !13
  %26 = getelementptr inbounds i8, ptr %1, i64 4
  %27 = load i32, ptr %26, align 4, !tbaa !14
  %28 = getelementptr inbounds i8, ptr %1, i64 8
  %29 = load i32, ptr %28, align 8, !tbaa !15
  %30 = getelementptr inbounds i8, ptr %1, i64 12
  %31 = load i32, ptr %30, align 4, !tbaa !16
  %32 = getelementptr inbounds i8, ptr %1, i64 16
  %33 = load i32, ptr %32, align 8, !tbaa !17
  %34 = getelementptr inbounds i8, ptr %1, i64 20
  %35 = load i32, ptr %34, align 4, !tbaa !18
  %36 = tail call ptr @libxsmm_gemm_descriptor_init(ptr noundef %0, i32 noundef %18, i32 noundef %20, i32 noundef %22, i32 noundef %24, i32 noundef %25, i32 noundef %27, i32 noundef %29, i32 noundef %31, i32 noundef %33, i32 noundef %35, i32 noundef %.0, i32 noundef %3)
  switch i32 %.sroa.0.0.extract.trunc, label %42 [
    i32 0, label %48
    i32 4, label %37
  ]

37:                                               ; preds = %16
  %38 = ashr i64 %4, 32
  %39 = getelementptr inbounds i8, ptr %36, i64 33
  store i64 %38, ptr %39, align 1, !tbaa !19
  %sext = shl i64 %5, 32
  %40 = ashr exact i64 %sext, 32
  %41 = getelementptr inbounds i8, ptr %36, i64 41
  store i64 %40, ptr %41, align 1, !tbaa !23
  br label %.sink.split

42:                                               ; preds = %16
  %43 = getelementptr inbounds i8, ptr %36, i64 33
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 1 dereferenceable(16) %43, i8 0, i64 16, i1 false)
  br label %.sink.split

.sink.split:                                      ; preds = %42, %37
  %44 = and i32 %.sroa.9.8.extract.trunc, 255
  %.not33 = icmp eq i32 %44, 0
  %.not34 = icmp eq i32 %44, 255
  %45 = trunc i64 %.sroa.9.8.extract.shift to i8
  %46 = or i1 %.not33, %.not34
  %.sink = select i1 %46, i8 0, i8 %45
  %47 = getelementptr inbounds i8, ptr %36, i64 49
  store i8 %.sink, ptr %47, align 1, !tbaa !24
  br label %48

48:                                               ; preds = %.sink.split, %6, %6, %16
  %.029 = phi ptr [ null, %6 ], [ %36, %16 ], [ null, %6 ], [ %36, %.sink.split ]
  ret ptr %.029
}

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #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 nounwind willreturn memory(argmem: write) }

!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_shape", !7, i64 0, !7, i64 4, !7, i64 8, !7, i64 12, !7, i64 16, !7, i64 20, !7, i64 24, !7, i64 28, !7, i64 32, !7, i64 36}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!6, !7, i64 28}
!11 = !{!6, !7, i64 36}
!12 = !{!6, !7, i64 32}
!13 = !{!6, !7, i64 0}
!14 = !{!6, !7, i64 4}
!15 = !{!6, !7, i64 8}
!16 = !{!6, !7, i64 12}
!17 = !{!6, !7, i64 16}
!18 = !{!6, !7, i64 20}
!19 = !{!20, !21, i64 33}
!20 = !{!"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, !21, i64 33, !21, i64 41, !8, i64 49, !7, i64 50, !7, i64 54, !7, i64 58, !22, i64 62, !22, i64 64, !8, i64 66, !8, i64 67, !8, i64 68, !8, i64 69, !22, i64 70, !22, i64 72, !22, i64 74, !22, i64 76, !22, i64 78, !22, i64 80, !7, i64 82, !7, i64 86, !7, i64 90, !8, i64 94}
!21 = !{!"long long", !8, i64 0}
!22 = !{!"short", !8, i64 0}
!23 = !{!20, !21, i64 41}
!24 = !{!20, !8, i64 49}


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