; 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_csc_kernel = external hidden unnamed_addr constant [43 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_csc_kernel(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %4, i32 noundef %5) #1 {
  %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 ugt 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 eq 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 3
  %30 = load i32, ptr %29, align 1, !tbaa !11
  %31 = load ptr, ptr %8, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.libxsmm_gemm_descriptor, ptr %31, i32 0, i32 2
  %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 90007, ptr noundef @__func__.libxsmm_generator_packed_spgemm_csc_kernel, ptr noundef @.str, i32 noundef 71, i32 noundef %43)
  br label %117

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 !18
  %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_csc_kernel, ptr noundef @.str, i32 noundef 76, i32 noundef %60)
  br label %117

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_csc_bsparse(ptr noundef %62, ptr noundef %63, ptr noundef %64, ptr noundef %65, ptr noundef %66, i32 noundef %67)
  br label %117

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 %107

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 ugt i32 %76, 0
  br i1 %77, label %78, label %107

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 eq i32 %81, 0
  br i1 %82, label %83, label %107

83:                                               ; preds = %78
  %84 = load ptr, ptr %8, align 8, !tbaa !5
  %85 = getelementptr inbounds %struct.libxsmm_gemm_descriptor, ptr %84, i32 0, i32 4
  %86 = load i32, ptr %85, align 1, !tbaa !15
  %87 = load ptr, ptr %8, align 8, !tbaa !5
  %88 = getelementptr inbounds %struct.libxsmm_gemm_descriptor, ptr %87, i32 0, i32 1
  %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 90008, ptr noundef @__func__.libxsmm_generator_packed_spgemm_csc_kernel, ptr noundef @.str, i32 noundef 91, i32 noundef %99)
  br label %117

100:                                              ; preds = %83
  %101 = load ptr, ptr %7, align 8, !tbaa !5
  %102 = load ptr, ptr %8, align 8, !tbaa !5
  %103 = load ptr, ptr %9, align 8, !tbaa !5
  %104 = load ptr, ptr %10, align 8, !tbaa !5
  %105 = load ptr, ptr %11, align 8, !tbaa !5
  %106 = load i32, ptr %12, align 4, !tbaa !9
  call void @libxsmm_generator_packed_spgemm_csc_csparse(ptr noundef %101, ptr noundef %102, ptr noundef %103, ptr noundef %104, ptr noundef %105, i32 noundef %106)
  br label %116

107:                                              ; preds = %78, %73, %68
  %108 = load ptr, ptr %7, align 8, !tbaa !5
  %109 = load i32, ptr @libxsmm_ninit, align 4, !tbaa !9
  %110 = icmp ult i32 1, %109
  br i1 %110, label %111, label %113

111:                                              ; preds = %107
  %112 = load i32, ptr @libxsmm_verbosity, align 4, !tbaa !9
  br label %114

113:                                              ; preds = %107
  br label %114

114:                                              ; preds = %113, %111
  %115 = phi i32 [ %112, %111 ], [ 1, %113 ]
  call void @libxsmm_handle_error(ptr noundef %108, i32 noundef 90010, ptr noundef @__func__.libxsmm_generator_packed_spgemm_csc_kernel, ptr noundef @.str, i32 noundef 97, i32 noundef %115)
  br label %117

116:                                              ; preds = %100
  br label %117

117:                                              ; preds = %116, %114, %98, %61, %59, %42
  ret void
}

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

declare void @libxsmm_generator_packed_spgemm_csc_csparse(ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr 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 16}
!16 = !{!12, !10, i64 20}
!17 = !{!12, !10, i64 8}
!18 = !{!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_csc_kernel = external hidden unnamed_addr constant [43 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_csc_kernel(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %4, i32 noundef %5) local_unnamed_addr #1 {
  %7 = getelementptr inbounds i8, ptr %1, i64 12
  %8 = load i32, ptr %7, align 1, !tbaa !5
  %.not = icmp eq i32 %8, 0
  br i1 %.not, label %.thread, label %9

9:                                                ; preds = %6
  %10 = getelementptr inbounds i8, ptr %1, i64 16
  %11 = load i32, ptr %10, align 1, !tbaa !12
  %12 = icmp eq i32 %11, 0
  %13 = getelementptr inbounds i8, ptr %1, i64 20
  %14 = load i32, ptr %13, align 1, !tbaa !13
  %.not29 = icmp eq i32 %14, 0
  br i1 %12, label %15, label %35

15:                                               ; preds = %9
  br i1 %.not29, label %.thread, label %16

16:                                               ; preds = %15
  %17 = getelementptr inbounds i8, ptr %1, i64 8
  %18 = load i32, ptr %17, align 1, !tbaa !14
  %19 = icmp ult i32 %8, %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 90007, ptr noundef nonnull @__func__.libxsmm_generator_packed_spgemm_csc_kernel, ptr noundef nonnull @.str, i32 noundef 71, i32 noundef %24) #2
  br label %50

25:                                               ; preds = %16
  %26 = getelementptr inbounds i8, ptr %1, i64 4
  %27 = load i32, ptr %26, align 1, !tbaa !16
  %28 = icmp ult i32 %14, %27
  br i1 %28, label %29, label %34

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

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

35:                                               ; preds = %9
  br i1 %.not29, label %36, label %.thread

36:                                               ; preds = %35
  %37 = getelementptr inbounds i8, ptr %1, i64 4
  %38 = load i32, ptr %37, align 1, !tbaa !16
  %39 = icmp ult i32 %11, %38
  br i1 %39, label %40, label %45

40:                                               ; preds = %36
  %41 = load i32, ptr @libxsmm_ninit, align 4, !tbaa !15
  %42 = icmp ugt i32 %41, 1
  %43 = load i32, ptr @libxsmm_verbosity, align 4
  %44 = select i1 %42, i32 %43, i32 1
  tail call void @libxsmm_handle_error(ptr noundef %0, i32 noundef 90008, ptr noundef nonnull @__func__.libxsmm_generator_packed_spgemm_csc_kernel, ptr noundef nonnull @.str, i32 noundef 91, i32 noundef %44) #2
  br label %50

45:                                               ; preds = %36
  tail call void @libxsmm_generator_packed_spgemm_csc_csparse(ptr noundef %0, ptr noundef nonnull %1, ptr noundef %2, ptr noundef %3, ptr noundef %4, i32 noundef %5) #2
  br label %50

.thread:                                          ; preds = %15, %6, %35
  %46 = load i32, ptr @libxsmm_ninit, align 4, !tbaa !15
  %47 = icmp ugt i32 %46, 1
  %48 = load i32, ptr @libxsmm_verbosity, align 4
  %49 = select i1 %47, i32 %48, i32 1
  tail call void @libxsmm_handle_error(ptr noundef %0, i32 noundef 90010, ptr noundef nonnull @__func__.libxsmm_generator_packed_spgemm_csc_kernel, ptr noundef nonnull @.str, i32 noundef 97, i32 noundef %49) #2
  br label %50

50:                                               ; preds = %45, %.thread, %40, %34, %29, %20
  ret void
}

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

declare void @libxsmm_generator_packed_spgemm_csc_csparse(ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr 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 16}
!13 = !{!6, !7, i64 20}
!14 = !{!6, !7, i64 8}
!15 = !{!7, !7, i64 0}
!16 = !{!6, !7, i64 4}


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