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

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

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

13:                                               ; preds = %3
  %14 = load ptr, ptr %6, align 8, !tbaa !5
  store i32 0, ptr %14, align 4, !tbaa !9
  br label %15

15:                                               ; preds = %13, %3
  %16 = load ptr, ptr %4, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct.libxsmm_meqn_elem, ptr %16, i32 0, i32 4
  %18 = load i32, ptr %17, align 8, !tbaa !11
  %19 = icmp eq i32 %18, 8
  br i1 %19, label %20, label %21

20:                                               ; preds = %15
  br label %72

21:                                               ; preds = %15
  %22 = load ptr, ptr %4, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.libxsmm_meqn_elem, ptr %22, i32 0, i32 4
  %24 = load i32, ptr %23, align 8, !tbaa !11
  %25 = icmp eq i32 %24, 1
  br i1 %25, label %26, label %32

26:                                               ; preds = %21
  %27 = load ptr, ptr %4, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.libxsmm_meqn_elem, ptr %27, i32 0, i32 0
  %29 = load ptr, ptr %28, align 8, !tbaa !11
  %30 = load i32, ptr %5, align 4, !tbaa !9
  %31 = load ptr, ptr %6, align 8, !tbaa !5
  call void @libxsmm_meqn_tree_all_nodes_dtype(ptr noundef %29, i32 noundef %30, ptr noundef %31)
  br label %71

32:                                               ; preds = %21
  %33 = load ptr, ptr %4, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.libxsmm_meqn_elem, ptr %33, i32 0, i32 4
  %35 = load i32, ptr %34, align 8, !tbaa !11
  %36 = icmp eq i32 %35, 2
  br i1 %36, label %37, label %48

37:                                               ; preds = %32
  %38 = load ptr, ptr %4, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.libxsmm_meqn_elem, ptr %38, i32 0, i32 0
  %40 = load ptr, ptr %39, align 8, !tbaa !11
  %41 = load i32, ptr %5, align 4, !tbaa !9
  %42 = load ptr, ptr %6, align 8, !tbaa !5
  call void @libxsmm_meqn_tree_all_nodes_dtype(ptr noundef %40, i32 noundef %41, ptr noundef %42)
  %43 = load ptr, ptr %4, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.libxsmm_meqn_elem, ptr %43, i32 0, i32 1
  %45 = load ptr, ptr %44, align 8, !tbaa !11
  %46 = load i32, ptr %5, align 4, !tbaa !9
  %47 = load ptr, ptr %6, align 8, !tbaa !5
  call void @libxsmm_meqn_tree_all_nodes_dtype(ptr noundef %45, i32 noundef %46, ptr noundef %47)
  br label %70

48:                                               ; preds = %32
  %49 = load ptr, ptr %4, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.libxsmm_meqn_elem, ptr %49, i32 0, i32 4
  %51 = load i32, ptr %50, align 8, !tbaa !11
  %52 = icmp eq i32 %51, 4
  br i1 %52, label %53, label %69

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

69:                                               ; preds = %53, %48
  br label %70

70:                                               ; preds = %69, %37
  br label %71

71:                                               ; preds = %70, %26
  br label %72

72:                                               ; preds = %71, %20
  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 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!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: nofree nosync nounwind memory(readwrite, inaccessiblemem: none) uwtable
define dso_local void @libxsmm_meqn_tree_all_nodes_dtype(ptr nocapture noundef readonly %0, i32 noundef %1, ptr noundef %2) local_unnamed_addr #0 {
  br label %tailrecurse

tailrecurse:                                      ; preds = %tailrecurse.backedge, %3
  %.tr = phi ptr [ %0, %3 ], [ %.tr.be, %tailrecurse.backedge ]
  %4 = getelementptr inbounds i8, ptr %.tr, i64 104
  %5 = load i32, ptr %4, align 8, !tbaa !5
  %.not = icmp eq i32 %5, %1
  br i1 %.not, label %7, label %6

6:                                                ; preds = %tailrecurse
  store i32 0, ptr %2, align 4, !tbaa !8
  br label %7

7:                                                ; preds = %6, %tailrecurse
  %8 = getelementptr inbounds i8, ptr %.tr, i64 32
  %9 = load i32, ptr %8, align 8, !tbaa !5
  switch i32 %9, label %15 [
    i32 4, label %12
    i32 1, label %tailrecurse.backedge
    i32 2, label %tailrecurse.backedge.sink.split
  ]

tailrecurse.backedge.sink.split:                  ; preds = %7, %12
  %.tr.sink = phi ptr [ %14, %12 ], [ %.tr, %7 ]
  %.sink = phi i64 [ 16, %12 ], [ 8, %7 ]
  %10 = load ptr, ptr %.tr.sink, align 8, !tbaa !5
  tail call void @libxsmm_meqn_tree_all_nodes_dtype(ptr noundef %10, i32 noundef %1, ptr noundef %2)
  %11 = getelementptr inbounds i8, ptr %.tr, i64 %.sink
  br label %tailrecurse.backedge

tailrecurse.backedge:                             ; preds = %tailrecurse.backedge.sink.split, %7
  %.tr.be.in = phi ptr [ %.tr, %7 ], [ %11, %tailrecurse.backedge.sink.split ]
  %.tr.be = load ptr, ptr %.tr.be.in, align 8, !tbaa !5
  br label %tailrecurse

12:                                               ; preds = %7
  %13 = load ptr, ptr %.tr, align 8, !tbaa !5
  tail call void @libxsmm_meqn_tree_all_nodes_dtype(ptr noundef %13, i32 noundef %1, ptr noundef %2)
  %14 = getelementptr inbounds i8, ptr %.tr, i64 8
  br label %tailrecurse.backedge.sink.split

15:                                               ; preds = %7
  ret void
}

attributes #0 = { nofree nosync nounwind memory(readwrite, inaccessiblemem: none) 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"}
!8 = !{!9, !9, i64 0}
!9 = !{!"int", !6, i64 0}


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