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

; 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.tbb::tick_count" = type { i64 }

@.str = external hidden unnamed_addr constant [91 x i8], align 1
@_ZN7Harness8internalL6tracerE = external hidden global %"class.Harness::internal::Tracer", align 8
@_ZL7Verbose = external hidden global i8, align 1
@.str.35 = external hidden unnamed_addr constant [16 x i8], align 1
@__FUNCTION__._Z8TestMainv = external hidden unnamed_addr constant [9 x i8], align 1
@.str.36 = external hidden unnamed_addr constant [28 x i8], align 1
@.str.37 = external hidden unnamed_addr constant [16 x i8], align 1
@.str.38 = external hidden unnamed_addr constant [68 x i8], align 1
@.str.39 = external hidden unnamed_addr constant [18 x i8], align 1
@.str.40 = external hidden unnamed_addr constant [82 x i8], align 1

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z11ReportErrorPKciS0_S0_(ptr noundef, i32 noundef, ptr noundef, ptr noundef) #0

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z14TestArithmeticRKN3tbb10tick_countES2_S2_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) #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: 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) #2 align 2

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

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_Z8TestMainv() #0 {
  %1 = alloca double, align 8
  %2 = alloca %"class.tbb::tick_count", align 8
  %3 = alloca %"class.tbb::tick_count", align 8
  %4 = alloca %"class.tbb::tick_count", align 8
  %5 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 8, ptr %1) #5
  %6 = call noundef ptr @_ZN7Harness6GetEnvEPKc(ptr noundef @.str.35)
  %7 = icmp ne ptr %6, null
  %8 = zext i1 %7 to i64
  %9 = select i1 %7, double 5.000000e+01, double 1.000000e+00
  store double %9, ptr %1, align 8, !tbaa !5
  %10 = load i8, ptr @_ZL7Verbose, align 1, !tbaa !9, !range !11, !noundef !12
  %11 = trunc i8 %10 to i1
  br i1 %11, label %13, label %12

12:                                               ; preds = %0
  br label %16

13:                                               ; preds = %0
  %14 = call noundef ptr @_ZN7Harness8internal6Tracer14set_trace_infoEiPKcmS3_(ptr noundef nonnull align 8 dereferenceable(33) @_ZN7Harness8internalL6tracerE, i32 noundef 0, ptr noundef @.str, i64 noundef 178, ptr noundef @__FUNCTION__._Z8TestMainv)
  %15 = load double, ptr %1, align 8, !tbaa !5
  call void (ptr, ptr, ...) @_ZN7Harness8internal6Tracer5traceEPKcz(ptr noundef nonnull align 8 dereferenceable(33) %14, ptr noundef @.str.36, double noundef %15)
  br label %16

16:                                               ; preds = %13, %12
  call void @llvm.lifetime.start.p0(i64 8, ptr %2) #5
  %17 = call i64 @_ZN3tbb10tick_count3nowEv()
  %18 = getelementptr inbounds %"class.tbb::tick_count", ptr %2, i32 0, i32 0
  store i64 %17, ptr %18, align 8
  %19 = load double, ptr %1, align 8, !tbaa !5
  %20 = fmul double 6.000000e-06, %19
  call void @_Z15TestSimpleDelayidd(i32 noundef 1000000, double noundef 0.000000e+00, double noundef %20)
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #5
  %21 = call i64 @_ZN3tbb10tick_count3nowEv()
  %22 = getelementptr inbounds %"class.tbb::tick_count", ptr %3, i32 0, i32 0
  store i64 %21, ptr %22, align 8
  %23 = load double, ptr %1, align 8, !tbaa !5
  %24 = fmul double 1.500000e-05, %23
  call void @_Z15TestSimpleDelayidd(i32 noundef 1000, double noundef 1.000000e-03, double noundef %24)
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #5
  %25 = call i64 @_ZN3tbb10tick_count3nowEv()
  %26 = getelementptr inbounds %"class.tbb::tick_count", ptr %4, i32 0, i32 0
  store i64 %25, ptr %26, align 8
  call void @_Z14TestArithmeticRKN3tbb10tick_countES2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %2, ptr noundef nonnull align 8 dereferenceable(8) %3, ptr noundef nonnull align 8 dereferenceable(8) %4)
  call void @_Z14TestResolutionv()
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #5
  %27 = call noundef i32 @_ZN3tbb8internal13tbb_thread_v320hardware_concurrencyEv() #5
  store i32 %27, ptr %5, align 4, !tbaa !13
  %28 = load i32, ptr %5, align 4, !tbaa !13
  %29 = icmp sgt i32 %28, 0
  br i1 %29, label %30, label %31

30:                                               ; preds = %16
  br label %32

31:                                               ; preds = %16
  call void @_Z11ReportErrorPKciS0_S0_(ptr noundef @.str, i32 noundef 190, ptr noundef @.str.37, ptr noundef @.str.38)
  br label %32

32:                                               ; preds = %31, %30
  %33 = load i32, ptr %5, align 4, !tbaa !13
  %34 = icmp sgt i32 %33, 1
  br i1 %34, label %35, label %44

35:                                               ; preds = %32
  %36 = load i8, ptr @_ZL7Verbose, align 1, !tbaa !9, !range !11, !noundef !12
  %37 = trunc i8 %36 to i1
  br i1 %37, label %39, label %38

38:                                               ; preds = %35
  br label %42

39:                                               ; preds = %35
  %40 = call noundef ptr @_ZN7Harness8internal6Tracer14set_trace_infoEiPKcmS3_(ptr noundef nonnull align 8 dereferenceable(33) @_ZN7Harness8internalL6tracerE, i32 noundef 0, ptr noundef @.str, i64 noundef 192, ptr noundef @__FUNCTION__._Z8TestMainv)
  %41 = load i32, ptr %5, align 4, !tbaa !13
  call void (ptr, ptr, ...) @_ZN7Harness8internal6Tracer5traceEPKcz(ptr noundef nonnull align 8 dereferenceable(33) %40, ptr noundef @.str.39, i32 noundef %41)
  br label %42

42:                                               ; preds = %39, %38
  %43 = load i32, ptr %5, align 4, !tbaa !13
  call void @_Z23TestTickCountDifferencei(i32 noundef %43)
  br label %47

44:                                               ; preds = %32
  %45 = call noundef ptr @_ZN7Harness8internal6Tracer14set_trace_infoEiPKcmS3_(ptr noundef nonnull align 8 dereferenceable(33) @_ZN7Harness8internalL6tracerE, i32 noundef 0, ptr noundef @.str, i64 noundef 195, ptr noundef @__FUNCTION__._Z8TestMainv)
  %46 = load i32, ptr %5, align 4, !tbaa !13
  call void (ptr, ptr, ...) @_ZN7Harness8internal6Tracer5traceEPKcz(ptr noundef nonnull align 8 dereferenceable(33) %45, ptr noundef @.str.40, i32 noundef %46)
  br label %47

47:                                               ; preds = %44, %42
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %2) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %1) #5
  ret i32 0
}

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_ZN7Harness6GetEnvEPKc(ptr noundef) #0

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z15TestSimpleDelayidd(i32 noundef, double noundef, double noundef) #0

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local i64 @_ZN3tbb10tick_count3nowEv() #3 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z23TestTickCountDifferencei(i32 noundef) #0

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z14TestResolutionv() #0

; Function Attrs: nounwind
declare noundef i32 @_ZN3tbb8internal13tbb_thread_v320hardware_concurrencyEv() #4

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 = { 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 = { inlinehint 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 "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 #5 = { 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 = !{!"double", !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 = !{!"int", !7, i64 0}


; 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.tbb::tick_count" = type { i64 }

@.str = external hidden unnamed_addr constant [91 x i8], align 1
@_ZN7Harness8internalL6tracerE = external hidden global %"class.Harness::internal::Tracer", align 8
@_ZL7Verbose = external hidden local_unnamed_addr global i8, align 1
@.str.35 = external hidden unnamed_addr constant [16 x i8], align 1
@__FUNCTION__._Z8TestMainv = external hidden unnamed_addr constant [9 x i8], align 1
@.str.36 = external hidden unnamed_addr constant [28 x i8], align 1
@.str.37 = external hidden unnamed_addr constant [16 x i8], align 1
@.str.38 = external hidden unnamed_addr constant [68 x i8], align 1
@.str.39 = external hidden unnamed_addr constant [18 x i8], align 1
@.str.40 = external hidden unnamed_addr constant [82 x i8], align 1

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z11ReportErrorPKciS0_S0_(ptr noundef, i32 noundef, ptr noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z14TestArithmeticRKN3tbb10tick_countES2_S2_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) 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: 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 #2 align 2

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

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_Z8TestMainv() local_unnamed_addr #0 {
  %1 = alloca %"class.tbb::tick_count", align 8
  %2 = alloca %"class.tbb::tick_count", align 8
  %3 = alloca %"class.tbb::tick_count", align 8
  %4 = tail call noundef ptr @_ZN7Harness6GetEnvEPKc(ptr noundef nonnull @.str.35)
  %.not = icmp eq ptr %4, null
  %5 = select i1 %.not, double 1.000000e+00, double 5.000000e+01
  %6 = load i8, ptr @_ZL7Verbose, align 1, !tbaa !5, !range !9, !noundef !10
  %7 = trunc nuw i8 %6 to i1
  br i1 %7, label %8, label %10

8:                                                ; preds = %0
  %9 = tail call noundef ptr @_ZN7Harness8internal6Tracer14set_trace_infoEiPKcmS3_(ptr noundef nonnull align 8 dereferenceable(33) @_ZN7Harness8internalL6tracerE, i32 noundef 0, ptr noundef nonnull @.str, i64 noundef 178, ptr noundef nonnull @__FUNCTION__._Z8TestMainv)
  tail call void (ptr, ptr, ...) @_ZN7Harness8internal6Tracer5traceEPKcz(ptr noundef nonnull align 8 dereferenceable(33) %9, ptr noundef nonnull @.str.36, double noundef %5)
  br label %10

10:                                               ; preds = %0, %8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %1) #5
  %11 = tail call i64 @_ZN3tbb10tick_count3nowEv()
  store i64 %11, ptr %1, align 8
  %12 = fmul double %5, 6.000000e-06
  tail call void @_Z15TestSimpleDelayidd(i32 noundef 1000000, double noundef 0.000000e+00, double noundef %12)
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #5
  %13 = tail call i64 @_ZN3tbb10tick_count3nowEv()
  store i64 %13, ptr %2, align 8
  %14 = fmul double %5, 1.500000e-05
  tail call void @_Z15TestSimpleDelayidd(i32 noundef 1000, double noundef 1.000000e-03, double noundef %14)
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #5
  %15 = tail call i64 @_ZN3tbb10tick_count3nowEv()
  store i64 %15, ptr %3, align 8
  call void @_Z14TestArithmeticRKN3tbb10tick_countES2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %1, ptr noundef nonnull align 8 dereferenceable(8) %2, ptr noundef nonnull align 8 dereferenceable(8) %3)
  call void @_Z14TestResolutionv()
  %16 = call noundef i32 @_ZN3tbb8internal13tbb_thread_v320hardware_concurrencyEv() #5
  %17 = icmp sgt i32 %16, 0
  br i1 %17, label %18, label %.thread

.thread:                                          ; preds = %10
  call void @_Z11ReportErrorPKciS0_S0_(ptr noundef nonnull @.str, i32 noundef 190, ptr noundef nonnull @.str.37, ptr noundef nonnull @.str.38)
  br label %25

18:                                               ; preds = %10
  %.not7 = icmp eq i32 %16, 1
  br i1 %.not7, label %25, label %19

19:                                               ; preds = %18
  %20 = load i8, ptr @_ZL7Verbose, align 1, !tbaa !5, !range !9, !noundef !10
  %21 = trunc nuw i8 %20 to i1
  br i1 %21, label %22, label %24

22:                                               ; preds = %19
  %23 = call noundef ptr @_ZN7Harness8internal6Tracer14set_trace_infoEiPKcmS3_(ptr noundef nonnull align 8 dereferenceable(33) @_ZN7Harness8internalL6tracerE, i32 noundef 0, ptr noundef nonnull @.str, i64 noundef 192, ptr noundef nonnull @__FUNCTION__._Z8TestMainv)
  call void (ptr, ptr, ...) @_ZN7Harness8internal6Tracer5traceEPKcz(ptr noundef nonnull align 8 dereferenceable(33) %23, ptr noundef nonnull @.str.39, i32 noundef %16)
  br label %24

24:                                               ; preds = %19, %22
  call void @_Z23TestTickCountDifferencei(i32 noundef %16)
  br label %27

25:                                               ; preds = %.thread, %18
  %26 = call noundef ptr @_ZN7Harness8internal6Tracer14set_trace_infoEiPKcmS3_(ptr noundef nonnull align 8 dereferenceable(33) @_ZN7Harness8internalL6tracerE, i32 noundef 0, ptr noundef nonnull @.str, i64 noundef 195, ptr noundef nonnull @__FUNCTION__._Z8TestMainv)
  call void (ptr, ptr, ...) @_ZN7Harness8internal6Tracer5traceEPKcz(ptr noundef nonnull align 8 dereferenceable(33) %26, ptr noundef nonnull @.str.40, i32 noundef %16)
  br label %27

27:                                               ; preds = %25, %24
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %1) #5
  ret i32 0
}

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_ZN7Harness6GetEnvEPKc(ptr noundef) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z15TestSimpleDelayidd(i32 noundef, double noundef, double noundef) local_unnamed_addr #0

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local i64 @_ZN3tbb10tick_count3nowEv() local_unnamed_addr #3 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z23TestTickCountDifferencei(i32 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z14TestResolutionv() local_unnamed_addr #0

; Function Attrs: nounwind
declare noundef i32 @_ZN3tbb8internal13tbb_thread_v320hardware_concurrencyEv() local_unnamed_addr #4

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 = { 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 = { inlinehint 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 "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 #5 = { 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 = !{}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,SROAPass,SimplifyCFGPass,TailCallElimPass