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

%struct.libxsmm_generated_code = type { ptr, i32, i32, i32, i32, i32, i32 }

@.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_32way_half_store_avx512 = external hidden unnamed_addr constant [52 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

declare void @libxsmm_x86_instruction_vec_move(ptr noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i8 noundef signext, i32 noundef, i32 noundef, i32 noundef, i32 noundef) #1

; Function Attrs: nounwind uwtable
define dso_local void @libxsmm_generator_transform_32way_half_store_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 i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  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
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #3
  store i32 0, ptr %13, align 4, !tbaa !10
  %16 = load i32, ptr %10, align 4, !tbaa !10
  %17 = icmp ne i32 %16, 0
  br i1 %17, label %18, label %30

18:                                               ; preds = %6
  %19 = load i32, ptr %10, align 4, !tbaa !10
  %20 = icmp ne i32 %19, 16
  br i1 %20, label %21, label %30

21:                                               ; preds = %18
  %22 = load ptr, ptr %7, 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_32way_half_store_avx512, ptr noundef @.str, i32 noundef 340, i32 noundef %29)
  store i32 1, ptr %14, align 4
  br label %66

30:                                               ; preds = %18, %6
  store i32 0, ptr %13, align 4, !tbaa !10
  br label %31

31:                                               ; preds = %62, %30
  %32 = load i32, ptr %13, align 4, !tbaa !10
  %33 = icmp ult i32 %32, 32
  br i1 %33, label %34, label %65

34:                                               ; preds = %31
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #3
  %35 = load i32, ptr %13, align 4, !tbaa !10
  %36 = udiv i32 %35, 2
  %37 = load i32, ptr %10, align 4, !tbaa !10
  %38 = add i32 %36, %37
  store i32 %38, ptr %15, align 4, !tbaa !10
  %39 = load i32, ptr %13, align 4, !tbaa !10
  %40 = urem i32 %39, 2
  %41 = icmp eq i32 %40, 1
  br i1 %41, label %42, label %50

42:                                               ; preds = %34
  %43 = load ptr, ptr %7, align 8, !tbaa !5
  %44 = load i8, ptr %8, align 1, !tbaa !9
  %45 = load i32, ptr %9, align 4, !tbaa !10
  %46 = load i32, ptr %13, align 4, !tbaa !10
  %47 = load i32, ptr %11, align 4, !tbaa !10
  %48 = mul i32 %46, %47
  %49 = load i32, ptr %15, align 4, !tbaa !10
  call void @libxsmm_x86_instruction_vec_compute_mem_2reg_mask_imm8(ptr noundef %43, i32 noundef -393396933, i8 noundef signext %44, i32 noundef %45, i32 noundef 127, i32 noundef 0, i32 noundef %48, i32 noundef 0, i32 noundef 255, i32 noundef %49, i32 noundef 0, i32 noundef 0, i32 noundef 1)
  br label %61

50:                                               ; preds = %34
  %51 = load ptr, ptr %7, align 8, !tbaa !5
  %52 = load ptr, ptr %7, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct.libxsmm_generated_code, ptr %52, i32 0, i32 6
  %54 = load i32, ptr %53, align 4, !tbaa !12
  %55 = load i32, ptr %12, align 4, !tbaa !10
  %56 = load i32, ptr %9, align 4, !tbaa !10
  %57 = load i32, ptr %13, align 4, !tbaa !10
  %58 = load i32, ptr %11, align 4, !tbaa !10
  %59 = mul i32 %57, %58
  %60 = load i32, ptr %15, align 4, !tbaa !10
  call void @libxsmm_x86_instruction_vec_move(ptr noundef %51, i32 noundef %54, i32 noundef %55, i32 noundef %56, i32 noundef 127, i32 noundef 0, i32 noundef %59, i8 noundef signext 121, i32 noundef %60, i32 noundef 0, i32 noundef 1, i32 noundef 1)
  br label %61

61:                                               ; preds = %50, %42
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #3
  br label %62

62:                                               ; preds = %61
  %63 = load i32, ptr %13, align 4, !tbaa !10
  %64 = add i32 %63, 1
  store i32 %64, ptr %13, align 4, !tbaa !10
  br label %31, !llvm.loop !14

65:                                               ; preds = %31
  store i32 0, ptr %14, align 4
  br label %66

66:                                               ; preds = %65, %28
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #3
  %67 = load i32, ptr %14, align 4
  switch i32 %67, label %69 [
    i32 0, label %68
    i32 1, label %68
  ]

68:                                               ; preds = %66, %66
  ret void

69:                                               ; preds = %66
  unreachable
}

declare void @libxsmm_x86_instruction_vec_compute_mem_2reg_mask_imm8(ptr noundef, i32 noundef, i8 noundef signext, i32 noundef, i32 noundef, i32 noundef, i32 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 = { 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 = !{!13, !11, i64 28}
!13 = !{!"libxsmm_generated_code", !6, i64 0, !11, i64 8, !11, i64 12, !11, i64 16, !11, i64 20, !11, i64 24, !11, i64 28}
!14 = distinct !{!14, !15}
!15 = !{!"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"

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

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

declare void @libxsmm_x86_instruction_vec_move(ptr noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i8 noundef signext, i32 noundef, i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local void @libxsmm_generator_transform_32way_half_store_avx512(ptr noundef %0, i8 noundef signext %1, i32 noundef %2, i32 noundef %3, i32 noundef %4, i32 noundef %5) local_unnamed_addr #1 {
  %7 = and i32 %3, -17
  %or.cond.not = icmp eq i32 %7, 0
  br i1 %or.cond.not, label %.preheader, label %9

.preheader:                                       ; preds = %6
  %8 = getelementptr inbounds i8, ptr %0, i64 28
  br label %14

9:                                                ; preds = %6
  %10 = load i32, ptr @libxsmm_ninit, align 4, !tbaa !5
  %11 = icmp ugt i32 %10, 1
  %12 = load i32, ptr @libxsmm_verbosity, align 4
  %13 = select i1 %11, i32 %12, i32 1
  tail call void @libxsmm_handle_error(ptr noundef %0, i32 noundef 90000, ptr noundef nonnull @__func__.libxsmm_generator_transform_32way_half_store_avx512, ptr noundef nonnull @.str, i32 noundef 340, i32 noundef %13) #2
  br label %.loopexit

14:                                               ; preds = %.preheader, %23
  %.021 = phi i32 [ 0, %.preheader ], [ %24, %23 ]
  %15 = lshr i32 %.021, 1
  %16 = or disjoint i32 %15, %3
  %17 = and i32 %.021, 1
  %.not = icmp eq i32 %17, 0
  br i1 %.not, label %20, label %18

18:                                               ; preds = %14
  %19 = mul i32 %.021, %4
  tail call void @libxsmm_x86_instruction_vec_compute_mem_2reg_mask_imm8(ptr noundef %0, i32 noundef -393396933, i8 noundef signext %1, i32 noundef %2, i32 noundef 127, i32 noundef 0, i32 noundef %19, i32 noundef 0, i32 noundef 255, i32 noundef %16, i32 noundef 0, i32 noundef 0, i32 noundef 1) #2
  br label %23

20:                                               ; preds = %14
  %21 = load i32, ptr %8, align 4, !tbaa !9
  %22 = mul i32 %.021, %4
  tail call void @libxsmm_x86_instruction_vec_move(ptr noundef %0, i32 noundef %21, i32 noundef %5, i32 noundef %2, i32 noundef 127, i32 noundef 0, i32 noundef %22, i8 noundef signext 121, i32 noundef %16, i32 noundef 0, i32 noundef 1, i32 noundef 1) #2
  br label %23

23:                                               ; preds = %20, %18
  %24 = add nuw nsw i32 %.021, 1
  %exitcond.not = icmp eq i32 %24, 32
  br i1 %exitcond.not, label %.loopexit, label %14, !llvm.loop !12

.loopexit:                                        ; preds = %23, %9
  ret void
}

declare void @libxsmm_x86_instruction_vec_compute_mem_2reg_mask_imm8(ptr noundef, i32 noundef, i8 noundef signext, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #0

attributes #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 = { 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 #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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !6, i64 28}
!10 = !{!"libxsmm_generated_code", !11, i64 0, !6, i64 8, !6, i64 12, !6, i64 16, !6, i64 20, !6, i64 24, !6, i64 28}
!11 = !{!"any pointer", !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass