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

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

@stderr = external global ptr, align 8
@.str.1 = external hidden unnamed_addr constant [86 x i8], align 1
@libxsmm_ninit = external global i32, align 4
@libxsmm_verbosity = external global i32, align 4
@.str.93 = external hidden unnamed_addr constant [76 x i8], align 1
@.str.95 = external hidden unnamed_addr constant [68 x i8], align 1
@__func__.libxsmm_aarch64_instruction_sme_mova = external hidden unnamed_addr constant [37 x i8], align 1

; Function Attrs: nounwind
declare i32 @fprintf(ptr noundef, ptr noundef, ...) #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.start.p0(i64 immarg, ptr nocapture) #2

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

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

25:                                               ; preds = %5
  %26 = load ptr, ptr @stderr, align 8, !tbaa !5
  %27 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %26, ptr noundef @.str.95) #4
  %28 = load ptr, ptr %6, align 8, !tbaa !5
  %29 = load i32, ptr @libxsmm_ninit, align 4, !tbaa !9
  %30 = icmp ult i32 1, %29
  br i1 %30, label %31, label %33

31:                                               ; preds = %25
  %32 = load i32, ptr @libxsmm_verbosity, align 4, !tbaa !9
  br label %34

33:                                               ; preds = %25
  br label %34

34:                                               ; preds = %33, %31
  %35 = phi i32 [ %32, %31 ], [ 1, %33 ]
  call void @libxsmm_handle_error(ptr noundef %28, i32 noundef 90000, ptr noundef @__func__.libxsmm_aarch64_instruction_sme_mova, ptr noundef @.str.1, i32 noundef 2311, i32 noundef %35)
  store i32 1, ptr %13, align 4
  br label %129

36:                                               ; preds = %5
  %37 = load i32, ptr %7, align 4, !tbaa !9
  switch i32 %37, label %39 [
    i32 -1064958976, label %38
    i32 -1065090048, label %38
    i32 -1064926208, label %38
  ]

38:                                               ; preds = %36, %36, %36
  br label %51

39:                                               ; preds = %36
  %40 = load ptr, ptr @stderr, align 8, !tbaa !5
  %41 = load i32, ptr %7, align 4, !tbaa !9
  %42 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %40, ptr noundef @.str.93, i32 noundef %41) #4
  %43 = load ptr, ptr %6, align 8, !tbaa !5
  %44 = load i32, ptr @libxsmm_ninit, align 4, !tbaa !9
  %45 = icmp ult i32 1, %44
  br i1 %45, label %46, label %48

46:                                               ; preds = %39
  %47 = load i32, ptr @libxsmm_verbosity, align 4, !tbaa !9
  br label %49

48:                                               ; preds = %39
  br label %49

49:                                               ; preds = %48, %46
  %50 = phi i32 [ %47, %46 ], [ 1, %48 ]
  call void @libxsmm_handle_error(ptr noundef %43, i32 noundef 90000, ptr noundef @__func__.libxsmm_aarch64_instruction_sme_mova, ptr noundef @.str.1, i32 noundef 2321, i32 noundef %50)
  store i32 1, ptr %13, align 4
  br label %129

51:                                               ; preds = %38
  %52 = load ptr, ptr %6, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct.libxsmm_generated_code, ptr %52, i32 0, i32 1
  %54 = load i32, ptr %53, align 8, !tbaa !15
  %55 = load ptr, ptr %6, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct.libxsmm_generated_code, ptr %55, i32 0, i32 2
  %57 = load i32, ptr %56, align 4, !tbaa !11
  %58 = sub i32 %54, %57
  %59 = icmp ult i32 %58, 4
  br i1 %59, label %60, label %69

60:                                               ; preds = %51
  %61 = load ptr, ptr %6, align 8, !tbaa !5
  %62 = load i32, ptr @libxsmm_ninit, align 4, !tbaa !9
  %63 = icmp ult i32 1, %62
  br i1 %63, label %64, label %66

64:                                               ; preds = %60
  %65 = load i32, ptr @libxsmm_verbosity, align 4, !tbaa !9
  br label %67

66:                                               ; preds = %60
  br label %67

67:                                               ; preds = %66, %64
  %68 = phi i32 [ %65, %64 ], [ 1, %66 ]
  call void @libxsmm_handle_error(ptr noundef %61, i32 noundef 90002, ptr noundef @__func__.libxsmm_aarch64_instruction_sme_mova, ptr noundef @.str.1, i32 noundef 2326, i32 noundef %68)
  store i32 1, ptr %13, align 4
  br label %129

69:                                               ; preds = %51
  %70 = load i32, ptr %7, align 4, !tbaa !9
  %71 = load ptr, ptr %12, align 8, !tbaa !5
  %72 = load i32, ptr %11, align 4, !tbaa !9
  %73 = zext i32 %72 to i64
  %74 = getelementptr inbounds i32, ptr %71, i64 %73
  store i32 %70, ptr %74, align 4, !tbaa !9
  %75 = load i32, ptr %9, align 4, !tbaa !9
  %76 = and i32 3, %75
  %77 = shl i32 %76, 13
  %78 = load ptr, ptr %12, align 8, !tbaa !5
  %79 = load i32, ptr %11, align 4, !tbaa !9
  %80 = zext i32 %79 to i64
  %81 = getelementptr inbounds i32, ptr %78, i64 %80
  %82 = load i32, ptr %81, align 4, !tbaa !9
  %83 = or i32 %82, %77
  store i32 %83, ptr %81, align 4, !tbaa !9
  %84 = load i32, ptr %7, align 4, !tbaa !9
  %85 = and i32 %84, 393216
  %86 = icmp eq i32 %85, 393216
  br i1 %86, label %87, label %106

87:                                               ; preds = %69
  %88 = load i32, ptr %8, align 4, !tbaa !9
  %89 = and i32 3, %88
  %90 = shl i32 %89, 5
  %91 = load ptr, ptr %12, align 8, !tbaa !5
  %92 = load i32, ptr %11, align 4, !tbaa !9
  %93 = zext i32 %92 to i64
  %94 = getelementptr inbounds i32, ptr %91, i64 %93
  %95 = load i32, ptr %94, align 4, !tbaa !9
  %96 = or i32 %95, %90
  store i32 %96, ptr %94, align 4, !tbaa !9
  %97 = load i32, ptr %10, align 4, !tbaa !9
  %98 = and i32 7, %97
  %99 = shl i32 %98, 2
  %100 = load ptr, ptr %12, align 8, !tbaa !5
  %101 = load i32, ptr %11, align 4, !tbaa !9
  %102 = zext i32 %101 to i64
  %103 = getelementptr inbounds i32, ptr %100, i64 %102
  %104 = load i32, ptr %103, align 4, !tbaa !9
  %105 = or i32 %104, %99
  store i32 %105, ptr %103, align 4, !tbaa !9
  br label %124

106:                                              ; preds = %69
  %107 = load i32, ptr %8, align 4, !tbaa !9
  %108 = and i32 3, %107
  %109 = load ptr, ptr %12, align 8, !tbaa !5
  %110 = load i32, ptr %11, align 4, !tbaa !9
  %111 = zext i32 %110 to i64
  %112 = getelementptr inbounds i32, ptr %109, i64 %111
  %113 = load i32, ptr %112, align 4, !tbaa !9
  %114 = or i32 %113, %108
  store i32 %114, ptr %112, align 4, !tbaa !9
  %115 = load i32, ptr %10, align 4, !tbaa !9
  %116 = and i32 7, %115
  %117 = shl i32 %116, 7
  %118 = load ptr, ptr %12, align 8, !tbaa !5
  %119 = load i32, ptr %11, align 4, !tbaa !9
  %120 = zext i32 %119 to i64
  %121 = getelementptr inbounds i32, ptr %118, i64 %120
  %122 = load i32, ptr %121, align 4, !tbaa !9
  %123 = or i32 %122, %117
  store i32 %123, ptr %121, align 4, !tbaa !9
  br label %124

124:                                              ; preds = %106, %87
  %125 = load ptr, ptr %6, align 8, !tbaa !5
  %126 = getelementptr inbounds %struct.libxsmm_generated_code, ptr %125, i32 0, i32 2
  %127 = load i32, ptr %126, align 4, !tbaa !11
  %128 = add i32 %127, 4
  store i32 %128, ptr %126, align 4, !tbaa !11
  store i32 1, ptr %13, align 4
  br label %129

129:                                              ; preds = %124, %67, %49, %34
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #4
  ret void
}

attributes #0 = { nounwind "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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { 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 #4 = { 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 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !10, i64 12}
!12 = !{!"libxsmm_generated_code", !6, i64 0, !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20, !10, i64 24, !10, i64 28}
!13 = !{!12, !6, i64 0}
!14 = !{!12, !10, i64 28}
!15 = !{!12, !10, i64 8}


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

@stderr = external local_unnamed_addr global ptr, align 8
@.str.1 = external hidden unnamed_addr constant [86 x i8], align 1
@libxsmm_ninit = external local_unnamed_addr global i32, align 4
@libxsmm_verbosity = external local_unnamed_addr global i32, align 4
@.str.93 = external hidden unnamed_addr constant [76 x i8], align 1
@.str.95 = external hidden unnamed_addr constant [68 x i8], align 1
@__func__.libxsmm_aarch64_instruction_sme_mova = external hidden unnamed_addr constant [37 x i8], align 1

; Function Attrs: nofree nounwind
declare noundef i32 @fprintf(ptr nocapture noundef, ptr nocapture noundef readonly, ...) local_unnamed_addr #0

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

; Function Attrs: nounwind uwtable
define dso_local void @libxsmm_aarch64_instruction_sme_mova(ptr noundef %0, i32 noundef %1, i32 noundef %2, i32 noundef %3, i32 noundef %4) local_unnamed_addr #2 {
  %6 = getelementptr inbounds i8, ptr %0, i64 12
  %7 = load i32, ptr %6, align 4, !tbaa !5
  %8 = lshr i32 %7, 2
  %9 = load ptr, ptr %0, align 8, !tbaa !11
  %10 = getelementptr inbounds i8, ptr %0, i64 28
  %11 = load i32, ptr %10, align 4, !tbaa !12
  %.not = icmp eq i32 %11, 2501
  br i1 %.not, label %19, label %12

12:                                               ; preds = %5
  %13 = load ptr, ptr @stderr, align 8, !tbaa !13
  %14 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %13, ptr noundef nonnull @.str.95) #3
  %15 = load i32, ptr @libxsmm_ninit, align 4, !tbaa !14
  %16 = icmp ugt i32 %15, 1
  %17 = load i32, ptr @libxsmm_verbosity, align 4
  %18 = select i1 %16, i32 %17, i32 1
  tail call void @libxsmm_handle_error(ptr noundef nonnull %0, i32 noundef 90000, ptr noundef nonnull @__func__.libxsmm_aarch64_instruction_sme_mova, ptr noundef nonnull @.str.1, i32 noundef 2311, i32 noundef %18) #4
  br label %53

19:                                               ; preds = %5
  switch i32 %1, label %20 [
    i32 -1064958976, label %27
    i32 -1065090048, label %27
    i32 -1064926208, label %27
  ]

20:                                               ; preds = %19
  %21 = load ptr, ptr @stderr, align 8, !tbaa !13
  %22 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %21, ptr noundef nonnull @.str.93, i32 noundef %1) #3
  %23 = load i32, ptr @libxsmm_ninit, align 4, !tbaa !14
  %24 = icmp ugt i32 %23, 1
  %25 = load i32, ptr @libxsmm_verbosity, align 4
  %26 = select i1 %24, i32 %25, i32 1
  tail call void @libxsmm_handle_error(ptr noundef nonnull %0, i32 noundef 90000, ptr noundef nonnull @__func__.libxsmm_aarch64_instruction_sme_mova, ptr noundef nonnull @.str.1, i32 noundef 2321, i32 noundef %26) #4
  br label %53

27:                                               ; preds = %19, %19, %19
  %28 = getelementptr inbounds i8, ptr %0, i64 8
  %29 = load i32, ptr %28, align 8, !tbaa !15
  %30 = sub i32 %29, %7
  %31 = icmp ult i32 %30, 4
  br i1 %31, label %32, label %37

32:                                               ; preds = %27
  %33 = load i32, ptr @libxsmm_ninit, align 4, !tbaa !14
  %34 = icmp ugt i32 %33, 1
  %35 = load i32, ptr @libxsmm_verbosity, align 4
  %36 = select i1 %34, i32 %35, i32 1
  tail call void @libxsmm_handle_error(ptr noundef nonnull %0, i32 noundef 90002, ptr noundef nonnull @__func__.libxsmm_aarch64_instruction_sme_mova, ptr noundef nonnull @.str.1, i32 noundef 2326, i32 noundef %36) #4
  br label %53

37:                                               ; preds = %27
  %38 = zext nneg i32 %8 to i64
  %39 = getelementptr inbounds i32, ptr %9, i64 %38
  %40 = shl i32 %3, 13
  %41 = and i32 %40, 24576
  %42 = or i32 %41, %1
  %43 = and i32 %1, 393216
  %44 = icmp eq i32 %43, 393216
  %45 = and i32 %2, 3
  %46 = shl i32 %2, 5
  %47 = and i32 %46, 96
  %.sink = select i1 %44, i32 2, i32 7
  %.sink31 = select i1 %44, i32 28, i32 896
  %.sink29 = select i1 %44, i32 %47, i32 %45
  %48 = shl i32 %4, %.sink
  %49 = and i32 %48, %.sink31
  %50 = or disjoint i32 %49, %.sink29
  %storemerge = or i32 %50, %42
  store i32 %storemerge, ptr %39, align 4, !tbaa !14
  %51 = load i32, ptr %6, align 4, !tbaa !5
  %52 = add i32 %51, 4
  store i32 %52, ptr %6, align 4, !tbaa !5
  br label %53

53:                                               ; preds = %37, %32, %20, %12
  ret void
}

attributes #0 = { nofree nounwind "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 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 = { cold nounwind }
attributes #4 = { 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 12}
!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 = !{!6, !7, i64 0}
!12 = !{!6, !10, i64 28}
!13 = !{!7, !7, i64 0}
!14 = !{!10, !10, i64 0}
!15 = !{!6, !10, i64 8}


; Effective O3 passes: DSEPass,EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass