; LLVM IR from AngoraFuzzer/Angora :: llvm_mode/dfsan_rt/sanitizer_common (sanitizer_thread_registry)

; 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.__sanitizer::GenericScopedLock" = type { ptr }
%"class.__sanitizer::ThreadRegistry" = type { ptr, i32, i32, i32, %"class.__sanitizer::BlockingMutex", i32, i64, i64, i64, i64, ptr, %"struct.__sanitizer::IntrusiveList", %"struct.__sanitizer::IntrusiveList" }
%"class.__sanitizer::BlockingMutex" = type { [10 x i64], i64 }
%"struct.__sanitizer::IntrusiveList" = type { i64, ptr, ptr }
%"class.__sanitizer::ThreadContextBase" = type { ptr, i32, i64, i32, i64, i64, [64 x i8], i32, i8, i32, ptr }

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

declare i32 @__gxx_personality_v0(...)

; 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 dso_local void @_ZN11__sanitizer17GenericScopedLockINS_13BlockingMutexEEC2EPS1_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef) unnamed_addr #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN11__sanitizer17GenericScopedLockINS_13BlockingMutexEED2Ev(ptr noundef nonnull align 8 dereferenceable(8)) unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZN11__sanitizer14ThreadRegistry10FindThreadEPFbPNS_17ThreadContextBaseEPvES3_(ptr noundef nonnull align 8 dereferenceable(208) %0, ptr noundef %1, ptr noundef %2) #1 align 2 personality ptr @__gxx_personality_v0 {
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca %"class.__sanitizer::GenericScopedLock", align 8
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store ptr %2, ptr %7, align 8, !tbaa !5
  %14 = load ptr, ptr %5, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  %15 = getelementptr inbounds %"class.__sanitizer::ThreadRegistry", ptr %14, i32 0, i32 4
  call void @_ZN11__sanitizer17GenericScopedLockINS_13BlockingMutexEEC2EPS1_(ptr noundef nonnull align 8 dereferenceable(8) %8, ptr noundef %15)
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #3
  store i32 0, ptr %9, align 4, !tbaa !9
  br label %16

16:                                               ; preds = %49, %3
  %17 = load i32, ptr %9, align 4, !tbaa !9
  %18 = getelementptr inbounds %"class.__sanitizer::ThreadRegistry", ptr %14, i32 0, i32 5
  %19 = load i32, ptr %18, align 8, !tbaa !11
  %20 = icmp ult i32 %17, %19
  br i1 %20, label %22, label %21

21:                                               ; preds = %16
  store i32 2, ptr %10, align 4
  br label %52

22:                                               ; preds = %16
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #3
  %23 = getelementptr inbounds %"class.__sanitizer::ThreadRegistry", ptr %14, i32 0, i32 10
  %24 = load ptr, ptr %23, align 8, !tbaa !17
  %25 = load i32, ptr %9, align 4, !tbaa !9
  %26 = zext i32 %25 to i64
  %27 = getelementptr inbounds ptr, ptr %24, i64 %26
  %28 = load ptr, ptr %27, align 8, !tbaa !5
  store ptr %28, ptr %11, align 8, !tbaa !5
  %29 = load ptr, ptr %11, align 8, !tbaa !5
  %30 = icmp ne ptr %29, null
  br i1 %30, label %31, label %45

31:                                               ; preds = %22
  %32 = load ptr, ptr %6, align 8, !tbaa !5
  %33 = load ptr, ptr %11, align 8, !tbaa !5
  %34 = load ptr, ptr %7, align 8, !tbaa !5
  %35 = invoke noundef zeroext i1 %32(ptr noundef %33, ptr noundef %34)
          to label %36 unwind label %41

36:                                               ; preds = %31
  br i1 %35, label %37, label %45

37:                                               ; preds = %36
  %38 = load ptr, ptr %11, align 8, !tbaa !5
  %39 = getelementptr inbounds %"class.__sanitizer::ThreadContextBase", ptr %38, i32 0, i32 1
  %40 = load i32, ptr %39, align 8, !tbaa !18
  store i32 %40, ptr %4, align 4
  store i32 1, ptr %10, align 4
  br label %46

41:                                               ; preds = %31
  %42 = landingpad { ptr, i32 }
          cleanup
  %43 = extractvalue { ptr, i32 } %42, 0
  store ptr %43, ptr %12, align 8
  %44 = extractvalue { ptr, i32 } %42, 1
  store i32 %44, ptr %13, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #3
  call void @_ZN11__sanitizer17GenericScopedLockINS_13BlockingMutexEED2Ev(ptr noundef nonnull align 8 dereferenceable(8) %8) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  br label %57

45:                                               ; preds = %36, %22
  store i32 0, ptr %10, align 4
  br label %46

46:                                               ; preds = %45, %37
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #3
  %47 = load i32, ptr %10, align 4
  switch i32 %47, label %52 [
    i32 0, label %48
  ]

48:                                               ; preds = %46
  br label %49

49:                                               ; preds = %48
  %50 = load i32, ptr %9, align 4, !tbaa !9
  %51 = add i32 %50, 1
  store i32 %51, ptr %9, align 4, !tbaa !9
  br label %16, !llvm.loop !22

52:                                               ; preds = %46, %21
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #3
  %53 = load i32, ptr %10, align 4
  switch i32 %53, label %55 [
    i32 2, label %54
  ]

54:                                               ; preds = %52
  store i32 -1, ptr %4, align 4
  store i32 1, ptr %10, align 4
  br label %55

55:                                               ; preds = %54, %52
  call void @_ZN11__sanitizer17GenericScopedLockINS_13BlockingMutexEED2Ev(ptr noundef nonnull align 8 dereferenceable(8) %8) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  %56 = load i32, ptr %4, align 4
  ret i32 %56

57:                                               ; preds = %41
  %58 = load ptr, ptr %12, align 8
  %59 = load i32, ptr %13, align 4
  %60 = insertvalue { ptr, i32 } poison, ptr %58, 0
  %61 = insertvalue { ptr, i32 } %60, i32 %59, 1
  resume { ptr, i32 } %61
}

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 = { 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 = !{!"int", !7, i64 0}
!11 = !{!12, !10, i64 112}
!12 = !{!"_ZTSN11__sanitizer14ThreadRegistryE", !6, i64 0, !10, i64 8, !10, i64 12, !10, i64 16, !13, i64 24, !10, i64 112, !15, i64 120, !14, i64 128, !14, i64 136, !14, i64 144, !6, i64 152, !16, i64 160, !16, i64 184}
!13 = !{!"_ZTSN11__sanitizer13BlockingMutexE", !7, i64 0, !14, i64 80}
!14 = !{!"long", !7, i64 0}
!15 = !{!"long long", !7, i64 0}
!16 = !{!"_ZTSN11__sanitizer13IntrusiveListINS_17ThreadContextBaseEEE", !14, i64 0, !6, i64 8, !6, i64 16}
!17 = !{!12, !6, i64 152}
!18 = !{!19, !10, i64 8}
!19 = !{!"_ZTSN11__sanitizer17ThreadContextBaseE", !10, i64 8, !15, i64 16, !10, i64 24, !14, i64 32, !14, i64 40, !7, i64 48, !20, i64 112, !21, i64 116, !10, i64 120, !6, i64 128}
!20 = !{!"_ZTSN11__sanitizer12ThreadStatusE", !7, i64 0}
!21 = !{!"bool", !7, i64 0}
!22 = distinct !{!22, !23}
!23 = !{!"llvm.loop.mustprogress"}


; 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.__sanitizer::GenericScopedLock" = type { ptr }

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

declare i32 @__gxx_personality_v0(...)

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN11__sanitizer17GenericScopedLockINS_13BlockingMutexEEC2EPS1_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef) unnamed_addr #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN11__sanitizer17GenericScopedLockINS_13BlockingMutexEED2Ev(ptr noundef nonnull align 8 dereferenceable(8)) unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZN11__sanitizer14ThreadRegistry10FindThreadEPFbPNS_17ThreadContextBaseEPvES3_(ptr noundef nonnull align 8 dereferenceable(208) %0, ptr nocapture noundef readonly %1, ptr noundef %2) local_unnamed_addr #1 align 2 personality ptr @__gxx_personality_v0 {
  %4 = alloca %"class.__sanitizer::GenericScopedLock", align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #3
  %5 = getelementptr inbounds i8, ptr %0, i64 24
  call void @_ZN11__sanitizer17GenericScopedLockINS_13BlockingMutexEEC2EPS1_(ptr noundef nonnull align 8 dereferenceable(8) %4, ptr noundef nonnull %5)
  %6 = getelementptr inbounds i8, ptr %0, i64 112
  %7 = load i32, ptr %6, align 8, !tbaa !5
  %.not1823.not = icmp eq i32 %7, 0
  br i1 %.not1823.not, label %.loopexit, label %.lr.ph

.lr.ph:                                           ; preds = %3
  %8 = getelementptr inbounds i8, ptr %0, i64 152
  br label %9

9:                                                ; preds = %.lr.ph, %22
  %10 = phi i32 [ %7, %.lr.ph ], [ %23, %22 ]
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %22 ]
  %11 = load ptr, ptr %8, align 8, !tbaa !15
  %12 = getelementptr inbounds ptr, ptr %11, i64 %indvars.iv
  %13 = load ptr, ptr %12, align 8, !tbaa !16
  %.not = icmp eq ptr %13, null
  br i1 %.not, label %22, label %14

14:                                               ; preds = %9
  %15 = invoke noundef zeroext i1 %1(ptr noundef nonnull %13, ptr noundef %2)
          to label %16 unwind label %17

16:                                               ; preds = %14
  br i1 %15, label %19, label %._crit_edge

._crit_edge:                                      ; preds = %16
  %.pre = load i32, ptr %6, align 8, !tbaa !5
  br label %22

17:                                               ; preds = %14
  %18 = landingpad { ptr, i32 }
          cleanup
  call void @_ZN11__sanitizer17GenericScopedLockINS_13BlockingMutexEED2Ev(ptr noundef nonnull align 8 dereferenceable(8) %4) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #3
  resume { ptr, i32 } %18

19:                                               ; preds = %16
  %20 = getelementptr inbounds i8, ptr %13, i64 8
  %21 = load i32, ptr %20, align 8, !tbaa !17
  br label %.loopexit

22:                                               ; preds = %._crit_edge, %9
  %23 = phi i32 [ %.pre, %._crit_edge ], [ %10, %9 ]
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %24 = zext i32 %23 to i64
  %.not18 = icmp ult i64 %indvars.iv.next, %24
  br i1 %.not18, label %9, label %.loopexit, !llvm.loop !21

.loopexit:                                        ; preds = %22, %3, %19
  %spec.select = phi i32 [ %21, %19 ], [ -1, %3 ], [ -1, %22 ]
  call void @_ZN11__sanitizer17GenericScopedLockINS_13BlockingMutexEED2Ev(ptr noundef nonnull align 8 dereferenceable(8) %4) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #3
  ret i32 %spec.select
}

attributes #0 = { mustprogress 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 = { 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, !10, i64 112}
!6 = !{!"_ZTSN11__sanitizer14ThreadRegistryE", !7, i64 0, !10, i64 8, !10, i64 12, !10, i64 16, !11, i64 24, !10, i64 112, !13, i64 120, !12, i64 128, !12, i64 136, !12, i64 144, !7, i64 152, !14, i64 160, !14, i64 184}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!"_ZTSN11__sanitizer13BlockingMutexE", !8, i64 0, !12, i64 80}
!12 = !{!"long", !8, i64 0}
!13 = !{!"long long", !8, i64 0}
!14 = !{!"_ZTSN11__sanitizer13IntrusiveListINS_17ThreadContextBaseEEE", !12, i64 0, !7, i64 8, !7, i64 16}
!15 = !{!6, !7, i64 152}
!16 = !{!7, !7, i64 0}
!17 = !{!18, !10, i64 8}
!18 = !{!"_ZTSN11__sanitizer17ThreadContextBaseE", !10, i64 8, !13, i64 16, !10, i64 24, !12, i64 32, !12, i64 40, !8, i64 48, !19, i64 112, !20, i64 116, !10, i64 120, !7, i64 128}
!19 = !{!"_ZTSN11__sanitizer12ThreadStatusE", !8, i64 0}
!20 = !{!"bool", !8, i64 0}
!21 = distinct !{!21, !22}
!22 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass