; LLVM IR from libxsmm/libxsmm :: src (generator_mateltwise_unary_binary_avx_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"

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

; 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
define dso_local void @libxsmm_generator_configure_M_N_blocking(i32 noundef %0, i32 noundef %1, i32 noundef %2, ptr noundef %3, ptr noundef %4, i32 noundef %5) #1 {
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %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
  store i32 %0, ptr %7, align 4, !tbaa !5
  store i32 %1, ptr %8, align 4, !tbaa !5
  store i32 %2, ptr %9, align 4, !tbaa !5
  store ptr %3, ptr %10, align 8, !tbaa !9
  store ptr %4, ptr %11, align 8, !tbaa !9
  store i32 %5, ptr %12, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #3
  %19 = load i32, ptr %7, align 4, !tbaa !5
  %20 = load i32, ptr %9, align 4, !tbaa !5
  %21 = add i32 %19, %20
  %22 = sub i32 %21, 1
  %23 = load i32, ptr %9, align 4, !tbaa !5
  %24 = udiv i32 %22, %23
  store i32 %24, ptr %13, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #3
  store i32 8, ptr %14, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #3
  %25 = load i32, ptr %7, align 4, !tbaa !5
  %26 = load i32, ptr %9, align 4, !tbaa !5
  %27 = urem i32 %25, %26
  %28 = icmp eq i32 %27, 0
  br i1 %28, label %29, label %46

29:                                               ; preds = %6
  %30 = load i32, ptr %13, align 4, !tbaa !5
  %31 = icmp ugt i32 %30, 32
  br i1 %31, label %32, label %42

32:                                               ; preds = %29
  %33 = load i32, ptr %13, align 4, !tbaa !5
  %34 = load i32, ptr %13, align 4, !tbaa !5
  %35 = add i32 %34, 1
  %36 = udiv i32 %35, 2
  %37 = call i32 @libxsmm_compute_equalized_blocking(i32 noundef %33, i32 noundef %36, ptr noundef %15, ptr noundef %16, ptr noundef %17, ptr noundef %18)
  %38 = load i32, ptr %15, align 4, !tbaa !5
  %39 = load i32, ptr %9, align 4, !tbaa !5
  %40 = mul i32 %38, %39
  %41 = load ptr, ptr %10, align 8, !tbaa !9
  store i32 %40, ptr %41, align 4, !tbaa !5
  br label %45

42:                                               ; preds = %29
  %43 = load i32, ptr %7, align 4, !tbaa !5
  %44 = load ptr, ptr %10, align 8, !tbaa !9
  store i32 %43, ptr %44, align 4, !tbaa !5
  br label %45

45:                                               ; preds = %42, %32
  br label %73

46:                                               ; preds = %6
  %47 = load i32, ptr %13, align 4, !tbaa !5
  %48 = icmp ugt i32 %47, 16
  br i1 %48, label %49, label %56

49:                                               ; preds = %46
  %50 = load i32, ptr %13, align 4, !tbaa !5
  %51 = load i32, ptr %14, align 4, !tbaa !5
  %52 = sub i32 %50, %51
  %53 = load i32, ptr %9, align 4, !tbaa !5
  %54 = mul i32 %52, %53
  %55 = load ptr, ptr %10, align 8, !tbaa !9
  store i32 %54, ptr %55, align 4, !tbaa !5
  br label %72

56:                                               ; preds = %46
  %57 = load i32, ptr %12, align 4, !tbaa !5
  %58 = load i32, ptr %9, align 4, !tbaa !5
  %59 = mul i32 %57, %58
  %60 = load i32, ptr %7, align 4, !tbaa !5
  %61 = icmp uge i32 %59, %60
  br i1 %61, label %62, label %65

62:                                               ; preds = %56
  %63 = load i32, ptr %7, align 4, !tbaa !5
  %64 = load ptr, ptr %10, align 8, !tbaa !9
  store i32 %63, ptr %64, align 4, !tbaa !5
  br label %71

65:                                               ; preds = %56
  %66 = load i32, ptr %13, align 4, !tbaa !5
  %67 = sub i32 %66, 1
  %68 = load i32, ptr %9, align 4, !tbaa !5
  %69 = mul i32 %67, %68
  %70 = load ptr, ptr %10, align 8, !tbaa !9
  store i32 %69, ptr %70, align 4, !tbaa !5
  br label %71

71:                                               ; preds = %65, %62
  br label %72

72:                                               ; preds = %71, %49
  br label %73

73:                                               ; preds = %72, %45
  %74 = load i32, ptr %8, align 4, !tbaa !5
  %75 = load ptr, ptr %11, align 8, !tbaa !9
  store i32 %74, ptr %75, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #3
  ret void
}

declare i32 @libxsmm_compute_equalized_blocking(i32 noundef, i32 noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef) #2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { "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 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !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"

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

; 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
define dso_local void @libxsmm_generator_configure_M_N_blocking(i32 noundef %0, i32 noundef %1, i32 noundef %2, ptr nocapture noundef writeonly %3, ptr nocapture noundef writeonly %4, i32 noundef %5) local_unnamed_addr #1 {
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = add i32 %0, -1
  %12 = add i32 %11, %2
  %13 = udiv i32 %12, %2
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %7) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %8) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %9) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %10) #3
  %14 = urem i32 %0, %2
  %15 = icmp eq i32 %14, 0
  br i1 %15, label %16, label %24

16:                                               ; preds = %6
  %17 = icmp ugt i32 %13, 32
  br i1 %17, label %18, label %34

18:                                               ; preds = %16
  %19 = add i32 %13, 1
  %20 = lshr i32 %19, 1
  %21 = call i32 @libxsmm_compute_equalized_blocking(i32 noundef %13, i32 noundef %20, ptr noundef nonnull %7, ptr noundef nonnull %8, ptr noundef nonnull %9, ptr noundef nonnull %10) #3
  %22 = load i32, ptr %7, align 4, !tbaa !5
  %23 = mul i32 %22, %2
  br label %34

24:                                               ; preds = %6
  %25 = icmp ugt i32 %13, 16
  br i1 %25, label %26, label %29

26:                                               ; preds = %24
  %27 = add i32 %13, -8
  %28 = mul i32 %27, %2
  br label %34

29:                                               ; preds = %24
  %30 = mul i32 %5, %2
  %.not = icmp ult i32 %30, %0
  br i1 %.not, label %31, label %34

31:                                               ; preds = %29
  %32 = add nsw i32 %13, -1
  %33 = mul i32 %32, %2
  br label %34

34:                                               ; preds = %29, %16, %26, %31, %18
  %.sink = phi i32 [ %28, %26 ], [ %33, %31 ], [ %23, %18 ], [ %0, %16 ], [ %0, %29 ]
  store i32 %.sink, ptr %3, align 4, !tbaa !5
  store i32 %1, ptr %4, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %10) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %9) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %8) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %7) #3
  ret void
}

declare i32 @libxsmm_compute_equalized_blocking(i32 noundef, i32 noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #2

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { "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: GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass