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

; 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_matequation_kernel = external hidden unnamed_addr constant [37 x i8], align 1
@.str = external hidden unnamed_addr constant [77 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_matequation_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 %32

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 %32

14:                                               ; preds = %9
  %15 = load ptr, ptr %3, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct.libxsmm_generated_code, ptr %15, i32 0, i32 6
  %17 = load i32, ptr %16, align 4, !tbaa !9
  %18 = icmp uge i32 %17, 1006
  br i1 %18, label %19, label %22

19:                                               ; preds = %14
  %20 = load ptr, ptr %3, align 8, !tbaa !5
  %21 = load ptr, ptr %4, align 8, !tbaa !5
  call void @libxsmm_generator_matequation_avx_avx512_kernel(ptr noundef %20, ptr noundef %21)
  br label %31

22:                                               ; preds = %14
  %23 = load ptr, ptr %3, align 8, !tbaa !5
  %24 = load i32, ptr @libxsmm_ninit, align 4, !tbaa !12
  %25 = icmp ult i32 1, %24
  br i1 %25, label %26, label %28

26:                                               ; preds = %22
  %27 = load i32, ptr @libxsmm_verbosity, align 4, !tbaa !12
  br label %29

28:                                               ; preds = %22
  br label %29

29:                                               ; preds = %28, %26
  %30 = phi i32 [ %27, %26 ], [ 1, %28 ]
  call void @libxsmm_handle_error(ptr noundef %23, i32 noundef 90005, ptr noundef @__func__.libxsmm_generator_matequation_kernel, ptr noundef @.str, i32 noundef 25, i32 noundef %30)
  br label %90

31:                                               ; preds = %19
  br label %90

32:                                               ; preds = %9, %2
  %33 = load ptr, ptr %3, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.libxsmm_generated_code, ptr %33, i32 0, i32 6
  %35 = load i32, ptr %34, align 4, !tbaa !9
  %36 = icmp eq i32 %35, 2001
  br i1 %36, label %77, label %37

37:                                               ; preds = %32
  %38 = load ptr, ptr %3, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.libxsmm_generated_code, ptr %38, i32 0, i32 6
  %40 = load i32, ptr %39, align 4, !tbaa !9
  %41 = icmp eq i32 %40, 2002
  br i1 %41, label %77, label %42

42:                                               ; preds = %37
  %43 = load ptr, ptr %3, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.libxsmm_generated_code, ptr %43, i32 0, i32 6
  %45 = load i32, ptr %44, align 4, !tbaa !9
  %46 = icmp eq i32 %45, 2101
  br i1 %46, label %77, label %47

47:                                               ; preds = %42
  %48 = load ptr, ptr %3, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.libxsmm_generated_code, ptr %48, i32 0, i32 6
  %50 = load i32, ptr %49, align 4, !tbaa !9
  %51 = icmp eq i32 %50, 2201
  br i1 %51, label %77, label %52

52:                                               ; preds = %47
  %53 = load ptr, ptr %3, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.libxsmm_generated_code, ptr %53, i32 0, i32 6
  %55 = load i32, ptr %54, align 4, !tbaa !9
  %56 = icmp eq i32 %55, 2202
  br i1 %56, label %77, label %57

57:                                               ; preds = %52
  %58 = load ptr, ptr %3, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.libxsmm_generated_code, ptr %58, i32 0, i32 6
  %60 = load i32, ptr %59, align 4, !tbaa !9
  %61 = icmp eq i32 %60, 2301
  br i1 %61, label %77, label %62

62:                                               ; preds = %57
  %63 = load ptr, ptr %3, align 8, !tbaa !5
  %64 = getelementptr inbounds %struct.libxsmm_generated_code, ptr %63, i32 0, i32 6
  %65 = load i32, ptr %64, align 4, !tbaa !9
  %66 = icmp eq i32 %65, 2302
  br i1 %66, label %77, label %67

67:                                               ; preds = %62
  %68 = load ptr, ptr %3, align 8, !tbaa !5
  %69 = getelementptr inbounds %struct.libxsmm_generated_code, ptr %68, i32 0, i32 6
  %70 = load i32, ptr %69, align 4, !tbaa !9
  %71 = icmp eq i32 %70, 2401
  br i1 %71, label %77, label %72

72:                                               ; preds = %67
  %73 = load ptr, ptr %3, align 8, !tbaa !5
  %74 = getelementptr inbounds %struct.libxsmm_generated_code, ptr %73, i32 0, i32 6
  %75 = load i32, ptr %74, align 4, !tbaa !9
  %76 = icmp eq i32 %75, 2402
  br i1 %76, label %77, label %80

77:                                               ; preds = %72, %67, %62, %57, %52, %47, %42, %37, %32
  %78 = load ptr, ptr %3, align 8, !tbaa !5
  %79 = load ptr, ptr %4, align 8, !tbaa !5
  call void @libxsmm_generator_matequation_aarch64_kernel(ptr noundef %78, ptr noundef %79)
  br label %89

80:                                               ; preds = %72
  %81 = load ptr, ptr %3, align 8, !tbaa !5
  %82 = load i32, ptr @libxsmm_ninit, align 4, !tbaa !12
  %83 = icmp ult i32 1, %82
  br i1 %83, label %84, label %86

84:                                               ; preds = %80
  %85 = load i32, ptr @libxsmm_verbosity, align 4, !tbaa !12
  br label %87

86:                                               ; preds = %80
  br label %87

87:                                               ; preds = %86, %84
  %88 = phi i32 [ %85, %84 ], [ 1, %86 ]
  call void @libxsmm_handle_error(ptr noundef %81, i32 noundef 90005, ptr noundef @__func__.libxsmm_generator_matequation_kernel, ptr noundef @.str, i32 noundef 40, i32 noundef %88)
  br label %90

89:                                               ; preds = %77
  br label %90

90:                                               ; preds = %89, %87, %31, %29
  ret void
}

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

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

declare void @libxsmm_generator_matequation_aarch64_kernel(ptr noundef, ptr 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_matequation_kernel = external hidden unnamed_addr constant [37 x i8], align 1
@.str = external hidden unnamed_addr constant [77 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_matequation_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 %14

6:                                                ; preds = %2
  %7 = icmp ugt i32 %4, 1005
  br i1 %7, label %8, label %9

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

9:                                                ; preds = %6
  %10 = load i32, ptr @libxsmm_ninit, align 4, !tbaa !11
  %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 nonnull %0, i32 noundef 90005, ptr noundef nonnull @__func__.libxsmm_generator_matequation_kernel, ptr noundef nonnull @.str, i32 noundef 25, i32 noundef %13) #2
  br label %21

14:                                               ; preds = %2
  switch i32 %4, label %16 [
    i32 2001, label %15
    i32 2002, label %15
    i32 2101, label %15
    i32 2201, label %15
    i32 2202, label %15
    i32 2301, label %15
    i32 2302, label %15
    i32 2401, label %15
    i32 2402, label %15
  ]

15:                                               ; preds = %14, %14, %14, %14, %14, %14, %14, %14, %14
  tail call void @libxsmm_generator_matequation_aarch64_kernel(ptr noundef nonnull %0, ptr noundef %1) #2
  br label %21

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

21:                                               ; preds = %15, %16, %8, %9
  ret void
}

declare void @libxsmm_generator_matequation_avx_avx512_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

declare void @libxsmm_generator_matequation_aarch64_kernel(ptr noundef, ptr 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