; 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_ternary_op = type { i32, i32, i32, i32, i32, i32 }

; Function Attrs: nounwind uwtable
define dso_local void @libxsmm_meqn_exec_plan_configure_ternary_tmp(ptr noundef %0) #0 {
  %2 = alloca ptr, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  %3 = load ptr, ptr %2, align 8, !tbaa !5
  %4 = getelementptr inbounds %struct.libxsmm_meqn_elem, ptr %3, i32 0, i32 2
  %5 = load ptr, ptr %4, align 8, !tbaa !9
  %6 = getelementptr inbounds %struct.libxsmm_meqn_elem, ptr %5, i32 0, i32 8
  %7 = getelementptr inbounds %struct.libxsmm_meqn_tmp_info, ptr %6, i32 0, i32 1
  %8 = load i32, ptr %7, align 4, !tbaa !9
  %9 = load ptr, ptr %2, align 8, !tbaa !5
  %10 = getelementptr inbounds %struct.libxsmm_meqn_elem, ptr %9, i32 0, i32 8
  %11 = getelementptr inbounds %struct.libxsmm_meqn_tmp_info, ptr %10, i32 0, i32 1
  store i32 %8, ptr %11, align 4, !tbaa !9
  %12 = load ptr, ptr %2, align 8, !tbaa !5
  %13 = getelementptr inbounds %struct.libxsmm_meqn_elem, ptr %12, i32 0, i32 2
  %14 = load ptr, ptr %13, align 8, !tbaa !9
  %15 = getelementptr inbounds %struct.libxsmm_meqn_elem, ptr %14, i32 0, i32 8
  %16 = getelementptr inbounds %struct.libxsmm_meqn_tmp_info, ptr %15, i32 0, i32 2
  %17 = load i32, ptr %16, align 8, !tbaa !9
  %18 = load ptr, ptr %2, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.libxsmm_meqn_elem, ptr %18, i32 0, i32 8
  %20 = getelementptr inbounds %struct.libxsmm_meqn_tmp_info, ptr %19, i32 0, i32 2
  store i32 %17, ptr %20, align 8, !tbaa !9
  %21 = load ptr, ptr %2, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.libxsmm_meqn_elem, ptr %21, i32 0, i32 2
  %23 = load ptr, ptr %22, align 8, !tbaa !9
  %24 = getelementptr inbounds %struct.libxsmm_meqn_elem, ptr %23, i32 0, i32 8
  %25 = getelementptr inbounds %struct.libxsmm_meqn_tmp_info, ptr %24, i32 0, i32 1
  %26 = load i32, ptr %25, align 4, !tbaa !9
  %27 = load ptr, ptr %2, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.libxsmm_meqn_elem, ptr %27, i32 0, i32 8
  %29 = getelementptr inbounds %struct.libxsmm_meqn_tmp_info, ptr %28, i32 0, i32 3
  store i32 %26, ptr %29, align 4, !tbaa !9
  %30 = load ptr, ptr %2, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.libxsmm_meqn_elem, ptr %30, i32 0, i32 5
  %32 = getelementptr inbounds %struct.libxsmm_meqn_ternary_op, ptr %31, i32 0, i32 4
  %33 = load i32, ptr %32, align 4, !tbaa !9
  %34 = icmp eq i32 %33, 1
  br i1 %34, label %41, label %35

35:                                               ; preds = %1
  %36 = load ptr, ptr %2, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.libxsmm_meqn_elem, ptr %36, i32 0, i32 5
  %38 = getelementptr inbounds %struct.libxsmm_meqn_ternary_op, ptr %37, i32 0, i32 5
  %39 = load i32, ptr %38, align 4, !tbaa !9
  %40 = icmp eq i32 %39, 1
  br i1 %40, label %41, label %69

41:                                               ; preds = %35, %1
  %42 = load ptr, ptr %2, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct.libxsmm_meqn_elem, ptr %42, i32 0, i32 2
  %44 = load ptr, ptr %43, align 8, !tbaa !9
  %45 = getelementptr inbounds %struct.libxsmm_meqn_elem, ptr %44, i32 0, i32 8
  %46 = getelementptr inbounds %struct.libxsmm_meqn_tmp_info, ptr %45, i32 0, i32 1
  %47 = load i32, ptr %46, align 4, !tbaa !9
  %48 = load ptr, ptr %2, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.libxsmm_meqn_elem, ptr %48, i32 0, i32 8
  %50 = getelementptr inbounds %struct.libxsmm_meqn_tmp_info, ptr %49, i32 0, i32 1
  store i32 %47, ptr %50, align 4, !tbaa !9
  %51 = load ptr, ptr %2, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.libxsmm_meqn_elem, ptr %51, i32 0, i32 2
  %53 = load ptr, ptr %52, align 8, !tbaa !9
  %54 = getelementptr inbounds %struct.libxsmm_meqn_elem, ptr %53, i32 0, i32 8
  %55 = getelementptr inbounds %struct.libxsmm_meqn_tmp_info, ptr %54, i32 0, i32 2
  %56 = load i32, ptr %55, align 8, !tbaa !9
  %57 = load ptr, ptr %2, align 8, !tbaa !5
  %58 = getelementptr inbounds %struct.libxsmm_meqn_elem, ptr %57, i32 0, i32 8
  %59 = getelementptr inbounds %struct.libxsmm_meqn_tmp_info, ptr %58, i32 0, i32 2
  store i32 %56, ptr %59, align 8, !tbaa !9
  %60 = load ptr, ptr %2, align 8, !tbaa !5
  %61 = getelementptr inbounds %struct.libxsmm_meqn_elem, ptr %60, i32 0, i32 2
  %62 = load ptr, ptr %61, align 8, !tbaa !9
  %63 = getelementptr inbounds %struct.libxsmm_meqn_elem, ptr %62, i32 0, i32 8
  %64 = getelementptr inbounds %struct.libxsmm_meqn_tmp_info, ptr %63, i32 0, i32 3
  %65 = load i32, ptr %64, align 4, !tbaa !9
  %66 = load ptr, ptr %2, align 8, !tbaa !5
  %67 = getelementptr inbounds %struct.libxsmm_meqn_elem, ptr %66, i32 0, i32 8
  %68 = getelementptr inbounds %struct.libxsmm_meqn_tmp_info, ptr %67, i32 0, i32 3
  store i32 %65, ptr %68, align 4, !tbaa !9
  br label %69

69:                                               ; preds = %41, %35
  %70 = load ptr, ptr %2, align 8, !tbaa !5
  %71 = getelementptr inbounds %struct.libxsmm_meqn_elem, ptr %70, i32 0, i32 5
  %72 = getelementptr inbounds %struct.libxsmm_meqn_ternary_op, ptr %71, i32 0, i32 2
  %73 = load i32, ptr %72, align 4, !tbaa !9
  %74 = load ptr, ptr %2, align 8, !tbaa !5
  %75 = getelementptr inbounds %struct.libxsmm_meqn_elem, ptr %74, i32 0, i32 8
  %76 = getelementptr inbounds %struct.libxsmm_meqn_tmp_info, ptr %75, i32 0, i32 4
  store i32 %73, ptr %76, align 8, !tbaa !9
  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: mustprogress nofree norecurse nosync nounwind willreturn memory(read, argmem: readwrite, inaccessiblemem: none) uwtable
define dso_local void @libxsmm_meqn_exec_plan_configure_ternary_tmp(ptr nocapture noundef %0) local_unnamed_addr #0 {
  %2 = getelementptr inbounds i8, ptr %0, i64 16
  %3 = load ptr, ptr %2, align 8, !tbaa !5
  %4 = getelementptr inbounds i8, ptr %3, i64 92
  %5 = load i32, ptr %4, align 4, !tbaa !5
  %6 = getelementptr inbounds i8, ptr %0, i64 92
  store i32 %5, ptr %6, align 4, !tbaa !5
  %7 = getelementptr inbounds i8, ptr %3, i64 96
  %8 = load i32, ptr %7, align 8, !tbaa !5
  %9 = getelementptr inbounds i8, ptr %0, i64 96
  store i32 %8, ptr %9, align 8, !tbaa !5
  %10 = load i32, ptr %4, align 4, !tbaa !5
  %11 = getelementptr inbounds i8, ptr %0, i64 100
  store i32 %10, ptr %11, align 4, !tbaa !5
  %12 = getelementptr inbounds i8, ptr %0, i64 52
  %13 = load i32, ptr %12, align 4, !tbaa !5
  %14 = icmp eq i32 %13, 1
  br i1 %14, label %19, label %15

15:                                               ; preds = %1
  %16 = getelementptr inbounds i8, ptr %0, i64 56
  %17 = load i32, ptr %16, align 4, !tbaa !5
  %18 = icmp eq i32 %17, 1
  br i1 %18, label %19, label %23

19:                                               ; preds = %15, %1
  store i32 %10, ptr %6, align 4, !tbaa !5
  %20 = load i32, ptr %7, align 8, !tbaa !5
  store i32 %20, ptr %9, align 8, !tbaa !5
  %21 = getelementptr inbounds i8, ptr %3, i64 100
  %22 = load i32, ptr %21, align 4, !tbaa !5
  store i32 %22, ptr %11, align 4, !tbaa !5
  br label %23

23:                                               ; preds = %19, %15
  %24 = getelementptr inbounds i8, ptr %0, i64 44
  %25 = load i32, ptr %24, align 4, !tbaa !5
  %26 = getelementptr inbounds i8, ptr %0, i64 104
  store i32 %25, ptr %26, align 8, !tbaa !5
  ret void
}

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


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass