; 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_8x8_16bit_norm_to_normt_avx512 = external hidden unnamed_addr constant [64 x i8], align 1
@__const.libxsmm_generator_transform_four_8x8_16bit_norm_to_normt_avx512.l_in_idx = external hidden unnamed_addr constant [8 x i8], align 1
@__const.libxsmm_generator_transform_four_8x8_16bit_norm_to_normt_avx512.l_in_idx.12 = external hidden unnamed_addr constant [8 x i8], align 1
@__const.libxsmm_generator_transform_four_8x8_16bit_norm_to_normt_avx512.l_in_idx.13 = external hidden unnamed_addr constant [8 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_8x8_16bit_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 [8 x i8], align 1
  %10 = alloca [8 x i8], align 1
  %11 = alloca [8 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
  %12 = load i32, ptr %7, align 4, !tbaa !10
  %13 = add i32 %12, 8
  %14 = load i32, ptr %8, align 4, !tbaa !10
  %15 = icmp ugt i32 %13, %14
  br i1 %15, label %16, label %30

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

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

25:                                               ; preds = %21
  %26 = load i32, ptr @libxsmm_verbosity, align 4, !tbaa !10
  br label %28

27:                                               ; preds = %21
  br label %28

28:                                               ; preds = %27, %25
  %29 = phi i32 [ %26, %25 ], [ 1, %27 ]
  call void @libxsmm_handle_error(ptr noundef %22, i32 noundef 90000, ptr noundef @__func__.libxsmm_generator_transform_four_8x8_16bit_norm_to_normt_avx512, ptr noundef @.str, i32 noundef 1426, i32 noundef %29)
  br label %46

30:                                               ; preds = %16, %4
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #4
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %9, ptr align 1 @__const.libxsmm_generator_transform_four_8x8_16bit_norm_to_normt_avx512.l_in_idx, i64 8, i1 false)
  %31 = load ptr, ptr %5, align 8, !tbaa !5
  %32 = load i8, ptr %6, align 1, !tbaa !9
  %33 = getelementptr inbounds [8 x i8], ptr %9, i64 0, i64 0
  %34 = load i32, ptr %7, align 4, !tbaa !10
  %35 = load i32, ptr %8, align 4, !tbaa !10
  call void @libxsmm_generator_transform_Xway_unpack_network_avx_avx512(ptr noundef %31, i8 noundef signext %32, ptr noundef %33, i32 noundef %34, i32 noundef %35, i32 noundef 1, i32 noundef 805639777, i32 noundef 805639785, i32 noundef 8)
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #4
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %10, ptr align 1 @__const.libxsmm_generator_transform_four_8x8_16bit_norm_to_normt_avx512.l_in_idx.12, i64 8, i1 false)
  %36 = load ptr, ptr %5, align 8, !tbaa !5
  %37 = load i8, ptr %6, align 1, !tbaa !9
  %38 = getelementptr inbounds [8 x i8], ptr %10, i64 0, i64 0
  %39 = load i32, ptr %8, align 4, !tbaa !10
  %40 = load i32, ptr %7, align 4, !tbaa !10
  call void @libxsmm_generator_transform_Xway_unpack_network_avx_avx512(ptr noundef %36, i8 noundef signext %37, ptr noundef %38, i32 noundef %39, i32 noundef %40, i32 noundef 2, i32 noundef 805639778, i32 noundef 805639786, i32 noundef 8)
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #4
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %11, ptr align 1 @__const.libxsmm_generator_transform_four_8x8_16bit_norm_to_normt_avx512.l_in_idx.13, i64 8, i1 false)
  %41 = load ptr, ptr %5, align 8, !tbaa !5
  %42 = load i8, ptr %6, align 1, !tbaa !9
  %43 = getelementptr inbounds [8 x i8], ptr %11, i64 0, i64 0
  %44 = load i32, ptr %7, align 4, !tbaa !10
  %45 = load i32, ptr %8, align 4, !tbaa !10
  call void @libxsmm_generator_transform_Xway_unpack_network_avx_avx512(ptr noundef %41, i8 noundef signext %42, ptr noundef %43, i32 noundef %44, i32 noundef %45, i32 noundef 4, i32 noundef 814028396, i32 noundef 814028397, i32 noundef 8)
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #4
  br label %46

46:                                               ; preds = %30, %28
  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_8x8_16bit_norm_to_normt_avx512 = external hidden unnamed_addr constant [64 x i8], align 1
@__const.libxsmm_generator_transform_four_8x8_16bit_norm_to_normt_avx512.l_in_idx = external hidden unnamed_addr constant [8 x i8], align 1
@__const.libxsmm_generator_transform_four_8x8_16bit_norm_to_normt_avx512.l_in_idx.12 = external hidden unnamed_addr constant [8 x i8], align 1
@__const.libxsmm_generator_transform_four_8x8_16bit_norm_to_normt_avx512.l_in_idx.13 = external hidden unnamed_addr constant [8 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_8x8_16bit_norm_to_normt_avx512(ptr noundef %0, i8 noundef signext %1, i32 noundef %2, i32 noundef %3) local_unnamed_addr #2 {
  %5 = alloca [8 x i8], align 8
  %6 = alloca [8 x i8], align 8
  %7 = alloca [8 x i8], align 8
  %8 = add i32 %2, 8
  %9 = icmp ugt i32 %8, %3
  %10 = add i32 %3, 8
  %11 = icmp ugt i32 %10, %2
  %or.cond = and i1 %9, %11
  br i1 %or.cond, label %12, label %17

12:                                               ; preds = %4
  %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_four_8x8_16bit_norm_to_normt_avx512, ptr noundef nonnull @.str, i32 noundef 1426, i32 noundef %16) #3
  br label %21

17:                                               ; preds = %4
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #3
  %18 = load i64, ptr @__const.libxsmm_generator_transform_four_8x8_16bit_norm_to_normt_avx512.l_in_idx, align 1
  store i64 %18, ptr %5, align 8
  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 805639777, i32 noundef 805639785, i32 noundef 8) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %6) #3
  %19 = load i64, ptr @__const.libxsmm_generator_transform_four_8x8_16bit_norm_to_normt_avx512.l_in_idx.12, align 1
  store i64 %19, ptr %6, align 8
  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 805639778, i32 noundef 805639786, i32 noundef 8) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %6) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %7) #3
  %20 = load i64, ptr @__const.libxsmm_generator_transform_four_8x8_16bit_norm_to_normt_avx512.l_in_idx.13, align 1
  store i64 %20, ptr %7, align 8
  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 4, i32 noundef 814028396, i32 noundef 814028397, i32 noundef 8) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %7) #3
  br label %21

21:                                               ; 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 = { 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