; 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_matrix_eqn = type { ptr, ptr, i32, i32, i32, i32 }
%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
declare dso_local void @libxsmm_meqn_reassign_children_bcast_tmp(ptr noundef, ptr noundef) #1

; Function Attrs: nounwind uwtable
define dso_local void @libxsmm_meqn_reassign_bcast_tmp(ptr noundef %0) #1 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #2
  %4 = load ptr, ptr %2, align 8, !tbaa !5
  %5 = getelementptr inbounds %struct.libxsmm_matrix_eqn, ptr %4, i32 0, i32 0
  %6 = load ptr, ptr %5, align 8, !tbaa !9
  store ptr %6, ptr %3, align 8, !tbaa !5
  %7 = load ptr, ptr %3, 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 %16

11:                                               ; preds = %1
  %12 = load ptr, ptr %2, align 8, !tbaa !5
  %13 = load ptr, ptr %3, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct.libxsmm_meqn_elem, ptr %13, i32 0, i32 0
  %15 = load ptr, ptr %14, align 8, !tbaa !9
  call void @libxsmm_meqn_reassign_children_bcast_tmp(ptr noundef %12, ptr noundef %15)
  br label %16

16:                                               ; preds = %11, %1
  %17 = load ptr, ptr %3, 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 !9
  %20 = icmp eq i32 %19, 2
  br i1 %20, label %21, label %30

21:                                               ; preds = %16
  %22 = load ptr, ptr %2, align 8, !tbaa !5
  %23 = load ptr, ptr %3, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.libxsmm_meqn_elem, ptr %23, i32 0, i32 0
  %25 = load ptr, ptr %24, align 8, !tbaa !9
  call void @libxsmm_meqn_reassign_children_bcast_tmp(ptr noundef %22, ptr noundef %25)
  %26 = load ptr, ptr %2, align 8, !tbaa !5
  %27 = load ptr, ptr %3, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.libxsmm_meqn_elem, ptr %27, i32 0, i32 1
  %29 = load ptr, ptr %28, align 8, !tbaa !9
  call void @libxsmm_meqn_reassign_children_bcast_tmp(ptr noundef %26, ptr noundef %29)
  br label %30

30:                                               ; preds = %21, %16
  %31 = load ptr, ptr %3, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.libxsmm_meqn_elem, ptr %31, i32 0, i32 4
  %33 = load i32, ptr %32, align 8, !tbaa !9
  %34 = icmp eq i32 %33, 4
  br i1 %34, label %35, label %48

35:                                               ; preds = %30
  %36 = load ptr, ptr %2, align 8, !tbaa !5
  %37 = load ptr, ptr %3, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.libxsmm_meqn_elem, ptr %37, i32 0, i32 0
  %39 = load ptr, ptr %38, align 8, !tbaa !9
  call void @libxsmm_meqn_reassign_children_bcast_tmp(ptr noundef %36, ptr noundef %39)
  %40 = load ptr, ptr %2, align 8, !tbaa !5
  %41 = load ptr, ptr %3, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.libxsmm_meqn_elem, ptr %41, i32 0, i32 1
  %43 = load ptr, ptr %42, align 8, !tbaa !9
  call void @libxsmm_meqn_reassign_children_bcast_tmp(ptr noundef %40, ptr noundef %43)
  %44 = load ptr, ptr %2, align 8, !tbaa !5
  %45 = load ptr, ptr %3, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.libxsmm_meqn_elem, ptr %45, i32 0, i32 2
  %47 = load ptr, ptr %46, align 8, !tbaa !9
  call void @libxsmm_meqn_reassign_children_bcast_tmp(ptr noundef %44, ptr noundef %47)
  br label %48

48:                                               ; preds = %35, %30
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #2
  ret void
}

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 = !{!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_meqn_reassign_children_bcast_tmp(ptr noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local void @libxsmm_meqn_reassign_bcast_tmp(ptr noundef %0) local_unnamed_addr #0 {
  %2 = load ptr, ptr %0, align 8, !tbaa !5
  %3 = getelementptr inbounds i8, ptr %2, i64 32
  %4 = load i32, ptr %3, align 8, !tbaa !5
  %5 = icmp eq i32 %4, 1
  br i1 %5, label %6, label %8

6:                                                ; preds = %1
  %7 = load ptr, ptr %2, align 8, !tbaa !5
  tail call void @libxsmm_meqn_reassign_children_bcast_tmp(ptr noundef nonnull %0, ptr noundef %7)
  %.pr = load i32, ptr %3, align 8, !tbaa !5
  br label %8

8:                                                ; preds = %6, %1
  %9 = phi i32 [ %.pr, %6 ], [ %4, %1 ]
  %10 = icmp eq i32 %9, 2
  br i1 %10, label %11, label %15

11:                                               ; preds = %8
  %12 = load ptr, ptr %2, align 8, !tbaa !5
  tail call void @libxsmm_meqn_reassign_children_bcast_tmp(ptr noundef nonnull %0, ptr noundef %12)
  %13 = getelementptr inbounds i8, ptr %2, i64 8
  %14 = load ptr, ptr %13, align 8, !tbaa !5
  tail call void @libxsmm_meqn_reassign_children_bcast_tmp(ptr noundef nonnull %0, ptr noundef %14)
  %.pre = load i32, ptr %3, align 8, !tbaa !5
  br label %15

15:                                               ; preds = %11, %8
  %16 = phi i32 [ %.pre, %11 ], [ %9, %8 ]
  %17 = icmp eq i32 %16, 4
  br i1 %17, label %18, label %24

18:                                               ; preds = %15
  %19 = load ptr, ptr %2, align 8, !tbaa !5
  tail call void @libxsmm_meqn_reassign_children_bcast_tmp(ptr noundef nonnull %0, ptr noundef %19)
  %20 = getelementptr inbounds i8, ptr %2, i64 8
  %21 = load ptr, ptr %20, align 8, !tbaa !5
  tail call void @libxsmm_meqn_reassign_children_bcast_tmp(ptr noundef nonnull %0, ptr noundef %21)
  %22 = getelementptr inbounds i8, ptr %2, i64 16
  %23 = load ptr, ptr %22, align 8, !tbaa !5
  tail call void @libxsmm_meqn_reassign_children_bcast_tmp(ptr noundef nonnull %0, ptr noundef %23)
  br label %24

24:                                               ; preds = %18, %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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C/C++ TBAA"}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,SROAPass,TailCallElimPass