; LLVM IR from stan-dev/math :: lib/tbb_2020.3/src/tbbproxy/tbbproxy.ll (ZN3tbb10interface614runtime_loader4loadEPPKcii)

; 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.tbb::interface6::runtime_loader" = type <{ i32, i32, i8, [3 x i8] }>

@.str = external hidden unnamed_addr constant [83 x i8], align 1

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZN3tbb10interface614runtime_loader4loadEPPKcii(ptr noundef nonnull align 4 dereferenceable(9) %0, ptr noundef %1, i32 noundef %2, i32 noundef %3) #0 align 2 {
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store i32 %2, ptr %7, align 4, !tbaa !9
  store i32 %3, ptr %8, align 4, !tbaa !9
  %9 = load ptr, ptr %5, align 8
  %10 = getelementptr inbounds %"class.tbb::interface6::runtime_loader", ptr %9, i32 0, i32 2
  %11 = load i8, ptr %10, align 4, !tbaa !11, !range !16, !noundef !17
  %12 = trunc i8 %11 to i1
  br i1 %12, label %13, label %18

13:                                               ; preds = %4
  %14 = getelementptr inbounds %"class.tbb::interface6::runtime_loader", ptr %9, i32 0, i32 0
  %15 = load i32, ptr %14, align 4, !tbaa !18
  %16 = call noundef i32 (i32, i32, ptr, ...) @_ZN3tbb10interface68internal14runtime_loaderL5errorENS0_14runtime_loader10error_modeENS3_10error_codeEPKcz(i32 noundef %15, i32 noundef 1, ptr noundef @.str)
  %17 = getelementptr inbounds %"class.tbb::interface6::runtime_loader", ptr %9, i32 0, i32 1
  store i32 %16, ptr %17, align 4, !tbaa !19
  br label %32

18:                                               ; preds = %4
  %19 = getelementptr inbounds %"class.tbb::interface6::runtime_loader", ptr %9, i32 0, i32 0
  %20 = load i32, ptr %19, align 4, !tbaa !18
  %21 = load ptr, ptr %6, align 8, !tbaa !5
  %22 = load i32, ptr %7, align 4, !tbaa !9
  %23 = load i32, ptr %8, align 4, !tbaa !9
  %24 = call noundef i32 @_ZN3tbb10interface68internal14runtime_loaderL4loadENS0_14runtime_loader10error_modeEPPKcii(i32 noundef %20, ptr noundef %21, i32 noundef %22, i32 noundef %23)
  %25 = getelementptr inbounds %"class.tbb::interface6::runtime_loader", ptr %9, i32 0, i32 1
  store i32 %24, ptr %25, align 4, !tbaa !19
  %26 = getelementptr inbounds %"class.tbb::interface6::runtime_loader", ptr %9, i32 0, i32 1
  %27 = load i32, ptr %26, align 4, !tbaa !19
  %28 = icmp eq i32 %27, 0
  br i1 %28, label %29, label %31

29:                                               ; preds = %18
  %30 = getelementptr inbounds %"class.tbb::interface6::runtime_loader", ptr %9, i32 0, i32 2
  store i8 1, ptr %30, align 4, !tbaa !11
  br label %31

31:                                               ; preds = %29, %18
  br label %32

32:                                               ; preds = %31, %13
  %33 = getelementptr inbounds %"class.tbb::interface6::runtime_loader", ptr %9, i32 0, i32 1
  %34 = load i32, ptr %33, align 4, !tbaa !19
  ret i32 %34
}

; Function Attrs: mustprogress uwtable
declare hidden noundef i32 @_ZN3tbb10interface68internal14runtime_loaderL5errorENS0_14runtime_loader10error_modeENS3_10error_codeEPKcz(i32 noundef, i32 noundef, ptr noundef, ...) #0

; Function Attrs: mustprogress uwtable
declare hidden noundef i32 @_ZN3tbb10interface68internal14runtime_loaderL4loadENS0_14runtime_loader10error_modeEPPKcii(i32 noundef, ptr noundef, i32 noundef, i32 noundef) #0

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

!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 = !{!"int", !7, i64 0}
!11 = !{!12, !15, i64 8}
!12 = !{!"_ZTSN3tbb10interface614runtime_loaderE", !13, i64 0, !14, i64 4, !15, i64 8}
!13 = !{!"_ZTSN3tbb10interface614runtime_loader10error_modeE", !7, i64 0}
!14 = !{!"_ZTSN3tbb10interface614runtime_loader10error_codeE", !7, i64 0}
!15 = !{!"bool", !7, i64 0}
!16 = !{i8 0, i8 2}
!17 = !{}
!18 = !{!12, !13, i64 0}
!19 = !{!12, !14, i64 4}


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

@.str = external hidden unnamed_addr constant [83 x i8], align 1

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZN3tbb10interface614runtime_loader4loadEPPKcii(ptr nocapture noundef nonnull align 4 dereferenceable(9) %0, ptr noundef %1, i32 noundef %2, i32 noundef %3) local_unnamed_addr #0 align 2 {
  %5 = getelementptr inbounds i8, ptr %0, i64 8
  %6 = load i8, ptr %5, align 4, !tbaa !5, !range !12, !noundef !13
  %7 = trunc nuw i8 %6 to i1
  %8 = load i32, ptr %0, align 4, !tbaa !14
  %9 = getelementptr inbounds i8, ptr %0, i64 4
  br i1 %7, label %10, label %12

10:                                               ; preds = %4
  %11 = tail call noundef i32 (i32, i32, ptr, ...) @_ZN3tbb10interface68internal14runtime_loaderL5errorENS0_14runtime_loader10error_modeENS3_10error_codeEPKcz(i32 noundef %8, i32 noundef 1, ptr noundef nonnull @.str)
  store i32 %11, ptr %9, align 4, !tbaa !15
  br label %16

12:                                               ; preds = %4
  %13 = tail call noundef i32 @_ZN3tbb10interface68internal14runtime_loaderL4loadENS0_14runtime_loader10error_modeEPPKcii(i32 noundef %8, ptr noundef %1, i32 noundef %2, i32 noundef %3)
  store i32 %13, ptr %9, align 4, !tbaa !15
  %14 = icmp eq i32 %13, 0
  br i1 %14, label %15, label %16

15:                                               ; preds = %12
  store i8 1, ptr %5, align 4, !tbaa !5
  br label %16

16:                                               ; preds = %12, %15, %10
  %17 = phi i32 [ %13, %12 ], [ 0, %15 ], [ %11, %10 ]
  ret i32 %17
}

; Function Attrs: mustprogress uwtable
declare hidden noundef i32 @_ZN3tbb10interface68internal14runtime_loaderL5errorENS0_14runtime_loader10error_modeENS3_10error_codeEPKcz(i32 noundef, i32 noundef, ptr noundef, ...) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
declare hidden noundef i32 @_ZN3tbb10interface68internal14runtime_loaderL4loadENS0_14runtime_loader10error_modeEPPKcii(i32 noundef, ptr noundef, i32 noundef, i32 noundef) local_unnamed_addr #0

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

!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, !11, i64 8}
!6 = !{!"_ZTSN3tbb10interface614runtime_loaderE", !7, i64 0, !10, i64 4, !11, i64 8}
!7 = !{!"_ZTSN3tbb10interface614runtime_loader10error_modeE", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"_ZTSN3tbb10interface614runtime_loader10error_codeE", !8, i64 0}
!11 = !{!"bool", !8, i64 0}
!12 = !{i8 0, i8 2}
!13 = !{}
!14 = !{!6, !7, i64 0}
!15 = !{!6, !10, i64 4}


; Effective O3 passes: BDCEPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass