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

@__func__.libxsmm_generator_packed_spgemm_csr_kernel = external hidden unnamed_addr constant [43 x i8], align 1
@.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

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

17:                                               ; preds = %6
  %18 = load ptr, ptr %8, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.libxsmm_gemm_descriptor, ptr %18, i32 0, i32 4
  %20 = load i32, ptr %19, align 1, !tbaa !15
  %21 = icmp ugt i32 %20, 0
  br i1 %21, label %22, label %68

22:                                               ; preds = %17
  %23 = load ptr, ptr %8, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.libxsmm_gemm_descriptor, ptr %23, i32 0, i32 5
  %25 = load i32, ptr %24, align 1, !tbaa !16
  %26 = icmp ugt i32 %25, 0
  br i1 %26, label %27, label %68

27:                                               ; preds = %22
  %28 = load ptr, ptr %8, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.libxsmm_gemm_descriptor, ptr %28, i32 0, i32 4
  %30 = load i32, ptr %29, align 1, !tbaa !15
  %31 = load ptr, ptr %8, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.libxsmm_gemm_descriptor, ptr %31, i32 0, i32 1
  %33 = load i32, ptr %32, align 1, !tbaa !17
  %34 = icmp ult i32 %30, %33
  br i1 %34, label %35, label %44

35:                                               ; preds = %27
  %36 = load ptr, ptr %7, align 8, !tbaa !5
  %37 = load i32, ptr @libxsmm_ninit, align 4, !tbaa !9
  %38 = icmp ult i32 1, %37
  br i1 %38, label %39, label %41

39:                                               ; preds = %35
  %40 = load i32, ptr @libxsmm_verbosity, align 4, !tbaa !9
  br label %42

41:                                               ; preds = %35
  br label %42

42:                                               ; preds = %41, %39
  %43 = phi i32 [ %40, %39 ], [ 1, %41 ]
  call void @libxsmm_handle_error(ptr noundef %36, i32 noundef 90008, ptr noundef @__func__.libxsmm_generator_packed_spgemm_csr_kernel, ptr noundef @.str, i32 noundef 30, i32 noundef %43)
  br label %134

44:                                               ; preds = %27
  %45 = load ptr, ptr %8, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.libxsmm_gemm_descriptor, ptr %45, i32 0, i32 5
  %47 = load i32, ptr %46, align 1, !tbaa !16
  %48 = load ptr, ptr %8, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.libxsmm_gemm_descriptor, ptr %48, i32 0, i32 1
  %50 = load i32, ptr %49, align 1, !tbaa !17
  %51 = icmp ult i32 %47, %50
  br i1 %51, label %52, label %61

52:                                               ; preds = %44
  %53 = load ptr, ptr %7, align 8, !tbaa !5
  %54 = load i32, ptr @libxsmm_ninit, align 4, !tbaa !9
  %55 = icmp ult i32 1, %54
  br i1 %55, label %56, label %58

56:                                               ; preds = %52
  %57 = load i32, ptr @libxsmm_verbosity, align 4, !tbaa !9
  br label %59

58:                                               ; preds = %52
  br label %59

59:                                               ; preds = %58, %56
  %60 = phi i32 [ %57, %56 ], [ 1, %58 ]
  call void @libxsmm_handle_error(ptr noundef %53, i32 noundef 90009, ptr noundef @__func__.libxsmm_generator_packed_spgemm_csr_kernel, ptr noundef @.str, i32 noundef 35, i32 noundef %60)
  br label %134

61:                                               ; preds = %44
  %62 = load ptr, ptr %7, align 8, !tbaa !5
  %63 = load ptr, ptr %8, align 8, !tbaa !5
  %64 = load ptr, ptr %9, align 8, !tbaa !5
  %65 = load ptr, ptr %10, align 8, !tbaa !5
  %66 = load ptr, ptr %11, align 8, !tbaa !5
  %67 = load i32, ptr %12, align 4, !tbaa !9
  call void @libxsmm_generator_packed_spgemm_csr_asparse(ptr noundef %62, ptr noundef %63, ptr noundef %64, ptr noundef %65, ptr noundef %66, i32 noundef %67)
  br label %134

68:                                               ; preds = %22, %17, %6
  %69 = load ptr, ptr %8, align 8, !tbaa !5
  %70 = getelementptr inbounds %struct.libxsmm_gemm_descriptor, ptr %69, i32 0, i32 3
  %71 = load i32, ptr %70, align 1, !tbaa !11
  %72 = icmp ugt i32 %71, 0
  br i1 %72, label %73, label %124

73:                                               ; preds = %68
  %74 = load ptr, ptr %8, align 8, !tbaa !5
  %75 = getelementptr inbounds %struct.libxsmm_gemm_descriptor, ptr %74, i32 0, i32 4
  %76 = load i32, ptr %75, align 1, !tbaa !15
  %77 = icmp eq i32 %76, 0
  br i1 %77, label %78, label %124

78:                                               ; preds = %73
  %79 = load ptr, ptr %8, align 8, !tbaa !5
  %80 = getelementptr inbounds %struct.libxsmm_gemm_descriptor, ptr %79, i32 0, i32 5
  %81 = load i32, ptr %80, align 1, !tbaa !16
  %82 = icmp ugt i32 %81, 0
  br i1 %82, label %83, label %124

83:                                               ; preds = %78
  %84 = load ptr, ptr %8, align 8, !tbaa !5
  %85 = getelementptr inbounds %struct.libxsmm_gemm_descriptor, ptr %84, i32 0, i32 3
  %86 = load i32, ptr %85, align 1, !tbaa !11
  %87 = load ptr, ptr %8, align 8, !tbaa !5
  %88 = getelementptr inbounds %struct.libxsmm_gemm_descriptor, ptr %87, i32 0, i32 2
  %89 = load i32, ptr %88, align 1, !tbaa !18
  %90 = icmp ult i32 %86, %89
  br i1 %90, label %91, label %100

91:                                               ; preds = %83
  %92 = load ptr, ptr %7, align 8, !tbaa !5
  %93 = load i32, ptr @libxsmm_ninit, align 4, !tbaa !9
  %94 = icmp ult i32 1, %93
  br i1 %94, label %95, label %97

95:                                               ; preds = %91
  %96 = load i32, ptr @libxsmm_verbosity, align 4, !tbaa !9
  br label %98

97:                                               ; preds = %91
  br label %98

98:                                               ; preds = %97, %95
  %99 = phi i32 [ %96, %95 ], [ 1, %97 ]
  call void @libxsmm_handle_error(ptr noundef %92, i32 noundef 90007, ptr noundef @__func__.libxsmm_generator_packed_spgemm_csr_kernel, ptr noundef @.str, i32 noundef 43, i32 noundef %99)
  br label %134

100:                                              ; preds = %83
  %101 = load ptr, ptr %8, align 8, !tbaa !5
  %102 = getelementptr inbounds %struct.libxsmm_gemm_descriptor, ptr %101, i32 0, i32 5
  %103 = load i32, ptr %102, align 1, !tbaa !16
  %104 = load ptr, ptr %8, align 8, !tbaa !5
  %105 = getelementptr inbounds %struct.libxsmm_gemm_descriptor, ptr %104, i32 0, i32 1
  %106 = load i32, ptr %105, align 1, !tbaa !17
  %107 = icmp ult i32 %103, %106
  br i1 %107, label %108, label %117

108:                                              ; preds = %100
  %109 = load ptr, ptr %7, align 8, !tbaa !5
  %110 = load i32, ptr @libxsmm_ninit, align 4, !tbaa !9
  %111 = icmp ult i32 1, %110
  br i1 %111, label %112, label %114

112:                                              ; preds = %108
  %113 = load i32, ptr @libxsmm_verbosity, align 4, !tbaa !9
  br label %115

114:                                              ; preds = %108
  br label %115

115:                                              ; preds = %114, %112
  %116 = phi i32 [ %113, %112 ], [ 1, %114 ]
  call void @libxsmm_handle_error(ptr noundef %109, i32 noundef 90009, ptr noundef @__func__.libxsmm_generator_packed_spgemm_csr_kernel, ptr noundef @.str, i32 noundef 49, i32 noundef %116)
  br label %134

117:                                              ; preds = %100
  %118 = load ptr, ptr %7, align 8, !tbaa !5
  %119 = load ptr, ptr %8, align 8, !tbaa !5
  %120 = load ptr, ptr %9, align 8, !tbaa !5
  %121 = load ptr, ptr %10, align 8, !tbaa !5
  %122 = load ptr, ptr %11, align 8, !tbaa !5
  %123 = load i32, ptr %12, align 4, !tbaa !9
  call void @libxsmm_generator_packed_spgemm_csr_bsparse(ptr noundef %118, ptr noundef %119, ptr noundef %120, ptr noundef %121, ptr noundef %122, i32 noundef %123)
  br label %133

124:                                              ; preds = %78, %73, %68
  %125 = load ptr, ptr %7, align 8, !tbaa !5
  %126 = load i32, ptr @libxsmm_ninit, align 4, !tbaa !9
  %127 = icmp ult i32 1, %126
  br i1 %127, label %128, label %130

128:                                              ; preds = %124
  %129 = load i32, ptr @libxsmm_verbosity, align 4, !tbaa !9
  br label %131

130:                                              ; preds = %124
  br label %131

131:                                              ; preds = %130, %128
  %132 = phi i32 [ %129, %128 ], [ 1, %130 ]
  call void @libxsmm_handle_error(ptr noundef %125, i32 noundef 90010, ptr noundef @__func__.libxsmm_generator_packed_spgemm_csr_kernel, ptr noundef @.str, i32 noundef 55, i32 noundef %132)
  br label %134

133:                                              ; preds = %117
  br label %134

134:                                              ; preds = %133, %131, %115, %98, %61, %59, %42
  ret void
}

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

declare void @libxsmm_generator_packed_spgemm_csr_asparse(ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, i32 noundef) #1

declare void @libxsmm_generator_packed_spgemm_csr_bsparse(ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, i32 noundef) #1

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" }
attributes #1 = { "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 16}
!16 = !{!12, !10, i64 20}
!17 = !{!12, !10, i64 4}
!18 = !{!12, !10, i64 8}


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

@__func__.libxsmm_generator_packed_spgemm_csr_kernel = external hidden unnamed_addr constant [43 x i8], align 1
@.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

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

12:                                               ; preds = %6
  br i1 %.not, label %.thread, label %13

13:                                               ; preds = %12
  %14 = getelementptr inbounds i8, ptr %1, i64 20
  %15 = load i32, ptr %14, align 1, !tbaa !13
  %.not34 = icmp eq i32 %15, 0
  br i1 %.not34, label %.thread, label %16

16:                                               ; preds = %13
  %17 = getelementptr inbounds i8, ptr %1, i64 4
  %18 = load i32, ptr %17, align 1, !tbaa !14
  %19 = icmp ult i32 %11, %18
  br i1 %19, label %20, label %25

20:                                               ; preds = %16
  %21 = load i32, ptr @libxsmm_ninit, align 4, !tbaa !15
  %22 = icmp ugt i32 %21, 1
  %23 = load i32, ptr @libxsmm_verbosity, align 4
  %24 = select i1 %22, i32 %23, i32 1
  tail call void @libxsmm_handle_error(ptr noundef %0, i32 noundef 90008, ptr noundef nonnull @__func__.libxsmm_generator_packed_spgemm_csr_kernel, ptr noundef nonnull @.str, i32 noundef 30, i32 noundef %24) #2
  br label %60

25:                                               ; preds = %16
  %26 = icmp ult i32 %15, %18
  br i1 %26, label %27, label %32

27:                                               ; preds = %25
  %28 = load i32, ptr @libxsmm_ninit, align 4, !tbaa !15
  %29 = icmp ugt i32 %28, 1
  %30 = load i32, ptr @libxsmm_verbosity, align 4
  %31 = select i1 %29, i32 %30, i32 1
  tail call void @libxsmm_handle_error(ptr noundef %0, i32 noundef 90009, ptr noundef nonnull @__func__.libxsmm_generator_packed_spgemm_csr_kernel, ptr noundef nonnull @.str, i32 noundef 35, i32 noundef %31) #2
  br label %60

32:                                               ; preds = %25
  tail call void @libxsmm_generator_packed_spgemm_csr_asparse(ptr noundef %0, ptr noundef nonnull %1, ptr noundef %2, ptr noundef %3, ptr noundef %4, i32 noundef %5) #2
  br label %60

33:                                               ; preds = %6
  br i1 %.not, label %34, label %.thread

34:                                               ; preds = %33
  %35 = getelementptr inbounds i8, ptr %1, i64 20
  %36 = load i32, ptr %35, align 1, !tbaa !13
  %.not36 = icmp eq i32 %36, 0
  br i1 %.not36, label %.thread, label %37

37:                                               ; preds = %34
  %38 = getelementptr inbounds i8, ptr %1, i64 8
  %39 = load i32, ptr %38, align 1, !tbaa !16
  %40 = icmp ult i32 %8, %39
  br i1 %40, label %41, label %46

41:                                               ; preds = %37
  %42 = load i32, ptr @libxsmm_ninit, align 4, !tbaa !15
  %43 = icmp ugt i32 %42, 1
  %44 = load i32, ptr @libxsmm_verbosity, align 4
  %45 = select i1 %43, i32 %44, i32 1
  tail call void @libxsmm_handle_error(ptr noundef %0, i32 noundef 90007, ptr noundef nonnull @__func__.libxsmm_generator_packed_spgemm_csr_kernel, ptr noundef nonnull @.str, i32 noundef 43, i32 noundef %45) #2
  br label %60

46:                                               ; preds = %37
  %47 = getelementptr inbounds i8, ptr %1, i64 4
  %48 = load i32, ptr %47, align 1, !tbaa !14
  %49 = icmp ult i32 %36, %48
  br i1 %49, label %50, label %55

50:                                               ; preds = %46
  %51 = load i32, ptr @libxsmm_ninit, align 4, !tbaa !15
  %52 = icmp ugt i32 %51, 1
  %53 = load i32, ptr @libxsmm_verbosity, align 4
  %54 = select i1 %52, i32 %53, i32 1
  tail call void @libxsmm_handle_error(ptr noundef %0, i32 noundef 90009, ptr noundef nonnull @__func__.libxsmm_generator_packed_spgemm_csr_kernel, ptr noundef nonnull @.str, i32 noundef 49, i32 noundef %54) #2
  br label %60

55:                                               ; preds = %46
  tail call void @libxsmm_generator_packed_spgemm_csr_bsparse(ptr noundef %0, ptr noundef nonnull %1, ptr noundef %2, ptr noundef %3, ptr noundef %4, i32 noundef %5) #2
  br label %60

.thread:                                          ; preds = %12, %13, %34, %33
  %56 = load i32, ptr @libxsmm_ninit, align 4, !tbaa !15
  %57 = icmp ugt i32 %56, 1
  %58 = load i32, ptr @libxsmm_verbosity, align 4
  %59 = select i1 %57, i32 %58, i32 1
  tail call void @libxsmm_handle_error(ptr noundef %0, i32 noundef 90010, ptr noundef nonnull @__func__.libxsmm_generator_packed_spgemm_csr_kernel, ptr noundef nonnull @.str, i32 noundef 55, i32 noundef %59) #2
  br label %60

60:                                               ; preds = %55, %.thread, %50, %41, %32, %27, %20
  ret void
}

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

declare void @libxsmm_generator_packed_spgemm_csr_asparse(ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #1

declare void @libxsmm_generator_packed_spgemm_csr_bsparse(ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #1

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" }
attributes #1 = { "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 16}
!13 = !{!6, !7, i64 20}
!14 = !{!6, !7, i64 4}
!15 = !{!7, !7, i64 0}
!16 = !{!6, !7, i64 8}


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