; LLVM IR from google/benchmark :: test/diagnostics_test.ll (Z31BM_diagnostic_test_keep_runningRN9benchmark5StateE)

; 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"

@_ZZ31BM_diagnostic_test_keep_runningRN9benchmark5StateEE11called_once = external hidden global i8, align 1

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z24try_invalid_pause_resumeRN9benchmark5StateE(ptr noundef nonnull align 64 dereferenceable(184)) #0

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

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

; Function Attrs: alwaysinline mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZNK9benchmark5State10iterationsEv(ptr noundef nonnull align 64 dereferenceable(184)) #2 align 2

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

; Function Attrs: mustprogress uwtable
define dso_local void @_Z31BM_diagnostic_test_keep_runningRN9benchmark5StateE(ptr noundef nonnull align 64 dereferenceable(184) %0) #0 {
  %2 = alloca ptr, align 8
  %3 = alloca double, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  %4 = load i8, ptr @_ZZ31BM_diagnostic_test_keep_runningRN9benchmark5StateEE11called_once, align 1, !tbaa !9, !range !11, !noundef !12
  %5 = trunc i8 %4 to i1
  br i1 %5, label %8, label %6

6:                                                ; preds = %1
  %7 = load ptr, ptr %2, align 8, !tbaa !5
  call void @_Z24try_invalid_pause_resumeRN9benchmark5StateE(ptr noundef nonnull align 64 dereferenceable(184) %7)
  br label %8

8:                                                ; preds = %6, %1
  br label %9

9:                                                ; preds = %12, %8
  %10 = load ptr, ptr %2, align 8, !tbaa !5
  %11 = call noundef zeroext i1 @_ZN9benchmark5State11KeepRunningEv(ptr noundef nonnull align 64 dereferenceable(184) %10)
  br i1 %11, label %12, label %20

12:                                               ; preds = %9
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #4
  %13 = load ptr, ptr %2, align 8, !tbaa !5
  %14 = call noundef i64 @_ZNK9benchmark5State10iterationsEv(ptr noundef nonnull align 64 dereferenceable(184) %13)
  %15 = sitofp i64 %14 to double
  %16 = load ptr, ptr %2, align 8, !tbaa !5
  %17 = call noundef i64 @_ZNK9benchmark5State10iterationsEv(ptr noundef nonnull align 64 dereferenceable(184) %16)
  %18 = sitofp i64 %17 to double
  %19 = fmul double %15, %18
  store double %19, ptr %3, align 8, !tbaa !13
  call void @_ZN9benchmark13DoNotOptimizeIdEEvRT_(ptr noundef nonnull align 8 dereferenceable(8) %3)
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #4
  br label %9, !llvm.loop !15

20:                                               ; preds = %9
  %21 = load i8, ptr @_ZZ31BM_diagnostic_test_keep_runningRN9benchmark5StateEE11called_once, align 1, !tbaa !9, !range !11, !noundef !12
  %22 = trunc i8 %21 to i1
  br i1 %22, label %25, label %23

23:                                               ; preds = %20
  %24 = load ptr, ptr %2, align 8, !tbaa !5
  call void @_Z24try_invalid_pause_resumeRN9benchmark5StateE(ptr noundef nonnull align 64 dereferenceable(184) %24)
  br label %25

25:                                               ; preds = %23, %20
  store i8 1, ptr @_ZZ31BM_diagnostic_test_keep_runningRN9benchmark5StateEE11called_once, align 1, !tbaa !9
  ret void
}

; Function Attrs: alwaysinline mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN9benchmark5State11KeepRunningEv(ptr noundef nonnull align 64 dereferenceable(184)) #3 align 2

attributes #0 = { 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 #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #3 = { 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 #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 = !{!"bool", !7, i64 0}
!11 = !{i8 0, i8 2}
!12 = !{}
!13 = !{!14, !14, i64 0}
!14 = !{!"double", !7, i64 0}
!15 = distinct !{!15, !16}
!16 = !{!"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"

@_ZZ31BM_diagnostic_test_keep_runningRN9benchmark5StateEE11called_once = external hidden local_unnamed_addr global i8, align 1

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z24try_invalid_pause_resumeRN9benchmark5StateE(ptr noundef nonnull align 64 dereferenceable(184)) local_unnamed_addr #0

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

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

; Function Attrs: alwaysinline mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZNK9benchmark5State10iterationsEv(ptr noundef nonnull align 64 dereferenceable(184)) local_unnamed_addr #2 align 2

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

; Function Attrs: mustprogress uwtable
define dso_local void @_Z31BM_diagnostic_test_keep_runningRN9benchmark5StateE(ptr noundef nonnull align 64 dereferenceable(184) %0) local_unnamed_addr #0 {
  %2 = alloca double, align 8
  %3 = load i8, ptr @_ZZ31BM_diagnostic_test_keep_runningRN9benchmark5StateEE11called_once, align 1, !tbaa !5, !range !9, !noundef !10
  %4 = trunc nuw i8 %3 to i1
  br i1 %4, label %6, label %5

5:                                                ; preds = %1
  tail call void @_Z24try_invalid_pause_resumeRN9benchmark5StateE(ptr noundef nonnull align 64 dereferenceable(184) %0)
  br label %6

6:                                                ; preds = %5, %1
  %7 = tail call noundef zeroext i1 @_ZN9benchmark5State11KeepRunningEv(ptr noundef nonnull align 64 dereferenceable(184) %0)
  br i1 %7, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %6, %.lr.ph
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #4
  %8 = call noundef i64 @_ZNK9benchmark5State10iterationsEv(ptr noundef nonnull align 64 dereferenceable(184) %0)
  %9 = sitofp i64 %8 to double
  %10 = call noundef i64 @_ZNK9benchmark5State10iterationsEv(ptr noundef nonnull align 64 dereferenceable(184) %0)
  %11 = sitofp i64 %10 to double
  %12 = fmul double %9, %11
  store double %12, ptr %2, align 8, !tbaa !11
  call void @_ZN9benchmark13DoNotOptimizeIdEEvRT_(ptr noundef nonnull align 8 dereferenceable(8) %2)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #4
  %13 = call noundef zeroext i1 @_ZN9benchmark5State11KeepRunningEv(ptr noundef nonnull align 64 dereferenceable(184) %0)
  br i1 %13, label %.lr.ph, label %._crit_edge, !llvm.loop !13

._crit_edge:                                      ; preds = %.lr.ph, %6
  %14 = load i8, ptr @_ZZ31BM_diagnostic_test_keep_runningRN9benchmark5StateEE11called_once, align 1, !tbaa !5, !range !9, !noundef !10
  %15 = trunc nuw i8 %14 to i1
  br i1 %15, label %17, label %16

16:                                               ; preds = %._crit_edge
  call void @_Z24try_invalid_pause_resumeRN9benchmark5StateE(ptr noundef nonnull align 64 dereferenceable(184) %0)
  br label %17

17:                                               ; preds = %16, %._crit_edge
  store i8 1, ptr @_ZZ31BM_diagnostic_test_keep_runningRN9benchmark5StateEE11called_once, align 1, !tbaa !5
  ret void
}

; Function Attrs: alwaysinline mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN9benchmark5State11KeepRunningEv(ptr noundef nonnull align 64 dereferenceable(184)) local_unnamed_addr #3 align 2

attributes #0 = { 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 #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #3 = { 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 #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 = !{!"bool", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{i8 0, i8 2}
!10 = !{}
!11 = !{!12, !12, i64 0}
!12 = !{!"double", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}


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