; LLVM IR from stan-dev/math :: lib/tbb_2020.3/src/test (test_atomic)

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

%"class.Harness::internal::Tracer" = type <{ i32, [4 x i8], ptr, ptr, i64, [8 x i8] }>
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<void (*)(), std::allocator<void (*)()>>::_Vector_impl" }
%"struct.std::_Vector_base<void (*)(), std::allocator<void (*)()>>::_Vector_impl" = type { %"struct.std::_Vector_base<void (*)(), std::allocator<void (*)()>>::_Vector_impl_data" }
%"struct.std::_Vector_base<void (*)(), std::allocator<void (*)()>>::_Vector_impl_data" = type { ptr, ptr, ptr }

@_ZN7Harness8internalL6tracerE = external hidden global %"class.Harness::internal::Tracer", align 8
@.str.18 = external hidden unnamed_addr constant [87 x i8], align 1
@_ZN48TestConstExprInitializationOfGlobalObjectsHelper28auto_registered_tests_helperL16const_expr_testsE = external hidden global %"class.std::vector", align 8
@_ZL7Verbose = external hidden global i8, align 1
@__FUNCTION__._ZN48TestConstExprInitializationOfGlobalObjectsHelper17CallExprInitTestsEv = external hidden unnamed_addr constant [18 x i8], align 1
@.str.26 = external hidden unnamed_addr constant [36 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: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZN7Harness8internal6Tracer14set_trace_infoEiPKcmS3_(ptr noundef nonnull align 8 dereferenceable(33), i32 noundef, ptr noundef, i64 noundef, ptr noundef) #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN7Harness8internal6Tracer5traceEPKcz(ptr noundef nonnull align 8 dereferenceable(33), ptr noundef, ...) #2 align 2

; 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 @_ZN48TestConstExprInitializationOfGlobalObjectsHelper17CallExprInitTestsEv() #2 {
  %1 = alloca i64, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %1) #3
  store i64 0, ptr %1, align 8, !tbaa !5
  br label %2

2:                                                ; preds = %11, %0
  %3 = load i64, ptr %1, align 8, !tbaa !5
  %4 = call noundef i64 @_ZNKSt6vectorIPFvvESaIS1_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) @_ZN48TestConstExprInitializationOfGlobalObjectsHelper28auto_registered_tests_helperL16const_expr_testsE) #3
  %5 = icmp ult i64 %3, %4
  br i1 %5, label %7, label %6

6:                                                ; preds = %2
  call void @llvm.lifetime.end.p0(i64 8, ptr %1) #3
  br label %14

7:                                                ; preds = %2
  %8 = load i64, ptr %1, align 8, !tbaa !5
  %9 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIPFvvESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) @_ZN48TestConstExprInitializationOfGlobalObjectsHelper28auto_registered_tests_helperL16const_expr_testsE, i64 noundef %8) #3
  %10 = load ptr, ptr %9, align 8, !tbaa !9
  call void %10()
  br label %11

11:                                               ; preds = %7
  %12 = load i64, ptr %1, align 8, !tbaa !5
  %13 = add i64 %12, 1
  store i64 %13, ptr %1, align 8, !tbaa !5
  br label %2, !llvm.loop !11

14:                                               ; preds = %6
  %15 = load i8, ptr @_ZL7Verbose, align 1, !tbaa !13, !range !15, !noundef !16
  %16 = trunc i8 %15 to i1
  br i1 %16, label %18, label %17

17:                                               ; preds = %14
  br label %21

18:                                               ; preds = %14
  %19 = call noundef ptr @_ZN7Harness8internal6Tracer14set_trace_infoEiPKcmS3_(ptr noundef nonnull align 8 dereferenceable(33) @_ZN7Harness8internalL6tracerE, i32 noundef 0, ptr noundef @.str.18, i64 noundef 493, ptr noundef @__FUNCTION__._ZN48TestConstExprInitializationOfGlobalObjectsHelper17CallExprInitTestsEv)
  %20 = call noundef i64 @_ZNKSt6vectorIPFvvESaIS1_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) @_ZN48TestConstExprInitializationOfGlobalObjectsHelper28auto_registered_tests_helperL16const_expr_testsE) #3
  call void (ptr, ptr, ...) @_ZN7Harness8internal6Tracer5traceEPKcz(ptr noundef nonnull align 8 dereferenceable(33) %19, ptr noundef @.str.26, i64 noundef %20)
  br label %21

21:                                               ; preds = %18, %17
  ret void
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZNKSt6vectorIPFvvESaIS1_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24)) #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIPFvvESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) #1 align 2

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


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

%"class.Harness::internal::Tracer" = type <{ i32, [4 x i8], ptr, ptr, i64, [8 x i8] }>
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<void (*)(), std::allocator<void (*)()>>::_Vector_impl" }
%"struct.std::_Vector_base<void (*)(), std::allocator<void (*)()>>::_Vector_impl" = type { %"struct.std::_Vector_base<void (*)(), std::allocator<void (*)()>>::_Vector_impl_data" }
%"struct.std::_Vector_base<void (*)(), std::allocator<void (*)()>>::_Vector_impl_data" = type { ptr, ptr, ptr }

@_ZN7Harness8internalL6tracerE = external hidden global %"class.Harness::internal::Tracer", align 8
@.str.18 = external hidden unnamed_addr constant [87 x i8], align 1
@_ZN48TestConstExprInitializationOfGlobalObjectsHelper28auto_registered_tests_helperL16const_expr_testsE = external hidden global %"class.std::vector", align 8
@_ZL7Verbose = external hidden local_unnamed_addr global i8, align 1
@__FUNCTION__._ZN48TestConstExprInitializationOfGlobalObjectsHelper17CallExprInitTestsEv = external hidden unnamed_addr constant [18 x i8], align 1
@.str.26 = external hidden unnamed_addr constant [36 x i8], align 1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZN7Harness8internal6Tracer14set_trace_infoEiPKcmS3_(ptr noundef nonnull align 8 dereferenceable(33), i32 noundef, ptr noundef, i64 noundef, ptr noundef) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN7Harness8internal6Tracer5traceEPKcz(ptr noundef nonnull align 8 dereferenceable(33), ptr noundef, ...) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN48TestConstExprInitializationOfGlobalObjectsHelper17CallExprInitTestsEv() local_unnamed_addr #1 {
  %1 = tail call noundef i64 @_ZNKSt6vectorIPFvvESaIS1_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) @_ZN48TestConstExprInitializationOfGlobalObjectsHelper28auto_registered_tests_helperL16const_expr_testsE) #2
  %.not = icmp eq i64 %1, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph

._crit_edge:                                      ; preds = %.lr.ph, %0
  %2 = load i8, ptr @_ZL7Verbose, align 1, !tbaa !5, !range !9, !noundef !10
  %3 = trunc nuw i8 %2 to i1
  br i1 %3, label %9, label %12

.lr.ph:                                           ; preds = %0, %.lr.ph
  %.03 = phi i64 [ %6, %.lr.ph ], [ 0, %0 ]
  %4 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIPFvvESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) @_ZN48TestConstExprInitializationOfGlobalObjectsHelper28auto_registered_tests_helperL16const_expr_testsE, i64 noundef %.03) #2
  %5 = load ptr, ptr %4, align 8, !tbaa !11
  tail call void %5()
  %6 = add nuw i64 %.03, 1
  %7 = tail call noundef i64 @_ZNKSt6vectorIPFvvESaIS1_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) @_ZN48TestConstExprInitializationOfGlobalObjectsHelper28auto_registered_tests_helperL16const_expr_testsE) #2
  %8 = icmp ult i64 %6, %7
  br i1 %8, label %.lr.ph, label %._crit_edge, !llvm.loop !13

9:                                                ; preds = %._crit_edge
  %10 = tail call noundef ptr @_ZN7Harness8internal6Tracer14set_trace_infoEiPKcmS3_(ptr noundef nonnull align 8 dereferenceable(33) @_ZN7Harness8internalL6tracerE, i32 noundef 0, ptr noundef nonnull @.str.18, i64 noundef 493, ptr noundef nonnull @__FUNCTION__._ZN48TestConstExprInitializationOfGlobalObjectsHelper17CallExprInitTestsEv)
  %11 = tail call noundef i64 @_ZNKSt6vectorIPFvvESaIS1_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) @_ZN48TestConstExprInitializationOfGlobalObjectsHelper28auto_registered_tests_helperL16const_expr_testsE) #2
  tail call void (ptr, ptr, ...) @_ZN7Harness8internal6Tracer5traceEPKcz(ptr noundef nonnull align 8 dereferenceable(33) %10, ptr noundef nonnull @.str.26, i64 noundef %11)
  br label %12

12:                                               ; preds = %._crit_edge, %9
  ret void
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZNKSt6vectorIPFvvESaIS1_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIPFvvESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) local_unnamed_addr #0 align 2

attributes #0 = { 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 #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 = { 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 = !{!"any pointer", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}


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