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

; 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.std::nothrow_t" = type { i8 }

@_ZSt7nothrow = external global %"struct.std::nothrow_t", 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: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: mustprogress uwtable
declare hidden void @_ZL23scalableMallocCheckSizePvm(ptr noundef, i64 noundef) #1

; Function Attrs: mustprogress uwtable
define dso_local void @_Z22CheckNewDeleteOverloadv() #1 {
  %1 = alloca ptr, align 8
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i1, align 1
  %7 = alloca ptr, align 8
  %8 = alloca i1, align 1
  call void @llvm.lifetime.start.p0(i64 8, ptr %1) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %2) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #5
  %9 = call noalias noundef nonnull ptr @_Znwm(i64 noundef 8129) #6
  store ptr %9, ptr %1, align 8, !tbaa !5
  %10 = load ptr, ptr %1, align 8, !tbaa !5
  call void @_ZL23scalableMallocCheckSizePvm(ptr noundef %10, i64 noundef 8129)
  %11 = load ptr, ptr %1, align 8, !tbaa !5
  %12 = icmp eq ptr %11, null
  br i1 %12, label %14, label %13

13:                                               ; preds = %0
  call void @_ZdlPvm(ptr noundef %11, i64 noundef 8129) #7
  br label %14

14:                                               ; preds = %13, %0
  %15 = call noalias noundef nonnull ptr @_Znam(i64 noundef 81290) #6
  store ptr %15, ptr %2, align 8, !tbaa !5
  %16 = load ptr, ptr %2, align 8, !tbaa !5
  call void @_ZL23scalableMallocCheckSizePvm(ptr noundef %16, i64 noundef 81290)
  %17 = load ptr, ptr %2, align 8, !tbaa !5
  %18 = icmp eq ptr %17, null
  br i1 %18, label %20, label %19

19:                                               ; preds = %14
  call void @_ZdaPv(ptr noundef %17) #7
  br label %20

20:                                               ; preds = %19, %14
  %21 = call noalias noundef ptr @_ZnwmRKSt9nothrow_t(i64 noundef 8129, ptr noundef nonnull align 1 dereferenceable(1) @_ZSt7nothrow) #8
  %22 = icmp eq ptr %21, null
  store i1 false, ptr %6, align 1
  br i1 %22, label %24, label %23

23:                                               ; preds = %20
  store ptr %21, ptr %5, align 8
  store i1 true, ptr %6, align 1
  br label %24

24:                                               ; preds = %23, %20
  %25 = phi ptr [ %21, %23 ], [ null, %20 ]
  store ptr %25, ptr %3, align 8, !tbaa !5
  %26 = load ptr, ptr %3, align 8, !tbaa !5
  call void @_ZL23scalableMallocCheckSizePvm(ptr noundef %26, i64 noundef 8129)
  %27 = load ptr, ptr %3, align 8, !tbaa !5
  %28 = icmp eq ptr %27, null
  br i1 %28, label %30, label %29

29:                                               ; preds = %24
  call void @_ZdlPvm(ptr noundef %27, i64 noundef 8129) #7
  br label %30

30:                                               ; preds = %29, %24
  %31 = call noalias noundef ptr @_ZnamRKSt9nothrow_t(i64 noundef 16258, ptr noundef nonnull align 1 dereferenceable(1) @_ZSt7nothrow) #8
  %32 = icmp eq ptr %31, null
  store i1 false, ptr %8, align 1
  br i1 %32, label %34, label %33

33:                                               ; preds = %30
  store ptr %31, ptr %7, align 8
  store i1 true, ptr %8, align 1
  br label %34

34:                                               ; preds = %33, %30
  %35 = phi ptr [ %31, %33 ], [ null, %30 ]
  store ptr %35, ptr %4, align 8, !tbaa !5
  %36 = load ptr, ptr %4, align 8, !tbaa !5
  call void @_ZL23scalableMallocCheckSizePvm(ptr noundef %36, i64 noundef 16258)
  %37 = load ptr, ptr %4, align 8, !tbaa !5
  %38 = icmp eq ptr %37, null
  br i1 %38, label %40, label %39

39:                                               ; preds = %34
  call void @_ZdaPv(ptr noundef %37) #7
  br label %40

40:                                               ; preds = %39, %34
  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 void
}

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znwm(i64 noundef) #2

; Function Attrs: nobuiltin nounwind
declare void @_ZdlPvm(ptr noundef, i64 noundef) #3

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znam(i64 noundef) #2

; Function Attrs: nobuiltin nounwind
declare void @_ZdaPv(ptr noundef) #3

; Function Attrs: nobuiltin nounwind allocsize(0)
declare noalias noundef ptr @_ZnwmRKSt9nothrow_t(i64 noundef, ptr noundef nonnull align 1 dereferenceable(1)) #4

; Function Attrs: nobuiltin nounwind allocsize(0)
declare noalias noundef ptr @_ZnamRKSt9nothrow_t(i64 noundef, ptr noundef nonnull align 1 dereferenceable(1)) #4

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 = { nobuiltin allocsize(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 = { nobuiltin 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 #4 = { nobuiltin nounwind allocsize(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 #5 = { nounwind }
attributes #6 = { builtin allocsize(0) }
attributes #7 = { builtin nounwind }
attributes #8 = { builtin nounwind allocsize(0) }

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


; 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.std::nothrow_t" = type { i8 }

@_ZSt7nothrow = external global %"struct.std::nothrow_t", align 1

; Function Attrs: mustprogress uwtable
declare hidden void @_ZL23scalableMallocCheckSizePvm(ptr noundef, i64 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
define dso_local void @_Z22CheckNewDeleteOverloadv() local_unnamed_addr #0 {
  %1 = tail call noalias noundef nonnull dereferenceable(8129) ptr @_Znwm(i64 noundef 8129) #4
  tail call void @_ZL23scalableMallocCheckSizePvm(ptr noundef nonnull %1, i64 noundef 8129)
  tail call void @_ZdlPvm(ptr noundef nonnull %1, i64 noundef 8129) #5
  %2 = tail call noalias noundef nonnull dereferenceable(81290) ptr @_Znam(i64 noundef 81290) #4
  tail call void @_ZL23scalableMallocCheckSizePvm(ptr noundef nonnull %2, i64 noundef 81290)
  tail call void @_ZdaPv(ptr noundef nonnull %2) #5
  %3 = tail call noalias noundef dereferenceable_or_null(8129) ptr @_ZnwmRKSt9nothrow_t(i64 noundef 8129, ptr noundef nonnull align 1 dereferenceable(1) @_ZSt7nothrow) #6
  %4 = icmp eq ptr %3, null
  tail call void @_ZL23scalableMallocCheckSizePvm(ptr noundef %3, i64 noundef 8129)
  br i1 %4, label %6, label %5

5:                                                ; preds = %0
  tail call void @_ZdlPvm(ptr noundef nonnull %3, i64 noundef 8129) #5
  br label %6

6:                                                ; preds = %5, %0
  %7 = tail call noalias noundef dereferenceable_or_null(16258) ptr @_ZnamRKSt9nothrow_t(i64 noundef 16258, ptr noundef nonnull align 1 dereferenceable(1) @_ZSt7nothrow) #6
  %8 = icmp eq ptr %7, null
  tail call void @_ZL23scalableMallocCheckSizePvm(ptr noundef %7, i64 noundef 16258)
  br i1 %8, label %10, label %9

9:                                                ; preds = %6
  tail call void @_ZdaPv(ptr noundef nonnull %7) #5
  br label %10

10:                                               ; preds = %9, %6
  ret void
}

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znwm(i64 noundef) local_unnamed_addr #1

; Function Attrs: nobuiltin nounwind
declare void @_ZdlPvm(ptr noundef, i64 noundef) local_unnamed_addr #2

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znam(i64 noundef) local_unnamed_addr #1

; Function Attrs: nobuiltin nounwind
declare void @_ZdaPv(ptr noundef) local_unnamed_addr #2

; Function Attrs: nobuiltin nounwind allocsize(0)
declare noalias noundef ptr @_ZnwmRKSt9nothrow_t(i64 noundef, ptr noundef nonnull align 1 dereferenceable(1)) local_unnamed_addr #3

; Function Attrs: nobuiltin nounwind allocsize(0)
declare noalias noundef ptr @_ZnamRKSt9nothrow_t(i64 noundef, ptr noundef nonnull align 1 dereferenceable(1)) local_unnamed_addr #3

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 = { nobuiltin allocsize(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 = { nobuiltin 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 #3 = { nobuiltin nounwind allocsize(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 = { builtin allocsize(0) }
attributes #5 = { builtin nounwind }
attributes #6 = { builtin nounwind allocsize(0) }

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


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