; 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 }
%struct.libxsmm_meqn_unary_op = type { i32, i32, i32, i32 }
%struct.libxsmm_meqn_binary_op = type { i32, i32, i32, i32, i32, i32 }
%struct.libxsmm_meqn_ternary_op = type { i32, i32, i32, i32, i32, i32 }

; Function Attrs: nounwind uwtable
define dso_local void @libxsmm_meqn_tree_contains_opcode(ptr noundef %0, i32 noundef %1, i32 noundef %2, i32 noundef %3, ptr noundef %4) #0 {
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca ptr, align 8
  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 ptr %4, ptr %10, align 8, !tbaa !5
  %11 = load ptr, ptr %6, align 8, !tbaa !5
  %12 = getelementptr inbounds %struct.libxsmm_meqn_elem, ptr %11, i32 0, i32 4
  %13 = load i32, ptr %12, align 8, !tbaa !11
  %14 = icmp eq i32 %13, 8
  br i1 %14, label %15, label %16

15:                                               ; preds = %5
  br label %106

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

21:                                               ; preds = %16
  %22 = load ptr, ptr %6, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.libxsmm_meqn_elem, ptr %22, i32 0, i32 5
  %24 = getelementptr inbounds %struct.libxsmm_meqn_unary_op, ptr %23, i32 0, i32 0
  %25 = load i32, ptr %24, align 4, !tbaa !11
  %26 = load i32, ptr %7, align 4, !tbaa !9
  %27 = icmp eq i32 %25, %26
  br i1 %27, label %28, label %30

28:                                               ; preds = %21
  %29 = load ptr, ptr %10, align 8, !tbaa !5
  store i32 1, ptr %29, align 4, !tbaa !9
  br label %30

30:                                               ; preds = %28, %21
  %31 = load ptr, ptr %6, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.libxsmm_meqn_elem, ptr %31, i32 0, i32 0
  %33 = load ptr, ptr %32, align 8, !tbaa !11
  %34 = load i32, ptr %7, align 4, !tbaa !9
  %35 = load i32, ptr %8, align 4, !tbaa !9
  %36 = load i32, ptr %9, align 4, !tbaa !9
  %37 = load ptr, ptr %10, align 8, !tbaa !5
  call void @libxsmm_meqn_tree_contains_opcode(ptr noundef %33, i32 noundef %34, i32 noundef %35, i32 noundef %36, ptr noundef %37)
  br label %105

38:                                               ; preds = %16
  %39 = load ptr, ptr %6, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.libxsmm_meqn_elem, ptr %39, i32 0, i32 4
  %41 = load i32, ptr %40, align 8, !tbaa !11
  %42 = icmp eq i32 %41, 2
  br i1 %42, label %43, label %67

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

50:                                               ; preds = %43
  %51 = load ptr, ptr %10, align 8, !tbaa !5
  store i32 1, ptr %51, align 4, !tbaa !9
  br label %52

52:                                               ; preds = %50, %43
  %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 !11
  %56 = load i32, ptr %7, align 4, !tbaa !9
  %57 = load i32, ptr %8, align 4, !tbaa !9
  %58 = load i32, ptr %9, align 4, !tbaa !9
  %59 = load ptr, ptr %10, align 8, !tbaa !5
  call void @libxsmm_meqn_tree_contains_opcode(ptr noundef %55, i32 noundef %56, i32 noundef %57, i32 noundef %58, ptr noundef %59)
  %60 = load ptr, ptr %6, align 8, !tbaa !5
  %61 = getelementptr inbounds %struct.libxsmm_meqn_elem, ptr %60, i32 0, i32 1
  %62 = load ptr, ptr %61, align 8, !tbaa !11
  %63 = load i32, ptr %7, align 4, !tbaa !9
  %64 = load i32, ptr %8, align 4, !tbaa !9
  %65 = load i32, ptr %9, align 4, !tbaa !9
  %66 = load ptr, ptr %10, align 8, !tbaa !5
  call void @libxsmm_meqn_tree_contains_opcode(ptr noundef %62, i32 noundef %63, i32 noundef %64, i32 noundef %65, ptr noundef %66)
  br label %104

67:                                               ; preds = %38
  %68 = load ptr, ptr %6, align 8, !tbaa !5
  %69 = getelementptr inbounds %struct.libxsmm_meqn_elem, ptr %68, i32 0, i32 4
  %70 = load i32, ptr %69, align 8, !tbaa !11
  %71 = icmp eq i32 %70, 4
  br i1 %71, label %72, label %103

72:                                               ; preds = %67
  %73 = load ptr, ptr %6, align 8, !tbaa !5
  %74 = getelementptr inbounds %struct.libxsmm_meqn_elem, ptr %73, i32 0, i32 5
  %75 = getelementptr inbounds %struct.libxsmm_meqn_ternary_op, ptr %74, i32 0, i32 0
  %76 = load i32, ptr %75, align 4, !tbaa !11
  %77 = load i32, ptr %9, align 4, !tbaa !9
  %78 = icmp eq i32 %76, %77
  br i1 %78, label %79, label %81

79:                                               ; preds = %72
  %80 = load ptr, ptr %10, align 8, !tbaa !5
  store i32 1, ptr %80, align 4, !tbaa !9
  br label %81

81:                                               ; preds = %79, %72
  %82 = load ptr, ptr %6, align 8, !tbaa !5
  %83 = getelementptr inbounds %struct.libxsmm_meqn_elem, ptr %82, i32 0, i32 0
  %84 = load ptr, ptr %83, align 8, !tbaa !11
  %85 = load i32, ptr %7, align 4, !tbaa !9
  %86 = load i32, ptr %8, align 4, !tbaa !9
  %87 = load i32, ptr %9, align 4, !tbaa !9
  %88 = load ptr, ptr %10, align 8, !tbaa !5
  call void @libxsmm_meqn_tree_contains_opcode(ptr noundef %84, i32 noundef %85, i32 noundef %86, i32 noundef %87, ptr noundef %88)
  %89 = load ptr, ptr %6, align 8, !tbaa !5
  %90 = getelementptr inbounds %struct.libxsmm_meqn_elem, ptr %89, i32 0, i32 1
  %91 = load ptr, ptr %90, align 8, !tbaa !11
  %92 = load i32, ptr %7, align 4, !tbaa !9
  %93 = load i32, ptr %8, align 4, !tbaa !9
  %94 = load i32, ptr %9, align 4, !tbaa !9
  %95 = load ptr, ptr %10, align 8, !tbaa !5
  call void @libxsmm_meqn_tree_contains_opcode(ptr noundef %91, i32 noundef %92, i32 noundef %93, i32 noundef %94, ptr noundef %95)
  %96 = load ptr, ptr %6, align 8, !tbaa !5
  %97 = getelementptr inbounds %struct.libxsmm_meqn_elem, ptr %96, i32 0, i32 2
  %98 = load ptr, ptr %97, align 8, !tbaa !11
  %99 = load i32, ptr %7, align 4, !tbaa !9
  %100 = load i32, ptr %8, align 4, !tbaa !9
  %101 = load i32, ptr %9, align 4, !tbaa !9
  %102 = load ptr, ptr %10, align 8, !tbaa !5
  call void @libxsmm_meqn_tree_contains_opcode(ptr noundef %98, i32 noundef %99, i32 noundef %100, i32 noundef %101, ptr noundef %102)
  br label %103

103:                                              ; preds = %81, %67
  br label %104

104:                                              ; preds = %103, %52
  br label %105

105:                                              ; preds = %104, %30
  br label %106

106:                                              ; preds = %105, %15
  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_contains_opcode(ptr nocapture noundef readonly %0, i32 noundef %1, i32 noundef %2, i32 noundef %3, ptr noundef %4) local_unnamed_addr #0 {
  br label %tailrecurse

tailrecurse:                                      ; preds = %tailrecurse.backedge, %5
  %.tr = phi ptr [ %0, %5 ], [ %.tr.be, %tailrecurse.backedge ]
  %6 = getelementptr inbounds i8, ptr %.tr, i64 32
  %7 = load i32, ptr %6, align 8, !tbaa !5
  switch i32 %7, label %31 [
    i32 4, label %21
    i32 1, label %8
    i32 2, label %13
  ]

8:                                                ; preds = %tailrecurse
  %9 = getelementptr inbounds i8, ptr %.tr, i64 36
  %10 = load i32, ptr %9, align 4, !tbaa !5
  %11 = icmp eq i32 %10, %1
  br i1 %11, label %12, label %tailrecurse.backedge

12:                                               ; preds = %8
  store i32 1, ptr %4, align 4, !tbaa !8
  br label %tailrecurse.backedge

tailrecurse.backedge:                             ; preds = %8, %12, %18, %26
  %.tr.be.in = phi ptr [ %20, %18 ], [ %30, %26 ], [ %.tr, %12 ], [ %.tr, %8 ]
  %.tr.be = load ptr, ptr %.tr.be.in, align 8, !tbaa !5
  br label %tailrecurse

13:                                               ; preds = %tailrecurse
  %14 = getelementptr inbounds i8, ptr %.tr, i64 36
  %15 = load i32, ptr %14, align 4, !tbaa !5
  %16 = icmp eq i32 %15, %2
  br i1 %16, label %17, label %18

17:                                               ; preds = %13
  store i32 1, ptr %4, align 4, !tbaa !8
  br label %18

18:                                               ; preds = %17, %13
  %19 = load ptr, ptr %.tr, align 8, !tbaa !5
  tail call void @libxsmm_meqn_tree_contains_opcode(ptr noundef %19, i32 noundef %1, i32 noundef %2, i32 noundef %3, ptr noundef %4)
  %20 = getelementptr inbounds i8, ptr %.tr, i64 8
  br label %tailrecurse.backedge

21:                                               ; preds = %tailrecurse
  %22 = getelementptr inbounds i8, ptr %.tr, i64 36
  %23 = load i32, ptr %22, align 4, !tbaa !5
  %24 = icmp eq i32 %23, %3
  br i1 %24, label %25, label %26

25:                                               ; preds = %21
  store i32 1, ptr %4, align 4, !tbaa !8
  br label %26

26:                                               ; preds = %25, %21
  %27 = load ptr, ptr %.tr, align 8, !tbaa !5
  tail call void @libxsmm_meqn_tree_contains_opcode(ptr noundef %27, i32 noundef %1, i32 noundef %2, i32 noundef %3, ptr noundef %4)
  %28 = getelementptr inbounds i8, ptr %.tr, i64 8
  %29 = load ptr, ptr %28, align 8, !tbaa !5
  tail call void @libxsmm_meqn_tree_contains_opcode(ptr noundef %29, i32 noundef %1, i32 noundef %2, i32 noundef %3, ptr noundef %4)
  %30 = getelementptr inbounds i8, ptr %.tr, i64 16
  br label %tailrecurse.backedge

31:                                               ; preds = %tailrecurse
  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