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

@__func__.libxsmm_generator_transform_Xway_shuffle_network_avx512 = external hidden unnamed_addr constant [56 x i8], align 1
@.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

; Function Attrs: nounwind uwtable
define dso_local void @libxsmm_generator_transform_Xway_shuffle_network_avx512(ptr noundef %0, i8 noundef signext %1, ptr noundef %2, ptr noundef %3, i32 noundef %4, i32 noundef %5, i32 noundef %6, i32 noundef %7, i32 noundef %8) #0 {
  %10 = alloca ptr, align 8
  %11 = alloca i8, align 1
  %12 = alloca ptr, align 8
  %13 = alloca ptr, align 8
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  %16 = alloca i32, align 4
  %17 = alloca i32, align 4
  %18 = alloca i32, align 4
  %19 = alloca i32, align 4
  %20 = alloca i32, align 4
  %21 = alloca i32, align 4
  %22 = alloca i32, align 4
  %23 = alloca i32, align 4
  store ptr %0, ptr %10, align 8, !tbaa !5
  store i8 %1, ptr %11, align 1, !tbaa !9
  store ptr %2, ptr %12, align 8, !tbaa !5
  store ptr %3, ptr %13, align 8, !tbaa !5
  store i32 %4, ptr %14, align 4, !tbaa !10
  store i32 %5, ptr %15, align 4, !tbaa !10
  store i32 %6, ptr %16, align 4, !tbaa !10
  store i32 %7, ptr %17, align 4, !tbaa !10
  store i32 %8, ptr %18, align 4, !tbaa !10
  call void @llvm.lifetime.start.p0(i64 4, ptr %19) #3
  store i32 0, ptr %19, align 4, !tbaa !10
  %24 = load i32, ptr %18, align 4, !tbaa !10
  %25 = icmp ne i32 %24, 4
  br i1 %25, label %26, label %41

26:                                               ; preds = %9
  %27 = load i32, ptr %18, align 4, !tbaa !10
  %28 = icmp ne i32 %27, 8
  br i1 %28, label %29, label %41

29:                                               ; preds = %26
  %30 = load i32, ptr %18, align 4, !tbaa !10
  %31 = icmp ne i32 %30, 16
  br i1 %31, label %32, label %41

32:                                               ; preds = %29
  %33 = load ptr, ptr %10, align 8, !tbaa !5
  %34 = load i32, ptr @libxsmm_ninit, align 4, !tbaa !10
  %35 = icmp ult i32 1, %34
  br i1 %35, label %36, label %38

36:                                               ; preds = %32
  %37 = load i32, ptr @libxsmm_verbosity, align 4, !tbaa !10
  br label %39

38:                                               ; preds = %32
  br label %39

39:                                               ; preds = %38, %36
  %40 = phi i32 [ %37, %36 ], [ 1, %38 ]
  call void @libxsmm_handle_error(ptr noundef %33, i32 noundef 90000, ptr noundef @__func__.libxsmm_generator_transform_Xway_shuffle_network_avx512, ptr noundef @.str, i32 noundef 36, i32 noundef %40)
  store i32 1, ptr %20, align 4
  br label %96

41:                                               ; preds = %29, %26, %9
  %42 = load i32, ptr %14, align 4, !tbaa !10
  %43 = load i32, ptr %18, align 4, !tbaa !10
  %44 = urem i32 %42, %43
  %45 = icmp ne i32 %44, 0
  br i1 %45, label %51, label %46

46:                                               ; preds = %41
  %47 = load i32, ptr %15, align 4, !tbaa !10
  %48 = load i32, ptr %18, align 4, !tbaa !10
  %49 = urem i32 %47, %48
  %50 = icmp ne i32 %49, 0
  br i1 %50, label %51, label %60

51:                                               ; preds = %46, %41
  %52 = load ptr, ptr %10, align 8, !tbaa !5
  %53 = load i32, ptr @libxsmm_ninit, align 4, !tbaa !10
  %54 = icmp ult i32 1, %53
  br i1 %54, label %55, label %57

55:                                               ; preds = %51
  %56 = load i32, ptr @libxsmm_verbosity, align 4, !tbaa !10
  br label %58

57:                                               ; preds = %51
  br label %58

58:                                               ; preds = %57, %55
  %59 = phi i32 [ %56, %55 ], [ 1, %57 ]
  call void @libxsmm_handle_error(ptr noundef %52, i32 noundef 90000, ptr noundef @__func__.libxsmm_generator_transform_Xway_shuffle_network_avx512, ptr noundef @.str, i32 noundef 42, i32 noundef %59)
  store i32 1, ptr %20, align 4
  br label %96

60:                                               ; preds = %46
  store i32 0, ptr %19, align 4, !tbaa !10
  br label %61

61:                                               ; preds = %92, %60
  %62 = load i32, ptr %19, align 4, !tbaa !10
  %63 = load i32, ptr %18, align 4, !tbaa !10
  %64 = icmp ult i32 %62, %63
  br i1 %64, label %65, label %95

65:                                               ; preds = %61
  call void @llvm.lifetime.start.p0(i64 4, ptr %21) #3
  %66 = load ptr, ptr %12, align 8, !tbaa !5
  %67 = load i32, ptr %19, align 4, !tbaa !10
  %68 = zext i32 %67 to i64
  %69 = getelementptr inbounds i8, ptr %66, i64 %68
  %70 = load i8, ptr %69, align 1, !tbaa !9
  %71 = zext i8 %70 to i32
  %72 = load i32, ptr %14, align 4, !tbaa !10
  %73 = add i32 %71, %72
  store i32 %73, ptr %21, align 4, !tbaa !10
  call void @llvm.lifetime.start.p0(i64 4, ptr %22) #3
  %74 = load i32, ptr %21, align 4, !tbaa !10
  %75 = load i32, ptr %16, align 4, !tbaa !10
  %76 = add i32 %74, %75
  store i32 %76, ptr %22, align 4, !tbaa !10
  call void @llvm.lifetime.start.p0(i64 4, ptr %23) #3
  %77 = load i32, ptr %19, align 4, !tbaa !10
  %78 = load i32, ptr %15, align 4, !tbaa !10
  %79 = add i32 %77, %78
  store i32 %79, ptr %23, align 4, !tbaa !10
  %80 = load ptr, ptr %10, align 8, !tbaa !5
  %81 = load i32, ptr %17, align 4, !tbaa !10
  %82 = load i8, ptr %11, align 1, !tbaa !9
  %83 = load i32, ptr %22, align 4, !tbaa !10
  %84 = load i32, ptr %21, align 4, !tbaa !10
  %85 = load i32, ptr %23, align 4, !tbaa !10
  %86 = load ptr, ptr %13, align 8, !tbaa !5
  %87 = load i32, ptr %19, align 4, !tbaa !10
  %88 = zext i32 %87 to i64
  %89 = getelementptr inbounds i8, ptr %86, i64 %88
  %90 = load i8, ptr %89, align 1, !tbaa !9
  %91 = zext i8 %90 to i32
  call void @libxsmm_x86_instruction_vec_compute_3reg_mask_sae_imm8(ptr noundef %80, i32 noundef %81, i8 noundef signext %82, i32 noundef %83, i32 noundef %84, i32 noundef %85, i32 noundef 0, i32 noundef 0, i8 noundef zeroext 0, i32 noundef %91)
  call void @llvm.lifetime.end.p0(i64 4, ptr %23) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %22) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %21) #3
  br label %92

92:                                               ; preds = %65
  %93 = load i32, ptr %19, align 4, !tbaa !10
  %94 = add i32 %93, 1
  store i32 %94, ptr %19, align 4, !tbaa !10
  br label %61, !llvm.loop !12

95:                                               ; preds = %61
  store i32 0, ptr %20, align 4
  br label %96

96:                                               ; preds = %95, %58, %39
  call void @llvm.lifetime.end.p0(i64 4, ptr %19) #3
  %97 = load i32, ptr %20, align 4
  switch i32 %97, label %99 [
    i32 0, label %98
    i32 1, label %98
  ]

98:                                               ; preds = %96, %96
  ret void

99:                                               ; preds = %96
  unreachable
}

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1

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

declare void @libxsmm_x86_instruction_vec_compute_3reg_mask_sae_imm8(ptr noundef, i32 noundef, i8 noundef signext, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i8 noundef zeroext, i32 noundef) #2

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

attributes #0 = { 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 #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { "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 = !{!"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}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}


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

@__func__.libxsmm_generator_transform_Xway_shuffle_network_avx512 = external hidden unnamed_addr constant [56 x i8], align 1
@.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

; Function Attrs: nounwind uwtable
define dso_local void @libxsmm_generator_transform_Xway_shuffle_network_avx512(ptr noundef %0, i8 noundef signext %1, ptr nocapture noundef readonly %2, ptr nocapture noundef readonly %3, i32 noundef %4, i32 noundef %5, i32 noundef %6, i32 noundef %7, i32 noundef %8) local_unnamed_addr #0 {
  switch i32 %8, label %.loopexit.sink.split [
    i32 16, label %10
    i32 8, label %10
    i32 4, label %10
  ]

10:                                               ; preds = %9, %9, %9
  %11 = urem i32 %4, %8
  %.not = icmp eq i32 %11, 0
  br i1 %.not, label %12, label %.loopexit.sink.split

12:                                               ; preds = %10
  %13 = urem i32 %5, %8
  %.not29 = icmp eq i32 %13, 0
  br i1 %.not29, label %.preheader.preheader, label %.loopexit.sink.split

.preheader.preheader:                             ; preds = %12
  %wide.trip.count = zext nneg i32 %8 to i64
  br label %.preheader

.preheader:                                       ; preds = %.preheader.preheader, %.preheader
  %indvars.iv = phi i64 [ 0, %.preheader.preheader ], [ %indvars.iv.next, %.preheader ]
  %14 = getelementptr inbounds i8, ptr %2, i64 %indvars.iv
  %15 = load i8, ptr %14, align 1, !tbaa !5
  %16 = zext i8 %15 to i32
  %17 = add i32 %16, %4
  %18 = add i32 %17, %6
  %19 = trunc nuw i64 %indvars.iv to i32
  %20 = add i32 %19, %5
  %21 = getelementptr inbounds i8, ptr %3, i64 %indvars.iv
  %22 = load i8, ptr %21, align 1, !tbaa !5
  %23 = zext i8 %22 to i32
  tail call void @libxsmm_x86_instruction_vec_compute_3reg_mask_sae_imm8(ptr noundef %0, i32 noundef %7, i8 noundef signext %1, i32 noundef %18, i32 noundef %17, i32 noundef %20, i32 noundef 0, i32 noundef 0, i8 noundef zeroext 0, i32 noundef %23) #2
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
  br i1 %exitcond.not, label %.loopexit, label %.preheader, !llvm.loop !8

.loopexit.sink.split:                             ; preds = %10, %12, %9
  %.sink = phi i32 [ 36, %9 ], [ 42, %12 ], [ 42, %10 ]
  %24 = load i32, ptr @libxsmm_ninit, align 4, !tbaa !10
  %25 = icmp ugt i32 %24, 1
  %26 = load i32, ptr @libxsmm_verbosity, align 4
  %27 = select i1 %25, i32 %26, i32 1
  tail call void @libxsmm_handle_error(ptr noundef %0, i32 noundef 90000, ptr noundef nonnull @__func__.libxsmm_generator_transform_Xway_shuffle_network_avx512, ptr noundef nonnull @.str, i32 noundef %.sink, i32 noundef %27) #2
  br label %.loopexit

.loopexit:                                        ; preds = %.preheader, %.loopexit.sink.split
  ret void
}

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

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

attributes #0 = { 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 #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 }

!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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C/C++ TBAA"}
!8 = distinct !{!8, !9}
!9 = !{!"llvm.loop.mustprogress"}
!10 = !{!11, !11, i64 0}
!11 = !{!"int", !6, i64 0}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass