; LLVM IR from brewlin/garbage-collect :: gc-golang/mgc (sweep)

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

%struct.mheap = type { %union.pthread_mutex_t, %struct.mtreap, %struct.mtreap, %struct.array_t, [2 x %struct.gcSweepBuf], %struct.mfixalloc, %struct.mfixalloc, %struct.mfixalloc, %struct.mfixalloc, %struct.mfixalloc, %struct.mfixalloc, %struct.lineralloc, %struct.array_t, ptr, [1 x %struct.array_t], i64, i32, i32, i32, ptr, i64, i64, i64, [134 x %struct.mcentral] }
%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 }
%struct.mtreap = type { ptr }
%struct.gcSweepBuf = type { %union.pthread_mutex_t, ptr, i64, i64, i32 }
%struct.mfixalloc = type { i64, ptr, ptr, ptr, i64, i32, i64, i8 }
%struct.lineralloc = type { i64, i64, i64 }
%struct.array_t = type { ptr, i32, i64, i32 }
%struct.mcentral = type { %union.pthread_mutex_t, i8, %struct.mspanlist, %struct.mspanlist, i64 }
%struct.mspanlist = type { ptr, ptr }
%struct.mspan = type { ptr, ptr, ptr, i64, i64, i64, i8, i8, i8, i16, i32, i64, i8, i16, i8, i8, i16, i64, i64, i64, ptr, ptr, i64 }
%struct.gg = type { ptr, i8, %struct.mstack, i64, i64, i64, %union.pthread_mutex_t }
%struct.mstack = type { i64, i64 }
%struct.mm = type { i64, i32, ptr, ptr, ptr, %union.pthread_mutex_t, ptr, i32, ptr, [2 x i32] }
%struct.mcache = type { i64, i64, i64, i64, [134 x ptr], [67 x i64], i32 }

@heap_ = external global %struct.mheap, align 8
@.str = external hidden unnamed_addr constant [28 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [33 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [40 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local zeroext i8 @span_sweep(ptr noundef %0, i8 noundef zeroext %1) #0 {
  %3 = alloca ptr, align 8
  %4 = alloca i8, align 1
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i8, align 1
  %10 = alloca i64, align 8
  %11 = alloca i8, align 1
  %12 = alloca ptr, align 8
  %13 = alloca i8, align 1
  %14 = alloca i16, align 2
  %15 = alloca i64, align 8
  %16 = alloca i32, align 4
  %17 = alloca i8, align 1
  %18 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store i8 %1, ptr %4, align 1, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #3
  store ptr @heap_, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  %19 = call ptr (...) @getg()
  store ptr %19, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  %20 = load ptr, ptr %5, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.mheap, ptr %20, i32 0, i32 16
  %22 = load i32, ptr %21, align 8, !tbaa !10
  store i32 %22, ptr %7, align 4, !tbaa !18
  %23 = load ptr, ptr %3, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.mspan, ptr %23, i32 0, i32 6
  %25 = load i8, ptr %24, align 8, !tbaa !19
  %26 = zext i8 %25 to i32
  %27 = icmp ne i32 %26, 2
  br i1 %27, label %35, label %28

28:                                               ; preds = %2
  %29 = load ptr, ptr %3, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.mspan, ptr %29, i32 0, i32 10
  %31 = load i32, ptr %30, align 8, !tbaa !22
  %32 = load i32, ptr %7, align 4, !tbaa !18
  %33 = sub i32 %32, 1
  %34 = icmp ne i32 %31, %33
  br i1 %34, label %35, label %37

35:                                               ; preds = %28, %2
  %36 = call i32 (ptr, ...) @printf(ptr noundef @.str)
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #3
  store i32 poison, ptr %8, align 4, !tbaa !18
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  br label %37

37:                                               ; preds = %35, %28
  call void @llvm.lifetime.start.p0(i64 1, ptr %9) #3
  %38 = load ptr, ptr %3, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.mspan, ptr %38, i32 0, i32 12
  %40 = load i8, ptr %39, align 8, !tbaa !23
  store i8 %40, ptr %9, align 1, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #3
  %41 = load ptr, ptr %3, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.mspan, ptr %41, i32 0, i32 17
  %43 = load i64, ptr %42, align 8, !tbaa !24
  store i64 %43, ptr %10, align 8, !tbaa !25
  call void @llvm.lifetime.start.p0(i64 1, ptr %11) #3
  store i8 0, ptr %11, align 1, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #3
  %44 = load ptr, ptr %6, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.gg, ptr %44, i32 0, i32 0
  %46 = load ptr, ptr %45, align 8, !tbaa !26
  %47 = getelementptr inbounds %struct.mm, ptr %46, i32 0, i32 3
  %48 = load ptr, ptr %47, align 8, !tbaa !29
  store ptr %48, ptr %12, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 1, ptr %13) #3
  store i8 0, ptr %13, align 1, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 2, ptr %14) #3
  %49 = load ptr, ptr %3, align 8, !tbaa !5
  %50 = call i32 @span_countAlloc(ptr noundef %49)
  %51 = trunc i32 %50 to i16
  store i16 %51, ptr %14, align 2, !tbaa !31
  %52 = load i8, ptr %9, align 1, !tbaa !9
  %53 = call signext i8 @sizeclass(i8 noundef zeroext %52)
  %54 = sext i8 %53 to i32
  %55 = icmp eq i32 %54, 0
  br i1 %55, label %56, label %63

56:                                               ; preds = %37
  %57 = load i16, ptr %14, align 2, !tbaa !31
  %58 = zext i16 %57 to i32
  %59 = icmp eq i32 %58, 0
  br i1 %59, label %60, label %63

60:                                               ; preds = %56
  %61 = load ptr, ptr %3, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct.mspan, ptr %61, i32 0, i32 7
  store i8 1, ptr %62, align 1, !tbaa !32
  store i8 1, ptr %13, align 1, !tbaa !9
  br label %63

63:                                               ; preds = %60, %56, %37
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #3
  %64 = load ptr, ptr %3, align 8, !tbaa !5
  %65 = getelementptr inbounds %struct.mspan, ptr %64, i32 0, i32 9
  %66 = load i16, ptr %65, align 4, !tbaa !33
  %67 = zext i16 %66 to i32
  %68 = load i16, ptr %14, align 2, !tbaa !31
  %69 = zext i16 %68 to i32
  %70 = sub nsw i32 %67, %69
  %71 = sext i32 %70 to i64
  store i64 %71, ptr %15, align 8, !tbaa !25
  %72 = load i16, ptr %14, align 2, !tbaa !31
  %73 = zext i16 %72 to i32
  %74 = load ptr, ptr %3, align 8, !tbaa !5
  %75 = getelementptr inbounds %struct.mspan, ptr %74, i32 0, i32 9
  %76 = load i16, ptr %75, align 4, !tbaa !33
  %77 = zext i16 %76 to i32
  %78 = icmp sgt i32 %73, %77
  br i1 %78, label %79, label %81

79:                                               ; preds = %63
  %80 = call i32 (ptr, ...) @printf(ptr noundef @.str.1)
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #3
  store i32 poison, ptr %16, align 4, !tbaa !18
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #3
  br label %81

81:                                               ; preds = %79, %63
  %82 = load i16, ptr %14, align 2, !tbaa !31
  %83 = load ptr, ptr %3, align 8, !tbaa !5
  %84 = getelementptr inbounds %struct.mspan, ptr %83, i32 0, i32 9
  store i16 %82, ptr %84, align 4, !tbaa !33
  call void @llvm.lifetime.start.p0(i64 1, ptr %17) #3
  %85 = load ptr, ptr %3, align 8, !tbaa !5
  %86 = call i64 @span_nextFreeIndex(ptr noundef %85)
  %87 = load ptr, ptr %3, align 8, !tbaa !5
  %88 = getelementptr inbounds %struct.mspan, ptr %87, i32 0, i32 19
  %89 = load i64, ptr %88, align 8, !tbaa !34
  %90 = icmp eq i64 %86, %89
  %91 = zext i1 %90 to i32
  %92 = trunc i32 %91 to i8
  store i8 %92, ptr %17, align 1, !tbaa !9
  %93 = load ptr, ptr %3, align 8, !tbaa !5
  %94 = getelementptr inbounds %struct.mspan, ptr %93, i32 0, i32 18
  store i64 0, ptr %94, align 8, !tbaa !35
  %95 = load ptr, ptr %3, align 8, !tbaa !5
  %96 = getelementptr inbounds %struct.mspan, ptr %95, i32 0, i32 21
  %97 = load ptr, ptr %96, align 8, !tbaa !36
  %98 = load ptr, ptr %3, align 8, !tbaa !5
  %99 = getelementptr inbounds %struct.mspan, ptr %98, i32 0, i32 20
  store ptr %97, ptr %99, align 8, !tbaa !37
  %100 = load ptr, ptr %3, align 8, !tbaa !5
  %101 = getelementptr inbounds %struct.mspan, ptr %100, i32 0, i32 19
  %102 = load i64, ptr %101, align 8, !tbaa !34
  %103 = call ptr @newMarkBits(i64 noundef %102)
  %104 = load ptr, ptr %3, align 8, !tbaa !5
  %105 = getelementptr inbounds %struct.mspan, ptr %104, i32 0, i32 21
  store ptr %103, ptr %105, align 8, !tbaa !36
  %106 = load ptr, ptr %3, align 8, !tbaa !5
  call void @span_refillAllocCache(ptr noundef %106, i64 noundef 0)
  %107 = load i8, ptr %13, align 1, !tbaa !9
  %108 = zext i8 %107 to i32
  %109 = icmp ne i32 %108, 0
  br i1 %109, label %113, label %110

110:                                              ; preds = %81
  %111 = load i64, ptr %15, align 8, !tbaa !25
  %112 = icmp eq i64 %111, 0
  br i1 %112, label %113, label %132

113:                                              ; preds = %110, %81
  %114 = load ptr, ptr %3, align 8, !tbaa !5
  %115 = getelementptr inbounds %struct.mspan, ptr %114, i32 0, i32 6
  %116 = load i8, ptr %115, align 8, !tbaa !19
  %117 = zext i8 %116 to i32
  %118 = icmp ne i32 %117, 2
  br i1 %118, label %126, label %119

119:                                              ; preds = %113
  %120 = load ptr, ptr %3, align 8, !tbaa !5
  %121 = getelementptr inbounds %struct.mspan, ptr %120, i32 0, i32 10
  %122 = load i32, ptr %121, align 8, !tbaa !22
  %123 = load i32, ptr %7, align 4, !tbaa !18
  %124 = sub i32 %123, 1
  %125 = icmp ne i32 %122, %124
  br i1 %125, label %126, label %128

126:                                              ; preds = %119, %113
  %127 = call i32 (ptr, ...) @printf(ptr noundef @.str.2)
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #3
  store i32 poison, ptr %18, align 4, !tbaa !18
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #3
  br label %128

128:                                              ; preds = %126, %119
  %129 = load ptr, ptr %3, align 8, !tbaa !5
  %130 = getelementptr inbounds %struct.mspan, ptr %129, i32 0, i32 10
  %131 = load i32, ptr %7, align 4, !tbaa !18
  call void @atomic_Store(ptr noundef %130, i32 noundef %131)
  br label %132

132:                                              ; preds = %128, %110
  %133 = load i64, ptr %15, align 8, !tbaa !25
  %134 = icmp ugt i64 %133, 0
  br i1 %134, label %135, label %159

135:                                              ; preds = %132
  %136 = load i8, ptr %9, align 1, !tbaa !9
  %137 = call signext i8 @sizeclass(i8 noundef zeroext %136)
  %138 = sext i8 %137 to i32
  %139 = icmp ne i32 %138, 0
  br i1 %139, label %140, label %159

140:                                              ; preds = %135
  %141 = load i64, ptr %15, align 8, !tbaa !25
  %142 = load ptr, ptr %12, align 8, !tbaa !5
  %143 = getelementptr inbounds %struct.mcache, ptr %142, i32 0, i32 5
  %144 = load i8, ptr %9, align 1, !tbaa !9
  %145 = call signext i8 @sizeclass(i8 noundef zeroext %144)
  %146 = sext i8 %145 to i64
  %147 = getelementptr inbounds [67 x i64], ptr %143, i64 0, i64 %146
  %148 = load i64, ptr %147, align 8, !tbaa !25
  %149 = add i64 %148, %141
  store i64 %149, ptr %147, align 8, !tbaa !25
  %150 = load ptr, ptr %5, align 8, !tbaa !5
  %151 = getelementptr inbounds %struct.mheap, ptr %150, i32 0, i32 23
  %152 = load i8, ptr %9, align 1, !tbaa !9
  %153 = zext i8 %152 to i64
  %154 = getelementptr inbounds [134 x %struct.mcentral], ptr %151, i64 0, i64 %153
  %155 = load ptr, ptr %3, align 8, !tbaa !5
  %156 = load i8, ptr %4, align 1, !tbaa !9
  %157 = load i8, ptr %17, align 1, !tbaa !9
  %158 = call zeroext i8 @central_freeSpan(ptr noundef %154, ptr noundef %155, i8 noundef zeroext %156, i8 noundef zeroext %157)
  store i8 %158, ptr %11, align 1, !tbaa !9
  br label %165

159:                                              ; preds = %135, %132
  %160 = load i8, ptr %13, align 1, !tbaa !9
  %161 = icmp ne i8 %160, 0
  br i1 %161, label %162, label %164

162:                                              ; preds = %159
  %163 = load ptr, ptr %3, align 8, !tbaa !5
  call void @heap_freeSpan(ptr noundef %163, i8 noundef zeroext 1)
  store i8 1, ptr %11, align 1, !tbaa !9
  br label %164

164:                                              ; preds = %162, %159
  br label %165

165:                                              ; preds = %164, %140
  %166 = load i8, ptr %11, align 1, !tbaa !9
  %167 = icmp ne i8 %166, 0
  br i1 %167, label %177, label %168

168:                                              ; preds = %165
  %169 = load ptr, ptr %5, align 8, !tbaa !5
  %170 = getelementptr inbounds %struct.mheap, ptr %169, i32 0, i32 4
  %171 = load i32, ptr %7, align 4, !tbaa !18
  %172 = udiv i32 %171, 2
  %173 = urem i32 %172, 2
  %174 = zext i32 %173 to i64
  %175 = getelementptr inbounds [2 x %struct.gcSweepBuf], ptr %170, i64 0, i64 %174
  %176 = load ptr, ptr %3, align 8, !tbaa !5
  call void @gcsweepbuf_push(ptr noundef %175, ptr noundef %176)
  br label %177

177:                                              ; preds = %168, %165
  %178 = load i8, ptr %11, align 1, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 1, ptr %17) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #3
  call void @llvm.lifetime.end.p0(i64 2, ptr %14) #3
  call void @llvm.lifetime.end.p0(i64 1, ptr %13) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #3
  call void @llvm.lifetime.end.p0(i64 1, ptr %11) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 1, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #3
  ret i8 %178
}

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

declare ptr @getg(...) #2

declare i32 @printf(ptr noundef, ...) #2

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

declare i32 @span_countAlloc(ptr noundef) #2

declare signext i8 @sizeclass(i8 noundef zeroext) #2

declare i64 @span_nextFreeIndex(ptr noundef) #2

declare ptr @newMarkBits(i64 noundef) #2

declare void @span_refillAllocCache(ptr noundef, i64 noundef) #2

declare void @atomic_Store(ptr noundef, i32 noundef) #2

declare zeroext i8 @central_freeSpan(ptr noundef, ptr noundef, i8 noundef zeroext, i8 noundef zeroext) #2

declare void @heap_freeSpan(ptr noundef, i8 noundef zeroext) #2

declare void @gcsweepbuf_push(ptr noundef, ptr noundef) #2

attributes #0 = { 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 #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { "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/C++ TBAA"}
!9 = !{!7, !7, i64 0}
!10 = !{!11, !14, i64 720}
!11 = !{!"mheap", !7, i64 0, !12, i64 40, !12, i64 48, !13, i64 56, !7, i64 88, !16, i64 232, !16, i64 296, !16, i64 360, !16, i64 424, !16, i64 488, !16, i64 552, !17, i64 616, !13, i64 640, !6, i64 672, !7, i64 680, !15, i64 712, !14, i64 720, !14, i64 724, !14, i64 728, !6, i64 736, !15, i64 744, !15, i64 752, !15, i64 760, !7, i64 768}
!12 = !{!"mtreap", !6, i64 0}
!13 = !{!"", !6, i64 0, !14, i64 8, !15, i64 16, !14, i64 24}
!14 = !{!"int", !7, i64 0}
!15 = !{!"long", !7, i64 0}
!16 = !{!"mfixalloc", !15, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !15, i64 32, !14, i64 40, !15, i64 48, !7, i64 56}
!17 = !{!"", !15, i64 0, !15, i64 8, !15, i64 16}
!18 = !{!14, !14, i64 0}
!19 = !{!20, !7, i64 48}
!20 = !{!"mspan", !6, i64 0, !6, i64 8, !6, i64 16, !15, i64 24, !15, i64 32, !15, i64 40, !7, i64 48, !7, i64 49, !7, i64 50, !21, i64 52, !14, i64 56, !15, i64 64, !7, i64 72, !21, i64 74, !7, i64 76, !7, i64 77, !21, i64 78, !15, i64 80, !15, i64 88, !15, i64 96, !6, i64 104, !6, i64 112, !15, i64 120}
!21 = !{!"short", !7, i64 0}
!22 = !{!20, !14, i64 56}
!23 = !{!20, !7, i64 72}
!24 = !{!20, !15, i64 80}
!25 = !{!15, !15, i64 0}
!26 = !{!27, !6, i64 0}
!27 = !{!"gg", !6, i64 0, !7, i64 8, !28, i64 16, !15, i64 32, !15, i64 40, !15, i64 48, !7, i64 56}
!28 = !{!"mstack", !15, i64 0, !15, i64 8}
!29 = !{!30, !6, i64 24}
!30 = !{!"mm", !15, i64 0, !14, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !7, i64 40, !6, i64 80, !14, i64 88, !6, i64 96, !7, i64 104}
!31 = !{!21, !21, i64 0}
!32 = !{!20, !7, i64 49}
!33 = !{!20, !21, i64 52}
!34 = !{!20, !15, i64 96}
!35 = !{!20, !15, i64 88}
!36 = !{!20, !6, i64 112}
!37 = !{!20, !6, i64 104}


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

%struct.mheap = type { %union.pthread_mutex_t, %struct.mtreap, %struct.mtreap, %struct.array_t, [2 x %struct.gcSweepBuf], %struct.mfixalloc, %struct.mfixalloc, %struct.mfixalloc, %struct.mfixalloc, %struct.mfixalloc, %struct.mfixalloc, %struct.lineralloc, %struct.array_t, ptr, [1 x %struct.array_t], i64, i32, i32, i32, ptr, i64, i64, i64, [134 x %struct.mcentral] }
%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 }
%struct.mtreap = type { ptr }
%struct.gcSweepBuf = type { %union.pthread_mutex_t, ptr, i64, i64, i32 }
%struct.mfixalloc = type { i64, ptr, ptr, ptr, i64, i32, i64, i8 }
%struct.lineralloc = type { i64, i64, i64 }
%struct.array_t = type { ptr, i32, i64, i32 }
%struct.mcentral = type { %union.pthread_mutex_t, i8, %struct.mspanlist, %struct.mspanlist, i64 }
%struct.mspanlist = type { ptr, ptr }

@heap_ = external global %struct.mheap, align 8
@.str = external hidden unnamed_addr constant [28 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [33 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [40 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local zeroext i8 @span_sweep(ptr noundef %0, i8 noundef zeroext %1) local_unnamed_addr #0 {
  %3 = tail call ptr (...) @getg() #3
  %4 = load i32, ptr getelementptr inbounds (i8, ptr @heap_, i64 720), align 8, !tbaa !5
  %5 = getelementptr inbounds i8, ptr %0, i64 48
  %6 = load i8, ptr %5, align 8, !tbaa !16
  %.not = icmp eq i8 %6, 2
  br i1 %.not, label %7, label %11

7:                                                ; preds = %2
  %8 = getelementptr inbounds i8, ptr %0, i64 56
  %9 = load i32, ptr %8, align 8, !tbaa !19
  %10 = add i32 %4, -1
  %.not54 = icmp eq i32 %9, %10
  br i1 %.not54, label %13, label %11

11:                                               ; preds = %7, %2
  %12 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str)
  br label %13

13:                                               ; preds = %11, %7
  %14 = getelementptr inbounds i8, ptr %0, i64 72
  %15 = load i8, ptr %14, align 8, !tbaa !20
  %16 = load ptr, ptr %3, align 8, !tbaa !21
  %17 = getelementptr inbounds i8, ptr %16, i64 24
  %18 = load ptr, ptr %17, align 8, !tbaa !24
  %19 = tail call i32 @span_countAlloc(ptr noundef nonnull %0) #3
  %20 = trunc i32 %19 to i16
  %21 = tail call signext i8 @sizeclass(i8 noundef zeroext %15) #3
  %22 = icmp eq i8 %21, 0
  %23 = and i32 %19, 65535
  %24 = icmp eq i32 %23, 0
  %or.cond = select i1 %22, i1 %24, i1 false
  br i1 %or.cond, label %25, label %27

25:                                               ; preds = %13
  %26 = getelementptr inbounds i8, ptr %0, i64 49
  store i8 1, ptr %26, align 1, !tbaa !26
  br label %27

27:                                               ; preds = %25, %13
  %28 = getelementptr inbounds i8, ptr %0, i64 52
  %29 = load i16, ptr %28, align 4, !tbaa !27
  %30 = zext i16 %29 to i32
  %31 = sub nsw i32 %30, %23
  %32 = sext i32 %31 to i64
  %33 = icmp ugt i32 %23, %30
  br i1 %33, label %34, label %36

34:                                               ; preds = %27
  %35 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1)
  br label %36

36:                                               ; preds = %34, %27
  store i16 %20, ptr %28, align 4, !tbaa !27
  %37 = tail call i64 @span_nextFreeIndex(ptr noundef nonnull %0) #3
  %38 = getelementptr inbounds i8, ptr %0, i64 96
  %39 = load i64, ptr %38, align 8, !tbaa !28
  %40 = icmp eq i64 %37, %39
  %41 = zext i1 %40 to i8
  %42 = getelementptr inbounds i8, ptr %0, i64 88
  store i64 0, ptr %42, align 8, !tbaa !29
  %43 = getelementptr inbounds i8, ptr %0, i64 112
  %44 = load ptr, ptr %43, align 8, !tbaa !30
  %45 = getelementptr inbounds i8, ptr %0, i64 104
  store ptr %44, ptr %45, align 8, !tbaa !31
  %46 = tail call ptr @newMarkBits(i64 noundef %39) #3
  store ptr %46, ptr %43, align 8, !tbaa !30
  tail call void @span_refillAllocCache(ptr noundef nonnull %0, i64 noundef 0) #3
  %47 = icmp eq i32 %23, %30
  %or.cond4 = select i1 %or.cond, i1 true, i1 %47
  br i1 %or.cond4, label %48, label %58

48:                                               ; preds = %36
  %49 = load i8, ptr %5, align 8, !tbaa !16
  %.not55 = icmp eq i8 %49, 2
  br i1 %.not55, label %50, label %54

50:                                               ; preds = %48
  %51 = getelementptr inbounds i8, ptr %0, i64 56
  %52 = load i32, ptr %51, align 8, !tbaa !19
  %53 = add i32 %4, -1
  %.not56 = icmp eq i32 %52, %53
  br i1 %.not56, label %56, label %54

54:                                               ; preds = %50, %48
  %55 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2)
  br label %56

56:                                               ; preds = %54, %50
  %57 = getelementptr inbounds i8, ptr %0, i64 56
  tail call void @atomic_Store(ptr noundef nonnull %57, i32 noundef %4) #3
  br label %58

58:                                               ; preds = %36, %56
  br i1 %47, label %61, label %59

59:                                               ; preds = %58
  %60 = tail call signext i8 @sizeclass(i8 noundef zeroext %15) #3
  %.not58 = icmp eq i8 %60, 0
  br i1 %.not58, label %61, label %62

61:                                               ; preds = %59, %58
  br i1 %or.cond, label %.thread65, label %.thread

.thread65:                                        ; preds = %61
  tail call void @heap_freeSpan(ptr noundef nonnull %0, i8 noundef zeroext 1) #3
  br label %76

62:                                               ; preds = %59
  %63 = getelementptr inbounds i8, ptr %18, i64 1104
  %64 = tail call signext i8 @sizeclass(i8 noundef zeroext %15) #3
  %65 = sext i8 %64 to i64
  %66 = getelementptr inbounds [67 x i64], ptr %63, i64 0, i64 %65
  %67 = load i64, ptr %66, align 8, !tbaa !32
  %68 = add i64 %67, %32
  store i64 %68, ptr %66, align 8, !tbaa !32
  %69 = zext i8 %15 to i64
  %70 = getelementptr inbounds [134 x %struct.mcentral], ptr getelementptr inbounds (i8, ptr @heap_, i64 768), i64 0, i64 %69
  %71 = tail call zeroext i8 @central_freeSpan(ptr noundef nonnull %70, ptr noundef nonnull %0, i8 noundef zeroext %1, i8 noundef zeroext %41) #3
  %.not60 = icmp eq i8 %71, 0
  br i1 %.not60, label %.thread, label %76

.thread:                                          ; preds = %61, %62
  %72 = lshr i32 %4, 1
  %73 = and i32 %72, 1
  %74 = zext nneg i32 %73 to i64
  %75 = getelementptr inbounds [2 x %struct.gcSweepBuf], ptr getelementptr inbounds (i8, ptr @heap_, i64 88), i64 0, i64 %74
  tail call void @gcsweepbuf_push(ptr noundef nonnull %75, ptr noundef nonnull %0) #3
  br label %76

76:                                               ; preds = %.thread65, %.thread, %62
  %.063 = phi i8 [ 0, %.thread ], [ %71, %62 ], [ 1, %.thread65 ]
  ret i8 %.063
}

declare ptr @getg(...) local_unnamed_addr #1

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2

declare i32 @span_countAlloc(ptr noundef) local_unnamed_addr #1

declare signext i8 @sizeclass(i8 noundef zeroext) local_unnamed_addr #1

declare i64 @span_nextFreeIndex(ptr noundef) local_unnamed_addr #1

declare ptr @newMarkBits(i64 noundef) local_unnamed_addr #1

declare void @span_refillAllocCache(ptr noundef, i64 noundef) local_unnamed_addr #1

declare void @atomic_Store(ptr noundef, i32 noundef) local_unnamed_addr #1

declare zeroext i8 @central_freeSpan(ptr noundef, ptr noundef, i8 noundef zeroext, i8 noundef zeroext) local_unnamed_addr #1

declare void @heap_freeSpan(ptr noundef, i8 noundef zeroext) local_unnamed_addr #1

declare void @gcsweepbuf_push(ptr noundef, ptr noundef) local_unnamed_addr #1

attributes #0 = { 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 #1 = { "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 = { nofree nounwind "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, !12, i64 720}
!6 = !{!"mheap", !7, i64 0, !9, i64 40, !9, i64 48, !11, i64 56, !7, i64 88, !14, i64 232, !14, i64 296, !14, i64 360, !14, i64 424, !14, i64 488, !14, i64 552, !15, i64 616, !11, i64 640, !10, i64 672, !7, i64 680, !13, i64 712, !12, i64 720, !12, i64 724, !12, i64 728, !10, i64 736, !13, i64 744, !13, i64 752, !13, i64 760, !7, i64 768}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!"mtreap", !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!"", !10, i64 0, !12, i64 8, !13, i64 16, !12, i64 24}
!12 = !{!"int", !7, i64 0}
!13 = !{!"long", !7, i64 0}
!14 = !{!"mfixalloc", !13, i64 0, !10, i64 8, !10, i64 16, !10, i64 24, !13, i64 32, !12, i64 40, !13, i64 48, !7, i64 56}
!15 = !{!"", !13, i64 0, !13, i64 8, !13, i64 16}
!16 = !{!17, !7, i64 48}
!17 = !{!"mspan", !10, i64 0, !10, i64 8, !10, i64 16, !13, i64 24, !13, i64 32, !13, i64 40, !7, i64 48, !7, i64 49, !7, i64 50, !18, i64 52, !12, i64 56, !13, i64 64, !7, i64 72, !18, i64 74, !7, i64 76, !7, i64 77, !18, i64 78, !13, i64 80, !13, i64 88, !13, i64 96, !10, i64 104, !10, i64 112, !13, i64 120}
!18 = !{!"short", !7, i64 0}
!19 = !{!17, !12, i64 56}
!20 = !{!17, !7, i64 72}
!21 = !{!22, !10, i64 0}
!22 = !{!"gg", !10, i64 0, !7, i64 8, !23, i64 16, !13, i64 32, !13, i64 40, !13, i64 48, !7, i64 56}
!23 = !{!"mstack", !13, i64 0, !13, i64 8}
!24 = !{!25, !10, i64 24}
!25 = !{!"mm", !13, i64 0, !12, i64 8, !10, i64 16, !10, i64 24, !10, i64 32, !7, i64 40, !10, i64 80, !12, i64 88, !10, i64 96, !7, i64 104}
!26 = !{!17, !7, i64 49}
!27 = !{!17, !18, i64 52}
!28 = !{!17, !13, i64 96}
!29 = !{!17, !13, i64 88}
!30 = !{!17, !10, i64 112}
!31 = !{!17, !10, i64 104}
!32 = !{!13, !13, i64 0}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,SROAPass,SimplifyCFGPass,TailCallElimPass