; LLVM IR from v4kst1z/TinyGC :: TinyGC.ll (ZN6TinyGC14CheckThresholdEv)

; 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.std::basic_ostream" = type { ptr, %"class.std::basic_ios" }
%"class.std::basic_ios" = type { %"class.std::ios_base", ptr, i8, i8, ptr, ptr, ptr, ptr }
%"class.std::ios_base" = type { ptr, i64, i64, i32, i32, i32, ptr, %"struct.std::ios_base::_Words", [8 x %"struct.std::ios_base::_Words"], i32, ptr, %"class.std::locale" }
%"struct.std::ios_base::_Words" = type { ptr, i64 }
%"class.std::locale" = type { ptr }
%class.TinyGC = type <{ %"class.std::unordered_set", %"class.std::unordered_map", %"class.std::mutex", %"class.std::mutex", ptr, i32, i32, i32, i32, i32, [4 x i8] }>
%"class.std::unordered_set" = type { %"class.std::_Hashtable" }
%"class.std::_Hashtable" = type { ptr, i64, %"struct.std::__detail::_Hash_node_base", i64, %"struct.std::__detail::_Prime_rehash_policy", ptr }
%"struct.std::__detail::_Hash_node_base" = type { ptr }
%"struct.std::__detail::_Prime_rehash_policy" = type { float, i64 }
%"class.std::unordered_map" = type { %"class.std::_Hashtable.2" }
%"class.std::_Hashtable.2" = type { ptr, i64, %"struct.std::__detail::_Hash_node_base", i64, %"struct.std::__detail::_Prime_rehash_policy", ptr }
%"class.std::mutex" = type { %"class.std::__mutex_base" }
%"class.std::__mutex_base" = type { %union.pthread_mutex_t }
%union.pthread_mutex_t = type { %struct.__pthread_mutex_s }
%struct.__pthread_mutex_s = type { i32, i32, i32, i32, i32, i16, i16, %struct.__pthread_internal_list }
%struct.__pthread_internal_list = type { ptr, ptr }

@_ZSt4cerr = external global %"class.std::basic_ostream", align 8
@.str.13 = external hidden unnamed_addr constant [36 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [38 x i8], align 1

; Function Attrs: inlinehint mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef) #0

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

; Function Attrs: inlinehint mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_(ptr noundef nonnull align 8 dereferenceable(8)) #0

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN6TinyGC14CheckThresholdEv(ptr noundef nonnull align 8 dereferenceable(220) %0) #1 align 2 {
  %2 = alloca ptr, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  %3 = load ptr, ptr %2, align 8
  %4 = getelementptr inbounds %class.TinyGC, ptr %3, i32 0, i32 7
  %5 = load i32, ptr %4, align 8, !tbaa !9
  %6 = getelementptr inbounds %class.TinyGC, ptr %3, i32 0, i32 8
  %7 = load i32, ptr %6, align 4, !tbaa !23
  %8 = icmp sge i32 %5, %7
  br i1 %8, label %9, label %14

9:                                                ; preds = %1
  br label %10

10:                                               ; preds = %9
  %11 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cerr, ptr noundef @.str.13)
  %12 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %11, ptr noundef @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
  br label %13

13:                                               ; preds = %10
  call void @_ZN6TinyGC11MarkSweepGCEv(ptr noundef nonnull align 8 dereferenceable(220) %3)
  br label %14

14:                                               ; preds = %13, %1
  %15 = getelementptr inbounds %class.TinyGC, ptr %3, i32 0, i32 7
  %16 = load i32, ptr %15, align 8, !tbaa !9
  %17 = getelementptr inbounds %class.TinyGC, ptr %3, i32 0, i32 8
  %18 = load i32, ptr %17, align 4, !tbaa !23
  %19 = icmp sge i32 %16, %18
  br i1 %19, label %20, label %24

20:                                               ; preds = %14
  %21 = getelementptr inbounds %class.TinyGC, ptr %3, i32 0, i32 8
  %22 = load i32, ptr %21, align 4, !tbaa !23
  %23 = mul nsw i32 %22, 2
  store i32 %23, ptr %21, align 4, !tbaa !23
  br label %24

24:                                               ; preds = %20, %14
  %25 = getelementptr inbounds %class.TinyGC, ptr %3, i32 0, i32 6
  %26 = load i32, ptr %25, align 4, !tbaa !24
  %27 = getelementptr inbounds %class.TinyGC, ptr %3, i32 0, i32 9
  %28 = load i32, ptr %27, align 8, !tbaa !25
  %29 = icmp sge i32 %26, %28
  br i1 %29, label %30, label %35

30:                                               ; preds = %24
  br label %31

31:                                               ; preds = %30
  %32 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cerr, ptr noundef @.str.14)
  %33 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %32, ptr noundef @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
  br label %34

34:                                               ; preds = %31
  call void @_ZN6TinyGC11MarkSweepGCEv(ptr noundef nonnull align 8 dereferenceable(220) %3)
  br label %35

35:                                               ; preds = %34, %24
  %36 = getelementptr inbounds %class.TinyGC, ptr %3, i32 0, i32 6
  %37 = load i32, ptr %36, align 4, !tbaa !24
  %38 = getelementptr inbounds %class.TinyGC, ptr %3, i32 0, i32 9
  %39 = load i32, ptr %38, align 8, !tbaa !25
  %40 = icmp sge i32 %37, %39
  br i1 %40, label %41, label %45

41:                                               ; preds = %35
  %42 = getelementptr inbounds %class.TinyGC, ptr %3, i32 0, i32 9
  %43 = load i32, ptr %42, align 8, !tbaa !25
  %44 = mul nsw i32 %43, 2
  store i32 %44, ptr %42, align 8, !tbaa !25
  br label %45

45:                                               ; preds = %41, %35
  ret void
}

attributes #0 = { inlinehint 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 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, !22, i64 208}
!10 = !{!"_ZTS6TinyGC", !11, i64 0, !17, i64 56, !19, i64 112, !19, i64 152, !6, i64 192, !21, i64 200, !22, i64 204, !22, i64 208, !22, i64 212, !22, i64 216}
!11 = !{!"_ZTSSt13unordered_setIP20GarbageCollectedBaseSt4hashIS1_ESt8equal_toIS1_ESaIS1_EE", !12, i64 0}
!12 = !{!"_ZTSSt10_HashtableIP20GarbageCollectedBaseS1_SaIS1_ENSt8__detail9_IdentityESt8equal_toIS1_ESt4hashIS1_ENS3_18_Mod_range_hashingENS3_20_Default_ranged_hashENS3_20_Prime_rehash_policyENS3_17_Hashtable_traitsILb0ELb1ELb1EEEE", !6, i64 0, !13, i64 8, !14, i64 16, !13, i64 24, !15, i64 32, !6, i64 48}
!13 = !{!"long", !7, i64 0}
!14 = !{!"_ZTSNSt8__detail15_Hash_node_baseE", !6, i64 0}
!15 = !{!"_ZTSNSt8__detail20_Prime_rehash_policyE", !16, i64 0, !13, i64 8}
!16 = !{!"float", !7, i64 0}
!17 = !{!"_ZTSSt13unordered_mapINSt6thread2idEPN6TinyGC11ThreadStateESt4hashIS1_ESt8equal_toIS1_ESaISt4pairIKS1_S4_EEE", !18, i64 0}
!18 = !{!"_ZTSSt10_HashtableINSt6thread2idESt4pairIKS1_PN6TinyGC11ThreadStateEESaIS7_ENSt8__detail10_Select1stESt8equal_toIS1_ESt4hashIS1_ENS9_18_Mod_range_hashingENS9_20_Default_ranged_hashENS9_20_Prime_rehash_policyENS9_17_Hashtable_traitsILb0ELb0ELb1EEEE", !6, i64 0, !13, i64 8, !14, i64 16, !13, i64 24, !15, i64 32, !6, i64 48}
!19 = !{!"_ZTSSt5mutex", !20, i64 0}
!20 = !{!"_ZTSSt12__mutex_base", !7, i64 0}
!21 = !{!"_ZTSN6TinyGC7GCPhaseE", !7, i64 0}
!22 = !{!"int", !7, i64 0}
!23 = !{!10, !22, i64 212}
!24 = !{!10, !22, i64 204}
!25 = !{!10, !22, i64 216}


; 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.std::basic_ostream" = type { ptr, %"class.std::basic_ios" }
%"class.std::basic_ios" = type { %"class.std::ios_base", ptr, i8, i8, ptr, ptr, ptr, ptr }
%"class.std::ios_base" = type { ptr, i64, i64, i32, i32, i32, ptr, %"struct.std::ios_base::_Words", [8 x %"struct.std::ios_base::_Words"], i32, ptr, %"class.std::locale" }
%"struct.std::ios_base::_Words" = type { ptr, i64 }
%"class.std::locale" = type { ptr }

@_ZSt4cerr = external global %"class.std::basic_ostream", align 8
@.str.13 = external hidden unnamed_addr constant [36 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [38 x i8], align 1

; Function Attrs: inlinehint mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef) local_unnamed_addr #1 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_(ptr noundef nonnull align 8 dereferenceable(8)) #0

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN6TinyGC11MarkSweepGCEv(ptr noundef nonnull align 8 dereferenceable(220)) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN6TinyGC14CheckThresholdEv(ptr noundef nonnull align 8 dereferenceable(220) %0) local_unnamed_addr #1 align 2 {
  %2 = getelementptr inbounds i8, ptr %0, i64 208
  %3 = load i32, ptr %2, align 8, !tbaa !5
  %4 = getelementptr inbounds i8, ptr %0, i64 212
  %5 = load i32, ptr %4, align 4, !tbaa !22
  %.not = icmp slt i32 %3, %5
  br i1 %.not, label %9, label %6

6:                                                ; preds = %1
  %7 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cerr, ptr noundef nonnull @.str.13)
  %8 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %7, ptr noundef nonnull @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
  tail call void @_ZN6TinyGC11MarkSweepGCEv(ptr noundef nonnull align 8 dereferenceable(220) %0)
  %.pre = load i32, ptr %2, align 8, !tbaa !5
  %.pre5 = load i32, ptr %4, align 4, !tbaa !22
  br label %9

9:                                                ; preds = %6, %1
  %10 = phi i32 [ %.pre5, %6 ], [ %5, %1 ]
  %11 = phi i32 [ %.pre, %6 ], [ %3, %1 ]
  %.not2 = icmp slt i32 %11, %10
  br i1 %.not2, label %14, label %12

12:                                               ; preds = %9
  %13 = shl nsw i32 %10, 1
  store i32 %13, ptr %4, align 4, !tbaa !22
  br label %14

14:                                               ; preds = %12, %9
  %15 = getelementptr inbounds i8, ptr %0, i64 204
  %16 = load i32, ptr %15, align 4, !tbaa !23
  %17 = getelementptr inbounds i8, ptr %0, i64 216
  %18 = load i32, ptr %17, align 8, !tbaa !24
  %.not3 = icmp slt i32 %16, %18
  br i1 %.not3, label %22, label %19

19:                                               ; preds = %14
  %20 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cerr, ptr noundef nonnull @.str.14)
  %21 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %20, ptr noundef nonnull @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
  tail call void @_ZN6TinyGC11MarkSweepGCEv(ptr noundef nonnull align 8 dereferenceable(220) %0)
  %.pre6 = load i32, ptr %15, align 4, !tbaa !23
  %.pre7 = load i32, ptr %17, align 8, !tbaa !24
  br label %22

22:                                               ; preds = %19, %14
  %23 = phi i32 [ %.pre7, %19 ], [ %18, %14 ]
  %24 = phi i32 [ %.pre6, %19 ], [ %16, %14 ]
  %.not4 = icmp slt i32 %24, %23
  br i1 %.not4, label %27, label %25

25:                                               ; preds = %22
  %26 = shl nsw i32 %23, 1
  store i32 %26, ptr %17, align 8, !tbaa !24
  br label %27

27:                                               ; preds = %25, %22
  ret void
}

attributes #0 = { inlinehint 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 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, !21, i64 208}
!6 = !{!"_ZTS6TinyGC", !7, i64 0, !16, i64 56, !18, i64 112, !18, i64 152, !9, i64 192, !20, i64 200, !21, i64 204, !21, i64 208, !21, i64 212, !21, i64 216}
!7 = !{!"_ZTSSt13unordered_setIP20GarbageCollectedBaseSt4hashIS1_ESt8equal_toIS1_ESaIS1_EE", !8, i64 0}
!8 = !{!"_ZTSSt10_HashtableIP20GarbageCollectedBaseS1_SaIS1_ENSt8__detail9_IdentityESt8equal_toIS1_ESt4hashIS1_ENS3_18_Mod_range_hashingENS3_20_Default_ranged_hashENS3_20_Prime_rehash_policyENS3_17_Hashtable_traitsILb0ELb1ELb1EEEE", !9, i64 0, !12, i64 8, !13, i64 16, !12, i64 24, !14, i64 32, !9, i64 48}
!9 = !{!"any pointer", !10, i64 0}
!10 = !{!"omnipotent char", !11, i64 0}
!11 = !{!"Simple C++ TBAA"}
!12 = !{!"long", !10, i64 0}
!13 = !{!"_ZTSNSt8__detail15_Hash_node_baseE", !9, i64 0}
!14 = !{!"_ZTSNSt8__detail20_Prime_rehash_policyE", !15, i64 0, !12, i64 8}
!15 = !{!"float", !10, i64 0}
!16 = !{!"_ZTSSt13unordered_mapINSt6thread2idEPN6TinyGC11ThreadStateESt4hashIS1_ESt8equal_toIS1_ESaISt4pairIKS1_S4_EEE", !17, i64 0}
!17 = !{!"_ZTSSt10_HashtableINSt6thread2idESt4pairIKS1_PN6TinyGC11ThreadStateEESaIS7_ENSt8__detail10_Select1stESt8equal_toIS1_ESt4hashIS1_ENS9_18_Mod_range_hashingENS9_20_Default_ranged_hashENS9_20_Prime_rehash_policyENS9_17_Hashtable_traitsILb0ELb0ELb1EEEE", !9, i64 0, !12, i64 8, !13, i64 16, !12, i64 24, !14, i64 32, !9, i64 48}
!18 = !{!"_ZTSSt5mutex", !19, i64 0}
!19 = !{!"_ZTSSt12__mutex_base", !10, i64 0}
!20 = !{!"_ZTSN6TinyGC7GCPhaseE", !10, i64 0}
!21 = !{!"int", !10, i64 0}
!22 = !{!6, !21, i64 212}
!23 = !{!6, !21, i64 204}
!24 = !{!6, !21, i64 216}


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