; LLVM IR from humz2k/sugaryc :: ext/bdwgc (headers)

; 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._GC_arrays = type { i64, i64, i64, ptr, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, i32, i32, i32, i64, i64, i64, ptr, ptr, i64, i32, i64, i64, i64, %struct.dl_hashtbl_s, %struct.dl_hashtbl_s, %struct.fnlz_roots_s, i32, ptr, i64, i64, i32, i64, i64, i64, ptr, [64 x ptr], [8 x i8], [64 x ptr], [129 x ptr], [129 x ptr], [129 x ptr], [2049 x i64], [129 x ptr], [4096 x i8], [4096 x i64], [4096 x i64], ptr, [2048 x %struct.roots], [512 x %struct.exclusion], [2048 x ptr] }
%struct.dl_hashtbl_s = type { ptr, i64, i32 }
%struct.fnlz_roots_s = type { ptr, ptr }
%struct.roots = type { ptr, ptr, ptr, i32 }
%struct.exclusion = type { ptr, ptr }
%struct.bi = type { [1024 x ptr], ptr, ptr, i64, ptr }

@GC_arrays = external global %struct._GC_arrays, align 8

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

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

; Function Attrs: nounwind uwtable
define dso_local ptr @GC_prev_block(ptr noundef %0) #1 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i64, align 8
  %6 = alloca i64, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i64, align 8
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #2
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #2
  %11 = load ptr, ptr %3, align 8, !tbaa !5
  %12 = ptrtoint ptr %11 to i64
  %13 = lshr i64 %12, 12
  %14 = and i64 %13, 1023
  store i64 %14, ptr %5, align 8, !tbaa !9
  br label %15

15:                                               ; preds = %1
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #2
  %16 = load ptr, ptr %3, align 8, !tbaa !5
  %17 = ptrtoint ptr %16 to i64
  %18 = lshr i64 %17, 22
  store i64 %18, ptr %6, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #2
  %19 = load i64, ptr %6, align 8, !tbaa !9
  %20 = and i64 %19, 2047
  %21 = getelementptr inbounds [2048 x ptr], ptr getelementptr inbounds (%struct._GC_arrays, ptr @GC_arrays, i32 0, i32 61), i64 0, i64 %20
  %22 = load ptr, ptr %21, align 8, !tbaa !5
  store ptr %22, ptr %7, align 8, !tbaa !5
  br label %23

23:                                               ; preds = %35, %15
  %24 = load ptr, ptr %7, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.bi, ptr %24, i32 0, i32 3
  %26 = load i64, ptr %25, align 8, !tbaa !11
  %27 = load i64, ptr %6, align 8, !tbaa !9
  %28 = icmp ne i64 %26, %27
  br i1 %28, label %29, label %33

29:                                               ; preds = %23
  %30 = load ptr, ptr %7, align 8, !tbaa !5
  %31 = load ptr, ptr getelementptr inbounds (%struct._GC_arrays, ptr @GC_arrays, i32 0, i32 28), align 8, !tbaa !13
  %32 = icmp ne ptr %30, %31
  br label %33

33:                                               ; preds = %29, %23
  %34 = phi i1 [ false, %23 ], [ %32, %29 ]
  br i1 %34, label %35, label %39

35:                                               ; preds = %33
  %36 = load ptr, ptr %7, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.bi, ptr %36, i32 0, i32 4
  %38 = load ptr, ptr %37, align 8, !tbaa !18
  store ptr %38, ptr %7, align 8, !tbaa !5
  br label %23, !llvm.loop !19

39:                                               ; preds = %33
  %40 = load ptr, ptr %7, align 8, !tbaa !5
  store ptr %40, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #2
  br label %41

41:                                               ; preds = %39
  br label %42

42:                                               ; preds = %41
  %43 = load ptr, ptr %4, align 8, !tbaa !5
  %44 = load ptr, ptr getelementptr inbounds (%struct._GC_arrays, ptr @GC_arrays, i32 0, i32 28), align 8, !tbaa !13
  %45 = icmp eq ptr %43, %44
  br i1 %45, label %46, label %67

46:                                               ; preds = %42
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #2
  %47 = load ptr, ptr %3, align 8, !tbaa !5
  %48 = ptrtoint ptr %47 to i64
  %49 = lshr i64 %48, 22
  store i64 %49, ptr %8, align 8, !tbaa !9
  %50 = load ptr, ptr getelementptr inbounds (%struct._GC_arrays, ptr @GC_arrays, i32 0, i32 15), align 8, !tbaa !21
  store ptr %50, ptr %4, align 8, !tbaa !5
  br label %51

51:                                               ; preds = %62, %46
  %52 = load ptr, ptr %4, align 8, !tbaa !5
  %53 = icmp ne ptr %52, null
  br i1 %53, label %54, label %60

54:                                               ; preds = %51
  %55 = load ptr, ptr %4, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct.bi, ptr %55, i32 0, i32 3
  %57 = load i64, ptr %56, align 8, !tbaa !11
  %58 = load i64, ptr %8, align 8, !tbaa !9
  %59 = icmp ugt i64 %57, %58
  br label %60

60:                                               ; preds = %54, %51
  %61 = phi i1 [ false, %51 ], [ %59, %54 ]
  br i1 %61, label %62, label %66

62:                                               ; preds = %60
  %63 = load ptr, ptr %4, align 8, !tbaa !5
  %64 = getelementptr inbounds %struct.bi, ptr %63, i32 0, i32 2
  %65 = load ptr, ptr %64, align 8, !tbaa !22
  store ptr %65, ptr %4, align 8, !tbaa !5
  br label %51, !llvm.loop !23

66:                                               ; preds = %60
  store i64 1023, ptr %5, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #2
  br label %67

67:                                               ; preds = %66, %42
  br label %68

68:                                               ; preds = %110, %67
  %69 = load ptr, ptr %4, align 8, !tbaa !5
  %70 = icmp ne ptr %69, null
  br i1 %70, label %71, label %114

71:                                               ; preds = %68
  br label %72

72:                                               ; preds = %108, %71
  %73 = load i64, ptr %5, align 8, !tbaa !9
  %74 = icmp sge i64 %73, 0
  br i1 %74, label %75, label %109

75:                                               ; preds = %72
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #2
  %76 = load ptr, ptr %4, align 8, !tbaa !5
  %77 = getelementptr inbounds %struct.bi, ptr %76, i32 0, i32 0
  %78 = load i64, ptr %5, align 8, !tbaa !9
  %79 = getelementptr inbounds [1024 x ptr], ptr %77, i64 0, i64 %78
  %80 = load ptr, ptr %79, align 8, !tbaa !5
  store ptr %80, ptr %9, align 8, !tbaa !5
  %81 = load ptr, ptr %9, align 8, !tbaa !5
  %82 = icmp eq ptr null, %81
  br i1 %82, label %83, label %86

83:                                               ; preds = %75
  %84 = load i64, ptr %5, align 8, !tbaa !9
  %85 = add nsw i64 %84, -1
  store i64 %85, ptr %5, align 8, !tbaa !9
  br label %105

86:                                               ; preds = %75
  %87 = load ptr, ptr %9, align 8, !tbaa !5
  %88 = ptrtoint ptr %87 to i64
  %89 = icmp ule i64 %88, 4095
  br i1 %89, label %90, label %95

90:                                               ; preds = %86
  %91 = load ptr, ptr %9, align 8, !tbaa !5
  %92 = ptrtoint ptr %91 to i64
  %93 = load i64, ptr %5, align 8, !tbaa !9
  %94 = sub nsw i64 %93, %92
  store i64 %94, ptr %5, align 8, !tbaa !9
  br label %104

95:                                               ; preds = %86
  %96 = load ptr, ptr %4, align 8, !tbaa !5
  %97 = getelementptr inbounds %struct.bi, ptr %96, i32 0, i32 3
  %98 = load i64, ptr %97, align 8, !tbaa !11
  %99 = shl i64 %98, 10
  %100 = load i64, ptr %5, align 8, !tbaa !9
  %101 = add i64 %99, %100
  %102 = shl i64 %101, 12
  %103 = inttoptr i64 %102 to ptr
  store ptr %103, ptr %2, align 8
  store i32 1, ptr %10, align 4
  br label %106

104:                                              ; preds = %90
  br label %105

105:                                              ; preds = %104, %83
  store i32 0, ptr %10, align 4
  br label %106

106:                                              ; preds = %105, %95
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #2
  %107 = load i32, ptr %10, align 4
  switch i32 %107, label %115 [
    i32 0, label %108
  ]

108:                                              ; preds = %106
  br label %72, !llvm.loop !24

109:                                              ; preds = %72
  store i64 1023, ptr %5, align 8, !tbaa !9
  br label %110

110:                                              ; preds = %109
  %111 = load ptr, ptr %4, align 8, !tbaa !5
  %112 = getelementptr inbounds %struct.bi, ptr %111, i32 0, i32 2
  %113 = load ptr, ptr %112, align 8, !tbaa !22
  store ptr %113, ptr %4, align 8, !tbaa !5
  br label %68, !llvm.loop !25

114:                                              ; preds = %68
  store ptr null, ptr %2, align 8
  store i32 1, ptr %10, align 4
  br label %115

115:                                              ; preds = %114, %106
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #2
  %116 = load ptr, ptr %2, align 8
  ret ptr %116
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { 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 = !{!10, !10, i64 0}
!10 = !{!"long", !7, i64 0}
!11 = !{!12, !10, i64 8208}
!12 = !{!"bi", !7, i64 0, !6, i64 8192, !6, i64 8200, !10, i64 8208, !6, i64 8216}
!13 = !{!14, !6, i64 216}
!14 = !{!"_GC_arrays", !10, i64 0, !10, i64 8, !10, i64 16, !6, i64 24, !10, i64 32, !10, i64 40, !10, i64 48, !10, i64 56, !10, i64 64, !10, i64 72, !10, i64 80, !10, i64 88, !10, i64 96, !10, i64 104, !6, i64 112, !6, i64 120, !6, i64 128, !6, i64 136, !6, i64 144, !6, i64 152, !6, i64 160, !6, i64 168, !15, i64 176, !15, i64 180, !15, i64 184, !10, i64 192, !10, i64 200, !10, i64 208, !6, i64 216, !6, i64 224, !10, i64 232, !15, i64 240, !10, i64 248, !10, i64 256, !10, i64 264, !16, i64 272, !16, i64 296, !17, i64 320, !15, i64 336, !6, i64 344, !10, i64 352, !10, i64 360, !15, i64 368, !10, i64 376, !10, i64 384, !10, i64 392, !6, i64 400, !7, i64 408, !7, i64 920, !7, i64 928, !7, i64 1440, !7, i64 2472, !7, i64 3504, !7, i64 4536, !7, i64 20928, !7, i64 21960, !7, i64 26056, !7, i64 58824, !6, i64 91592, !7, i64 91600, !7, i64 157136, !7, i64 165328}
!15 = !{!"int", !7, i64 0}
!16 = !{!"dl_hashtbl_s", !6, i64 0, !10, i64 8, !15, i64 16}
!17 = !{!"fnlz_roots_s", !6, i64 0, !6, i64 8}
!18 = !{!12, !6, i64 8216}
!19 = distinct !{!19, !20}
!20 = !{!"llvm.loop.mustprogress"}
!21 = !{!14, !6, i64 120}
!22 = !{!12, !6, i64 8200}
!23 = distinct !{!23, !20}
!24 = distinct !{!24, !20}
!25 = distinct !{!25, !20}


; 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._GC_arrays = type { i64, i64, i64, ptr, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, i32, i32, i32, i64, i64, i64, ptr, ptr, i64, i32, i64, i64, i64, %struct.dl_hashtbl_s, %struct.dl_hashtbl_s, %struct.fnlz_roots_s, i32, ptr, i64, i64, i32, i64, i64, i64, ptr, [64 x ptr], [8 x i8], [64 x ptr], [129 x ptr], [129 x ptr], [129 x ptr], [2049 x i64], [129 x ptr], [4096 x i8], [4096 x i64], [4096 x i64], ptr, [2048 x %struct.roots], [512 x %struct.exclusion], [2048 x ptr] }
%struct.dl_hashtbl_s = type { ptr, i64, i32 }
%struct.fnlz_roots_s = type { ptr, ptr }
%struct.roots = type { ptr, ptr, ptr, i32 }
%struct.exclusion = type { ptr, ptr }

@GC_arrays = external local_unnamed_addr global %struct._GC_arrays, align 8

; Function Attrs: nofree norecurse nosync nounwind memory(read, inaccessiblemem: none) uwtable
define dso_local ptr @GC_prev_block(ptr noundef %0) local_unnamed_addr #0 {
  %2 = ptrtoint ptr %0 to i64
  %3 = lshr i64 %2, 12
  %4 = lshr i64 %2, 22
  %5 = and i64 %4, 2047
  %6 = getelementptr inbounds [2048 x ptr], ptr getelementptr inbounds (i8, ptr @GC_arrays, i64 165328), i64 0, i64 %5
  %7 = load ptr, ptr getelementptr inbounds (i8, ptr @GC_arrays, i64 216), align 8
  br label %8

8:                                                ; preds = %8, %1
  %.031.in = phi ptr [ %6, %1 ], [ %14, %8 ]
  %.031 = load ptr, ptr %.031.in, align 8, !tbaa !5
  %9 = getelementptr inbounds i8, ptr %.031, i64 8208
  %10 = load i64, ptr %9, align 8, !tbaa !9
  %11 = icmp ne i64 %10, %4
  %12 = icmp ne ptr %.031, %7
  %13 = select i1 %11, i1 %12, i1 false
  %14 = getelementptr inbounds i8, ptr %.031, i64 8216
  br i1 %13, label %8, label %15, !llvm.loop !12

15:                                               ; preds = %8
  %16 = and i64 %3, 1023
  %17 = icmp eq ptr %.031, %7
  br i1 %17, label %.preheader42, label %.preheader.preheader

.preheader.preheader:                             ; preds = %.lr.ph, %15
  %.23053.ph = phi ptr [ %.031, %15 ], [ %.02847, %.lr.ph ]
  %.13352.ph = phi i64 [ %16, %15 ], [ 1023, %.lr.ph ]
  br label %.preheader

.preheader42:                                     ; preds = %15
  %.02845 = load ptr, ptr getelementptr inbounds (i8, ptr @GC_arrays, i64 120), align 8, !tbaa !5
  %.not46 = icmp eq ptr %.02845, null
  br i1 %.not46, label %.loopexit, label %.lr.ph

.lr.ph:                                           ; preds = %.preheader42, %21
  %.02847 = phi ptr [ %.028, %21 ], [ %.02845, %.preheader42 ]
  %18 = getelementptr inbounds i8, ptr %.02847, i64 8208
  %19 = load i64, ptr %18, align 8, !tbaa !9
  %20 = icmp ugt i64 %19, %4
  br i1 %20, label %21, label %.preheader.preheader

21:                                               ; preds = %.lr.ph
  %22 = getelementptr inbounds i8, ptr %.02847, i64 8200
  %.028 = load ptr, ptr %22, align 8, !tbaa !5
  %.not = icmp eq ptr %.028, null
  br i1 %.not, label %.loopexit, label %.lr.ph, !llvm.loop !14

.preheader:                                       ; preds = %.preheader.preheader, %42
  %.23053 = phi ptr [ %44, %42 ], [ %.23053.ph, %.preheader.preheader ]
  %.13352 = phi i64 [ 1023, %42 ], [ %.13352.ph, %.preheader.preheader ]
  br label %23

23:                                               ; preds = %.preheader, %40
  %.23450 = phi i64 [ %.13352, %.preheader ], [ %.4, %40 ]
  %24 = getelementptr inbounds [1024 x ptr], ptr %.23053, i64 0, i64 %.23450
  %25 = load ptr, ptr %24, align 8, !tbaa !5
  %26 = icmp eq ptr %25, null
  br i1 %26, label %27, label %29

27:                                               ; preds = %23
  %28 = add nsw i64 %.23450, -1
  br label %40

29:                                               ; preds = %23
  %30 = icmp ult ptr %25, inttoptr (i64 4096 to ptr)
  br i1 %30, label %31, label %.thread

31:                                               ; preds = %29
  %32 = ptrtoint ptr %25 to i64
  %33 = sub nsw i64 %.23450, %32
  br label %40

.thread:                                          ; preds = %29
  %34 = getelementptr inbounds i8, ptr %.23053, i64 8208
  %35 = load i64, ptr %34, align 8, !tbaa !9
  %36 = shl i64 %35, 22
  %37 = shl i64 %.23450, 12
  %38 = add i64 %36, %37
  %39 = inttoptr i64 %38 to ptr
  br label %.loopexit

40:                                               ; preds = %27, %31
  %.4 = phi i64 [ %28, %27 ], [ %33, %31 ]
  %41 = icmp sgt i64 %.4, -1
  br i1 %41, label %23, label %42, !llvm.loop !15

42:                                               ; preds = %40
  %43 = getelementptr inbounds i8, ptr %.23053, i64 8200
  %44 = load ptr, ptr %43, align 8, !tbaa !16
  %.not38 = icmp eq ptr %44, null
  br i1 %.not38, label %.loopexit, label %.preheader, !llvm.loop !17

.loopexit:                                        ; preds = %21, %42, %.preheader42, %.thread
  %.3 = phi ptr [ %39, %.thread ], [ null, %.preheader42 ], [ null, %42 ], [ null, %21 ]
  ret ptr %.3
}

attributes #0 = { nofree norecurse nosync nounwind memory(read, inaccessiblemem: none) 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/C++ TBAA"}
!9 = !{!10, !11, i64 8208}
!10 = !{!"bi", !7, i64 0, !6, i64 8192, !6, i64 8200, !11, i64 8208, !6, i64 8216}
!11 = !{!"long", !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}
!14 = distinct !{!14, !13}
!15 = distinct !{!15, !13}
!16 = !{!10, !6, i64 8200}
!17 = distinct !{!17, !13}


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