; LLVM IR from libxsmm/libxsmm :: samples/external_aux (perf_counter_markers)

; 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.ipc_rate = type { double, double, double, double, double }
%struct.ctrs_core = type { [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], [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 @get_ipc_core_ctr(ptr noundef %0, ptr noundef %1) #1 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i64, align 8
  %6 = alloca i64, align 8
  %7 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #2
  store i64 0, ptr %5, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #2
  store i64 0, ptr %6, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #2
  store i32 0, ptr %7, align 4, !tbaa !11
  %8 = load ptr, ptr %4, align 8, !tbaa !5
  %9 = getelementptr inbounds %struct.ipc_rate, ptr %8, i32 0, i32 0
  store double 0.000000e+00, ptr %9, align 8, !tbaa !13
  %10 = load ptr, ptr %4, align 8, !tbaa !5
  %11 = getelementptr inbounds %struct.ipc_rate, ptr %10, i32 0, i32 1
  store double 0.000000e+00, ptr %11, align 8, !tbaa !16
  %12 = load ptr, ptr %4, align 8, !tbaa !5
  %13 = getelementptr inbounds %struct.ipc_rate, ptr %12, i32 0, i32 2
  store double 0.000000e+00, ptr %13, align 8, !tbaa !17
  %14 = load ptr, ptr %4, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct.ipc_rate, ptr %14, i32 0, i32 3
  store double 0.000000e+00, ptr %15, align 8, !tbaa !18
  %16 = load ptr, ptr %4, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct.ipc_rate, ptr %16, i32 0, i32 4
  store double 0.000000e+00, ptr %17, align 8, !tbaa !19
  store i32 0, ptr %7, align 4, !tbaa !11
  br label %18

18:                                               ; preds = %38, %2
  %19 = load i32, ptr %7, align 4, !tbaa !11
  %20 = icmp slt i32 %19, 28
  br i1 %20, label %21, label %41

21:                                               ; preds = %18
  %22 = load ptr, ptr %3, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.ctrs_core, ptr %22, i32 0, i32 0
  %24 = load i32, ptr %7, align 4, !tbaa !11
  %25 = sext i32 %24 to i64
  %26 = getelementptr inbounds [28 x i64], ptr %23, i64 0, i64 %25
  %27 = load i64, ptr %26, align 8, !tbaa !9
  %28 = load i64, ptr %5, align 8, !tbaa !9
  %29 = add i64 %28, %27
  store i64 %29, ptr %5, align 8, !tbaa !9
  %30 = load ptr, ptr %3, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.ctrs_core, ptr %30, i32 0, i32 1
  %32 = load i32, ptr %7, align 4, !tbaa !11
  %33 = sext i32 %32 to i64
  %34 = getelementptr inbounds [28 x i64], ptr %31, i64 0, i64 %33
  %35 = load i64, ptr %34, align 8, !tbaa !9
  %36 = load i64, ptr %6, align 8, !tbaa !9
  %37 = add i64 %36, %35
  store i64 %37, ptr %6, align 8, !tbaa !9
  br label %38

38:                                               ; preds = %21
  %39 = load i32, ptr %7, align 4, !tbaa !11
  %40 = add nsw i32 %39, 1
  store i32 %40, ptr %7, align 4, !tbaa !11
  br label %18, !llvm.loop !20

41:                                               ; preds = %18
  %42 = load i64, ptr %5, align 8, !tbaa !9
  %43 = uitofp i64 %42 to double
  %44 = fdiv double %43, 2.800000e+01
  %45 = load ptr, ptr %4, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.ipc_rate, ptr %45, i32 0, i32 0
  store double %44, ptr %46, align 8, !tbaa !13
  %47 = load i64, ptr %6, align 8, !tbaa !9
  %48 = uitofp i64 %47 to double
  %49 = fdiv double %48, 2.800000e+01
  %50 = load ptr, ptr %4, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.ipc_rate, ptr %50, i32 0, i32 1
  store double %49, ptr %51, align 8, !tbaa !16
  %52 = load i64, ptr %6, align 8, !tbaa !9
  %53 = uitofp i64 %52 to double
  %54 = load ptr, ptr %4, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct.ipc_rate, ptr %54, i32 0, i32 2
  store double %53, ptr %55, align 8, !tbaa !17
  %56 = load ptr, ptr %4, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct.ipc_rate, ptr %56, i32 0, i32 1
  %58 = load double, ptr %57, align 8, !tbaa !16
  %59 = load ptr, ptr %4, align 8, !tbaa !5
  %60 = getelementptr inbounds %struct.ipc_rate, ptr %59, i32 0, i32 0
  %61 = load double, ptr %60, align 8, !tbaa !13
  %62 = fdiv double %58, %61
  %63 = load ptr, ptr %4, align 8, !tbaa !5
  %64 = getelementptr inbounds %struct.ipc_rate, ptr %63, i32 0, i32 3
  store double %62, ptr %64, align 8, !tbaa !18
  %65 = load ptr, ptr %4, align 8, !tbaa !5
  %66 = getelementptr inbounds %struct.ipc_rate, ptr %65, i32 0, i32 2
  %67 = load double, ptr %66, align 8, !tbaa !17
  %68 = load ptr, ptr %4, align 8, !tbaa !5
  %69 = getelementptr inbounds %struct.ipc_rate, ptr %68, i32 0, i32 0
  %70 = load double, ptr %69, align 8, !tbaa !13
  %71 = fdiv double %67, %70
  %72 = load ptr, ptr %4, align 8, !tbaa !5
  %73 = getelementptr inbounds %struct.ipc_rate, ptr %72, i32 0, i32 4
  store double %71, ptr %73, align 8, !tbaa !19
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #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 = !{!"long", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!14, !15, i64 0}
!14 = !{!"ipc_rate", !15, i64 0, !15, i64 8, !15, i64 16, !15, i64 24, !15, i64 32}
!15 = !{!"double", !7, i64 0}
!16 = !{!14, !15, i64 8}
!17 = !{!14, !15, i64 16}
!18 = !{!14, !15, i64 24}
!19 = !{!14, !15, i64 32}
!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"

; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: readwrite) uwtable
define dso_local void @get_ipc_core_ctr(ptr nocapture noundef readonly %0, ptr nocapture noundef writeonly %1) local_unnamed_addr #0 {
  %3 = getelementptr inbounds i8, ptr %1, i64 8
  %4 = getelementptr inbounds i8, ptr %1, i64 16
  %5 = getelementptr inbounds i8, ptr %1, i64 24
  %6 = getelementptr inbounds i8, ptr %0, i64 224
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(40) %1, i8 0, i64 40, i1 false)
  %7 = load <16 x i64>, ptr %0, align 8, !tbaa !5
  %8 = load <16 x i64>, ptr %6, align 8, !tbaa !5
  %9 = getelementptr inbounds i8, ptr %0, i64 128
  %10 = getelementptr inbounds i8, ptr %0, i64 352
  %11 = load <8 x i64>, ptr %9, align 8, !tbaa !5
  %12 = load <8 x i64>, ptr %10, align 8, !tbaa !5
  %13 = getelementptr inbounds i8, ptr %0, i64 192
  %14 = getelementptr inbounds i8, ptr %0, i64 416
  %15 = load <4 x i64>, ptr %13, align 8, !tbaa !5
  %16 = tail call i64 @llvm.vector.reduce.add.v16i64(<16 x i64> %7)
  %17 = tail call i64 @llvm.vector.reduce.add.v8i64(<8 x i64> %11)
  %op.rdx = add i64 %16, %17
  %18 = tail call i64 @llvm.vector.reduce.add.v4i64(<4 x i64> %15)
  %op.rdx31 = add i64 %op.rdx, %18
  %19 = load <4 x i64>, ptr %14, align 8, !tbaa !5
  %20 = tail call i64 @llvm.vector.reduce.add.v16i64(<16 x i64> %8)
  %21 = tail call i64 @llvm.vector.reduce.add.v8i64(<8 x i64> %12)
  %op.rdx32 = add i64 %20, %21
  %22 = tail call i64 @llvm.vector.reduce.add.v4i64(<4 x i64> %19)
  %op.rdx33 = add i64 %op.rdx32, %22
  %23 = uitofp i64 %op.rdx31 to double
  %24 = fdiv double %23, 2.800000e+01
  store double %24, ptr %1, align 8, !tbaa !9
  %25 = uitofp i64 %op.rdx33 to double
  %26 = fdiv double %25, 2.800000e+01
  store double %26, ptr %3, align 8, !tbaa !12
  store double %25, ptr %4, align 8, !tbaa !13
  %27 = insertelement <2 x double> poison, double %26, i64 0
  %28 = insertelement <2 x double> %27, double %25, i64 1
  %29 = insertelement <2 x double> poison, double %24, i64 0
  %30 = shufflevector <2 x double> %29, <2 x double> poison, <2 x i32> zeroinitializer
  %31 = fdiv <2 x double> %28, %30
  store <2 x double> %31, ptr %5, align 8, !tbaa !14
  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

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i64 @llvm.vector.reduce.add.v16i64(<16 x i64>) #2

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i64 @llvm.vector.reduce.add.v8i64(<8 x i64>) #2

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i64 @llvm.vector.reduce.add.v4i64(<4 x i64>) #2

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

!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 = !{!"long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !11, i64 0}
!10 = !{!"ipc_rate", !11, i64 0, !11, i64 8, !11, i64 16, !11, i64 24, !11, i64 32}
!11 = !{!"double", !7, i64 0}
!12 = !{!10, !11, i64 8}
!13 = !{!10, !11, i64 16}
!14 = !{!11, !11, i64 0}


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