; 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_four_4x4_32bit_norm_to_normt_avx512 = external hidden unnamed_addr constant [64 x i8], align 1
@__const.libxsmm_generator_transform_four_4x4_32bit_norm_to_normt_avx512.l_in_idx = external hidden unnamed_addr constant [4 x i8], align 1
@__const.libxsmm_generator_transform_four_4x4_32bit_norm_to_normt_avx512.l_in_idx.5 = external hidden unnamed_addr constant [4 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: 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) #2

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_four_4x4_32bit_norm_to_normt_avx512(ptr noundef %0, i8 noundef signext %1, i32 noundef %2, i32 noundef %3) #3 {
  %5 = alloca ptr, align 8
  %6 = alloca i8, align 1
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca [4 x i8], align 1
  %10 = alloca [4 x i8], align 1
  store ptr %0, ptr %5, align 8, !tbaa !5
  store i8 %1, ptr %6, align 1, !tbaa !9
  store i32 %2, ptr %7, align 4, !tbaa !10
  store i32 %3, ptr %8, align 4, !tbaa !10
  %11 = load i32, ptr %7, align 4, !tbaa !10
  %12 = add i32 %11, 4
  %13 = load i32, ptr %8, align 4, !tbaa !10
  %14 = icmp ugt i32 %12, %13
  br i1 %14, label %15, label %29

15:                                               ; preds = %4
  %16 = load i32, ptr %8, align 4, !tbaa !10
  %17 = add i32 %16, 4
  %18 = load i32, ptr %7, align 4, !tbaa !10
  %19 = icmp ugt i32 %17, %18
  br i1 %19, label %20, label %29

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

24:                                               ; preds = %20
  %25 = load i32, ptr @libxsmm_verbosity, align 4, !tbaa !10
  br label %27

26:                                               ; preds = %20
  br label %27

27:                                               ; preds = %26, %24
  %28 = phi i32 [ %25, %24 ], [ 1, %26 ]
  call void @libxsmm_handle_error(ptr noundef %21, i32 noundef 90000, ptr noundef @__func__.libxsmm_generator_transform_four_4x4_32bit_norm_to_normt_avx512, ptr noundef @.str, i32 noundef 795, i32 noundef %28)
  br label %40

29:                                               ; preds = %15, %4
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #4
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %9, ptr align 1 @__const.libxsmm_generator_transform_four_4x4_32bit_norm_to_normt_avx512.l_in_idx, i64 4, i1 false)
  %30 = load ptr, ptr %5, align 8, !tbaa !5
  %31 = load i8, ptr %6, align 1, !tbaa !9
  %32 = getelementptr inbounds [4 x i8], ptr %9, i64 0, i64 0
  %33 = load i32, ptr %7, align 4, !tbaa !10
  %34 = load i32, ptr %8, align 4, !tbaa !10
  call void @libxsmm_generator_transform_Xway_unpack_network_avx_avx512(ptr noundef %30, i8 noundef signext %31, ptr noundef %32, i32 noundef %33, i32 noundef %34, i32 noundef 1, i32 noundef 805639778, i32 noundef 805639786, i32 noundef 4)
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #4
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %10, ptr align 1 @__const.libxsmm_generator_transform_four_4x4_32bit_norm_to_normt_avx512.l_in_idx.5, i64 4, i1 false)
  %35 = load ptr, ptr %5, align 8, !tbaa !5
  %36 = load i8, ptr %6, align 1, !tbaa !9
  %37 = getelementptr inbounds [4 x i8], ptr %10, i64 0, i64 0
  %38 = load i32, ptr %8, align 4, !tbaa !10
  %39 = load i32, ptr %7, 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 2, i32 noundef 814028396, i32 noundef 814028397, i32 noundef 4)
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #4
  br label %40

40:                                               ; preds = %29, %27
  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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { 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 #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_four_4x4_32bit_norm_to_normt_avx512 = external hidden unnamed_addr constant [64 x i8], align 1
@__const.libxsmm_generator_transform_four_4x4_32bit_norm_to_normt_avx512.l_in_idx = external hidden unnamed_addr constant [4 x i8], align 1
@__const.libxsmm_generator_transform_four_4x4_32bit_norm_to_normt_avx512.l_in_idx.5 = external hidden unnamed_addr constant [4 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

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_four_4x4_32bit_norm_to_normt_avx512(ptr noundef %0, i8 noundef signext %1, i32 noundef %2, i32 noundef %3) local_unnamed_addr #2 {
  %5 = alloca [4 x i8], align 4
  %6 = alloca [4 x i8], align 4
  %7 = add i32 %2, 4
  %8 = icmp ugt i32 %7, %3
  %9 = add i32 %3, 4
  %10 = icmp ugt i32 %9, %2
  %or.cond = and i1 %8, %10
  br i1 %or.cond, label %11, label %16

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

16:                                               ; preds = %4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %5) #3
  %17 = load i32, ptr @__const.libxsmm_generator_transform_four_4x4_32bit_norm_to_normt_avx512.l_in_idx, align 1
  store i32 %17, ptr %5, align 4
  call void @libxsmm_generator_transform_Xway_unpack_network_avx_avx512(ptr noundef %0, i8 noundef signext %1, ptr noundef nonnull %5, i32 noundef %2, i32 noundef %3, i32 noundef 1, i32 noundef 805639778, i32 noundef 805639786, i32 noundef 4) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %5) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %6) #3
  %18 = load i32, ptr @__const.libxsmm_generator_transform_four_4x4_32bit_norm_to_normt_avx512.l_in_idx.5, align 1
  store i32 %18, ptr %6, align 4
  call void @libxsmm_generator_transform_Xway_unpack_network_avx_avx512(ptr noundef %0, i8 noundef signext %1, ptr noundef nonnull %6, i32 noundef %3, i32 noundef %2, i32 noundef 2, i32 noundef 814028396, i32 noundef 814028397, i32 noundef 4) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %6) #3
  br label %19

19:                                               ; preds = %16, %11
  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 = { 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"}


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