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

; 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_meqn_elem = type { ptr, ptr, ptr, ptr, i32, %union.libxsmm_meqn_info, i32, i32, %struct.libxsmm_meqn_tmp_info, i32, i32, i32, %union.libxsmm_meqn_fusion_info }
%union.libxsmm_meqn_info = type { %struct.libxsmm_meqn_arg }
%struct.libxsmm_meqn_arg = type { i32, i32, i32, i32, i32, i32, i32, %struct.libxsmm_matrix_arg_attributes }
%struct.libxsmm_matrix_arg_attributes = type { i32, i32, i32, i32 }
%struct.libxsmm_meqn_tmp_info = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32 }
%union.libxsmm_meqn_fusion_info = type { %struct.libxsmm_meqn_xgemm_fusion_info }
%struct.libxsmm_meqn_xgemm_fusion_info = type { i32, i32, i32, i32, i32 }
%struct.libxsmm_meqn_unary_op = type { i32, i32, i32, i32 }
%struct.libxsmm_meqn_binary_op = type { i32, i32, i32, i32, i32, i32 }

; Function Attrs: nounwind uwtable
declare dso_local void @libxsmm_adjust_required_zmms_aarch64(ptr noundef, ptr noundef, i32 noundef, i32 noundef, i32 noundef) #0

; Function Attrs: nounwind uwtable
define dso_local void @libxsmm_mark_reserved_zmms_aarch64(ptr noundef %0, ptr noundef %1, ptr noundef %2) #0 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store ptr %2, ptr %6, align 8, !tbaa !5
  %7 = load ptr, ptr %6, align 8, !tbaa !5
  %8 = getelementptr inbounds %struct.libxsmm_meqn_elem, ptr %7, i32 0, i32 4
  %9 = load i32, ptr %8, align 8, !tbaa !9
  %10 = icmp eq i32 %9, 1
  br i1 %10, label %11, label %23

11:                                               ; preds = %3
  %12 = load ptr, ptr %4, align 8, !tbaa !5
  %13 = load ptr, ptr %5, align 8, !tbaa !5
  %14 = load ptr, ptr %6, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct.libxsmm_meqn_elem, ptr %14, i32 0, i32 5
  %16 = getelementptr inbounds %struct.libxsmm_meqn_unary_op, ptr %15, i32 0, i32 0
  %17 = load i32, ptr %16, align 4, !tbaa !9
  call void @libxsmm_adjust_required_zmms_aarch64(ptr noundef %12, ptr noundef %13, i32 noundef %17, i32 noundef 0, i32 noundef 0)
  %18 = load ptr, ptr %4, align 8, !tbaa !5
  %19 = load ptr, ptr %5, align 8, !tbaa !5
  %20 = load ptr, ptr %6, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.libxsmm_meqn_elem, ptr %20, i32 0, i32 0
  %22 = load ptr, ptr %21, align 8, !tbaa !9
  call void @libxsmm_mark_reserved_zmms_aarch64(ptr noundef %18, ptr noundef %19, ptr noundef %22)
  br label %68

23:                                               ; preds = %3
  %24 = load ptr, ptr %6, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.libxsmm_meqn_elem, ptr %24, i32 0, i32 4
  %26 = load i32, ptr %25, align 8, !tbaa !9
  %27 = icmp eq i32 %26, 2
  br i1 %27, label %28, label %45

28:                                               ; preds = %23
  %29 = load ptr, ptr %4, align 8, !tbaa !5
  %30 = load ptr, ptr %5, align 8, !tbaa !5
  %31 = load ptr, ptr %6, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.libxsmm_meqn_elem, ptr %31, i32 0, i32 5
  %33 = getelementptr inbounds %struct.libxsmm_meqn_binary_op, ptr %32, i32 0, i32 0
  %34 = load i32, ptr %33, align 4, !tbaa !9
  call void @libxsmm_adjust_required_zmms_aarch64(ptr noundef %29, ptr noundef %30, i32 noundef 0, i32 noundef %34, i32 noundef 1)
  %35 = load ptr, ptr %4, align 8, !tbaa !5
  %36 = load ptr, ptr %5, align 8, !tbaa !5
  %37 = load ptr, ptr %6, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.libxsmm_meqn_elem, ptr %37, i32 0, i32 0
  %39 = load ptr, ptr %38, align 8, !tbaa !9
  call void @libxsmm_mark_reserved_zmms_aarch64(ptr noundef %35, ptr noundef %36, ptr noundef %39)
  %40 = load ptr, ptr %4, align 8, !tbaa !5
  %41 = load ptr, ptr %5, align 8, !tbaa !5
  %42 = load ptr, ptr %6, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct.libxsmm_meqn_elem, ptr %42, i32 0, i32 1
  %44 = load ptr, ptr %43, align 8, !tbaa !9
  call void @libxsmm_mark_reserved_zmms_aarch64(ptr noundef %40, ptr noundef %41, ptr noundef %44)
  br label %67

45:                                               ; preds = %23
  %46 = load ptr, ptr %6, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct.libxsmm_meqn_elem, ptr %46, i32 0, i32 4
  %48 = load i32, ptr %47, align 8, !tbaa !9
  %49 = icmp eq i32 %48, 4
  br i1 %49, label %50, label %66

50:                                               ; preds = %45
  %51 = load ptr, ptr %4, align 8, !tbaa !5
  %52 = load ptr, ptr %5, align 8, !tbaa !5
  %53 = load ptr, ptr %6, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.libxsmm_meqn_elem, ptr %53, i32 0, i32 0
  %55 = load ptr, ptr %54, align 8, !tbaa !9
  call void @libxsmm_mark_reserved_zmms_aarch64(ptr noundef %51, ptr noundef %52, ptr noundef %55)
  %56 = load ptr, ptr %4, align 8, !tbaa !5
  %57 = load ptr, ptr %5, align 8, !tbaa !5
  %58 = load ptr, ptr %6, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.libxsmm_meqn_elem, ptr %58, i32 0, i32 1
  %60 = load ptr, ptr %59, align 8, !tbaa !9
  call void @libxsmm_mark_reserved_zmms_aarch64(ptr noundef %56, ptr noundef %57, ptr noundef %60)
  %61 = load ptr, ptr %4, align 8, !tbaa !5
  %62 = load ptr, ptr %5, align 8, !tbaa !5
  %63 = load ptr, ptr %6, align 8, !tbaa !5
  %64 = getelementptr inbounds %struct.libxsmm_meqn_elem, ptr %63, i32 0, i32 2
  %65 = load ptr, ptr %64, align 8, !tbaa !9
  call void @libxsmm_mark_reserved_zmms_aarch64(ptr noundef %61, ptr noundef %62, ptr noundef %65)
  br label %66

66:                                               ; preds = %50, %45
  br label %67

67:                                               ; preds = %66, %28
  br label %68

68:                                               ; preds = %67, %11
  ret void
}

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

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


; 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: nounwind uwtable
declare dso_local void @libxsmm_adjust_required_zmms_aarch64(ptr noundef, ptr noundef, i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local void @libxsmm_mark_reserved_zmms_aarch64(ptr noundef %0, ptr noundef %1, ptr nocapture noundef readonly %2) local_unnamed_addr #0 {
  br label %tailrecurse

tailrecurse:                                      ; preds = %tailrecurse.backedge, %3
  %.tr28 = phi ptr [ %2, %3 ], [ %.tr28.be, %tailrecurse.backedge ]
  %4 = getelementptr inbounds i8, ptr %.tr28, i64 32
  %5 = load i32, ptr %4, align 8, !tbaa !5
  switch i32 %5, label %19 [
    i32 1, label %6
    i32 2, label %9
    i32 4, label %14
  ]

6:                                                ; preds = %tailrecurse
  %7 = getelementptr inbounds i8, ptr %.tr28, i64 36
  %8 = load i32, ptr %7, align 4, !tbaa !5
  tail call void @libxsmm_adjust_required_zmms_aarch64(ptr noundef %0, ptr noundef %1, i32 noundef %8, i32 noundef 0, i32 noundef 0)
  br label %tailrecurse.backedge

tailrecurse.backedge:                             ; preds = %6, %9, %14
  %.tr28.be.in = phi ptr [ %.tr28, %6 ], [ %13, %9 ], [ %18, %14 ]
  %.tr28.be = load ptr, ptr %.tr28.be.in, align 8, !tbaa !5
  br label %tailrecurse

9:                                                ; preds = %tailrecurse
  %10 = getelementptr inbounds i8, ptr %.tr28, i64 36
  %11 = load i32, ptr %10, align 4, !tbaa !5
  tail call void @libxsmm_adjust_required_zmms_aarch64(ptr noundef %0, ptr noundef %1, i32 noundef 0, i32 noundef %11, i32 noundef 1)
  %12 = load ptr, ptr %.tr28, align 8, !tbaa !5
  tail call void @libxsmm_mark_reserved_zmms_aarch64(ptr noundef %0, ptr noundef %1, ptr noundef %12)
  %13 = getelementptr inbounds i8, ptr %.tr28, i64 8
  br label %tailrecurse.backedge

14:                                               ; preds = %tailrecurse
  %15 = load ptr, ptr %.tr28, align 8, !tbaa !5
  tail call void @libxsmm_mark_reserved_zmms_aarch64(ptr noundef %0, ptr noundef %1, ptr noundef %15)
  %16 = getelementptr inbounds i8, ptr %.tr28, i64 8
  %17 = load ptr, ptr %16, align 8, !tbaa !5
  tail call void @libxsmm_mark_reserved_zmms_aarch64(ptr noundef %0, ptr noundef %1, ptr noundef %17)
  %18 = getelementptr inbounds i8, ptr %.tr28, i64 16
  br label %tailrecurse.backedge

19:                                               ; preds = %tailrecurse
  ret void
}

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

!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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C/C++ TBAA"}


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