; 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_4x4_64bit_norm_to_normt_avx512 = external hidden unnamed_addr constant [63 x i8], align 1
@__const.libxsmm_generator_transform_two_4x4_64bit_norm_to_normt_avx512.l_in_idx = external hidden unnamed_addr constant [4 x i8], align 1
@__const.libxsmm_generator_transform_two_4x4_64bit_norm_to_normt_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_permute_network_avx512(ptr noundef, i8 noundef signext, ptr noundef, ptr noundef, i32 noundef, i32 noundef, i32 noundef) #2

; Function Attrs: nounwind uwtable
define dso_local void @libxsmm_generator_transform_two_4x4_64bit_norm_to_normt_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 [4 x i8], align 1
  %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, 4
  %18 = load i32, ptr %10, align 4, !tbaa !10
  %19 = icmp ugt i32 %17, %18
  br i1 %19, label %20, label %34

20:                                               ; preds = %6
  %21 = load i32, ptr %10, align 4, !tbaa !10
  %22 = add i32 %21, 4
  %23 = load i32, ptr %9, align 4, !tbaa !10
  %24 = icmp ugt i32 %22, %23
  br i1 %24, label %25, label %34

25:                                               ; preds = %20
  %26 = load ptr, ptr %7, align 8, !tbaa !5
  %27 = load i32, ptr @libxsmm_ninit, align 4, !tbaa !10
  %28 = icmp ult i32 1, %27
  br i1 %28, label %29, label %31

29:                                               ; preds = %25
  %30 = load i32, ptr @libxsmm_verbosity, align 4, !tbaa !10
  br label %32

31:                                               ; preds = %25
  br label %32

32:                                               ; preds = %31, %29
  %33 = phi i32 [ %30, %29 ], [ 1, %31 ]
  call void @libxsmm_handle_error(ptr noundef %26, i32 noundef 90000, ptr noundef @__func__.libxsmm_generator_transform_two_4x4_64bit_norm_to_normt_avx512, ptr noundef @.str, i32 noundef 367, i32 noundef %33)
  br label %51

34:                                               ; preds = %20, %6
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #4
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %13, ptr align 1 @__const.libxsmm_generator_transform_two_4x4_64bit_norm_to_normt_avx512.l_in_idx, i64 4, i1 false)
  %35 = load ptr, ptr %7, align 8, !tbaa !5
  %36 = load i8, ptr %8, align 1, !tbaa !9
  %37 = getelementptr inbounds [4 x i8], ptr %13, i64 0, i64 0
  %38 = load i32, ptr %9, align 4, !tbaa !10
  %39 = load i32, ptr %10, align 4, !tbaa !10
  call void @libxsmm_generator_transform_Xway_unpack_network_avx_avx512(ptr noundef %35, i8 noundef signext %36, ptr noundef %37, i32 noundef %38, i32 noundef %39, i32 noundef 1, i32 noundef 814028396, i32 noundef 814028397, i32 noundef 4)
  call void @llvm.lifetime.end.p0(i64 4, 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_4x4_64bit_norm_to_normt_avx512.l_perm_imm, i64 2, i1 false)
  call void @llvm.lifetime.start.p0(i64 2, ptr %15) #4
  %40 = load i32, ptr %11, align 4, !tbaa !10
  %41 = trunc i32 %40 to i8
  %42 = getelementptr inbounds [2 x i8], ptr %15, i64 0, i64 0
  store i8 %41, ptr %42, align 1, !tbaa !9
  %43 = load i32, ptr %12, align 4, !tbaa !10
  %44 = trunc i32 %43 to i8
  %45 = getelementptr inbounds [2 x i8], ptr %15, i64 0, i64 1
  store i8 %44, ptr %45, align 1, !tbaa !9
  %46 = load ptr, ptr %7, align 8, !tbaa !5
  %47 = load i8, ptr %8, align 1, !tbaa !9
  %48 = getelementptr inbounds [2 x i8], ptr %15, i64 0, i64 0
  %49 = getelementptr inbounds [2 x i8], ptr %14, i64 0, i64 0
  %50 = load i32, ptr %10, align 4, !tbaa !10
  call void @libxsmm_generator_transform_Xway_permute_network_avx512(ptr noundef %46, i8 noundef signext %47, ptr noundef %48, ptr noundef %49, i32 noundef %50, i32 noundef 546127360, i32 noundef 4)
  call void @llvm.lifetime.end.p0(i64 2, ptr %15) #4
  call void @llvm.lifetime.end.p0(i64 2, ptr %14) #4
  br label %51

51:                                               ; preds = %34, %32
  ret void
}

; 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

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_4x4_64bit_norm_to_normt_avx512 = external hidden unnamed_addr constant [63 x i8], align 1
@__const.libxsmm_generator_transform_two_4x4_64bit_norm_to_normt_avx512.l_in_idx = external hidden unnamed_addr constant [4 x i8], align 1
@__const.libxsmm_generator_transform_two_4x4_64bit_norm_to_normt_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_permute_network_avx512(ptr noundef, i8 noundef signext, ptr noundef, ptr noundef, i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
define dso_local void @libxsmm_generator_transform_two_4x4_64bit_norm_to_normt_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 [4 x i8], align 4
  %8 = alloca [2 x i8], align 2
  %9 = alloca [2 x i8], align 1
  %10 = add i32 %2, 4
  %11 = icmp ugt i32 %10, %3
  %12 = add i32 %3, 4
  %13 = icmp ugt i32 %12, %2
  %or.cond = and i1 %11, %13
  br i1 %or.cond, label %14, label %19

14:                                               ; preds = %6
  %15 = load i32, ptr @libxsmm_ninit, align 4, !tbaa !5
  %16 = icmp ugt i32 %15, 1
  %17 = load i32, ptr @libxsmm_verbosity, align 4
  %18 = select i1 %16, i32 %17, i32 1
  tail call void @libxsmm_handle_error(ptr noundef %0, i32 noundef 90000, ptr noundef nonnull @__func__.libxsmm_generator_transform_two_4x4_64bit_norm_to_normt_avx512, ptr noundef nonnull @.str, i32 noundef 367, i32 noundef %18) #3
  br label %25

19:                                               ; preds = %6
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %7) #3
  %20 = load i32, ptr @__const.libxsmm_generator_transform_two_4x4_64bit_norm_to_normt_avx512.l_in_idx, align 1
  store i32 %20, ptr %7, align 4
  call void @libxsmm_generator_transform_Xway_unpack_network_avx_avx512(ptr noundef %0, i8 noundef signext %1, ptr noundef nonnull %7, i32 noundef %2, i32 noundef %3, i32 noundef 1, i32 noundef 814028396, i32 noundef 814028397, i32 noundef 4) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %7) #3
  call void @llvm.lifetime.start.p0(i64 2, ptr nonnull %8) #3
  %21 = load i16, ptr @__const.libxsmm_generator_transform_two_4x4_64bit_norm_to_normt_avx512.l_perm_imm, align 1
  store i16 %21, ptr %8, align 2
  call void @llvm.lifetime.start.p0(i64 2, ptr nonnull %9) #3
  %22 = trunc i32 %4 to i8
  store i8 %22, ptr %9, align 1, !tbaa !9
  %23 = trunc i32 %5 to i8
  %24 = getelementptr inbounds i8, ptr %9, i64 1
  store i8 %23, ptr %24, 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 %3, i32 noundef 546127360, i32 noundef 4)
  call void @llvm.lifetime.end.p0(i64 2, ptr nonnull %9) #3
  call void @llvm.lifetime.end.p0(i64 2, ptr nonnull %8) #3
  br label %25

25:                                               ; preds = %19, %14
  ret void
}

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

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 = { 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