; LLVM IR from codee-com/open-catalog :: Benchmark/external/google_benchmark/test (perf_counters_test)

; 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.benchmark::State::StateIterator" = type { i64, ptr }
%"struct.benchmark::State::StateIterator::Value" = type { i8 }

; 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: mustprogress uwtable
define dso_local void @_Z21BM_WithoutPauseResumeRN9benchmark5StateE(ptr noundef nonnull align 8 dereferenceable(176) %0) #1 {
  %2 = alloca ptr, align 8
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca %"struct.benchmark::State::StateIterator", align 8
  %6 = alloca %"struct.benchmark::State::StateIterator", align 8
  %7 = alloca i32, align 4
  %8 = alloca %"struct.benchmark::State::StateIterator::Value", align 1
  %9 = alloca %"struct.benchmark::State::StateIterator::Value", align 1
  %10 = alloca i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #4
  store i32 0, ptr %3, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #4
  %11 = load ptr, ptr %2, align 8, !tbaa !5
  store ptr %11, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 16, ptr %5) #4
  %12 = load ptr, ptr %4, align 8, !tbaa !5
  %13 = call { i64, ptr } @_ZN9benchmark5State5beginEv(ptr noundef nonnull align 8 dereferenceable(176) %12)
  %14 = getelementptr inbounds { i64, ptr }, ptr %5, i32 0, i32 0
  %15 = extractvalue { i64, ptr } %13, 0
  store i64 %15, ptr %14, align 8
  %16 = getelementptr inbounds { i64, ptr }, ptr %5, i32 0, i32 1
  %17 = extractvalue { i64, ptr } %13, 1
  store ptr %17, ptr %16, align 8
  call void @llvm.lifetime.start.p0(i64 16, ptr %6) #4
  %18 = load ptr, ptr %4, align 8, !tbaa !5
  %19 = call { i64, ptr } @_ZN9benchmark5State3endEv(ptr noundef nonnull align 8 dereferenceable(176) %18)
  %20 = getelementptr inbounds { i64, ptr }, ptr %6, i32 0, i32 0
  %21 = extractvalue { i64, ptr } %19, 0
  store i64 %21, ptr %20, align 8
  %22 = getelementptr inbounds { i64, ptr }, ptr %6, i32 0, i32 1
  %23 = extractvalue { i64, ptr } %19, 1
  store ptr %23, ptr %22, align 8
  br label %24

24:                                               ; preds = %39, %1
  %25 = call noundef zeroext i1 @_ZNK9benchmark5State13StateIteratorneERKS1_(ptr noundef nonnull align 8 dereferenceable(16) %5, ptr noundef nonnull align 8 dereferenceable(16) %6)
  br i1 %25, label %27, label %26

26:                                               ; preds = %24
  store i32 2, ptr %7, align 4
  call void @llvm.lifetime.end.p0(i64 16, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr %5) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #4
  br label %41

27:                                               ; preds = %24
  call void @llvm.lifetime.start.p0(i64 1, ptr %8) #4
  call void @_ZNK9benchmark5State13StateIteratordeEv(ptr noundef nonnull align 8 dereferenceable(16) %5)
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #4
  store i32 0, ptr %10, align 4, !tbaa !9
  br label %28

28:                                               ; preds = %35, %27
  %29 = load i32, ptr %10, align 4, !tbaa !9
  %30 = icmp slt i32 %29, 1000000
  br i1 %30, label %32, label %31

31:                                               ; preds = %28
  store i32 4, ptr %7, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #4
  br label %38

32:                                               ; preds = %28
  %33 = load i32, ptr %3, align 4, !tbaa !9
  %34 = sub nsw i32 1, %33
  store i32 %34, ptr %3, align 4, !tbaa !9
  call void @_ZN9benchmark13DoNotOptimizeIiEEvRT_(ptr noundef nonnull align 4 dereferenceable(4) %3)
  br label %35

35:                                               ; preds = %32
  %36 = load i32, ptr %10, align 4, !tbaa !9
  %37 = add nsw i32 %36, 1
  store i32 %37, ptr %10, align 4, !tbaa !9
  br label %28, !llvm.loop !11

38:                                               ; preds = %31
  call void @llvm.lifetime.end.p0(i64 1, ptr %8) #4
  br label %39

39:                                               ; preds = %38
  %40 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZN9benchmark5State13StateIteratorppEv(ptr noundef nonnull align 8 dereferenceable(16) %5)
  br label %24

41:                                               ; preds = %26
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #4
  ret void
}

; Function Attrs: alwaysinline mustprogress uwtable
declare dso_local { i64, ptr } @_ZN9benchmark5State5beginEv(ptr noundef nonnull align 8 dereferenceable(176)) #2 align 2

; Function Attrs: alwaysinline mustprogress uwtable
declare dso_local { i64, ptr } @_ZN9benchmark5State3endEv(ptr noundef nonnull align 8 dereferenceable(176)) #2 align 2

; Function Attrs: alwaysinline mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZNK9benchmark5State13StateIteratorneERKS1_(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(16)) #2 align 2

; Function Attrs: alwaysinline mustprogress nounwind uwtable
declare dso_local void @_ZNK9benchmark5State13StateIteratordeEv(ptr noundef nonnull align 8 dereferenceable(16)) #3 align 2

; Function Attrs: alwaysinline mustprogress nounwind uwtable
declare dso_local void @_ZN9benchmark13DoNotOptimizeIiEEvRT_(ptr noundef nonnull align 4 dereferenceable(4)) #3

; Function Attrs: alwaysinline mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(16) ptr @_ZN9benchmark5State13StateIteratorppEv(ptr noundef nonnull align 8 dereferenceable(16)) #3 align 2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress 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 = { alwaysinline mustprogress 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 = { alwaysinline mustprogress 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 #4 = { 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++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"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"

%"struct.benchmark::State::StateIterator" = type { i64, ptr }

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: mustprogress uwtable
define dso_local void @_Z21BM_WithoutPauseResumeRN9benchmark5StateE(ptr noundef nonnull align 8 dereferenceable(176) %0) local_unnamed_addr #1 {
  %2 = alloca i32, align 4
  %3 = alloca %"struct.benchmark::State::StateIterator", align 8
  %4 = alloca %"struct.benchmark::State::StateIterator", align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #4
  store i32 0, ptr %2, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %3) #4
  %5 = tail call { i64, ptr } @_ZN9benchmark5State5beginEv(ptr noundef nonnull align 8 dereferenceable(176) %0)
  %6 = extractvalue { i64, ptr } %5, 0
  store i64 %6, ptr %3, align 8
  %7 = getelementptr inbounds i8, ptr %3, i64 8
  %8 = extractvalue { i64, ptr } %5, 1
  store ptr %8, ptr %7, align 8
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %4) #4
  %9 = tail call { i64, ptr } @_ZN9benchmark5State3endEv(ptr noundef nonnull align 8 dereferenceable(176) %0)
  %10 = extractvalue { i64, ptr } %9, 0
  store i64 %10, ptr %4, align 8
  %11 = getelementptr inbounds i8, ptr %4, i64 8
  %12 = extractvalue { i64, ptr } %9, 1
  store ptr %12, ptr %11, align 8
  %13 = call noundef zeroext i1 @_ZNK9benchmark5State13StateIteratorneERKS1_(ptr noundef nonnull align 8 dereferenceable(16) %3, ptr noundef nonnull align 8 dereferenceable(16) %4)
  br i1 %13, label %.lr.ph, label %._crit_edge

._crit_edge:                                      ; preds = %14, %1
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %4) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %3) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #4
  ret void

.lr.ph:                                           ; preds = %1, %14
  call void @_ZNK9benchmark5State13StateIteratordeEv(ptr noundef nonnull align 8 dereferenceable(16) %3)
  br label %17

14:                                               ; preds = %17
  %15 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZN9benchmark5State13StateIteratorppEv(ptr noundef nonnull align 8 dereferenceable(16) %3)
  %16 = call noundef zeroext i1 @_ZNK9benchmark5State13StateIteratorneERKS1_(ptr noundef nonnull align 8 dereferenceable(16) %3, ptr noundef nonnull align 8 dereferenceable(16) %4)
  br i1 %16, label %.lr.ph, label %._crit_edge

17:                                               ; preds = %.lr.ph, %17
  %.04 = phi i32 [ 0, %.lr.ph ], [ %20, %17 ]
  %18 = load i32, ptr %2, align 4, !tbaa !5
  %19 = sub nsw i32 1, %18
  store i32 %19, ptr %2, align 4, !tbaa !5
  call void @_ZN9benchmark13DoNotOptimizeIiEEvRT_(ptr noundef nonnull align 4 dereferenceable(4) %2)
  %20 = add nuw nsw i32 %.04, 1
  %exitcond.not = icmp eq i32 %20, 1000000
  br i1 %exitcond.not, label %14, label %17, !llvm.loop !9
}

; Function Attrs: alwaysinline mustprogress uwtable
declare dso_local { i64, ptr } @_ZN9benchmark5State5beginEv(ptr noundef nonnull align 8 dereferenceable(176)) local_unnamed_addr #2 align 2

; Function Attrs: alwaysinline mustprogress uwtable
declare dso_local { i64, ptr } @_ZN9benchmark5State3endEv(ptr noundef nonnull align 8 dereferenceable(176)) local_unnamed_addr #2 align 2

; Function Attrs: alwaysinline mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZNK9benchmark5State13StateIteratorneERKS1_(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #2 align 2

; Function Attrs: alwaysinline mustprogress nounwind uwtable
declare dso_local void @_ZNK9benchmark5State13StateIteratordeEv(ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #3 align 2

; Function Attrs: alwaysinline mustprogress nounwind uwtable
declare dso_local void @_ZN9benchmark13DoNotOptimizeIiEEvRT_(ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #3

; Function Attrs: alwaysinline mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(16) ptr @_ZN9benchmark5State13StateIteratorppEv(ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #3 align 2

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress 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 = { alwaysinline mustprogress 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 = { alwaysinline mustprogress 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 #4 = { 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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass