; 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__sanitizer17ThreadContextBase7SetNameEPKc(ptr noundef nonnull align 8 dereferenceable(136), ptr noundef) #1 align 2

; 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 void @_ZN11__sanitizer14ThreadRegistry21SetThreadNameByUserIdEmPKc(ptr noundef nonnull align 8 dereferenceable(208) %0, i64 noundef %1, ptr noundef %2) #1 align 2 personality ptr @__gxx_personality_v0 {
  %4 = alloca ptr, align 8
  %5 = alloca i64, align 8
  %6 = alloca ptr, align 8
  %7 = alloca %"class.__sanitizer::GenericScopedLock", align 8
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i64 %1, ptr %5, align 8, !tbaa !9
  store ptr %2, ptr %6, align 8, !tbaa !5
  %13 = load ptr, ptr %4, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  %14 = getelementptr inbounds %"class.__sanitizer::ThreadRegistry", ptr %13, i32 0, i32 4
  call void @_ZN11__sanitizer17GenericScopedLockINS_13BlockingMutexEEC2EPS1_(ptr noundef nonnull align 8 dereferenceable(8) %7, ptr noundef %14)
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #3
  store i32 0, ptr %8, align 4, !tbaa !11
  br label %15

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

20:                                               ; preds = %15
  store i32 2, ptr %9, align 4
  br label %56

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

30:                                               ; preds = %21
  %31 = load ptr, ptr %10, align 8, !tbaa !5
  %32 = getelementptr inbounds %"class.__sanitizer::ThreadContextBase", ptr %31, i32 0, i32 5
  %33 = load i64, ptr %32, align 8, !tbaa !19
  %34 = load i64, ptr %5, align 8, !tbaa !9
  %35 = icmp eq i64 %33, %34
  br i1 %35, label %36, label %49

36:                                               ; preds = %30
  %37 = load ptr, ptr %10, align 8, !tbaa !5
  %38 = getelementptr inbounds %"class.__sanitizer::ThreadContextBase", ptr %37, i32 0, i32 7
  %39 = load i32, ptr %38, align 8, !tbaa !23
  %40 = icmp ne i32 %39, 0
  br i1 %40, label %41, label %49

41:                                               ; preds = %36
  %42 = load ptr, ptr %10, align 8, !tbaa !5
  %43 = load ptr, ptr %6, align 8, !tbaa !5
  invoke void @_ZN11__sanitizer17ThreadContextBase7SetNameEPKc(ptr noundef nonnull align 8 dereferenceable(136) %42, ptr noundef %43)
          to label %44 unwind label %45

44:                                               ; preds = %41
  store i32 1, ptr %9, align 4
  br label %50

45:                                               ; preds = %41
  %46 = landingpad { ptr, i32 }
          cleanup
  %47 = extractvalue { ptr, i32 } %46, 0
  store ptr %47, ptr %11, align 8
  %48 = extractvalue { ptr, i32 } %46, 1
  store i32 %48, ptr %12, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  call void @_ZN11__sanitizer17GenericScopedLockINS_13BlockingMutexEED2Ev(ptr noundef nonnull align 8 dereferenceable(8) %7) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  br label %62

49:                                               ; preds = %36, %30, %21
  store i32 0, ptr %9, align 4
  br label %50

50:                                               ; preds = %49, %44
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  %51 = load i32, ptr %9, align 4
  switch i32 %51, label %56 [
    i32 0, label %52
  ]

52:                                               ; preds = %50
  br label %53

53:                                               ; preds = %52
  %54 = load i32, ptr %8, align 4, !tbaa !11
  %55 = add i32 %54, 1
  store i32 %55, ptr %8, align 4, !tbaa !11
  br label %15, !llvm.loop !24

56:                                               ; preds = %50, %20
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  %57 = load i32, ptr %9, align 4
  switch i32 %57, label %59 [
    i32 2, label %58
  ]

58:                                               ; preds = %56
  store i32 0, ptr %9, align 4
  br label %59

59:                                               ; preds = %58, %56
  call void @_ZN11__sanitizer17GenericScopedLockINS_13BlockingMutexEED2Ev(ptr noundef nonnull align 8 dereferenceable(8) %7) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  %60 = load i32, ptr %9, align 4
  switch i32 %60, label %67 [
    i32 0, label %61
    i32 1, label %61
  ]

61:                                               ; preds = %59, %59
  ret void

62:                                               ; preds = %45
  %63 = load ptr, ptr %11, align 8
  %64 = load i32, ptr %12, align 4
  %65 = insertvalue { ptr, i32 } poison, ptr %63, 0
  %66 = insertvalue { ptr, i32 } %65, i32 %64, 1
  resume { ptr, i32 } %66

67:                                               ; preds = %59
  unreachable
}

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 = !{!"long", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!14, !12, i64 112}
!14 = !{!"_ZTSN11__sanitizer14ThreadRegistryE", !6, i64 0, !12, i64 8, !12, i64 12, !12, i64 16, !15, i64 24, !12, i64 112, !16, i64 120, !10, i64 128, !10, i64 136, !10, i64 144, !6, i64 152, !17, i64 160, !17, i64 184}
!15 = !{!"_ZTSN11__sanitizer13BlockingMutexE", !7, i64 0, !10, i64 80}
!16 = !{!"long long", !7, i64 0}
!17 = !{!"_ZTSN11__sanitizer13IntrusiveListINS_17ThreadContextBaseEEE", !10, i64 0, !6, i64 8, !6, i64 16}
!18 = !{!14, !6, i64 152}
!19 = !{!20, !10, i64 40}
!20 = !{!"_ZTSN11__sanitizer17ThreadContextBaseE", !12, i64 8, !16, i64 16, !12, i64 24, !10, i64 32, !10, i64 40, !7, i64 48, !21, i64 112, !22, i64 116, !12, i64 120, !6, i64 128}
!21 = !{!"_ZTSN11__sanitizer12ThreadStatusE", !7, i64 0}
!22 = !{!"bool", !7, i64 0}
!23 = !{!20, !21, i64 112}
!24 = distinct !{!24, !25}
!25 = !{!"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__sanitizer17ThreadContextBase7SetNameEPKc(ptr noundef nonnull align 8 dereferenceable(136), ptr noundef) local_unnamed_addr #1 align 2

; 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 void @_ZN11__sanitizer14ThreadRegistry21SetThreadNameByUserIdEmPKc(ptr noundef nonnull align 8 dereferenceable(208) %0, i64 noundef %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
  %.not18 = icmp eq i32 %7, 0
  br i1 %.not18, label %.critedge, label %.lr.ph

.lr.ph:                                           ; preds = %3
  %8 = getelementptr inbounds i8, ptr %0, i64 152
  %9 = load ptr, ptr %8, align 8, !tbaa !15
  %wide.trip.count = zext i32 %7 to i64
  br label %10

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

13:                                               ; preds = %10
  %14 = getelementptr inbounds i8, ptr %12, i64 40
  %15 = load i64, ptr %14, align 8, !tbaa !17
  %16 = icmp eq i64 %15, %1
  br i1 %16, label %17, label %23

17:                                               ; preds = %13
  %18 = getelementptr inbounds i8, ptr %12, i64 112
  %19 = load i32, ptr %18, align 8, !tbaa !21
  %.not16 = icmp eq i32 %19, 0
  br i1 %.not16, label %23, label %20

20:                                               ; preds = %17
  invoke void @_ZN11__sanitizer17ThreadContextBase7SetNameEPKc(ptr noundef nonnull align 8 dereferenceable(136) %12, ptr noundef %2)
          to label %.critedge unwind label %21

21:                                               ; preds = %20
  %22 = 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 } %22

23:                                               ; preds = %17, %13, %10
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
  br i1 %exitcond.not, label %.critedge, label %10, !llvm.loop !22

.critedge:                                        ; preds = %23, %3, %20
  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 void
}

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, !12, i64 40}
!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 = !{!18, !19, i64 112}
!22 = distinct !{!22, !23}
!23 = !{!"llvm.loop.mustprogress"}


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