; LLVM IR from stan-dev/math :: lib/tbb_2020.3/src/rml/client (omp_dynamic_link)

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

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_ZN5__kmp12dynamic_loadEPKcPKNS_23dynamic_link_descriptorEm(ptr noundef, ptr noundef, i64 noundef) #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 uwtable
define dso_local noundef zeroext i1 @_ZN5__kmp12dynamic_linkEPKcPKNS_23dynamic_link_descriptorEmPPvi(ptr noundef %0, ptr noundef %1, i64 noundef %2, ptr noundef %3, i32 noundef %4) #0 {
  %6 = alloca i1, align 1
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i64, align 8
  %10 = alloca ptr, align 8
  %11 = alloca i32, align 4
  %12 = alloca ptr, align 8
  %13 = alloca i32, align 4
  store ptr %0, ptr %7, align 8, !tbaa !5
  store ptr %1, ptr %8, align 8, !tbaa !5
  store i64 %2, ptr %9, align 8, !tbaa !9
  store ptr %3, ptr %10, align 8, !tbaa !5
  store i32 %4, ptr %11, align 4, !tbaa !11
  call void @_ZN5__kmp22init_dynamic_link_dataEv()
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #3
  %14 = load i32, ptr %11, align 4, !tbaa !11
  %15 = and i32 %14, 1
  %16 = icmp ne i32 %15, 0
  br i1 %16, label %17, label %22

17:                                               ; preds = %5
  %18 = load ptr, ptr %7, align 8, !tbaa !5
  %19 = load ptr, ptr %8, align 8, !tbaa !5
  %20 = load i64, ptr %9, align 8, !tbaa !9
  %21 = call noundef ptr @_ZN5__kmpL19global_symbols_linkEPKcPKNS_23dynamic_link_descriptorEm(ptr noundef %18, ptr noundef %19, i64 noundef %20)
  br label %23

22:                                               ; preds = %5
  br label %23

23:                                               ; preds = %22, %17
  %24 = phi ptr [ %21, %17 ], [ null, %22 ]
  store ptr %24, ptr %12, align 8, !tbaa !5
  %25 = load ptr, ptr %12, align 8, !tbaa !5
  %26 = icmp ne ptr %25, null
  br i1 %26, label %36, label %27

27:                                               ; preds = %23
  %28 = load i32, ptr %11, align 4, !tbaa !11
  %29 = and i32 %28, 2
  %30 = icmp ne i32 %29, 0
  br i1 %30, label %31, label %36

31:                                               ; preds = %27
  %32 = load ptr, ptr %7, align 8, !tbaa !5
  %33 = load ptr, ptr %8, align 8, !tbaa !5
  %34 = load i64, ptr %9, align 8, !tbaa !9
  %35 = call noundef ptr @_ZN5__kmp12dynamic_loadEPKcPKNS_23dynamic_link_descriptorEm(ptr noundef %32, ptr noundef %33, i64 noundef %34)
  store ptr %35, ptr %12, align 8, !tbaa !5
  br label %36

36:                                               ; preds = %31, %27, %23
  %37 = load ptr, ptr %12, align 8, !tbaa !5
  %38 = icmp ne ptr %37, null
  br i1 %38, label %47, label %39

39:                                               ; preds = %36
  %40 = load i32, ptr %11, align 4, !tbaa !11
  %41 = and i32 %40, 4
  %42 = icmp ne i32 %41, 0
  br i1 %42, label %43, label %47

43:                                               ; preds = %39
  %44 = load ptr, ptr %8, align 8, !tbaa !5
  %45 = load i64, ptr %9, align 8, !tbaa !9
  %46 = call noundef zeroext i1 @_ZN5__kmpL16weak_symbol_linkEPKNS_23dynamic_link_descriptorEm(ptr noundef %44, i64 noundef %45)
  store i1 %46, ptr %6, align 1
  store i32 1, ptr %13, align 4
  br label %54

47:                                               ; preds = %39, %36
  %48 = load ptr, ptr %12, align 8, !tbaa !5
  %49 = icmp ne ptr %48, null
  br i1 %49, label %50, label %53

50:                                               ; preds = %47
  %51 = load ptr, ptr %12, align 8, !tbaa !5
  %52 = load ptr, ptr %10, align 8, !tbaa !5
  call void @_ZN5__kmpL19save_library_handleEPvPS0_(ptr noundef %51, ptr noundef %52)
  store i1 true, ptr %6, align 1
  store i32 1, ptr %13, align 4
  br label %54

53:                                               ; preds = %47
  store i1 false, ptr %6, align 1
  store i32 1, ptr %13, align 4
  br label %54

54:                                               ; preds = %53, %50, %43
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #3
  %55 = load i1, ptr %6, align 1
  ret i1 %55
}

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

; Function Attrs: mustprogress nounwind uwtable
declare hidden noundef zeroext i1 @_ZN5__kmpL16weak_symbol_linkEPKNS_23dynamic_link_descriptorEm(ptr noundef, i64 noundef) #2

; Function Attrs: mustprogress uwtable
declare hidden void @_ZN5__kmpL19save_library_handleEPvPS0_(ptr noundef, ptr 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" }
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 = { 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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"long", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"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"

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

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

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZN5__kmp12dynamic_linkEPKcPKNS_23dynamic_link_descriptorEmPPvi(ptr noundef %0, ptr noundef %1, i64 noundef %2, ptr noundef %3, i32 noundef %4) local_unnamed_addr #0 {
  tail call void @_ZN5__kmp22init_dynamic_link_dataEv()
  %6 = and i32 %4, 1
  %.not = icmp eq i32 %6, 0
  br i1 %.not, label %.thread, label %7

7:                                                ; preds = %5
  %8 = tail call noundef ptr @_ZN5__kmpL19global_symbols_linkEPKcPKNS_23dynamic_link_descriptorEm(ptr noundef %0, ptr noundef %1, i64 noundef %2)
  %.not18 = icmp eq ptr %8, null
  br i1 %.not18, label %.thread, label %.thread31

.thread:                                          ; preds = %5, %7
  %9 = and i32 %4, 2
  %.not19 = icmp eq i32 %9, 0
  br i1 %.not19, label %12, label %10

10:                                               ; preds = %.thread
  %11 = tail call noundef ptr @_ZN5__kmp12dynamic_loadEPKcPKNS_23dynamic_link_descriptorEm(ptr noundef %0, ptr noundef %1, i64 noundef %2)
  br label %12

12:                                               ; preds = %10, %.thread
  %.0 = phi ptr [ %11, %10 ], [ null, %.thread ]
  %.not20 = icmp ne ptr %.0, null
  %13 = and i32 %4, 4
  %.not21 = icmp eq i32 %13, 0
  %or.cond = or i1 %.not21, %.not20
  br i1 %or.cond, label %16, label %14

14:                                               ; preds = %12
  %15 = tail call noundef zeroext i1 @_ZN5__kmpL16weak_symbol_linkEPKNS_23dynamic_link_descriptorEm(ptr noundef %1, i64 noundef %2)
  br label %17

16:                                               ; preds = %12
  br i1 %.not20, label %.thread31, label %17

.thread31:                                        ; preds = %7, %16
  %.02934 = phi ptr [ %.0, %16 ], [ %8, %7 ]
  tail call void @_ZN5__kmpL19save_library_handleEPvPS0_(ptr noundef nonnull %.02934, ptr noundef %3)
  br label %17

17:                                               ; preds = %16, %.thread31, %14
  %.016 = phi i1 [ true, %.thread31 ], [ %15, %14 ], [ false, %16 ]
  ret i1 %.016
}

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

; Function Attrs: mustprogress nounwind uwtable
declare hidden noundef zeroext i1 @_ZN5__kmpL16weak_symbol_linkEPKNS_23dynamic_link_descriptorEm(ptr noundef, i64 noundef) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
declare hidden void @_ZN5__kmpL19save_library_handleEPvPS0_(ptr noundef, ptr 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" }
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" }

!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,JumpThreadingPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass