; 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.bw_gibs = type { double, double, double, double, double, double }
%struct.ctrs_uncore = 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], [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], [28 x i64], [28 x i64], [28 x i64], [28 x i64], [28 x i64], [28 x i64], [28 x i64], i32 }

@.str.9 = 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_act_ddr_bw_uncore_ctrs(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
  store i64 0, ptr %7, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  store i64 0, ptr %8, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #3
  store i32 0, ptr %9, align 4, !tbaa !13
  %11 = load ptr, ptr %6, align 8, !tbaa !5
  %12 = getelementptr inbounds %struct.bw_gibs, ptr %11, i32 0, i32 0
  store double 0.000000e+00, ptr %12, align 8, !tbaa !15
  %13 = load ptr, ptr %6, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct.bw_gibs, ptr %13, i32 0, i32 1
  store double 0.000000e+00, ptr %14, align 8, !tbaa !17
  %15 = load ptr, ptr %6, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct.bw_gibs, ptr %15, i32 0, i32 2
  store double 0.000000e+00, ptr %16, align 8, !tbaa !18
  %17 = load ptr, ptr %6, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.bw_gibs, ptr %17, i32 0, i32 3
  store double 0.000000e+00, ptr %18, align 8, !tbaa !19
  %19 = load ptr, ptr %6, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.bw_gibs, ptr %19, i32 0, i32 4
  store double 0.000000e+00, ptr %20, align 8, !tbaa !20
  %21 = load ptr, ptr %6, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.bw_gibs, ptr %21, i32 0, i32 5
  store double 0.000000e+00, ptr %22, align 8, !tbaa !21
  %23 = load ptr, ptr %4, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.ctrs_uncore, ptr %23, i32 0, i32 32
  %25 = load i32, ptr %24, align 8, !tbaa !22
  %26 = icmp ne i32 %25, 0
  br i1 %26, label %27, label %29

27:                                               ; preds = %3
  %28 = call i32 (ptr, ...) @printf(ptr noundef @.str.9)
  store i32 1, ptr %10, align 4
  br label %70

29:                                               ; preds = %3
  store i32 0, ptr %9, align 4, !tbaa !13
  br label %30

30:                                               ; preds = %52, %29
  %31 = load i32, ptr %9, align 4, !tbaa !13
  %32 = icmp slt i32 %31, 6
  br i1 %32, label %33, label %55

33:                                               ; preds = %30
  %34 = load ptr, ptr %4, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.ctrs_uncore, ptr %34, i32 0, i32 0
  %36 = load i32, ptr %9, align 4, !tbaa !13
  %37 = sext i32 %36 to i64
  %38 = getelementptr inbounds [6 x i64], ptr %35, i64 0, i64 %37
  %39 = load i64, ptr %38, align 8, !tbaa !11
  %40 = mul i64 %39, 64
  %41 = load i64, ptr %7, align 8, !tbaa !11
  %42 = add i64 %41, %40
  store i64 %42, ptr %7, align 8, !tbaa !11
  %43 = load ptr, ptr %4, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.ctrs_uncore, ptr %43, i32 0, i32 1
  %45 = load i32, ptr %9, align 4, !tbaa !13
  %46 = sext i32 %45 to i64
  %47 = getelementptr inbounds [6 x i64], ptr %44, i64 0, i64 %46
  %48 = load i64, ptr %47, align 8, !tbaa !11
  %49 = mul i64 %48, 64
  %50 = load i64, ptr %8, align 8, !tbaa !11
  %51 = add i64 %50, %49
  store i64 %51, ptr %8, align 8, !tbaa !11
  br label %52

52:                                               ; preds = %33
  %53 = load i32, ptr %9, align 4, !tbaa !13
  %54 = add nsw i32 %53, 1
  store i32 %54, ptr %9, align 4, !tbaa !13
  br label %30, !llvm.loop !24

55:                                               ; preds = %30
  %56 = load i64, ptr %7, align 8, !tbaa !11
  %57 = uitofp i64 %56 to double
  %58 = load double, ptr %5, align 8, !tbaa !9
  %59 = fdiv double %57, %58
  %60 = fdiv double %59, 0x41D0000000000000
  %61 = load ptr, ptr %6, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct.bw_gibs, ptr %61, i32 0, i32 0
  store double %60, ptr %62, align 8, !tbaa !15
  %63 = load i64, ptr %8, align 8, !tbaa !11
  %64 = uitofp i64 %63 to double
  %65 = load double, ptr %5, align 8, !tbaa !9
  %66 = fdiv double %64, %65
  %67 = fdiv double %66, 0x41D0000000000000
  %68 = load ptr, ptr %6, align 8, !tbaa !5
  %69 = getelementptr inbounds %struct.bw_gibs, ptr %68, i32 0, i32 2
  store double %67, ptr %69, align 8, !tbaa !18
  store i32 0, ptr %10, align 4
  br label %70

70:                                               ; preds = %55, %27
  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
  %71 = load i32, ptr %10, align 4
  switch i32 %71, label %73 [
    i32 0, label %72
    i32 1, label %72
  ]

72:                                               ; preds = %70, %70
  ret void

73:                                               ; preds = %70
  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, !14, i64 0}
!14 = !{!"int", !7, i64 0}
!15 = !{!16, !10, i64 0}
!16 = !{!"bw_gibs", !10, i64 0, !10, i64 8, !10, i64 16, !10, i64 24, !10, i64 32, !10, i64 40}
!17 = !{!16, !10, i64 8}
!18 = !{!16, !10, i64 16}
!19 = !{!16, !10, i64 24}
!20 = !{!16, !10, i64 32}
!21 = !{!16, !10, i64 40}
!22 = !{!23, !14, i64 6288}
!23 = !{!"ctrs_uncore", !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, !7, i64 2256, !7, i64 2480, !7, i64 2704, !7, i64 2928, !7, i64 3152, !7, i64 3376, !7, i64 3600, !7, i64 3824, !7, i64 4048, !7, i64 4272, !7, i64 4496, !7, i64 4720, !7, i64 4944, !7, i64 5168, !7, i64 5392, !7, i64 5616, !7, i64 5840, !7, i64 6064, !14, i64 6288}
!24 = distinct !{!24, !25}
!25 = !{!"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.9 = 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_act_ddr_bw_uncore_ctrs(ptr nocapture noundef readonly %0, double noundef %1, ptr nocapture noundef writeonly %2) local_unnamed_addr #1 {
  %4 = getelementptr inbounds i8, ptr %0, i64 6288
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(48) %2, i8 0, i64 48, i1 false)
  %5 = load i32, ptr %4, align 8, !tbaa !5
  %.not = icmp eq i32 %5, 0
  br i1 %.not, label %.preheader, label %48

.preheader:                                       ; preds = %3
  %6 = getelementptr inbounds i8, ptr %2, i64 16
  %7 = getelementptr inbounds i8, ptr %0, i64 48
  %8 = load i64, ptr %0, align 8, !tbaa !10
  %9 = load i64, ptr %7, align 8, !tbaa !10
  %10 = getelementptr inbounds i8, ptr %0, i64 8
  %11 = load i64, ptr %10, align 8, !tbaa !10
  %12 = add i64 %11, %8
  %13 = getelementptr inbounds i8, ptr %0, i64 56
  %14 = load i64, ptr %13, align 8, !tbaa !10
  %15 = add i64 %14, %9
  %16 = getelementptr inbounds i8, ptr %0, i64 16
  %17 = load i64, ptr %16, align 8, !tbaa !10
  %18 = add i64 %17, %12
  %19 = getelementptr inbounds i8, ptr %0, i64 64
  %20 = load i64, ptr %19, align 8, !tbaa !10
  %21 = add i64 %20, %15
  %22 = getelementptr inbounds i8, ptr %0, i64 24
  %23 = load i64, ptr %22, align 8, !tbaa !10
  %24 = add i64 %23, %18
  %25 = getelementptr inbounds i8, ptr %0, i64 72
  %26 = load i64, ptr %25, align 8, !tbaa !10
  %27 = add i64 %26, %21
  %28 = getelementptr inbounds i8, ptr %0, i64 32
  %29 = load i64, ptr %28, align 8, !tbaa !10
  %30 = add i64 %29, %24
  %31 = getelementptr inbounds i8, ptr %0, i64 80
  %32 = load i64, ptr %31, align 8, !tbaa !10
  %33 = add i64 %32, %27
  %34 = getelementptr inbounds i8, ptr %0, i64 40
  %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 88
  %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
  store double %47, ptr %6, align 8, !tbaa !15
  br label %50

48:                                               ; preds = %3
  %49 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.9)
  br label %50

50:                                               ; preds = %.preheader, %48
  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 6288}
!6 = !{!"ctrs_uncore", !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, !7, i64 2256, !7, i64 2480, !7, i64 2704, !7, i64 2928, !7, i64 3152, !7, i64 3376, !7, i64 3600, !7, i64 3824, !7, i64 4048, !7, i64 4272, !7, i64 4496, !7, i64 4720, !7, i64 4944, !7, i64 5168, !7, i64 5392, !7, i64 5616, !7, i64 5840, !7, i64 6064, !9, i64 6288}
!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, i64 16, !14, i64 24, !14, i64 32, !14, i64 40}
!14 = !{!"double", !7, i64 0}
!15 = !{!13, !14, i64 16}


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