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

; 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_meltw_unary_param = type { %struct.libxsmm_matrix_op_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_meltw_descriptor = type <{ i32, i32, i32, i32, i32, i32, i8, i8, i8, i16, i16, i8 }>

; 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: nounwind uwtable
define dso_local void @libxsmm_ref_norm_to_vnni4_08bit(ptr noundef %0, ptr noundef %1) #1 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #2
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #2
  %15 = load ptr, ptr %3, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct.libxsmm_meltw_unary_param, ptr %15, i32 0, i32 1
  %17 = getelementptr inbounds %struct.libxsmm_matrix_arg, ptr %16, i32 0, i32 0
  %18 = load ptr, ptr %17, align 8, !tbaa !9
  store ptr %18, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #2
  %19 = load ptr, ptr %3, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.libxsmm_meltw_unary_param, ptr %19, i32 0, i32 2
  %21 = getelementptr inbounds %struct.libxsmm_matrix_arg, ptr %20, i32 0, i32 0
  %22 = load ptr, ptr %21, align 8, !tbaa !13
  store ptr %22, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #2
  %23 = load ptr, ptr %4, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.libxsmm_meltw_descriptor, ptr %23, i32 0, i32 0
  %25 = load i32, ptr %24, align 1, !tbaa !14
  store i32 %25, ptr %10, align 4, !tbaa !18
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #2
  %26 = load ptr, ptr %4, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.libxsmm_meltw_descriptor, ptr %26, i32 0, i32 1
  %28 = load i32, ptr %27, align 1, !tbaa !19
  store i32 %28, ptr %11, align 4, !tbaa !18
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #2
  %29 = load ptr, ptr %4, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.libxsmm_meltw_descriptor, ptr %29, i32 0, i32 2
  %31 = load i32, ptr %30, align 1, !tbaa !20
  store i32 %31, ptr %12, align 4, !tbaa !18
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #2
  %32 = load ptr, ptr %4, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.libxsmm_meltw_descriptor, ptr %32, i32 0, i32 3
  %34 = load i32, ptr %33, align 1, !tbaa !21
  store i32 %34, ptr %13, align 4, !tbaa !18
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #2
  %35 = load i32, ptr %11, align 4, !tbaa !18
  %36 = srem i32 %35, 4
  %37 = icmp eq i32 %36, 0
  br i1 %37, label %38, label %40

38:                                               ; preds = %2
  %39 = load i32, ptr %11, align 4, !tbaa !18
  br label %45

40:                                               ; preds = %2
  %41 = load i32, ptr %11, align 4, !tbaa !18
  %42 = add nsw i32 %41, 3
  %43 = sdiv i32 %42, 4
  %44 = mul nsw i32 %43, 4
  br label %45

45:                                               ; preds = %40, %38
  %46 = phi i32 [ %39, %38 ], [ %44, %40 ]
  store i32 %46, ptr %14, align 4, !tbaa !18
  store i32 0, ptr %5, align 4, !tbaa !18
  br label %47

47:                                               ; preds = %58, %45
  %48 = load i32, ptr %5, align 4, !tbaa !18
  %49 = load i32, ptr %13, align 4, !tbaa !18
  %50 = load i32, ptr %14, align 4, !tbaa !18
  %51 = mul nsw i32 %49, %50
  %52 = icmp slt i32 %48, %51
  br i1 %52, label %53, label %61

53:                                               ; preds = %47
  %54 = load ptr, ptr %9, align 8, !tbaa !5
  %55 = load i32, ptr %5, align 4, !tbaa !18
  %56 = sext i32 %55 to i64
  %57 = getelementptr inbounds i8, ptr %54, i64 %56
  store i8 0, ptr %57, align 1, !tbaa !22
  br label %58

58:                                               ; preds = %53
  %59 = load i32, ptr %5, align 4, !tbaa !18
  %60 = add nsw i32 %59, 1
  store i32 %60, ptr %5, align 4, !tbaa !18
  br label %47, !llvm.loop !23

61:                                               ; preds = %47
  store i32 0, ptr %6, align 4, !tbaa !18
  br label %62

62:                                               ; preds = %109, %61
  %63 = load i32, ptr %6, align 4, !tbaa !18
  %64 = load i32, ptr %14, align 4, !tbaa !18
  %65 = sdiv i32 %64, 4
  %66 = icmp slt i32 %63, %65
  br i1 %66, label %67, label %112

67:                                               ; preds = %62
  store i32 0, ptr %5, align 4, !tbaa !18
  br label %68

68:                                               ; preds = %105, %67
  %69 = load i32, ptr %5, align 4, !tbaa !18
  %70 = load i32, ptr %10, align 4, !tbaa !18
  %71 = icmp slt i32 %69, %70
  br i1 %71, label %72, label %108

72:                                               ; preds = %68
  store i32 0, ptr %7, align 4, !tbaa !18
  br label %73

73:                                               ; preds = %101, %72
  %74 = load i32, ptr %7, align 4, !tbaa !18
  %75 = icmp slt i32 %74, 4
  br i1 %75, label %76, label %104

76:                                               ; preds = %73
  %77 = load ptr, ptr %8, align 8, !tbaa !5
  %78 = load i32, ptr %6, align 4, !tbaa !18
  %79 = mul nsw i32 %78, 4
  %80 = load i32, ptr %7, align 4, !tbaa !18
  %81 = add nsw i32 %79, %80
  %82 = load i32, ptr %12, align 4, !tbaa !18
  %83 = mul nsw i32 %81, %82
  %84 = load i32, ptr %5, align 4, !tbaa !18
  %85 = add nsw i32 %83, %84
  %86 = sext i32 %85 to i64
  %87 = getelementptr inbounds i8, ptr %77, i64 %86
  %88 = load i8, ptr %87, align 1, !tbaa !22
  %89 = load ptr, ptr %9, align 8, !tbaa !5
  %90 = load i32, ptr %6, align 4, !tbaa !18
  %91 = load i32, ptr %13, align 4, !tbaa !18
  %92 = mul nsw i32 %90, %91
  %93 = mul nsw i32 %92, 4
  %94 = load i32, ptr %5, align 4, !tbaa !18
  %95 = mul nsw i32 %94, 4
  %96 = add nsw i32 %93, %95
  %97 = load i32, ptr %7, align 4, !tbaa !18
  %98 = add nsw i32 %96, %97
  %99 = sext i32 %98 to i64
  %100 = getelementptr inbounds i8, ptr %89, i64 %99
  store i8 %88, ptr %100, align 1, !tbaa !22
  br label %101

101:                                              ; preds = %76
  %102 = load i32, ptr %7, align 4, !tbaa !18
  %103 = add nsw i32 %102, 1
  store i32 %103, ptr %7, align 4, !tbaa !18
  br label %73, !llvm.loop !25

104:                                              ; preds = %73
  br label %105

105:                                              ; preds = %104
  %106 = load i32, ptr %5, align 4, !tbaa !18
  %107 = add nsw i32 %106, 1
  store i32 %107, ptr %5, align 4, !tbaa !18
  br label %68, !llvm.loop !26

108:                                              ; preds = %68
  br label %109

109:                                              ; preds = %108
  %110 = load i32, ptr %6, align 4, !tbaa !18
  %111 = add nsw i32 %110, 1
  store i32 %111, ptr %6, align 4, !tbaa !18
  br label %62, !llvm.loop !27

112:                                              ; preds = %62
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #2
  ret void
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 = { 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 32}
!10 = !{!"libxsmm_meltw_unary_param", !11, i64 0, !12, i64 32, !12, i64 80}
!11 = !{!"libxsmm_matrix_op_arg", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24}
!12 = !{!"libxsmm_matrix_arg", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40}
!13 = !{!10, !6, i64 80}
!14 = !{!15, !16, i64 0}
!15 = !{!"libxsmm_meltw_descriptor", !16, i64 0, !16, i64 4, !16, i64 8, !16, i64 12, !16, i64 16, !16, i64 20, !7, i64 24, !7, i64 25, !7, i64 26, !17, i64 27, !17, i64 29, !7, i64 31}
!16 = !{!"int", !7, i64 0}
!17 = !{!"short", !7, i64 0}
!18 = !{!16, !16, i64 0}
!19 = !{!15, !16, i64 4}
!20 = !{!15, !16, i64 8}
!21 = !{!15, !16, i64 12}
!22 = !{!7, !7, i64 0}
!23 = distinct !{!23, !24}
!24 = !{!"llvm.loop.mustprogress"}
!25 = distinct !{!25, !24}
!26 = distinct !{!26, !24}
!27 = distinct !{!27, !24}


; 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: nofree norecurse nosync nounwind memory(readwrite, inaccessiblemem: none) uwtable
define dso_local void @libxsmm_ref_norm_to_vnni4_08bit(ptr nocapture noundef readonly %0, ptr nocapture noundef readonly %1) local_unnamed_addr #0 {
  %3 = getelementptr inbounds i8, ptr %0, i64 32
  %4 = load ptr, ptr %3, align 8, !tbaa !5
  %5 = getelementptr inbounds i8, ptr %0, i64 80
  %6 = load ptr, ptr %5, align 8, !tbaa !12
  %7 = load i32, ptr %1, align 1, !tbaa !13
  %8 = getelementptr inbounds i8, ptr %1, i64 4
  %9 = load i32, ptr %8, align 1, !tbaa !17
  %10 = getelementptr inbounds i8, ptr %1, i64 8
  %11 = load i32, ptr %10, align 1, !tbaa !18
  %12 = getelementptr inbounds i8, ptr %1, i64 12
  %13 = load i32, ptr %12, align 1, !tbaa !19
  %14 = and i32 %9, 3
  %15 = icmp eq i32 %14, 0
  br i1 %15, label %20, label %16

16:                                               ; preds = %2
  %17 = add nsw i32 %9, 3
  %18 = sdiv i32 %17, 4
  %19 = shl nsw i32 %18, 2
  br label %20

20:                                               ; preds = %2, %16
  %21 = phi i32 [ %19, %16 ], [ %9, %2 ]
  %22 = mul nsw i32 %21, %13
  %23 = icmp sgt i32 %22, 0
  br i1 %23, label %.lr.ph.preheader, label %.preheader35

.lr.ph.preheader:                                 ; preds = %20
  %24 = zext nneg i32 %22 to i64
  tail call void @llvm.memset.p0.i64(ptr align 1 %6, i8 0, i64 %24, i1 false), !tbaa !20
  br label %.preheader35

.preheader35:                                     ; preds = %.lr.ph.preheader, %20
  %25 = ashr exact i32 %21, 2
  %26 = icmp sgt i32 %25, 0
  %27 = icmp sgt i32 %7, 0
  %or.cond = select i1 %26, i1 %27, i1 false
  br i1 %or.cond, label %.preheader34.us.preheader, label %._crit_edge40

.preheader34.us.preheader:                        ; preds = %.preheader35
  %28 = sext i32 %11 to i64
  %wide.trip.count48 = zext nneg i32 %25 to i64
  %wide.trip.count = zext nneg i32 %7 to i64
  br label %.preheader34.us

.preheader34.us:                                  ; preds = %.preheader34.us.preheader, %._crit_edge.us
  %indvars.iv45 = phi i64 [ 0, %.preheader34.us.preheader ], [ %indvars.iv.next46, %._crit_edge.us ]
  %29 = shl nsw i64 %indvars.iv45, 2
  %30 = mul nsw i64 %29, %28
  %31 = trunc i64 %indvars.iv45 to i32
  %32 = mul i32 %13, %31
  %33 = getelementptr i8, ptr %4, i64 %30
  %34 = or disjoint i64 %29, 1
  %35 = mul nsw i64 %34, %28
  %36 = getelementptr i8, ptr %4, i64 %35
  %37 = or disjoint i64 %29, 2
  %38 = mul nsw i64 %37, %28
  %39 = getelementptr i8, ptr %4, i64 %38
  %40 = or disjoint i64 %29, 3
  %41 = mul nsw i64 %40, %28
  %42 = getelementptr i8, ptr %4, i64 %41
  br label %.preheader.us

.preheader.us:                                    ; preds = %.preheader34.us, %.preheader.us
  %indvars.iv = phi i64 [ 0, %.preheader34.us ], [ %indvars.iv.next, %.preheader.us ]
  %43 = trunc nuw nsw i64 %indvars.iv to i32
  %44 = add i32 %32, %43
  %45 = shl i32 %44, 2
  %46 = sext i32 %45 to i64
  %47 = getelementptr i8, ptr %33, i64 %indvars.iv
  %48 = load i8, ptr %47, align 1, !tbaa !20
  %49 = getelementptr inbounds i8, ptr %6, i64 %46
  store i8 %48, ptr %49, align 1, !tbaa !20
  %50 = getelementptr i8, ptr %36, i64 %indvars.iv
  %51 = load i8, ptr %50, align 1, !tbaa !20
  %52 = or disjoint i64 %46, 1
  %53 = getelementptr inbounds i8, ptr %6, i64 %52
  store i8 %51, ptr %53, align 1, !tbaa !20
  %54 = getelementptr i8, ptr %39, i64 %indvars.iv
  %55 = load i8, ptr %54, align 1, !tbaa !20
  %56 = or disjoint i64 %46, 2
  %57 = getelementptr inbounds i8, ptr %6, i64 %56
  store i8 %55, ptr %57, align 1, !tbaa !20
  %58 = getelementptr i8, ptr %42, i64 %indvars.iv
  %59 = load i8, ptr %58, align 1, !tbaa !20
  %60 = or disjoint i64 %46, 3
  %61 = getelementptr inbounds i8, ptr %6, i64 %60
  store i8 %59, ptr %61, align 1, !tbaa !20
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
  br i1 %exitcond.not, label %._crit_edge.us, label %.preheader.us, !llvm.loop !21

._crit_edge.us:                                   ; preds = %.preheader.us
  %indvars.iv.next46 = add nuw nsw i64 %indvars.iv45, 1
  %exitcond49.not = icmp eq i64 %indvars.iv.next46, %wide.trip.count48
  br i1 %exitcond49.not, label %._crit_edge40, label %.preheader34.us, !llvm.loop !23

._crit_edge40:                                    ; preds = %._crit_edge.us, %.preheader35
  ret void
}

; 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 = { nofree norecurse nosync nounwind memory(readwrite, inaccessiblemem: none) 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, !8, i64 32}
!6 = !{!"libxsmm_meltw_unary_param", !7, i64 0, !11, i64 32, !11, i64 80}
!7 = !{!"libxsmm_matrix_op_arg", !8, i64 0, !8, i64 8, !8, i64 16, !8, i64 24}
!8 = !{!"any pointer", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C/C++ TBAA"}
!11 = !{!"libxsmm_matrix_arg", !8, i64 0, !8, i64 8, !8, i64 16, !8, i64 24, !8, i64 32, !8, i64 40}
!12 = !{!6, !8, i64 80}
!13 = !{!14, !15, i64 0}
!14 = !{!"libxsmm_meltw_descriptor", !15, i64 0, !15, i64 4, !15, i64 8, !15, i64 12, !15, i64 16, !15, i64 20, !9, i64 24, !9, i64 25, !9, i64 26, !16, i64 27, !16, i64 29, !9, i64 31}
!15 = !{!"int", !9, i64 0}
!16 = !{!"short", !9, i64 0}
!17 = !{!14, !15, i64 4}
!18 = !{!14, !15, i64 8}
!19 = !{!14, !15, i64 12}
!20 = !{!9, !9, i64 0}
!21 = distinct !{!21, !22}
!22 = !{!"llvm.loop.mustprogress"}
!23 = distinct !{!23, !22}


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