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

; 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] }>

@_ZN7Harness8internalL6tracerE = external hidden global %"class.Harness::internal::Tracer", align 8
@.str.17 = external hidden unnamed_addr constant [97 x i8], align 1
@_ZL7Verbose = external hidden global i8, align 1
@_ZL9MaxThread = external hidden global i32, align 4
@__FUNCTION__._Z21TestConcurrentPushPopv = external hidden unnamed_addr constant [22 x i8], align 1
@.str.32 = external hidden unnamed_addr constant [50 x i8], align 1
@_ZL9MinThread = external hidden global i32, align 4
@.str.33 = external hidden unnamed_addr constant [28 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 @_Z21TestConcurrentPushPopv() #2 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i64, align 8
  %4 = alloca i64, align 8
  %5 = load i8, ptr @_ZL7Verbose, align 1, !tbaa !5, !range !9, !noundef !10
  %6 = trunc i8 %5 to i1
  br i1 %6, label %8, label %7

7:                                                ; preds = %0
  br label %10

8:                                                ; preds = %0
  %9 = call noundef ptr @_ZN7Harness8internal6Tracer14set_trace_infoEiPKcmS3_(ptr noundef nonnull align 8 dereferenceable(33) @_ZN7Harness8internalL6tracerE, i32 noundef 0, ptr noundef @.str.17, i64 noundef 1297, ptr noundef @__FUNCTION__._Z21TestConcurrentPushPopv)
  call void (ptr, ptr, ...) @_ZN7Harness8internal6Tracer5traceEPKcz(ptr noundef nonnull align 8 dereferenceable(33) %9, ptr noundef @.str.32)
  br label %10

10:                                               ; preds = %8, %7
  call void @llvm.lifetime.start.p0(i64 4, ptr %1) #3
  %11 = load i32, ptr @_ZL9MinThread, align 4, !tbaa !11
  store i32 %11, ptr %1, align 4, !tbaa !11
  br label %12

12:                                               ; preds = %70, %10
  %13 = load i32, ptr %1, align 4, !tbaa !11
  %14 = load i32, ptr @_ZL9MaxThread, align 4, !tbaa !11
  %15 = icmp sle i32 %13, %14
  br i1 %15, label %17, label %16

16:                                               ; preds = %12
  store i32 2, ptr %2, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %1) #3
  br label %73

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

20:                                               ; preds = %17
  br label %24

21:                                               ; preds = %17
  %22 = call noundef ptr @_ZN7Harness8internal6Tracer14set_trace_infoEiPKcmS3_(ptr noundef nonnull align 8 dereferenceable(33) @_ZN7Harness8internalL6tracerE, i32 noundef 0, ptr noundef @.str.17, i64 noundef 1299, ptr noundef @__FUNCTION__._Z21TestConcurrentPushPopv)
  %23 = load i32, ptr %1, align 4, !tbaa !11
  call void (ptr, ptr, ...) @_ZN7Harness8internal6Tracer5traceEPKcz(ptr noundef nonnull align 8 dereferenceable(33) %22, ptr noundef @.str.33, i32 noundef %23)
  br label %24

24:                                               ; preds = %21, %20
  %25 = load i32, ptr %1, align 4, !tbaa !11
  call void @_Z17TestNegativeQueueI3FooEvi(i32 noundef %25)
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #3
  store i64 0, ptr %3, align 8, !tbaa !13
  br label %26

26:                                               ; preds = %41, %24
  %27 = load i64, ptr %3, align 8, !tbaa !13
  %28 = icmp ult i64 %27, 64
  br i1 %28, label %30, label %29

29:                                               ; preds = %26
  store i32 5, ptr %2, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #3
  br label %47

30:                                               ; preds = %26
  %31 = load i64, ptr %3, align 8, !tbaa !13
  %32 = load i32, ptr %1, align 4, !tbaa !11
  call void @_Z11TestPushPopI19ConcQPushPopWrapperI3FooES1_Evmli(i64 noundef %31, i64 noundef -1, i32 noundef %32)
  %33 = load i64, ptr %3, align 8, !tbaa !13
  %34 = load i32, ptr %1, align 4, !tbaa !11
  call void @_Z11TestPushPopI19ConcQPushPopWrapperI3FooES1_Evmli(i64 noundef %33, i64 noundef 1, i32 noundef %34)
  %35 = load i64, ptr %3, align 8, !tbaa !13
  %36 = load i32, ptr %1, align 4, !tbaa !11
  call void @_Z11TestPushPopI19ConcQPushPopWrapperI3FooES1_Evmli(i64 noundef %35, i64 noundef 2, i32 noundef %36)
  %37 = load i64, ptr %3, align 8, !tbaa !13
  %38 = load i32, ptr %1, align 4, !tbaa !11
  call void @_Z11TestPushPopI19ConcQPushPopWrapperI3FooES1_Evmli(i64 noundef %37, i64 noundef 10, i32 noundef %38)
  %39 = load i64, ptr %3, align 8, !tbaa !13
  %40 = load i32, ptr %1, align 4, !tbaa !11
  call void @_Z11TestPushPopI19ConcQPushPopWrapperI3FooES1_Evmli(i64 noundef %39, i64 noundef 100, i32 noundef %40)
  br label %41

41:                                               ; preds = %30
  %42 = load i64, ptr %3, align 8, !tbaa !13
  %43 = udiv i64 %42, 3
  %44 = add i64 1, %43
  %45 = load i64, ptr %3, align 8, !tbaa !13
  %46 = add i64 %45, %44
  store i64 %46, ptr %3, align 8, !tbaa !13
  br label %26, !llvm.loop !15

47:                                               ; preds = %29
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #3
  store i64 0, ptr %4, align 8, !tbaa !13
  br label %48

48:                                               ; preds = %63, %47
  %49 = load i64, ptr %4, align 8, !tbaa !13
  %50 = icmp ult i64 %49, 64
  br i1 %50, label %52, label %51

51:                                               ; preds = %48
  store i32 8, ptr %2, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #3
  br label %69

52:                                               ; preds = %48
  %53 = load i64, ptr %4, align 8, !tbaa !13
  %54 = load i32, ptr %1, align 4, !tbaa !11
  call void @_Z11TestPushPopIN3tbb24concurrent_bounded_queueI3FooNS0_23cache_aligned_allocatorIS2_EEEES2_Evmli(i64 noundef %53, i64 noundef -1, i32 noundef %54)
  %55 = load i64, ptr %4, align 8, !tbaa !13
  %56 = load i32, ptr %1, align 4, !tbaa !11
  call void @_Z11TestPushPopIN3tbb24concurrent_bounded_queueI3FooNS0_23cache_aligned_allocatorIS2_EEEES2_Evmli(i64 noundef %55, i64 noundef 1, i32 noundef %56)
  %57 = load i64, ptr %4, align 8, !tbaa !13
  %58 = load i32, ptr %1, align 4, !tbaa !11
  call void @_Z11TestPushPopIN3tbb24concurrent_bounded_queueI3FooNS0_23cache_aligned_allocatorIS2_EEEES2_Evmli(i64 noundef %57, i64 noundef 2, i32 noundef %58)
  %59 = load i64, ptr %4, align 8, !tbaa !13
  %60 = load i32, ptr %1, align 4, !tbaa !11
  call void @_Z11TestPushPopIN3tbb24concurrent_bounded_queueI3FooNS0_23cache_aligned_allocatorIS2_EEEES2_Evmli(i64 noundef %59, i64 noundef 10, i32 noundef %60)
  %61 = load i64, ptr %4, align 8, !tbaa !13
  %62 = load i32, ptr %1, align 4, !tbaa !11
  call void @_Z11TestPushPopIN3tbb24concurrent_bounded_queueI3FooNS0_23cache_aligned_allocatorIS2_EEEES2_Evmli(i64 noundef %61, i64 noundef 100, i32 noundef %62)
  br label %63

63:                                               ; preds = %52
  %64 = load i64, ptr %4, align 8, !tbaa !13
  %65 = udiv i64 %64, 3
  %66 = add i64 1, %65
  %67 = load i64, ptr %4, align 8, !tbaa !13
  %68 = add i64 %67, %66
  store i64 %68, ptr %4, align 8, !tbaa !13
  br label %48, !llvm.loop !17

69:                                               ; preds = %51
  br label %70

70:                                               ; preds = %69
  %71 = load i32, ptr %1, align 4, !tbaa !11
  %72 = add nsw i32 %71, 1
  store i32 %72, ptr %1, align 4, !tbaa !11
  br label %12, !llvm.loop !18

73:                                               ; preds = %16
  ret void
}

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z17TestNegativeQueueI3FooEvi(i32 noundef) #2

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z11TestPushPopI19ConcQPushPopWrapperI3FooES1_Evmli(i64 noundef, i64 noundef, i32 noundef) #2

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z11TestPushPopIN3tbb24concurrent_bounded_queueI3FooNS0_23cache_aligned_allocatorIS2_EEEES2_Evmli(i64 noundef, i64 noundef, i32 noundef) #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 = !{!"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 = !{!"int", !7, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"long", !7, i64 0}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}
!17 = distinct !{!17, !16}
!18 = distinct !{!18, !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] }>

@_ZN7Harness8internalL6tracerE = external hidden global %"class.Harness::internal::Tracer", align 8
@.str.17 = external hidden unnamed_addr constant [97 x i8], align 1
@_ZL7Verbose = external hidden local_unnamed_addr global i8, align 1
@_ZL9MaxThread = external hidden local_unnamed_addr global i32, align 4
@__FUNCTION__._Z21TestConcurrentPushPopv = external hidden unnamed_addr constant [22 x i8], align 1
@.str.32 = external hidden unnamed_addr constant [50 x i8], align 1
@_ZL9MinThread = external hidden local_unnamed_addr global i32, align 4
@.str.33 = external hidden unnamed_addr constant [28 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 @_Z21TestConcurrentPushPopv() local_unnamed_addr #1 {
  %1 = load i8, ptr @_ZL7Verbose, align 1, !tbaa !5, !range !9, !noundef !10
  %2 = trunc nuw i8 %1 to i1
  br i1 %2, label %3, label %5

3:                                                ; preds = %0
  %4 = tail call noundef ptr @_ZN7Harness8internal6Tracer14set_trace_infoEiPKcmS3_(ptr noundef nonnull align 8 dereferenceable(33) @_ZN7Harness8internalL6tracerE, i32 noundef 0, ptr noundef nonnull @.str.17, i64 noundef 1297, ptr noundef nonnull @__FUNCTION__._Z21TestConcurrentPushPopv)
  tail call void (ptr, ptr, ...) @_ZN7Harness8internal6Tracer5traceEPKcz(ptr noundef nonnull align 8 dereferenceable(33) %4, ptr noundef nonnull @.str.32)
  br label %5

5:                                                ; preds = %0, %3
  %6 = load i32, ptr @_ZL9MinThread, align 4, !tbaa !11
  %7 = load i32, ptr @_ZL9MaxThread, align 4, !tbaa !11
  %.not37 = icmp sgt i32 %6, %7
  br i1 %.not37, label %._crit_edge, label %.lr.ph

._crit_edge:                                      ; preds = %18, %5
  ret void

.lr.ph:                                           ; preds = %5, %18
  %.03138 = phi i32 [ %19, %18 ], [ %6, %5 ]
  %8 = load i8, ptr @_ZL7Verbose, align 1, !tbaa !5, !range !9, !noundef !10
  %9 = trunc nuw i8 %8 to i1
  br i1 %9, label %10, label %12

10:                                               ; preds = %.lr.ph
  %11 = tail call noundef ptr @_ZN7Harness8internal6Tracer14set_trace_infoEiPKcmS3_(ptr noundef nonnull align 8 dereferenceable(33) @_ZN7Harness8internalL6tracerE, i32 noundef 0, ptr noundef nonnull @.str.17, i64 noundef 1299, ptr noundef nonnull @__FUNCTION__._Z21TestConcurrentPushPopv)
  tail call void (ptr, ptr, ...) @_ZN7Harness8internal6Tracer5traceEPKcz(ptr noundef nonnull align 8 dereferenceable(33) %11, ptr noundef nonnull @.str.33, i32 noundef %.03138)
  br label %12

12:                                               ; preds = %.lr.ph, %10
  tail call void @_Z17TestNegativeQueueI3FooEvi(i32 noundef %.03138)
  br label %13

13:                                               ; preds = %12, %13
  %.03035 = phi i64 [ 0, %12 ], [ %16, %13 ]
  tail call void @_Z11TestPushPopI19ConcQPushPopWrapperI3FooES1_Evmli(i64 noundef %.03035, i64 noundef -1, i32 noundef %.03138)
  tail call void @_Z11TestPushPopI19ConcQPushPopWrapperI3FooES1_Evmli(i64 noundef %.03035, i64 noundef 1, i32 noundef %.03138)
  tail call void @_Z11TestPushPopI19ConcQPushPopWrapperI3FooES1_Evmli(i64 noundef %.03035, i64 noundef 2, i32 noundef %.03138)
  tail call void @_Z11TestPushPopI19ConcQPushPopWrapperI3FooES1_Evmli(i64 noundef %.03035, i64 noundef 10, i32 noundef %.03138)
  tail call void @_Z11TestPushPopI19ConcQPushPopWrapperI3FooES1_Evmli(i64 noundef %.03035, i64 noundef 100, i32 noundef %.03138)
  %.lhs.trunc = trunc nuw i64 %.03035 to i8
  %14 = udiv i8 %.lhs.trunc, 3
  %narrow34 = add nuw nsw i8 %14, 1
  %15 = zext nneg i8 %narrow34 to i64
  %16 = add nuw nsw i64 %.03035, %15
  %17 = icmp ult i64 %16, 64
  br i1 %17, label %13, label %.preheader, !llvm.loop !13

18:                                               ; preds = %.preheader
  %19 = add nsw i32 %.03138, 1
  %20 = load i32, ptr @_ZL9MaxThread, align 4, !tbaa !11
  %.not.not = icmp slt i32 %.03138, %20
  br i1 %.not.not, label %.lr.ph, label %._crit_edge, !llvm.loop !15

.preheader:                                       ; preds = %13, %.preheader
  %.036 = phi i64 [ %23, %.preheader ], [ 0, %13 ]
  tail call void @_Z11TestPushPopIN3tbb24concurrent_bounded_queueI3FooNS0_23cache_aligned_allocatorIS2_EEEES2_Evmli(i64 noundef %.036, i64 noundef -1, i32 noundef %.03138)
  tail call void @_Z11TestPushPopIN3tbb24concurrent_bounded_queueI3FooNS0_23cache_aligned_allocatorIS2_EEEES2_Evmli(i64 noundef %.036, i64 noundef 1, i32 noundef %.03138)
  tail call void @_Z11TestPushPopIN3tbb24concurrent_bounded_queueI3FooNS0_23cache_aligned_allocatorIS2_EEEES2_Evmli(i64 noundef %.036, i64 noundef 2, i32 noundef %.03138)
  tail call void @_Z11TestPushPopIN3tbb24concurrent_bounded_queueI3FooNS0_23cache_aligned_allocatorIS2_EEEES2_Evmli(i64 noundef %.036, i64 noundef 10, i32 noundef %.03138)
  tail call void @_Z11TestPushPopIN3tbb24concurrent_bounded_queueI3FooNS0_23cache_aligned_allocatorIS2_EEEES2_Evmli(i64 noundef %.036, i64 noundef 100, i32 noundef %.03138)
  %.lhs.trunc32 = trunc nuw i64 %.036 to i8
  %21 = udiv i8 %.lhs.trunc32, 3
  %narrow = add nuw nsw i8 %21, 1
  %22 = zext nneg i8 %narrow to i64
  %23 = add nuw nsw i64 %.036, %22
  %24 = icmp ult i64 %23, 64
  br i1 %24, label %.preheader, label %18, !llvm.loop !16
}

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z11TestPushPopI19ConcQPushPopWrapperI3FooES1_Evmli(i64 noundef, i64 noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z11TestPushPopIN3tbb24concurrent_bounded_queueI3FooNS0_23cache_aligned_allocatorIS2_EEEES2_Evmli(i64 noundef, i64 noundef, i32 noundef) local_unnamed_addr #1

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

!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 = !{!"int", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = distinct !{!15, !14}
!16 = distinct !{!16, !14}


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