; LLVM IR from libxsmm/libxsmm :: src (generator_mateltwise)

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

@__func__.libxsmm_generator_mateltwise_kernel = external hidden unnamed_addr constant [36 x i8], align 1
@.str = external hidden unnamed_addr constant [76 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_mateltwise_kernel(ptr noundef %0, ptr noundef %1) #0 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  %5 = load ptr, ptr %3, align 8, !tbaa !5
  %6 = getelementptr inbounds %struct.libxsmm_generated_code, ptr %5, i32 0, i32 6
  %7 = load i32, ptr %6, align 4, !tbaa !9
  %8 = icmp uge i32 %7, 1002
  br i1 %8, label %9, label %17

9:                                                ; preds = %2
  %10 = load ptr, ptr %3, align 8, !tbaa !5
  %11 = getelementptr inbounds %struct.libxsmm_generated_code, ptr %10, i32 0, i32 6
  %12 = load i32, ptr %11, align 4, !tbaa !9
  %13 = icmp ule i32 %12, 1999
  br i1 %13, label %14, label %17

14:                                               ; preds = %9
  %15 = load ptr, ptr %3, align 8, !tbaa !5
  %16 = load ptr, ptr %4, align 8, !tbaa !5
  call void @libxsmm_generator_mateltwise_sse_avx_avx512_kernel(ptr noundef %15, ptr noundef %16)
  br label %54

17:                                               ; preds = %9, %2
  %18 = load ptr, ptr %3, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.libxsmm_generated_code, ptr %18, i32 0, i32 6
  %20 = load i32, ptr %19, align 4, !tbaa !9
  %21 = icmp uge i32 %20, 2001
  br i1 %21, label %22, label %30

22:                                               ; preds = %17
  %23 = load ptr, ptr %3, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.libxsmm_generated_code, ptr %23, i32 0, i32 6
  %25 = load i32, ptr %24, align 4, !tbaa !9
  %26 = icmp ule i32 %25, 2999
  br i1 %26, label %27, label %30

27:                                               ; preds = %22
  %28 = load ptr, ptr %3, align 8, !tbaa !5
  %29 = load ptr, ptr %4, align 8, !tbaa !5
  call void @libxsmm_generator_mateltwise_aarch64_kernel(ptr noundef %28, ptr noundef %29)
  br label %53

30:                                               ; preds = %22, %17
  %31 = load ptr, ptr %3, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.libxsmm_generated_code, ptr %31, i32 0, i32 6
  %33 = load i32, ptr %32, align 4, !tbaa !9
  %34 = icmp uge i32 %33, 3001
  br i1 %34, label %35, label %43

35:                                               ; preds = %30
  %36 = load ptr, ptr %3, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.libxsmm_generated_code, ptr %36, i32 0, i32 6
  %38 = load i32, ptr %37, align 4, !tbaa !9
  %39 = icmp ule i32 %38, 3999
  br i1 %39, label %40, label %43

40:                                               ; preds = %35
  %41 = load ptr, ptr %3, align 8, !tbaa !5
  %42 = load ptr, ptr %4, align 8, !tbaa !5
  call void @libxsmm_generator_mateltwise_rv64_kernel(ptr noundef %41, ptr noundef %42)
  br label %52

43:                                               ; preds = %35, %30
  %44 = load ptr, ptr %3, align 8, !tbaa !5
  %45 = load i32, ptr @libxsmm_ninit, align 4, !tbaa !12
  %46 = icmp ult i32 1, %45
  br i1 %46, label %47, label %49

47:                                               ; preds = %43
  %48 = load i32, ptr @libxsmm_verbosity, align 4, !tbaa !12
  br label %50

49:                                               ; preds = %43
  br label %50

50:                                               ; preds = %49, %47
  %51 = phi i32 [ %48, %47 ], [ 1, %49 ]
  call void @libxsmm_handle_error(ptr noundef %44, i32 noundef 90005, ptr noundef @__func__.libxsmm_generator_mateltwise_kernel, ptr noundef @.str, i32 noundef 30, i32 noundef %51)
  br label %54

52:                                               ; preds = %40
  br label %53

53:                                               ; preds = %52, %27
  br label %54

54:                                               ; preds = %53, %50, %14
  ret void
}

declare void @libxsmm_generator_mateltwise_sse_avx_avx512_kernel(ptr noundef, ptr noundef) #1

declare void @libxsmm_generator_mateltwise_aarch64_kernel(ptr noundef, ptr noundef) #1

declare void @libxsmm_generator_mateltwise_rv64_kernel(ptr noundef, ptr noundef) #1

declare void @libxsmm_handle_error(ptr noundef, i32 noundef, ptr noundef, ptr noundef, i32 noundef, i32 noundef) #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" }

!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 = !{!10, !11, i64 28}
!10 = !{!"libxsmm_generated_code", !6, i64 0, !11, i64 8, !11, i64 12, !11, i64 16, !11, i64 20, !11, i64 24, !11, i64 28}
!11 = !{!"int", !7, i64 0}
!12 = !{!11, !11, 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"

@__func__.libxsmm_generator_mateltwise_kernel = external hidden unnamed_addr constant [36 x i8], align 1
@.str = external hidden unnamed_addr constant [76 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_mateltwise_kernel(ptr noundef %0, ptr noundef %1) local_unnamed_addr #0 {
  %3 = getelementptr inbounds i8, ptr %0, i64 28
  %4 = load i32, ptr %3, align 4, !tbaa !5
  %5 = add i32 %4, -1002
  %or.cond = icmp ult i32 %5, 998
  br i1 %or.cond, label %6, label %7

6:                                                ; preds = %2
  tail call void @libxsmm_generator_mateltwise_sse_avx_avx512_kernel(ptr noundef nonnull %0, ptr noundef %1) #2
  br label %18

7:                                                ; preds = %2
  %8 = add i32 %4, -2001
  %or.cond15 = icmp ult i32 %8, 999
  br i1 %or.cond15, label %9, label %10

9:                                                ; preds = %7
  tail call void @libxsmm_generator_mateltwise_aarch64_kernel(ptr noundef nonnull %0, ptr noundef %1) #2
  br label %18

10:                                               ; preds = %7
  %11 = add i32 %4, -3001
  %or.cond16 = icmp ult i32 %11, 999
  br i1 %or.cond16, label %12, label %13

12:                                               ; preds = %10
  tail call void @libxsmm_generator_mateltwise_rv64_kernel(ptr noundef nonnull %0, ptr noundef %1) #2
  br label %18

13:                                               ; preds = %10
  %14 = load i32, ptr @libxsmm_ninit, align 4, !tbaa !11
  %15 = icmp ugt i32 %14, 1
  %16 = load i32, ptr @libxsmm_verbosity, align 4
  %17 = select i1 %15, i32 %16, i32 1
  tail call void @libxsmm_handle_error(ptr noundef nonnull %0, i32 noundef 90005, ptr noundef nonnull @__func__.libxsmm_generator_mateltwise_kernel, ptr noundef nonnull @.str, i32 noundef 30, i32 noundef %17) #2
  br label %18

18:                                               ; preds = %9, %12, %13, %6
  ret void
}

declare void @libxsmm_generator_mateltwise_sse_avx_avx512_kernel(ptr noundef, ptr noundef) local_unnamed_addr #1

declare void @libxsmm_generator_mateltwise_aarch64_kernel(ptr noundef, ptr noundef) local_unnamed_addr #1

declare void @libxsmm_generator_mateltwise_rv64_kernel(ptr noundef, ptr noundef) local_unnamed_addr #1

declare void @libxsmm_handle_error(ptr noundef, i32 noundef, ptr noundef, ptr noundef, i32 noundef, 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, !10, i64 28}
!6 = !{!"libxsmm_generated_code", !7, i64 0, !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20, !10, i64 24, !10, i64 28}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!10, !10, i64 0}


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