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

%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(ptr noundef, ptr noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef) #0

; Function Attrs: nounwind uwtable
define dso_local void @libxsmm_mark_reserved_zmms(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 %27

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 2
  %17 = load i32, ptr %16, align 4, !tbaa !9
  %18 = load ptr, ptr %6, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.libxsmm_meqn_elem, ptr %18, i32 0, i32 5
  %20 = getelementptr inbounds %struct.libxsmm_meqn_unary_op, ptr %19, i32 0, i32 0
  %21 = load i32, ptr %20, align 4, !tbaa !9
  call void @libxsmm_adjust_required_zmms(ptr noundef %12, ptr noundef %13, i32 noundef %17, i32 noundef %21, i32 noundef 0, i32 noundef 0)
  %22 = load ptr, ptr %4, align 8, !tbaa !5
  %23 = load ptr, ptr %5, align 8, !tbaa !5
  %24 = load ptr, ptr %6, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.libxsmm_meqn_elem, ptr %24, i32 0, i32 0
  %26 = load ptr, ptr %25, align 8, !tbaa !9
  call void @libxsmm_mark_reserved_zmms(ptr noundef %22, ptr noundef %23, ptr noundef %26)
  br label %76

27:                                               ; preds = %3
  %28 = load ptr, ptr %6, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.libxsmm_meqn_elem, ptr %28, i32 0, i32 4
  %30 = load i32, ptr %29, align 8, !tbaa !9
  %31 = icmp eq i32 %30, 2
  br i1 %31, label %32, label %53

32:                                               ; preds = %27
  %33 = load ptr, ptr %4, align 8, !tbaa !5
  %34 = load ptr, ptr %5, align 8, !tbaa !5
  %35 = load ptr, ptr %6, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.libxsmm_meqn_elem, ptr %35, i32 0, i32 5
  %37 = getelementptr inbounds %struct.libxsmm_meqn_binary_op, ptr %36, i32 0, i32 2
  %38 = load i32, ptr %37, align 4, !tbaa !9
  %39 = load ptr, ptr %6, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.libxsmm_meqn_elem, ptr %39, i32 0, i32 5
  %41 = getelementptr inbounds %struct.libxsmm_meqn_binary_op, ptr %40, i32 0, i32 0
  %42 = load i32, ptr %41, align 4, !tbaa !9
  call void @libxsmm_adjust_required_zmms(ptr noundef %33, ptr noundef %34, i32 noundef %38, i32 noundef 0, i32 noundef %42, i32 noundef 1)
  %43 = load ptr, ptr %4, align 8, !tbaa !5
  %44 = load ptr, ptr %5, align 8, !tbaa !5
  %45 = load ptr, ptr %6, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.libxsmm_meqn_elem, ptr %45, i32 0, i32 0
  %47 = load ptr, ptr %46, align 8, !tbaa !9
  call void @libxsmm_mark_reserved_zmms(ptr noundef %43, ptr noundef %44, ptr noundef %47)
  %48 = load ptr, ptr %4, align 8, !tbaa !5
  %49 = load ptr, ptr %5, align 8, !tbaa !5
  %50 = load ptr, ptr %6, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.libxsmm_meqn_elem, ptr %50, i32 0, i32 1
  %52 = load ptr, ptr %51, align 8, !tbaa !9
  call void @libxsmm_mark_reserved_zmms(ptr noundef %48, ptr noundef %49, ptr noundef %52)
  br label %75

53:                                               ; preds = %27
  %54 = load ptr, ptr %6, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct.libxsmm_meqn_elem, ptr %54, i32 0, i32 4
  %56 = load i32, ptr %55, align 8, !tbaa !9
  %57 = icmp eq i32 %56, 4
  br i1 %57, label %58, label %74

58:                                               ; preds = %53
  %59 = load ptr, ptr %4, align 8, !tbaa !5
  %60 = load ptr, ptr %5, align 8, !tbaa !5
  %61 = load ptr, ptr %6, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct.libxsmm_meqn_elem, ptr %61, i32 0, i32 0
  %63 = load ptr, ptr %62, align 8, !tbaa !9
  call void @libxsmm_mark_reserved_zmms(ptr noundef %59, ptr noundef %60, ptr noundef %63)
  %64 = load ptr, ptr %4, align 8, !tbaa !5
  %65 = load ptr, ptr %5, align 8, !tbaa !5
  %66 = load ptr, ptr %6, align 8, !tbaa !5
  %67 = getelementptr inbounds %struct.libxsmm_meqn_elem, ptr %66, i32 0, i32 1
  %68 = load ptr, ptr %67, align 8, !tbaa !9
  call void @libxsmm_mark_reserved_zmms(ptr noundef %64, ptr noundef %65, ptr noundef %68)
  %69 = load ptr, ptr %4, align 8, !tbaa !5
  %70 = load ptr, ptr %5, align 8, !tbaa !5
  %71 = load ptr, ptr %6, align 8, !tbaa !5
  %72 = getelementptr inbounds %struct.libxsmm_meqn_elem, ptr %71, i32 0, i32 2
  %73 = load ptr, ptr %72, align 8, !tbaa !9
  call void @libxsmm_mark_reserved_zmms(ptr noundef %69, ptr noundef %70, ptr noundef %73)
  br label %74

74:                                               ; preds = %58, %53
  br label %75

75:                                               ; preds = %74, %32
  br label %76

76:                                               ; preds = %75, %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(ptr noundef, ptr noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #0

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

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

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

tailrecurse.backedge:                             ; preds = %6, %11, %18
  %.tr30.be.in = phi ptr [ %.tr30, %6 ], [ %17, %11 ], [ %22, %18 ]
  %.tr30.be = load ptr, ptr %.tr30.be.in, align 8, !tbaa !5
  br label %tailrecurse

11:                                               ; preds = %tailrecurse
  %12 = getelementptr inbounds i8, ptr %.tr30, i64 36
  %13 = getelementptr inbounds i8, ptr %.tr30, i64 44
  %14 = load i32, ptr %13, align 4, !tbaa !5
  %15 = load i32, ptr %12, align 4, !tbaa !5
  tail call void @libxsmm_adjust_required_zmms(ptr noundef %0, ptr noundef %1, i32 noundef %14, i32 noundef 0, i32 noundef %15, i32 noundef 1)
  %16 = load ptr, ptr %.tr30, align 8, !tbaa !5
  tail call void @libxsmm_mark_reserved_zmms(ptr noundef %0, ptr noundef %1, ptr noundef %16)
  %17 = getelementptr inbounds i8, ptr %.tr30, i64 8
  br label %tailrecurse.backedge

18:                                               ; preds = %tailrecurse
  %19 = load ptr, ptr %.tr30, align 8, !tbaa !5
  tail call void @libxsmm_mark_reserved_zmms(ptr noundef %0, ptr noundef %1, ptr noundef %19)
  %20 = getelementptr inbounds i8, ptr %.tr30, i64 8
  %21 = load ptr, ptr %20, align 8, !tbaa !5
  tail call void @libxsmm_mark_reserved_zmms(ptr noundef %0, ptr noundef %1, ptr noundef %21)
  %22 = getelementptr inbounds i8, ptr %.tr30, i64 16
  br label %tailrecurse.backedge

23:                                               ; 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