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

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

@.str = external hidden unnamed_addr constant [93 x i8], align 1
@libxsmm_ninit = external global i32, align 4
@libxsmm_verbosity = external global i32, align 4
@__func__.libxsmm_generator_transform_two_8x8_16bit_vnni2_to_vnni2t_avx512 = external hidden unnamed_addr constant [65 x i8], align 1
@__const.libxsmm_generator_transform_two_8x8_16bit_vnni2_to_vnni2t_avx512.l_in_idx = external hidden unnamed_addr constant <{ i8, i8, i8, i8, [12 x i8] }>, align 16
@__const.libxsmm_generator_transform_two_8x8_16bit_vnni2_to_vnni2t_avx512.l_in_idx.14 = external hidden unnamed_addr constant <{ i8, i8, i8, i8, [12 x i8] }>, align 16
@__const.libxsmm_generator_transform_two_8x8_16bit_vnni2_to_vnni2t_avx512.l_perm_imm = external hidden unnamed_addr constant [2 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

declare void @libxsmm_handle_error(ptr noundef, i32 noundef, ptr noundef, ptr noundef, i32 noundef, i32 noundef) #1

; 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
declare dso_local void @libxsmm_generator_transform_Xway_byteshuffle_network_avx512(ptr noundef, i8 noundef signext, ptr noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef) #2

; Function Attrs: nounwind uwtable
declare dso_local void @libxsmm_generator_transform_Xway_permute_network_avx512(ptr noundef, i8 noundef signext, ptr noundef, ptr noundef, i32 noundef, i32 noundef, i32 noundef) #2

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #3

declare void @libxsmm_generator_transform_Xway_unpack_network_avx_avx512(ptr noundef, i8 noundef signext, ptr noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef) #1

; Function Attrs: nounwind uwtable
define dso_local void @libxsmm_generator_transform_two_8x8_16bit_vnni2_to_vnni2t_avx512(ptr noundef %0, i8 noundef signext %1, i32 noundef %2, i32 noundef %3, i32 noundef %4, i32 noundef %5, i32 noundef %6) #2 {
  %8 = alloca ptr, align 8
  %9 = alloca i8, align 1
  %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
  %15 = alloca [16 x i8], align 16
  %16 = alloca [16 x i8], align 16
  %17 = alloca [2 x i8], align 1
  %18 = alloca [2 x i8], align 1
  store ptr %0, ptr %8, align 8, !tbaa !5
  store i8 %1, ptr %9, align 1, !tbaa !9
  store i32 %2, ptr %10, align 4, !tbaa !10
  store i32 %3, ptr %11, align 4, !tbaa !10
  store i32 %4, ptr %12, align 4, !tbaa !10
  store i32 %5, ptr %13, align 4, !tbaa !10
  store i32 %6, ptr %14, align 4, !tbaa !10
  %19 = load i32, ptr %10, align 4, !tbaa !10
  %20 = add i32 %19, 4
  %21 = load i32, ptr %11, align 4, !tbaa !10
  %22 = icmp ugt i32 %20, %21
  br i1 %22, label %23, label %37

23:                                               ; preds = %7
  %24 = load i32, ptr %11, align 4, !tbaa !10
  %25 = add i32 %24, 4
  %26 = load i32, ptr %10, align 4, !tbaa !10
  %27 = icmp ugt i32 %25, %26
  br i1 %27, label %28, label %37

28:                                               ; preds = %23
  %29 = load ptr, ptr %8, align 8, !tbaa !5
  %30 = load i32, ptr @libxsmm_ninit, align 4, !tbaa !10
  %31 = icmp ult i32 1, %30
  br i1 %31, label %32, label %34

32:                                               ; preds = %28
  %33 = load i32, ptr @libxsmm_verbosity, align 4, !tbaa !10
  br label %35

34:                                               ; preds = %28
  br label %35

35:                                               ; preds = %34, %32
  %36 = phi i32 [ %33, %32 ], [ 1, %34 ]
  call void @libxsmm_handle_error(ptr noundef %29, i32 noundef 90000, ptr noundef @__func__.libxsmm_generator_transform_two_8x8_16bit_vnni2_to_vnni2t_avx512, ptr noundef @.str, i32 noundef 1964, i32 noundef %36)
  br label %60

37:                                               ; preds = %23, %7
  call void @llvm.lifetime.start.p0(i64 16, ptr %15) #4
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %15, ptr align 16 @__const.libxsmm_generator_transform_two_8x8_16bit_vnni2_to_vnni2t_avx512.l_in_idx, i64 16, i1 false)
  %38 = load ptr, ptr %8, align 8, !tbaa !5
  %39 = load i8, ptr %9, align 1, !tbaa !9
  %40 = getelementptr inbounds [16 x i8], ptr %15, i64 0, i64 0
  %41 = load i32, ptr %12, align 4, !tbaa !10
  %42 = load i32, ptr %10, align 4, !tbaa !10
  %43 = load i32, ptr %11, align 4, !tbaa !10
  call void @libxsmm_generator_transform_Xway_byteshuffle_network_avx512(ptr noundef %38, i8 noundef signext %39, ptr noundef %40, i32 noundef %41, i32 noundef %42, i32 noundef %43, i32 noundef 805643776, i32 noundef 4)
  call void @llvm.lifetime.end.p0(i64 16, ptr %15) #4
  call void @llvm.lifetime.start.p0(i64 16, ptr %16) #4
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %16, ptr align 16 @__const.libxsmm_generator_transform_two_8x8_16bit_vnni2_to_vnni2t_avx512.l_in_idx.14, i64 16, i1 false)
  %44 = load ptr, ptr %8, align 8, !tbaa !5
  %45 = load i8, ptr %9, align 1, !tbaa !9
  %46 = getelementptr inbounds [16 x i8], ptr %16, i64 0, i64 0
  %47 = load i32, ptr %11, align 4, !tbaa !10
  %48 = load i32, ptr %10, align 4, !tbaa !10
  call void @libxsmm_generator_transform_Xway_unpack_network_avx_avx512(ptr noundef %44, i8 noundef signext %45, ptr noundef %46, i32 noundef %47, i32 noundef %48, i32 noundef 1, i32 noundef 814028396, i32 noundef 814028397, i32 noundef 4)
  call void @llvm.lifetime.end.p0(i64 16, ptr %16) #4
  call void @llvm.lifetime.start.p0(i64 2, ptr %17) #4
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %17, ptr align 1 @__const.libxsmm_generator_transform_two_8x8_16bit_vnni2_to_vnni2t_avx512.l_perm_imm, i64 2, i1 false)
  call void @llvm.lifetime.start.p0(i64 2, ptr %18) #4
  %49 = load i32, ptr %13, align 4, !tbaa !10
  %50 = trunc i32 %49 to i8
  %51 = getelementptr inbounds [2 x i8], ptr %18, i64 0, i64 0
  store i8 %50, ptr %51, align 1, !tbaa !9
  %52 = load i32, ptr %14, align 4, !tbaa !10
  %53 = trunc i32 %52 to i8
  %54 = getelementptr inbounds [2 x i8], ptr %18, i64 0, i64 1
  store i8 %53, ptr %54, align 1, !tbaa !9
  %55 = load ptr, ptr %8, align 8, !tbaa !5
  %56 = load i8, ptr %9, align 1, !tbaa !9
  %57 = getelementptr inbounds [2 x i8], ptr %18, i64 0, i64 0
  %58 = getelementptr inbounds [2 x i8], ptr %17, i64 0, i64 0
  %59 = load i32, ptr %10, align 4, !tbaa !10
  call void @libxsmm_generator_transform_Xway_permute_network_avx512(ptr noundef %55, i8 noundef signext %56, ptr noundef %57, ptr noundef %58, i32 noundef %59, i32 noundef 546127360, i32 noundef 4)
  call void @llvm.lifetime.end.p0(i64 2, ptr %18) #4
  call void @llvm.lifetime.end.p0(i64 2, ptr %17) #4
  br label %60

60:                                               ; preds = %37, %35
  ret void
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 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 #3 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!7, !7, i64 0}
!10 = !{!11, !11, i64 0}
!11 = !{!"int", !7, 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"

@.str = external hidden unnamed_addr constant [93 x i8], align 1
@libxsmm_ninit = external local_unnamed_addr global i32, align 4
@libxsmm_verbosity = external local_unnamed_addr global i32, align 4
@__func__.libxsmm_generator_transform_two_8x8_16bit_vnni2_to_vnni2t_avx512 = external hidden unnamed_addr constant [65 x i8], align 1
@__const.libxsmm_generator_transform_two_8x8_16bit_vnni2_to_vnni2t_avx512.l_in_idx = external hidden unnamed_addr constant <{ i8, i8, i8, i8, [12 x i8] }>, align 16
@__const.libxsmm_generator_transform_two_8x8_16bit_vnni2_to_vnni2t_avx512.l_in_idx.14 = external hidden unnamed_addr constant <{ i8, i8, i8, i8, [12 x i8] }>, align 16
@__const.libxsmm_generator_transform_two_8x8_16bit_vnni2_to_vnni2t_avx512.l_perm_imm = external hidden unnamed_addr constant [2 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

declare void @libxsmm_handle_error(ptr noundef, i32 noundef, ptr noundef, ptr noundef, i32 noundef, i32 noundef) local_unnamed_addr #1

; 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
declare dso_local void @libxsmm_generator_transform_Xway_byteshuffle_network_avx512(ptr noundef, i8 noundef signext, ptr noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
declare dso_local void @libxsmm_generator_transform_Xway_permute_network_avx512(ptr noundef, i8 noundef signext, ptr noundef, ptr noundef, i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #2

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #3

declare void @libxsmm_generator_transform_Xway_unpack_network_avx_avx512(ptr noundef, i8 noundef signext, ptr noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local void @libxsmm_generator_transform_two_8x8_16bit_vnni2_to_vnni2t_avx512(ptr noundef %0, i8 noundef signext %1, i32 noundef %2, i32 noundef %3, i32 noundef %4, i32 noundef %5, i32 noundef %6) local_unnamed_addr #2 {
  %8 = alloca [16 x i8], align 16
  %9 = alloca [16 x i8], align 16
  %10 = alloca [2 x i8], align 2
  %11 = alloca [2 x i8], align 1
  %12 = add i32 %2, 4
  %13 = icmp ugt i32 %12, %3
  %14 = add i32 %3, 4
  %15 = icmp ugt i32 %14, %2
  %or.cond = and i1 %13, %15
  br i1 %or.cond, label %16, label %21

16:                                               ; preds = %7
  %17 = load i32, ptr @libxsmm_ninit, align 4, !tbaa !5
  %18 = icmp ugt i32 %17, 1
  %19 = load i32, ptr @libxsmm_verbosity, align 4
  %20 = select i1 %18, i32 %19, i32 1
  tail call void @libxsmm_handle_error(ptr noundef %0, i32 noundef 90000, ptr noundef nonnull @__func__.libxsmm_generator_transform_two_8x8_16bit_vnni2_to_vnni2t_avx512, ptr noundef nonnull @.str, i32 noundef 1964, i32 noundef %20) #4
  br label %26

21:                                               ; preds = %7
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %8) #4
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 16 dereferenceable(16) %8, ptr noundef nonnull align 16 dereferenceable(16) @__const.libxsmm_generator_transform_two_8x8_16bit_vnni2_to_vnni2t_avx512.l_in_idx, i64 16, i1 false)
  call void @libxsmm_generator_transform_Xway_byteshuffle_network_avx512(ptr noundef %0, i8 noundef signext %1, ptr noundef nonnull %8, i32 noundef %4, i32 noundef %2, i32 noundef %3, i32 noundef 805643776, i32 noundef 4)
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %8) #4
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %9) #4
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 16 dereferenceable(16) %9, ptr noundef nonnull align 16 dereferenceable(16) @__const.libxsmm_generator_transform_two_8x8_16bit_vnni2_to_vnni2t_avx512.l_in_idx.14, i64 16, i1 false)
  call void @libxsmm_generator_transform_Xway_unpack_network_avx_avx512(ptr noundef %0, i8 noundef signext %1, ptr noundef nonnull %9, i32 noundef %3, i32 noundef %2, i32 noundef 1, i32 noundef 814028396, i32 noundef 814028397, i32 noundef 4) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %9) #4
  call void @llvm.lifetime.start.p0(i64 2, ptr nonnull %10) #4
  %22 = load i16, ptr @__const.libxsmm_generator_transform_two_8x8_16bit_vnni2_to_vnni2t_avx512.l_perm_imm, align 1
  store i16 %22, ptr %10, align 2
  call void @llvm.lifetime.start.p0(i64 2, ptr nonnull %11) #4
  %23 = trunc i32 %5 to i8
  store i8 %23, ptr %11, align 1, !tbaa !9
  %24 = trunc i32 %6 to i8
  %25 = getelementptr inbounds i8, ptr %11, i64 1
  store i8 %24, ptr %25, align 1, !tbaa !9
  call void @libxsmm_generator_transform_Xway_permute_network_avx512(ptr noundef %0, i8 noundef signext %1, ptr noundef nonnull %11, ptr noundef nonnull %10, i32 noundef %2, i32 noundef 546127360, i32 noundef 4)
  call void @llvm.lifetime.end.p0(i64 2, ptr nonnull %11) #4
  call void @llvm.lifetime.end.p0(i64 2, ptr nonnull %10) #4
  br label %26

26:                                               ; preds = %21, %16
  ret void
}

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 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 #3 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!7, !7, i64 0}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,SROAPass,SimplifyCFGPass,TailCallElimPass