; 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 }
%struct.bw_gibs = type { double, double }

@.str.10 = external hidden unnamed_addr constant [40 x i8], align 1

; 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

declare i32 @printf(ptr noundef, ...) #1

; Function Attrs: nounwind uwtable
define dso_local void @get_cas_ddr_bw_skx(ptr noundef %0, double noundef %1, ptr noundef %2) #2 {
  %4 = alloca ptr, align 8
  %5 = alloca double, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i64, align 8
  %8 = alloca i64, align 8
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store double %1, ptr %5, align 8, !tbaa !9
  store ptr %2, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #3
  store i64 0, ptr %7, align 8, !tbaa !11
  store i64 0, ptr %8, align 8, !tbaa !11
  %11 = load ptr, ptr %4, align 8, !tbaa !5
  %12 = getelementptr inbounds %struct.ctrs_skx_uc, ptr %11, i32 0, i32 14
  %13 = load i32, ptr %12, align 8, !tbaa !13
  %14 = icmp ne i32 %13, 1
  br i1 %14, label %15, label %21

15:                                               ; preds = %3
  %16 = call i32 (ptr, ...) @printf(ptr noundef @.str.10)
  %17 = load ptr, ptr %6, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.bw_gibs, ptr %17, i32 0, i32 0
  store double 0.000000e+00, ptr %18, align 8, !tbaa !16
  %19 = load ptr, ptr %6, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.bw_gibs, ptr %19, i32 0, i32 1
  store double 0.000000e+00, ptr %20, align 8, !tbaa !18
  store i32 1, ptr %10, align 4
  br label %62

21:                                               ; preds = %3
  store i32 0, ptr %9, align 4, !tbaa !19
  br label %22

22:                                               ; preds = %44, %21
  %23 = load i32, ptr %9, align 4, !tbaa !19
  %24 = icmp slt i32 %23, 6
  br i1 %24, label %25, label %47

25:                                               ; preds = %22
  %26 = load ptr, ptr %4, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.ctrs_skx_uc, ptr %26, i32 0, i32 2
  %28 = load i32, ptr %9, align 4, !tbaa !19
  %29 = sext i32 %28 to i64
  %30 = getelementptr inbounds [6 x i64], ptr %27, i64 0, i64 %29
  %31 = load i64, ptr %30, align 8, !tbaa !11
  %32 = mul i64 %31, 64
  %33 = load i64, ptr %7, align 8, !tbaa !11
  %34 = add i64 %33, %32
  store i64 %34, ptr %7, align 8, !tbaa !11
  %35 = load ptr, ptr %4, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.ctrs_skx_uc, ptr %35, i32 0, i32 3
  %37 = load i32, ptr %9, align 4, !tbaa !19
  %38 = sext i32 %37 to i64
  %39 = getelementptr inbounds [6 x i64], ptr %36, i64 0, i64 %38
  %40 = load i64, ptr %39, align 8, !tbaa !11
  %41 = mul i64 %40, 64
  %42 = load i64, ptr %8, align 8, !tbaa !11
  %43 = add i64 %42, %41
  store i64 %43, ptr %8, align 8, !tbaa !11
  br label %44

44:                                               ; preds = %25
  %45 = load i32, ptr %9, align 4, !tbaa !19
  %46 = add nsw i32 %45, 1
  store i32 %46, ptr %9, align 4, !tbaa !19
  br label %22, !llvm.loop !20

47:                                               ; preds = %22
  %48 = load i64, ptr %7, align 8, !tbaa !11
  %49 = uitofp i64 %48 to double
  %50 = load double, ptr %5, align 8, !tbaa !9
  %51 = fdiv double %49, %50
  %52 = fdiv double %51, 0x41D0000000000000
  %53 = load ptr, ptr %6, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.bw_gibs, ptr %53, i32 0, i32 0
  store double %52, ptr %54, align 8, !tbaa !16
  %55 = load i64, ptr %8, align 8, !tbaa !11
  %56 = uitofp i64 %55 to double
  %57 = load double, ptr %5, align 8, !tbaa !9
  %58 = fdiv double %56, %57
  %59 = fdiv double %58, 0x41D0000000000000
  %60 = load ptr, ptr %6, align 8, !tbaa !5
  %61 = getelementptr inbounds %struct.bw_gibs, ptr %60, i32 0, i32 1
  store double %59, ptr %61, align 8, !tbaa !18
  store i32 0, ptr %10, align 4
  br label %62

62:                                               ; preds = %47, %15
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  %63 = load i32, ptr %10, align 4
  switch i32 %63, label %65 [
    i32 0, label %64
    i32 1, label %64
  ]

64:                                               ; preds = %62, %62
  ret void

65:                                               ; preds = %62
  unreachable
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 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 #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 = !{!"double", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"long", !7, i64 0}
!13 = !{!14, !15, i64 2256}
!14 = !{!"ctrs_skx_uc", !7, i64 0, !7, i64 48, !7, i64 96, !7, i64 144, !7, i64 192, !7, i64 240, !7, i64 464, !7, i64 688, !7, i64 912, !7, i64 1136, !7, i64 1360, !7, i64 1584, !7, i64 1808, !7, i64 2032, !15, i64 2256}
!15 = !{!"int", !7, i64 0}
!16 = !{!17, !10, i64 0}
!17 = !{!"bw_gibs", !10, i64 0, !10, i64 8}
!18 = !{!17, !10, i64 8}
!19 = !{!15, !15, i64 0}
!20 = distinct !{!20, !21}
!21 = !{!"llvm.loop.mustprogress"}


; 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.10 = external hidden unnamed_addr constant [40 x i8], align 1

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

; Function Attrs: nofree nounwind uwtable
define dso_local void @get_cas_ddr_bw_skx(ptr nocapture noundef readonly %0, double noundef %1, ptr nocapture noundef writeonly %2) local_unnamed_addr #1 {
  %4 = getelementptr inbounds i8, ptr %0, i64 2256
  %5 = load i32, ptr %4, align 8, !tbaa !5
  %.not = icmp eq i32 %5, 1
  br i1 %.not, label %.preheader, label %49

.preheader:                                       ; preds = %3
  %6 = getelementptr inbounds i8, ptr %0, i64 96
  %7 = getelementptr inbounds i8, ptr %0, i64 144
  %8 = load i64, ptr %6, align 8, !tbaa !10
  %9 = load i64, ptr %7, align 8, !tbaa !10
  %10 = getelementptr inbounds i8, ptr %0, i64 104
  %11 = load i64, ptr %10, align 8, !tbaa !10
  %12 = add i64 %11, %8
  %13 = getelementptr inbounds i8, ptr %0, i64 152
  %14 = load i64, ptr %13, align 8, !tbaa !10
  %15 = add i64 %14, %9
  %16 = getelementptr inbounds i8, ptr %0, i64 112
  %17 = load i64, ptr %16, align 8, !tbaa !10
  %18 = add i64 %17, %12
  %19 = getelementptr inbounds i8, ptr %0, i64 160
  %20 = load i64, ptr %19, align 8, !tbaa !10
  %21 = add i64 %20, %15
  %22 = getelementptr inbounds i8, ptr %0, i64 120
  %23 = load i64, ptr %22, align 8, !tbaa !10
  %24 = add i64 %23, %18
  %25 = getelementptr inbounds i8, ptr %0, i64 168
  %26 = load i64, ptr %25, align 8, !tbaa !10
  %27 = add i64 %26, %21
  %28 = getelementptr inbounds i8, ptr %0, i64 128
  %29 = load i64, ptr %28, align 8, !tbaa !10
  %30 = add i64 %29, %24
  %31 = getelementptr inbounds i8, ptr %0, i64 176
  %32 = load i64, ptr %31, align 8, !tbaa !10
  %33 = add i64 %32, %27
  %34 = getelementptr inbounds i8, ptr %0, i64 136
  %35 = load i64, ptr %34, align 8, !tbaa !10
  %36 = add i64 %35, %30
  %37 = shl i64 %36, 6
  %38 = getelementptr inbounds i8, ptr %0, i64 184
  %39 = load i64, ptr %38, align 8, !tbaa !10
  %40 = add i64 %39, %33
  %41 = shl i64 %40, 6
  %42 = uitofp i64 %37 to double
  %43 = fdiv double %42, %1
  %44 = fmul double %43, 0x3E10000000000000
  store double %44, ptr %2, align 8, !tbaa !12
  %45 = uitofp i64 %41 to double
  %46 = fdiv double %45, %1
  %47 = fmul double %46, 0x3E10000000000000
  %48 = getelementptr inbounds i8, ptr %2, i64 8
  store double %47, ptr %48, align 8, !tbaa !15
  br label %51

49:                                               ; preds = %3
  %50 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.10)
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %2, i8 0, i64 16, i1 false)
  br label %51

51:                                               ; preds = %.preheader, %49
  ret void
}

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

attributes #0 = { 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 #1 = { nofree 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 = { 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)"}
!5 = !{!6, !9, i64 2256}
!6 = !{!"ctrs_skx_uc", !7, i64 0, !7, i64 48, !7, i64 96, !7, i64 144, !7, i64 192, !7, i64 240, !7, i64 464, !7, i64 688, !7, i64 912, !7, i64 1136, !7, i64 1360, !7, i64 1584, !7, i64 1808, !7, i64 2032, !9, i64 2256}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!"int", !7, i64 0}
!10 = !{!11, !11, i64 0}
!11 = !{!"long", !7, i64 0}
!12 = !{!13, !14, i64 0}
!13 = !{!"bw_gibs", !14, i64 0, !14, i64 8}
!14 = !{!"double", !7, i64 0}
!15 = !{!13, !14, i64 8}


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