; 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_08bit_vnni4_to_vnni4t_avx512 = external hidden unnamed_addr constant [65 x i8], align 1
@__const.libxsmm_generator_transform_two_8x8_08bit_vnni4_to_vnni4t_avx512.l_in_idx = external hidden unnamed_addr constant <{ i8, i8, [14 x i8] }>, align 16
@__const.libxsmm_generator_transform_two_8x8_08bit_vnni4_to_vnni4t_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

; Function Attrs: nounwind uwtable
define dso_local void @libxsmm_generator_transform_two_8x8_08bit_vnni4_to_vnni4t_avx512(ptr noundef %0, i8 noundef signext %1, i32 noundef %2, i32 noundef %3, i32 noundef %4, i32 noundef %5) #2 {
  %7 = alloca ptr, align 8
  %8 = alloca i8, align 1
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca [16 x i8], align 16
  %14 = alloca [2 x i8], align 1
  %15 = alloca [2 x i8], align 1
  store ptr %0, ptr %7, align 8, !tbaa !5
  store i8 %1, ptr %8, align 1, !tbaa !9
  store i32 %2, ptr %9, align 4, !tbaa !10
  store i32 %3, ptr %10, align 4, !tbaa !10
  store i32 %4, ptr %11, align 4, !tbaa !10
  store i32 %5, ptr %12, align 4, !tbaa !10
  %16 = load i32, ptr %9, align 4, !tbaa !10
  %17 = add i32 %16, 2
  %18 = icmp ugt i32 %17, 30
  br i1 %18, label %19, label %28

19:                                               ; preds = %6
  %20 = load ptr, ptr %7, align 8, !tbaa !5
  %21 = load i32, ptr @libxsmm_ninit, align 4, !tbaa !10
  %22 = icmp ult i32 1, %21
  br i1 %22, label %23, label %25

23:                                               ; preds = %19
  %24 = load i32, ptr @libxsmm_verbosity, align 4, !tbaa !10
  br label %26

25:                                               ; preds = %19
  br label %26

26:                                               ; preds = %25, %23
  %27 = phi i32 [ %24, %23 ], [ 1, %25 ]
  call void @libxsmm_handle_error(ptr noundef %20, i32 noundef 90000, ptr noundef @__func__.libxsmm_generator_transform_two_8x8_08bit_vnni4_to_vnni4t_avx512, ptr noundef @.str, i32 noundef 1933, i32 noundef %27)
  br label %46

28:                                               ; preds = %6
  call void @llvm.lifetime.start.p0(i64 16, ptr %13) #4
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %13, ptr align 16 @__const.libxsmm_generator_transform_two_8x8_08bit_vnni4_to_vnni4t_avx512.l_in_idx, i64 16, i1 false)
  %29 = load ptr, ptr %7, align 8, !tbaa !5
  %30 = load i8, ptr %8, align 1, !tbaa !9
  %31 = getelementptr inbounds [16 x i8], ptr %13, i64 0, i64 0
  %32 = load i32, ptr %10, align 4, !tbaa !10
  %33 = load i32, ptr %9, align 4, !tbaa !10
  %34 = load i32, ptr %9, align 4, !tbaa !10
  call void @libxsmm_generator_transform_Xway_byteshuffle_network_avx512(ptr noundef %29, i8 noundef signext %30, ptr noundef %31, i32 noundef %32, i32 noundef %33, i32 noundef %34, i32 noundef 805643776, i32 noundef 2)
  call void @llvm.lifetime.end.p0(i64 16, ptr %13) #4
  call void @llvm.lifetime.start.p0(i64 2, ptr %14) #4
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %14, ptr align 1 @__const.libxsmm_generator_transform_two_8x8_08bit_vnni4_to_vnni4t_avx512.l_perm_imm, i64 2, i1 false)
  call void @llvm.lifetime.start.p0(i64 2, ptr %15) #4
  %35 = load i32, ptr %11, align 4, !tbaa !10
  %36 = trunc i32 %35 to i8
  %37 = getelementptr inbounds [2 x i8], ptr %15, i64 0, i64 0
  store i8 %36, ptr %37, align 1, !tbaa !9
  %38 = load i32, ptr %12, align 4, !tbaa !10
  %39 = trunc i32 %38 to i8
  %40 = getelementptr inbounds [2 x i8], ptr %15, i64 0, i64 1
  store i8 %39, ptr %40, align 1, !tbaa !9
  %41 = load ptr, ptr %7, align 8, !tbaa !5
  %42 = load i8, ptr %8, align 1, !tbaa !9
  %43 = getelementptr inbounds [2 x i8], ptr %15, i64 0, i64 0
  %44 = getelementptr inbounds [2 x i8], ptr %14, i64 0, i64 0
  %45 = load i32, ptr %9, align 4, !tbaa !10
  call void @libxsmm_generator_transform_Xway_permute_network_avx512(ptr noundef %41, i8 noundef signext %42, ptr noundef %43, ptr noundef %44, i32 noundef %45, i32 noundef 546127360, i32 noundef 2)
  call void @llvm.lifetime.end.p0(i64 2, ptr %15) #4
  call void @llvm.lifetime.end.p0(i64 2, ptr %14) #4
  br label %46

46:                                               ; preds = %28, %26
  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_08bit_vnni4_to_vnni4t_avx512 = external hidden unnamed_addr constant [65 x i8], align 1
@__const.libxsmm_generator_transform_two_8x8_08bit_vnni4_to_vnni4t_avx512.l_in_idx = external hidden unnamed_addr constant <{ i8, i8, [14 x i8] }>, align 16
@__const.libxsmm_generator_transform_two_8x8_08bit_vnni4_to_vnni4t_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

; Function Attrs: nounwind uwtable
define dso_local void @libxsmm_generator_transform_two_8x8_08bit_vnni4_to_vnni4t_avx512(ptr noundef %0, i8 noundef signext %1, i32 noundef %2, i32 noundef %3, i32 noundef %4, i32 noundef %5) local_unnamed_addr #2 {
  %7 = alloca [16 x i8], align 16
  %8 = alloca [2 x i8], align 2
  %9 = alloca [2 x i8], align 1
  %10 = add i32 %2, -29
  %11 = icmp ult i32 %10, -31
  br i1 %11, label %12, label %17

12:                                               ; preds = %6
  %13 = load i32, ptr @libxsmm_ninit, align 4, !tbaa !5
  %14 = icmp ugt i32 %13, 1
  %15 = load i32, ptr @libxsmm_verbosity, align 4
  %16 = select i1 %14, i32 %15, i32 1
  tail call void @libxsmm_handle_error(ptr noundef %0, i32 noundef 90000, ptr noundef nonnull @__func__.libxsmm_generator_transform_two_8x8_08bit_vnni4_to_vnni4t_avx512, ptr noundef nonnull @.str, i32 noundef 1933, i32 noundef %16) #4
  br label %22

17:                                               ; preds = %6
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %7) #4
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 16 dereferenceable(16) %7, ptr noundef nonnull align 16 dereferenceable(16) @__const.libxsmm_generator_transform_two_8x8_08bit_vnni4_to_vnni4t_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 %7, i32 noundef %3, i32 noundef %2, i32 noundef %2, i32 noundef 805643776, i32 noundef 2)
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %7) #4
  call void @llvm.lifetime.start.p0(i64 2, ptr nonnull %8) #4
  %18 = load i16, ptr @__const.libxsmm_generator_transform_two_8x8_08bit_vnni4_to_vnni4t_avx512.l_perm_imm, align 1
  store i16 %18, ptr %8, align 2
  call void @llvm.lifetime.start.p0(i64 2, ptr nonnull %9) #4
  %19 = trunc i32 %4 to i8
  store i8 %19, ptr %9, align 1, !tbaa !9
  %20 = trunc i32 %5 to i8
  %21 = getelementptr inbounds i8, ptr %9, i64 1
  store i8 %20, ptr %21, align 1, !tbaa !9
  call void @libxsmm_generator_transform_Xway_permute_network_avx512(ptr noundef %0, i8 noundef signext %1, ptr noundef nonnull %9, ptr noundef nonnull %8, i32 noundef %2, i32 noundef 546127360, i32 noundef 2)
  call void @llvm.lifetime.end.p0(i64 2, ptr nonnull %9) #4
  call void @llvm.lifetime.end.p0(i64 2, ptr nonnull %8) #4
  br label %22

22:                                               ; preds = %17, %12
  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