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

; 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_gemm_descriptor = type <{ i32, i32, i32, i32, i32, i32, i32, i8, [3 x i8], i8, i64, i64, i8, i32, i32, i32, i16, i16, i8, i8, i8, i8, i16, i16, i16, i16, i16, i16, i32, i32, i32, i8 }>

@.str = external hidden unnamed_addr constant [79 x i8], align 1
@libxsmm_ninit = external global i32, align 4
@libxsmm_verbosity = external global i32, align 4
@__func__.libxsmm_generator_packed_spgemm_bcsc_kernel = external hidden unnamed_addr constant [44 x i8], align 1

declare void @libxsmm_handle_error(ptr noundef, i32 noundef, ptr noundef, ptr noundef, i32 noundef, i32 noundef) #0

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

15:                                               ; preds = %5
  %16 = load ptr, ptr %7, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct.libxsmm_gemm_descriptor, ptr %16, i32 0, i32 5
  %18 = load i32, ptr %17, align 1, !tbaa !15
  %19 = icmp ugt i32 %18, 0
  br i1 %19, label %20, label %60

20:                                               ; preds = %15
  %21 = load ptr, ptr %7, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.libxsmm_gemm_descriptor, ptr %21, i32 0, i32 3
  %23 = load i32, ptr %22, align 1, !tbaa !11
  %24 = load ptr, ptr %7, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.libxsmm_gemm_descriptor, ptr %24, i32 0, i32 2
  %26 = load i32, ptr %25, align 1, !tbaa !16
  %27 = icmp ult i32 %23, %26
  br i1 %27, label %28, label %37

28:                                               ; preds = %20
  %29 = load ptr, ptr %6, align 8, !tbaa !5
  %30 = load i32, ptr @libxsmm_ninit, align 4, !tbaa !9
  %31 = icmp ult i32 1, %30
  br i1 %31, label %32, label %34

32:                                               ; preds = %28
  %33 = load i32, ptr @libxsmm_verbosity, align 4, !tbaa !9
  br label %35

34:                                               ; preds = %28
  br label %35

35:                                               ; preds = %34, %32
  %36 = phi i32 [ %33, %32 ], [ 1, %34 ]
  call void @libxsmm_handle_error(ptr noundef %29, i32 noundef 90007, ptr noundef @__func__.libxsmm_generator_packed_spgemm_bcsc_kernel, ptr noundef @.str, i32 noundef 112, i32 noundef %36)
  br label %69

37:                                               ; preds = %20
  %38 = load ptr, ptr %7, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.libxsmm_gemm_descriptor, ptr %38, i32 0, i32 5
  %40 = load i32, ptr %39, align 1, !tbaa !15
  %41 = load ptr, ptr %7, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.libxsmm_gemm_descriptor, ptr %41, i32 0, i32 1
  %43 = load i32, ptr %42, align 1, !tbaa !17
  %44 = icmp ult i32 %40, %43
  br i1 %44, label %45, label %54

45:                                               ; preds = %37
  %46 = load ptr, ptr %6, align 8, !tbaa !5
  %47 = load i32, ptr @libxsmm_ninit, align 4, !tbaa !9
  %48 = icmp ult i32 1, %47
  br i1 %48, label %49, label %51

49:                                               ; preds = %45
  %50 = load i32, ptr @libxsmm_verbosity, align 4, !tbaa !9
  br label %52

51:                                               ; preds = %45
  br label %52

52:                                               ; preds = %51, %49
  %53 = phi i32 [ %50, %49 ], [ 1, %51 ]
  call void @libxsmm_handle_error(ptr noundef %46, i32 noundef 90009, ptr noundef @__func__.libxsmm_generator_packed_spgemm_bcsc_kernel, ptr noundef @.str, i32 noundef 117, i32 noundef %53)
  br label %69

54:                                               ; preds = %37
  %55 = load ptr, ptr %6, align 8, !tbaa !5
  %56 = load ptr, ptr %7, align 8, !tbaa !5
  %57 = load i32, ptr %8, align 4, !tbaa !9
  %58 = load i32, ptr %9, align 4, !tbaa !9
  %59 = load i32, ptr %10, align 4, !tbaa !9
  call void @libxsmm_generator_packed_spgemm_bcsc_bsparse(ptr noundef %55, ptr noundef %56, i32 noundef %57, i32 noundef %58, i32 noundef %59)
  br label %69

60:                                               ; preds = %15, %5
  %61 = load ptr, ptr %6, align 8, !tbaa !5
  %62 = load i32, ptr @libxsmm_ninit, align 4, !tbaa !9
  %63 = icmp ult i32 1, %62
  br i1 %63, label %64, label %66

64:                                               ; preds = %60
  %65 = load i32, ptr @libxsmm_verbosity, align 4, !tbaa !9
  br label %67

66:                                               ; preds = %60
  br label %67

67:                                               ; preds = %66, %64
  %68 = phi i32 [ %65, %64 ], [ 1, %66 ]
  call void @libxsmm_handle_error(ptr noundef %61, i32 noundef 90010, ptr noundef @__func__.libxsmm_generator_packed_spgemm_bcsc_kernel, ptr noundef @.str, i32 noundef 123, i32 noundef %68)
  br label %69

69:                                               ; preds = %67, %54, %52, %35
  ret void
}

declare void @libxsmm_generator_packed_spgemm_bcsc_bsparse(ptr noundef, ptr noundef, i32 noundef, i32 noundef, i32 noundef) #0

attributes #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 #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" }

!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 = !{!12, !10, i64 12}
!12 = !{!"libxsmm_gemm_descriptor", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20, !10, i64 24, !7, i64 28, !7, i64 29, !7, i64 32, !13, i64 33, !13, i64 41, !7, i64 49, !10, i64 50, !10, i64 54, !10, i64 58, !14, i64 62, !14, i64 64, !7, i64 66, !7, i64 67, !7, i64 68, !7, i64 69, !14, i64 70, !14, i64 72, !14, i64 74, !14, i64 76, !14, i64 78, !14, i64 80, !10, i64 82, !10, i64 86, !10, i64 90, !7, i64 94}
!13 = !{!"long long", !7, i64 0}
!14 = !{!"short", !7, i64 0}
!15 = !{!12, !10, i64 20}
!16 = !{!12, !10, i64 8}
!17 = !{!12, !10, i64 4}


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

@.str = external hidden unnamed_addr constant [79 x i8], align 1
@libxsmm_ninit = external local_unnamed_addr global i32, align 4
@libxsmm_verbosity = external local_unnamed_addr global i32, align 4
@__func__.libxsmm_generator_packed_spgemm_bcsc_kernel = external hidden unnamed_addr constant [44 x i8], align 1

declare void @libxsmm_handle_error(ptr noundef, i32 noundef, ptr noundef, ptr noundef, i32 noundef, i32 noundef) local_unnamed_addr #0

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

8:                                                ; preds = %5
  %9 = getelementptr inbounds i8, ptr %1, i64 20
  %10 = load i32, ptr %9, align 1, !tbaa !12
  %.not14 = icmp eq i32 %10, 0
  br i1 %.not14, label %30, label %11

11:                                               ; preds = %8
  %12 = getelementptr inbounds i8, ptr %1, i64 8
  %13 = load i32, ptr %12, align 1, !tbaa !13
  %14 = icmp ult i32 %7, %13
  br i1 %14, label %15, label %20

15:                                               ; preds = %11
  %16 = load i32, ptr @libxsmm_ninit, align 4, !tbaa !14
  %17 = icmp ugt i32 %16, 1
  %18 = load i32, ptr @libxsmm_verbosity, align 4
  %19 = select i1 %17, i32 %18, i32 1
  tail call void @libxsmm_handle_error(ptr noundef %0, i32 noundef 90007, ptr noundef nonnull @__func__.libxsmm_generator_packed_spgemm_bcsc_kernel, ptr noundef nonnull @.str, i32 noundef 112, i32 noundef %19) #2
  br label %35

20:                                               ; preds = %11
  %21 = getelementptr inbounds i8, ptr %1, i64 4
  %22 = load i32, ptr %21, align 1, !tbaa !15
  %23 = icmp ult i32 %10, %22
  br i1 %23, label %24, label %29

24:                                               ; preds = %20
  %25 = load i32, ptr @libxsmm_ninit, align 4, !tbaa !14
  %26 = icmp ugt i32 %25, 1
  %27 = load i32, ptr @libxsmm_verbosity, align 4
  %28 = select i1 %26, i32 %27, i32 1
  tail call void @libxsmm_handle_error(ptr noundef %0, i32 noundef 90009, ptr noundef nonnull @__func__.libxsmm_generator_packed_spgemm_bcsc_kernel, ptr noundef nonnull @.str, i32 noundef 117, i32 noundef %28) #2
  br label %35

29:                                               ; preds = %20
  tail call void @libxsmm_generator_packed_spgemm_bcsc_bsparse(ptr noundef %0, ptr noundef nonnull %1, i32 noundef %2, i32 noundef %3, i32 noundef %4) #2
  br label %35

30:                                               ; preds = %8, %5
  %31 = load i32, ptr @libxsmm_ninit, align 4, !tbaa !14
  %32 = icmp ugt i32 %31, 1
  %33 = load i32, ptr @libxsmm_verbosity, align 4
  %34 = select i1 %32, i32 %33, i32 1
  tail call void @libxsmm_handle_error(ptr noundef %0, i32 noundef 90010, ptr noundef nonnull @__func__.libxsmm_generator_packed_spgemm_bcsc_kernel, ptr noundef nonnull @.str, i32 noundef 123, i32 noundef %34) #2
  br label %35

35:                                               ; preds = %30, %29, %24, %15
  ret void
}

declare void @libxsmm_generator_packed_spgemm_bcsc_bsparse(ptr noundef, ptr noundef, i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #0

attributes #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 #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, !7, i64 12}
!6 = !{!"libxsmm_gemm_descriptor", !7, i64 0, !7, i64 4, !7, i64 8, !7, i64 12, !7, i64 16, !7, i64 20, !7, i64 24, !8, i64 28, !8, i64 29, !8, i64 32, !10, i64 33, !10, i64 41, !8, i64 49, !7, i64 50, !7, i64 54, !7, i64 58, !11, i64 62, !11, i64 64, !8, i64 66, !8, i64 67, !8, i64 68, !8, i64 69, !11, i64 70, !11, i64 72, !11, i64 74, !11, i64 76, !11, i64 78, !11, i64 80, !7, i64 82, !7, i64 86, !7, i64 90, !8, i64 94}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"long long", !8, i64 0}
!11 = !{!"short", !8, i64 0}
!12 = !{!6, !7, i64 20}
!13 = !{!6, !7, i64 8}
!14 = !{!7, !7, i64 0}
!15 = !{!6, !7, i64 4}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,InstCombinePass,SROAPass,SimplifyCFGPass,TailCallElimPass