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

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

@stderr = external global ptr, align 8
@.str = external hidden unnamed_addr constant [75 x i8], align 1
@__func__.libxsmm_generator_packed_spgemm_csc_bsparse = external hidden unnamed_addr constant [44 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [91 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_csc_bsparse(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 %7, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct.libxsmm_generated_code, ptr %13, i32 0, i32 6
  %15 = load i32, ptr %14, align 4, !tbaa !11
  %16 = icmp uge i32 %15, 1005
  br i1 %16, label %17, label %29

17:                                               ; preds = %6
  %18 = load ptr, ptr %7, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.libxsmm_generated_code, ptr %18, i32 0, i32 6
  %20 = load i32, ptr %19, align 4, !tbaa !11
  %21 = icmp ule i32 %20, 1999
  br i1 %21, label %22, label %29

22:                                               ; preds = %17
  %23 = load ptr, ptr %7, align 8, !tbaa !5
  %24 = load ptr, ptr %8, align 8, !tbaa !5
  %25 = load ptr, ptr %9, align 8, !tbaa !5
  %26 = load ptr, ptr %10, align 8, !tbaa !5
  %27 = load ptr, ptr %11, align 8, !tbaa !5
  %28 = load i32, ptr %12, align 4, !tbaa !9
  call void @libxsmm_generator_packed_spgemm_csc_bsparse_avx_avx2_avx512(ptr noundef %23, ptr noundef %24, ptr noundef %25, ptr noundef %26, ptr noundef %27, i32 noundef %28)
  br label %58

29:                                               ; preds = %17, %6
  %30 = load ptr, ptr %7, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.libxsmm_generated_code, ptr %30, i32 0, i32 6
  %32 = load i32, ptr %31, align 4, !tbaa !11
  %33 = icmp uge i32 %32, 2001
  br i1 %33, label %34, label %46

34:                                               ; preds = %29
  %35 = load ptr, ptr %7, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.libxsmm_generated_code, ptr %35, i32 0, i32 6
  %37 = load i32, ptr %36, align 4, !tbaa !11
  %38 = icmp ule i32 %37, 2999
  br i1 %38, label %39, label %46

39:                                               ; preds = %34
  %40 = load ptr, ptr %7, align 8, !tbaa !5
  %41 = load ptr, ptr %8, align 8, !tbaa !5
  %42 = load ptr, ptr %9, align 8, !tbaa !5
  %43 = load ptr, ptr %10, align 8, !tbaa !5
  %44 = load ptr, ptr %11, align 8, !tbaa !5
  %45 = load i32, ptr %12, align 4, !tbaa !9
  call void @libxsmm_generator_packed_spgemm_csc_bsparse_aarch64(ptr noundef %40, ptr noundef %41, ptr noundef %42, ptr noundef %43, ptr noundef %44, i32 noundef %45)
  br label %57

46:                                               ; preds = %34, %29
  %47 = load ptr, ptr @stderr, align 8, !tbaa !5
  %48 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %47, ptr noundef @.str) #3
  %49 = load ptr, ptr %7, align 8, !tbaa !5
  %50 = load i32, ptr @libxsmm_ninit, align 4, !tbaa !9
  %51 = icmp ult i32 1, %50
  br i1 %51, label %52, label %54

52:                                               ; preds = %46
  %53 = load i32, ptr @libxsmm_verbosity, align 4, !tbaa !9
  br label %55

54:                                               ; preds = %46
  br label %55

55:                                               ; preds = %54, %52
  %56 = phi i32 [ %53, %52 ], [ 1, %54 ]
  call void @libxsmm_handle_error(ptr noundef %49, i32 noundef 90000, ptr noundef @__func__.libxsmm_generator_packed_spgemm_csc_bsparse, ptr noundef @.str.1, i32 noundef 40, i32 noundef %56)
  br label %58

57:                                               ; preds = %39
  br label %58

58:                                               ; preds = %57, %55, %22
  ret void
}

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

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

; Function Attrs: nounwind
declare i32 @fprintf(ptr noundef, ptr noundef, ...) #2

declare void @libxsmm_handle_error(ptr noundef, i32 noundef, ptr noundef, ptr noundef, i32 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" }
attributes #2 = { nounwind "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 #3 = { 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 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !10, i64 28}
!12 = !{!"libxsmm_generated_code", !6, i64 0, !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20, !10, i64 24, !10, i64 28}


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

@stderr = external local_unnamed_addr global ptr, align 8
@.str = external hidden unnamed_addr constant [75 x i8], align 1
@__func__.libxsmm_generator_packed_spgemm_csc_bsparse = external hidden unnamed_addr constant [44 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [91 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_csc_bsparse(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 %0, i64 28
  %8 = load i32, ptr %7, align 4, !tbaa !5
  %9 = add i32 %8, -1005
  %or.cond = icmp ult i32 %9, 995
  br i1 %or.cond, label %10, label %11

10:                                               ; preds = %6
  tail call void @libxsmm_generator_packed_spgemm_csc_bsparse_avx_avx2_avx512(ptr noundef nonnull %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %4, i32 noundef %5) #3
  br label %21

11:                                               ; preds = %6
  %12 = add i32 %8, -2001
  %or.cond17 = icmp ult i32 %12, 999
  br i1 %or.cond17, label %13, label %14

13:                                               ; preds = %11
  tail call void @libxsmm_generator_packed_spgemm_csc_bsparse_aarch64(ptr noundef nonnull %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %4, i32 noundef %5) #3
  br label %21

14:                                               ; preds = %11
  %15 = load ptr, ptr @stderr, align 8, !tbaa !11
  %16 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %15, ptr noundef nonnull @.str) #4
  %17 = load i32, ptr @libxsmm_ninit, align 4, !tbaa !12
  %18 = icmp ugt i32 %17, 1
  %19 = load i32, ptr @libxsmm_verbosity, align 4
  %20 = select i1 %18, i32 %19, i32 1
  tail call void @libxsmm_handle_error(ptr noundef nonnull %0, i32 noundef 90000, ptr noundef nonnull @__func__.libxsmm_generator_packed_spgemm_csc_bsparse, ptr noundef nonnull @.str.1, i32 noundef 40, i32 noundef %20) #3
  br label %21

21:                                               ; preds = %13, %14, %10
  ret void
}

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

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

; Function Attrs: nofree nounwind
declare noundef i32 @fprintf(ptr nocapture noundef, ptr nocapture noundef readonly, ...) local_unnamed_addr #2

declare void @libxsmm_handle_error(ptr noundef, i32 noundef, ptr noundef, ptr noundef, i32 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 = { nofree nounwind "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 #3 = { nounwind }
attributes #4 = { cold 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, !10, i64 28}
!6 = !{!"libxsmm_generated_code", !7, i64 0, !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20, !10, i64 24, !10, i64 28}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!7, !7, i64 0}
!12 = !{!10, !10, i64 0}


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