; LLVM IR from libxsmm/libxsmm :: samples/deeplearning/sparse_adagrad_fused (counters)

; 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.ctrs_skx_uc = type { [6 x i64], [6 x i64], [6 x i64], [6 x i64], [6 x i64], [28 x i64], [28 x i64], [28 x i64], [28 x i64], [28 x i64], [28 x i64], [28 x i64], [28 x i64], [28 x i64], 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
define dso_local void @zero_skx_uc_ctrs(ptr noundef %0) #1 {
  %2 = alloca ptr, align 8
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #2
  store i32 0, ptr %3, align 4, !tbaa !9
  br label %5

5:                                                ; preds = %34, %1
  %6 = load i32, ptr %3, align 4, !tbaa !9
  %7 = icmp slt i32 %6, 6
  br i1 %7, label %8, label %37

8:                                                ; preds = %5
  %9 = load ptr, ptr %2, align 8, !tbaa !5
  %10 = getelementptr inbounds %struct.ctrs_skx_uc, ptr %9, i32 0, i32 0
  %11 = load i32, ptr %3, align 4, !tbaa !9
  %12 = sext i32 %11 to i64
  %13 = getelementptr inbounds [6 x i64], ptr %10, i64 0, i64 %12
  store i64 0, ptr %13, align 8, !tbaa !11
  %14 = load ptr, ptr %2, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct.ctrs_skx_uc, ptr %14, i32 0, i32 1
  %16 = load i32, ptr %3, align 4, !tbaa !9
  %17 = sext i32 %16 to i64
  %18 = getelementptr inbounds [6 x i64], ptr %15, i64 0, i64 %17
  store i64 0, ptr %18, align 8, !tbaa !11
  %19 = load ptr, ptr %2, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.ctrs_skx_uc, ptr %19, i32 0, i32 2
  %21 = load i32, ptr %3, align 4, !tbaa !9
  %22 = sext i32 %21 to i64
  %23 = getelementptr inbounds [6 x i64], ptr %20, i64 0, i64 %22
  store i64 0, ptr %23, align 8, !tbaa !11
  %24 = load ptr, ptr %2, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.ctrs_skx_uc, ptr %24, i32 0, i32 3
  %26 = load i32, ptr %3, align 4, !tbaa !9
  %27 = sext i32 %26 to i64
  %28 = getelementptr inbounds [6 x i64], ptr %25, i64 0, i64 %27
  store i64 0, ptr %28, align 8, !tbaa !11
  %29 = load ptr, ptr %2, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.ctrs_skx_uc, ptr %29, i32 0, i32 4
  %31 = load i32, ptr %3, align 4, !tbaa !9
  %32 = sext i32 %31 to i64
  %33 = getelementptr inbounds [6 x i64], ptr %30, i64 0, i64 %32
  store i64 0, ptr %33, align 8, !tbaa !11
  br label %34

34:                                               ; preds = %8
  %35 = load i32, ptr %3, align 4, !tbaa !9
  %36 = add nsw i32 %35, 1
  store i32 %36, ptr %3, align 4, !tbaa !9
  br label %5, !llvm.loop !13

37:                                               ; preds = %5
  store i32 0, ptr %4, align 4, !tbaa !9
  br label %38

38:                                               ; preds = %87, %37
  %39 = load i32, ptr %4, align 4, !tbaa !9
  %40 = icmp slt i32 %39, 28
  br i1 %40, label %41, label %90

41:                                               ; preds = %38
  %42 = load ptr, ptr %2, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct.ctrs_skx_uc, ptr %42, i32 0, i32 5
  %44 = load i32, ptr %4, align 4, !tbaa !9
  %45 = sext i32 %44 to i64
  %46 = getelementptr inbounds [28 x i64], ptr %43, i64 0, i64 %45
  store i64 0, ptr %46, align 8, !tbaa !11
  %47 = load ptr, ptr %2, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.ctrs_skx_uc, ptr %47, i32 0, i32 6
  %49 = load i32, ptr %4, align 4, !tbaa !9
  %50 = sext i32 %49 to i64
  %51 = getelementptr inbounds [28 x i64], ptr %48, i64 0, i64 %50
  store i64 0, ptr %51, align 8, !tbaa !11
  %52 = load ptr, ptr %2, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct.ctrs_skx_uc, ptr %52, i32 0, i32 7
  %54 = load i32, ptr %4, align 4, !tbaa !9
  %55 = sext i32 %54 to i64
  %56 = getelementptr inbounds [28 x i64], ptr %53, i64 0, i64 %55
  store i64 0, ptr %56, align 8, !tbaa !11
  %57 = load ptr, ptr %2, align 8, !tbaa !5
  %58 = getelementptr inbounds %struct.ctrs_skx_uc, ptr %57, i32 0, i32 8
  %59 = load i32, ptr %4, align 4, !tbaa !9
  %60 = sext i32 %59 to i64
  %61 = getelementptr inbounds [28 x i64], ptr %58, i64 0, i64 %60
  store i64 0, ptr %61, align 8, !tbaa !11
  %62 = load ptr, ptr %2, align 8, !tbaa !5
  %63 = getelementptr inbounds %struct.ctrs_skx_uc, ptr %62, i32 0, i32 9
  %64 = load i32, ptr %4, align 4, !tbaa !9
  %65 = sext i32 %64 to i64
  %66 = getelementptr inbounds [28 x i64], ptr %63, i64 0, i64 %65
  store i64 0, ptr %66, align 8, !tbaa !11
  %67 = load ptr, ptr %2, align 8, !tbaa !5
  %68 = getelementptr inbounds %struct.ctrs_skx_uc, ptr %67, i32 0, i32 10
  %69 = load i32, ptr %4, align 4, !tbaa !9
  %70 = sext i32 %69 to i64
  %71 = getelementptr inbounds [28 x i64], ptr %68, i64 0, i64 %70
  store i64 0, ptr %71, align 8, !tbaa !11
  %72 = load ptr, ptr %2, align 8, !tbaa !5
  %73 = getelementptr inbounds %struct.ctrs_skx_uc, ptr %72, i32 0, i32 11
  %74 = load i32, ptr %4, align 4, !tbaa !9
  %75 = sext i32 %74 to i64
  %76 = getelementptr inbounds [28 x i64], ptr %73, i64 0, i64 %75
  store i64 0, ptr %76, align 8, !tbaa !11
  %77 = load ptr, ptr %2, align 8, !tbaa !5
  %78 = getelementptr inbounds %struct.ctrs_skx_uc, ptr %77, i32 0, i32 12
  %79 = load i32, ptr %4, align 4, !tbaa !9
  %80 = sext i32 %79 to i64
  %81 = getelementptr inbounds [28 x i64], ptr %78, i64 0, i64 %80
  store i64 0, ptr %81, align 8, !tbaa !11
  %82 = load ptr, ptr %2, align 8, !tbaa !5
  %83 = getelementptr inbounds %struct.ctrs_skx_uc, ptr %82, i32 0, i32 13
  %84 = load i32, ptr %4, align 4, !tbaa !9
  %85 = sext i32 %84 to i64
  %86 = getelementptr inbounds [28 x i64], ptr %83, i64 0, i64 %85
  store i64 0, ptr %86, align 8, !tbaa !11
  br label %87

87:                                               ; preds = %41
  %88 = load i32, ptr %4, align 4, !tbaa !9
  %89 = add nsw i32 %88, 1
  store i32 %89, ptr %4, align 4, !tbaa !9
  br label %38, !llvm.loop !15

90:                                               ; preds = %38
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #2
  call void @llvm.lifetime.end.p0(i64 4, 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 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"long", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = distinct !{!15, !14}


; 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: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: write) uwtable
define dso_local void @zero_skx_uc_ctrs(ptr nocapture noundef writeonly %0) local_unnamed_addr #0 {
.preheader:
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(2256) %0, i8 0, i64 2256, i1 false)
  ret void
}

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #1

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: write) 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 = { nocallback nofree nounwind willreturn memory(argmem: write) }

!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)"}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LICMPass,LoopIdiomRecognizePass,LoopRotatePass,LoopSimplifyPass,MemCpyOptPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass