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

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

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

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

10:                                               ; preds = %2
  store ptr null, ptr %5, align 8, !tbaa !5
  br label %101

11:                                               ; preds = %2
  %12 = load ptr, ptr %3, align 8, !tbaa !5
  %13 = getelementptr inbounds %struct.libxsmm_meqn_elem, ptr %12, i32 0, i32 4
  %14 = load i32, ptr %13, align 8, !tbaa !11
  %15 = icmp eq i32 %14, 1
  br i1 %15, label %16, label %31

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

22:                                               ; preds = %16
  %23 = load ptr, ptr %3, align 8, !tbaa !5
  store ptr %23, ptr %5, align 8, !tbaa !5
  br label %30

24:                                               ; preds = %16
  %25 = load ptr, ptr %3, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.libxsmm_meqn_elem, ptr %25, i32 0, i32 0
  %27 = load ptr, ptr %26, align 8, !tbaa !11
  %28 = load i32, ptr %4, align 4, !tbaa !9
  %29 = call ptr @libxsmm_generator_matequation_find_op_at_timestamp(ptr noundef %27, i32 noundef %28)
  store ptr %29, ptr %5, align 8, !tbaa !5
  br label %30

30:                                               ; preds = %24, %22
  br label %100

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

36:                                               ; preds = %31
  %37 = load ptr, ptr %3, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.libxsmm_meqn_elem, ptr %37, i32 0, i32 7
  %39 = load i32, ptr %38, align 4, !tbaa !11
  %40 = load i32, ptr %4, align 4, !tbaa !9
  %41 = icmp eq i32 %39, %40
  br i1 %41, label %42, label %44

42:                                               ; preds = %36
  %43 = load ptr, ptr %3, align 8, !tbaa !5
  store ptr %43, ptr %5, align 8, !tbaa !5
  br label %59

44:                                               ; preds = %36
  %45 = load ptr, ptr %3, 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 !11
  %48 = load i32, ptr %4, align 4, !tbaa !9
  %49 = call ptr @libxsmm_generator_matequation_find_op_at_timestamp(ptr noundef %47, i32 noundef %48)
  store ptr %49, ptr %5, align 8, !tbaa !5
  %50 = load ptr, ptr %5, align 8, !tbaa !5
  %51 = icmp eq ptr %50, null
  br i1 %51, label %52, label %58

52:                                               ; preds = %44
  %53 = load ptr, ptr %3, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.libxsmm_meqn_elem, ptr %53, i32 0, i32 1
  %55 = load ptr, ptr %54, align 8, !tbaa !11
  %56 = load i32, ptr %4, align 4, !tbaa !9
  %57 = call ptr @libxsmm_generator_matequation_find_op_at_timestamp(ptr noundef %55, i32 noundef %56)
  store ptr %57, ptr %5, align 8, !tbaa !5
  br label %58

58:                                               ; preds = %52, %44
  br label %59

59:                                               ; preds = %58, %42
  br label %99

60:                                               ; preds = %31
  %61 = load ptr, ptr %3, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct.libxsmm_meqn_elem, ptr %61, i32 0, i32 4
  %63 = load i32, ptr %62, align 8, !tbaa !11
  %64 = icmp eq i32 %63, 4
  br i1 %64, label %65, label %98

65:                                               ; preds = %60
  %66 = load ptr, ptr %3, align 8, !tbaa !5
  %67 = getelementptr inbounds %struct.libxsmm_meqn_elem, ptr %66, i32 0, i32 7
  %68 = load i32, ptr %67, align 4, !tbaa !11
  %69 = load i32, ptr %4, align 4, !tbaa !9
  %70 = icmp eq i32 %68, %69
  br i1 %70, label %71, label %73

71:                                               ; preds = %65
  %72 = load ptr, ptr %3, align 8, !tbaa !5
  store ptr %72, ptr %5, align 8, !tbaa !5
  br label %97

73:                                               ; preds = %65
  %74 = load ptr, ptr %3, align 8, !tbaa !5
  %75 = getelementptr inbounds %struct.libxsmm_meqn_elem, ptr %74, i32 0, i32 0
  %76 = load ptr, ptr %75, align 8, !tbaa !11
  %77 = load i32, ptr %4, align 4, !tbaa !9
  %78 = call ptr @libxsmm_generator_matequation_find_op_at_timestamp(ptr noundef %76, i32 noundef %77)
  store ptr %78, ptr %5, align 8, !tbaa !5
  %79 = load ptr, ptr %5, align 8, !tbaa !5
  %80 = icmp eq ptr %79, null
  br i1 %80, label %81, label %96

81:                                               ; preds = %73
  %82 = load ptr, ptr %3, align 8, !tbaa !5
  %83 = getelementptr inbounds %struct.libxsmm_meqn_elem, ptr %82, i32 0, i32 1
  %84 = load ptr, ptr %83, align 8, !tbaa !11
  %85 = load i32, ptr %4, align 4, !tbaa !9
  %86 = call ptr @libxsmm_generator_matequation_find_op_at_timestamp(ptr noundef %84, i32 noundef %85)
  store ptr %86, ptr %5, align 8, !tbaa !5
  %87 = load ptr, ptr %5, align 8, !tbaa !5
  %88 = icmp eq ptr %87, null
  br i1 %88, label %89, label %95

89:                                               ; preds = %81
  %90 = load ptr, ptr %3, align 8, !tbaa !5
  %91 = getelementptr inbounds %struct.libxsmm_meqn_elem, ptr %90, i32 0, i32 2
  %92 = load ptr, ptr %91, align 8, !tbaa !11
  %93 = load i32, ptr %4, align 4, !tbaa !9
  %94 = call ptr @libxsmm_generator_matequation_find_op_at_timestamp(ptr noundef %92, i32 noundef %93)
  store ptr %94, ptr %5, align 8, !tbaa !5
  br label %95

95:                                               ; preds = %89, %81
  br label %96

96:                                               ; preds = %95, %73
  br label %97

97:                                               ; preds = %96, %71
  br label %98

98:                                               ; preds = %97, %60
  br label %99

99:                                               ; preds = %98, %59
  br label %100

100:                                              ; preds = %99, %30
  br label %101

101:                                              ; preds = %100, %10
  %102 = load ptr, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #2
  ret ptr %102
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { 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 = !{!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(read, inaccessiblemem: none) uwtable
define dso_local ptr @libxsmm_generator_matequation_find_op_at_timestamp(ptr noundef readonly %0, i32 noundef %1) local_unnamed_addr #0 {
  br label %tailrecurse

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

5:                                                ; preds = %tailrecurse
  %6 = getelementptr inbounds i8, ptr %.tr, i64 84
  %7 = load i32, ptr %6, align 4, !tbaa !5
  %8 = icmp eq i32 %7, %1
  br i1 %8, label %34, label %tailrecurse.backedge

tailrecurse.backedge:                             ; preds = %5, %17, %32
  %.tr.be.in = phi ptr [ %18, %17 ], [ %33, %32 ], [ %.tr, %5 ]
  %.tr.be = load ptr, ptr %.tr.be.in, align 8, !tbaa !5
  br label %tailrecurse

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

13:                                               ; preds = %9
  %14 = load ptr, ptr %.tr, align 8, !tbaa !5
  %15 = tail call ptr @libxsmm_generator_matequation_find_op_at_timestamp(ptr noundef %14, i32 noundef %1)
  %16 = icmp eq ptr %15, null
  br i1 %16, label %17, label %34

17:                                               ; preds = %13
  %18 = getelementptr inbounds i8, ptr %.tr, i64 8
  br label %tailrecurse.backedge

19:                                               ; preds = %tailrecurse
  %20 = getelementptr inbounds i8, ptr %.tr, i64 84
  %21 = load i32, ptr %20, align 4, !tbaa !5
  %22 = icmp eq i32 %21, %1
  br i1 %22, label %34, label %23

23:                                               ; preds = %19
  %24 = load ptr, ptr %.tr, align 8, !tbaa !5
  %25 = tail call ptr @libxsmm_generator_matequation_find_op_at_timestamp(ptr noundef %24, i32 noundef %1)
  %26 = icmp eq ptr %25, null
  br i1 %26, label %27, label %34

27:                                               ; preds = %23
  %28 = getelementptr inbounds i8, ptr %.tr, i64 8
  %29 = load ptr, ptr %28, align 8, !tbaa !5
  %30 = tail call ptr @libxsmm_generator_matequation_find_op_at_timestamp(ptr noundef %29, i32 noundef %1)
  %31 = icmp eq ptr %30, null
  br i1 %31, label %32, label %34

32:                                               ; preds = %27
  %33 = getelementptr inbounds i8, ptr %.tr, i64 16
  br label %tailrecurse.backedge

34:                                               ; preds = %19, %tailrecurse, %9, %5, %23, %27, %13
  %.0 = phi ptr [ %15, %13 ], [ %30, %27 ], [ %25, %23 ], [ %.tr, %5 ], [ %.tr, %9 ], [ null, %tailrecurse ], [ %.tr, %19 ]
  ret ptr %.0
}

attributes #0 = { nofree nosync nounwind memory(read, 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"}


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