; LLVM IR from ryanlayer/giggle :: src (ll)

; 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.cache_handler = type { ptr, ptr, ptr }
%struct.cache_def = type { ptr, ptr, ptr, ptr, ptr, ptr, ptr }
%struct.bpt_node = type { ptr }
%struct.uint64_t_ll_bpt_leading_data = type { ptr }
%struct.uint64_t_ll = type { i64, ptr, ptr }
%struct.uint64_t_ll_node = type { i64, ptr }
%struct.uint64_t_ll_bpt_non_leading_data = type { ptr, ptr }

@uint64_t_ll_non_leading_cache_handler = external dso_local global %struct.cache_handler, align 8
@uint64_t_ll_leading_cache_handler = external dso_local global %struct.cache_handler, align 8
@.str.14 = external hidden unnamed_addr constant [45 x i8], align 1
@cache = external dso_local global %struct.cache_def, align 8
@ORDER = external dso_local global i32, align 4

; 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: noreturn
declare void @err(i32 noundef, ptr noundef, ...) #1

; Function Attrs: nounwind
declare void @free(ptr noundef) #2

; Function Attrs: nounwind uwtable
define dso_local void @uint64_t_ll_leading_repair(i32 noundef %0, ptr noundef %1, ptr noundef %2) #3 {
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca i64, align 8
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca ptr, align 8
  %14 = alloca i64, align 8
  store i32 %0, ptr %4, align 4, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !9
  store ptr %2, ptr %6, align 8, !tbaa !9
  %15 = load ptr, ptr %5, align 8, !tbaa !9
  %16 = getelementptr inbounds %struct.bpt_node, ptr %15, i32 0, i32 0
  %17 = load ptr, ptr %16, align 8, !tbaa !11
  %18 = getelementptr inbounds i32, ptr %17, i64 2
  %19 = load i32, ptr %18, align 4, !tbaa !5
  %20 = icmp eq i32 %19, 1
  br i1 %20, label %21, label %173

21:                                               ; preds = %3
  %22 = load ptr, ptr %6, align 8, !tbaa !9
  %23 = getelementptr inbounds %struct.bpt_node, ptr %22, i32 0, i32 0
  %24 = load ptr, ptr %23, align 8, !tbaa !11
  %25 = getelementptr inbounds i32, ptr %24, i64 2
  %26 = load i32, ptr %25, align 4, !tbaa !5
  %27 = icmp eq i32 %26, 1
  br i1 %27, label %28, label %173

28:                                               ; preds = %21
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #5
  %29 = call noalias ptr @malloc(i64 noundef 8) #6
  store ptr %29, ptr %7, align 8, !tbaa !9
  %30 = load ptr, ptr %7, align 8, !tbaa !9
  %31 = icmp eq ptr %30, null
  br i1 %31, label %32, label %33

32:                                               ; preds = %28
  call void (i32, ptr, ...) @err(i32 noundef 1, ptr noundef @.str.14) #7
  unreachable

33:                                               ; preds = %28
  %34 = load ptr, ptr %7, align 8, !tbaa !9
  %35 = getelementptr inbounds %struct.uint64_t_ll_bpt_leading_data, ptr %34, i32 0, i32 0
  store ptr null, ptr %35, align 8, !tbaa !13
  %36 = load ptr, ptr %5, align 8, !tbaa !9
  %37 = getelementptr inbounds %struct.bpt_node, ptr %36, i32 0, i32 0
  %38 = load ptr, ptr %37, align 8, !tbaa !11
  %39 = getelementptr inbounds i32, ptr %38, i64 3
  %40 = load i32, ptr %39, align 4, !tbaa !5
  %41 = icmp ne i32 %40, 0
  br i1 %41, label %42, label %70

42:                                               ; preds = %33
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #5
  %43 = load ptr, ptr getelementptr inbounds (%struct.cache_def, ptr @cache, i32 0, i32 3), align 8, !tbaa !15
  %44 = load i32, ptr %4, align 4, !tbaa !5
  %45 = load ptr, ptr %5, align 8, !tbaa !9
  %46 = getelementptr inbounds %struct.bpt_node, ptr %45, i32 0, i32 0
  %47 = load ptr, ptr %46, align 8, !tbaa !11
  %48 = getelementptr inbounds i32, ptr %47, i64 3
  %49 = load i32, ptr %48, align 4, !tbaa !5
  %50 = sub i32 %49, 1
  %51 = call ptr %43(i32 noundef %44, i32 noundef %50, ptr noundef @uint64_t_ll_leading_cache_handler)
  store ptr %51, ptr %8, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #5
  %52 = load ptr, ptr %8, align 8, !tbaa !9
  %53 = getelementptr inbounds %struct.uint64_t_ll_bpt_leading_data, ptr %52, i32 0, i32 0
  %54 = load ptr, ptr %53, align 8, !tbaa !13
  %55 = getelementptr inbounds %struct.uint64_t_ll, ptr %54, i32 0, i32 1
  %56 = load ptr, ptr %55, align 8, !tbaa !17
  store ptr %56, ptr %9, align 8, !tbaa !9
  br label %57

57:                                               ; preds = %60, %42
  %58 = load ptr, ptr %9, align 8, !tbaa !9
  %59 = icmp ne ptr %58, null
  br i1 %59, label %60, label %69

60:                                               ; preds = %57
  %61 = load ptr, ptr %7, align 8, !tbaa !9
  %62 = getelementptr inbounds %struct.uint64_t_ll_bpt_leading_data, ptr %61, i32 0, i32 0
  %63 = load ptr, ptr %9, align 8, !tbaa !9
  %64 = getelementptr inbounds %struct.uint64_t_ll_node, ptr %63, i32 0, i32 0
  %65 = load i64, ptr %64, align 8, !tbaa !20
  call void @uint64_t_ll_uniq_append(ptr noundef %62, i64 noundef %65)
  %66 = load ptr, ptr %9, align 8, !tbaa !9
  %67 = getelementptr inbounds %struct.uint64_t_ll_node, ptr %66, i32 0, i32 1
  %68 = load ptr, ptr %67, align 8, !tbaa !22
  store ptr %68, ptr %9, align 8, !tbaa !9
  br label %57, !llvm.loop !23

69:                                               ; preds = %57
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #5
  br label %70

70:                                               ; preds = %69, %33
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #5
  store i64 0, ptr %10, align 8, !tbaa !25
  br label %71

71:                                               ; preds = %144, %70
  %72 = load i64, ptr %10, align 8, !tbaa !25
  %73 = load ptr, ptr %5, align 8, !tbaa !9
  %74 = getelementptr inbounds %struct.bpt_node, ptr %73, i32 0, i32 0
  %75 = load ptr, ptr %74, align 8, !tbaa !11
  %76 = getelementptr inbounds i32, ptr %75, i64 5
  %77 = load i32, ptr %76, align 4, !tbaa !5
  %78 = zext i32 %77 to i64
  %79 = icmp ult i64 %72, %78
  br i1 %79, label %80, label %147

80:                                               ; preds = %71
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #5
  %81 = load ptr, ptr getelementptr inbounds (%struct.cache_def, ptr @cache, i32 0, i32 3), align 8, !tbaa !15
  %82 = load i32, ptr %4, align 4, !tbaa !5
  %83 = load ptr, ptr %5, align 8, !tbaa !9
  %84 = getelementptr inbounds %struct.bpt_node, ptr %83, i32 0, i32 0
  %85 = load ptr, ptr %84, align 8, !tbaa !11
  %86 = load i32, ptr @ORDER, align 4, !tbaa !5
  %87 = add i32 6, %86
  %88 = add i32 %87, 2
  %89 = zext i32 %88 to i64
  %90 = getelementptr inbounds i32, ptr %85, i64 %89
  %91 = load i64, ptr %10, align 8, !tbaa !25
  %92 = getelementptr inbounds i32, ptr %90, i64 %91
  %93 = load i32, ptr %92, align 4, !tbaa !5
  %94 = sub i32 %93, 1
  %95 = call ptr %81(i32 noundef %82, i32 noundef %94, ptr noundef @uint64_t_ll_non_leading_cache_handler)
  store ptr %95, ptr %11, align 8, !tbaa !9
  %96 = load ptr, ptr %11, align 8, !tbaa !9
  %97 = getelementptr inbounds %struct.uint64_t_ll_bpt_non_leading_data, ptr %96, i32 0, i32 0
  %98 = load ptr, ptr %97, align 8, !tbaa !26
  %99 = icmp ne ptr %98, null
  br i1 %99, label %100, label %119

100:                                              ; preds = %80
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #5
  %101 = load ptr, ptr %11, align 8, !tbaa !9
  %102 = getelementptr inbounds %struct.uint64_t_ll_bpt_non_leading_data, ptr %101, i32 0, i32 0
  %103 = load ptr, ptr %102, align 8, !tbaa !26
  %104 = getelementptr inbounds %struct.uint64_t_ll, ptr %103, i32 0, i32 1
  %105 = load ptr, ptr %104, align 8, !tbaa !17
  store ptr %105, ptr %12, align 8, !tbaa !9
  br label %106

106:                                              ; preds = %109, %100
  %107 = load ptr, ptr %12, align 8, !tbaa !9
  %108 = icmp ne ptr %107, null
  br i1 %108, label %109, label %118

109:                                              ; preds = %106
  %110 = load ptr, ptr %7, align 8, !tbaa !9
  %111 = getelementptr inbounds %struct.uint64_t_ll_bpt_leading_data, ptr %110, i32 0, i32 0
  %112 = load ptr, ptr %12, align 8, !tbaa !9
  %113 = getelementptr inbounds %struct.uint64_t_ll_node, ptr %112, i32 0, i32 0
  %114 = load i64, ptr %113, align 8, !tbaa !20
  call void @uint64_t_ll_uniq_append(ptr noundef %111, i64 noundef %114)
  %115 = load ptr, ptr %12, align 8, !tbaa !9
  %116 = getelementptr inbounds %struct.uint64_t_ll_node, ptr %115, i32 0, i32 1
  %117 = load ptr, ptr %116, align 8, !tbaa !22
  store ptr %117, ptr %12, align 8, !tbaa !9
  br label %106, !llvm.loop !28

118:                                              ; preds = %106
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #5
  br label %119

119:                                              ; preds = %118, %80
  %120 = load ptr, ptr %11, align 8, !tbaa !9
  %121 = getelementptr inbounds %struct.uint64_t_ll_bpt_non_leading_data, ptr %120, i32 0, i32 1
  %122 = load ptr, ptr %121, align 8, !tbaa !29
  %123 = icmp ne ptr %122, null
  br i1 %123, label %124, label %143

124:                                              ; preds = %119
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #5
  %125 = load ptr, ptr %11, align 8, !tbaa !9
  %126 = getelementptr inbounds %struct.uint64_t_ll_bpt_non_leading_data, ptr %125, i32 0, i32 1
  %127 = load ptr, ptr %126, align 8, !tbaa !29
  %128 = getelementptr inbounds %struct.uint64_t_ll, ptr %127, i32 0, i32 1
  %129 = load ptr, ptr %128, align 8, !tbaa !17
  store ptr %129, ptr %13, align 8, !tbaa !9
  br label %130

130:                                              ; preds = %133, %124
  %131 = load ptr, ptr %13, align 8, !tbaa !9
  %132 = icmp ne ptr %131, null
  br i1 %132, label %133, label %142

133:                                              ; preds = %130
  %134 = load ptr, ptr %7, align 8, !tbaa !9
  %135 = getelementptr inbounds %struct.uint64_t_ll_bpt_leading_data, ptr %134, i32 0, i32 0
  %136 = load ptr, ptr %13, align 8, !tbaa !9
  %137 = getelementptr inbounds %struct.uint64_t_ll_node, ptr %136, i32 0, i32 0
  %138 = load i64, ptr %137, align 8, !tbaa !20
  call void @uint64_t_ll_remove(ptr noundef %135, i64 noundef %138)
  %139 = load ptr, ptr %13, align 8, !tbaa !9
  %140 = getelementptr inbounds %struct.uint64_t_ll_node, ptr %139, i32 0, i32 1
  %141 = load ptr, ptr %140, align 8, !tbaa !22
  store ptr %141, ptr %13, align 8, !tbaa !9
  br label %130, !llvm.loop !30

142:                                              ; preds = %130
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #5
  br label %143

143:                                              ; preds = %142, %119
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #5
  br label %144

144:                                              ; preds = %143
  %145 = load i64, ptr %10, align 8, !tbaa !25
  %146 = add i64 %145, 1
  store i64 %146, ptr %10, align 8, !tbaa !25
  br label %71, !llvm.loop !31

147:                                              ; preds = %71
  %148 = load ptr, ptr %7, align 8, !tbaa !9
  %149 = getelementptr inbounds %struct.uint64_t_ll_bpt_leading_data, ptr %148, i32 0, i32 0
  %150 = load ptr, ptr %149, align 8, !tbaa !13
  %151 = icmp ne ptr %150, null
  br i1 %151, label %152, label %170

152:                                              ; preds = %147
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #5
  %153 = load ptr, ptr getelementptr inbounds (%struct.cache_def, ptr @cache, i32 0, i32 1), align 8, !tbaa !32
  %154 = load i32, ptr %4, align 4, !tbaa !5
  %155 = call i32 %153(i32 noundef %154)
  %156 = add i32 %155, 1
  %157 = zext i32 %156 to i64
  store i64 %157, ptr %14, align 8, !tbaa !25
  %158 = load ptr, ptr getelementptr inbounds (%struct.cache_def, ptr @cache, i32 0, i32 2), align 8, !tbaa !33
  %159 = load i32, ptr %4, align 4, !tbaa !5
  %160 = load i64, ptr %14, align 8, !tbaa !25
  %161 = sub i64 %160, 1
  %162 = trunc i64 %161 to i32
  %163 = load ptr, ptr %7, align 8, !tbaa !9
  call void %158(i32 noundef %159, i32 noundef %162, ptr noundef %163, i64 noundef 8, ptr noundef @uint64_t_ll_leading_cache_handler)
  %164 = load i64, ptr %14, align 8, !tbaa !25
  %165 = trunc i64 %164 to i32
  %166 = load ptr, ptr %6, align 8, !tbaa !9
  %167 = getelementptr inbounds %struct.bpt_node, ptr %166, i32 0, i32 0
  %168 = load ptr, ptr %167, align 8, !tbaa !11
  %169 = getelementptr inbounds i32, ptr %168, i64 3
  store i32 %165, ptr %169, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #5
  br label %172

170:                                              ; preds = %147
  %171 = load ptr, ptr %7, align 8, !tbaa !9
  call void @free(ptr noundef %171) #5
  br label %172

172:                                              ; preds = %170, %152
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #5
  br label %173

173:                                              ; preds = %172, %21, %3
  ret void
}

; Function Attrs: nounwind allocsize(0)
declare noalias ptr @malloc(i64 noundef) #4

; Function Attrs: nounwind uwtable
declare dso_local void @uint64_t_ll_uniq_append(ptr noundef, i64 noundef) #3

; Function Attrs: nounwind uwtable
declare dso_local void @uint64_t_ll_remove(ptr noundef, i64 noundef) #3

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { noreturn "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 "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 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 #4 = { nounwind allocsize(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 #5 = { nounwind }
attributes #6 = { nounwind allocsize(0) }
attributes #7 = { noreturn }

!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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !10, i64 0}
!12 = !{!"bpt_node", !10, i64 0}
!13 = !{!14, !10, i64 0}
!14 = !{!"uint64_t_ll_bpt_leading_data", !10, i64 0}
!15 = !{!16, !10, i64 24}
!16 = !{!"cache_def", !10, i64 0, !10, i64 8, !10, i64 16, !10, i64 24, !10, i64 32, !10, i64 40, !10, i64 48}
!17 = !{!18, !10, i64 8}
!18 = !{!"uint64_t_ll", !19, i64 0, !10, i64 8, !10, i64 16}
!19 = !{!"long", !7, i64 0}
!20 = !{!21, !19, i64 0}
!21 = !{!"uint64_t_ll_node", !19, i64 0, !10, i64 8}
!22 = !{!21, !10, i64 8}
!23 = distinct !{!23, !24}
!24 = !{!"llvm.loop.mustprogress"}
!25 = !{!19, !19, i64 0}
!26 = !{!27, !10, i64 0}
!27 = !{!"uint64_t_ll_bpt_non_leading_data", !10, i64 0, !10, i64 8}
!28 = distinct !{!28, !24}
!29 = !{!27, !10, i64 8}
!30 = distinct !{!30, !24}
!31 = distinct !{!31, !24}
!32 = !{!16, !10, i64 8}
!33 = !{!16, !10, i64 16}


; 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.cache_handler = type { ptr, ptr, ptr }
%struct.cache_def = type { ptr, ptr, ptr, ptr, ptr, ptr, ptr }

@uint64_t_ll_non_leading_cache_handler = external dso_local global %struct.cache_handler, align 8
@uint64_t_ll_leading_cache_handler = external dso_local global %struct.cache_handler, align 8
@.str.14 = external hidden unnamed_addr constant [45 x i8], align 1
@cache = external dso_local local_unnamed_addr global %struct.cache_def, align 8
@ORDER = external dso_local local_unnamed_addr global i32, align 4

; Function Attrs: noreturn
declare void @err(i32 noundef, ptr noundef, ...) local_unnamed_addr #0

; Function Attrs: mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite)
declare void @free(ptr allocptr nocapture noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local void @uint64_t_ll_leading_repair(i32 noundef %0, ptr nocapture noundef readonly %1, ptr nocapture noundef readonly %2) local_unnamed_addr #2 {
  %4 = load ptr, ptr %1, align 8, !tbaa !5
  %5 = getelementptr inbounds i8, ptr %4, i64 8
  %6 = load i32, ptr %5, align 4, !tbaa !10
  %7 = icmp eq i32 %6, 1
  br i1 %7, label %8, label %59

8:                                                ; preds = %3
  %9 = load ptr, ptr %2, align 8, !tbaa !5
  %10 = getelementptr inbounds i8, ptr %9, i64 8
  %11 = load i32, ptr %10, align 4, !tbaa !10
  %12 = icmp eq i32 %11, 1
  br i1 %12, label %13, label %59

13:                                               ; preds = %8
  %14 = tail call noalias dereferenceable_or_null(8) ptr @malloc(i64 noundef 8) #4
  %15 = icmp eq ptr %14, null
  br i1 %15, label %16, label %17

16:                                               ; preds = %13
  tail call void (i32, ptr, ...) @err(i32 noundef 1, ptr noundef nonnull @.str.14) #5
  unreachable

17:                                               ; preds = %13
  store ptr null, ptr %14, align 8, !tbaa !12
  %18 = getelementptr inbounds i8, ptr %4, i64 12
  %19 = load i32, ptr %18, align 4, !tbaa !10
  %.not = icmp eq i32 %19, 0
  br i1 %.not, label %.loopexit54, label %20

20:                                               ; preds = %17
  %21 = load ptr, ptr getelementptr inbounds (i8, ptr @cache, i64 24), align 8, !tbaa !14
  %22 = add i32 %19, -1
  %23 = tail call ptr %21(i32 noundef %0, i32 noundef %22, ptr noundef nonnull @uint64_t_ll_leading_cache_handler) #6
  %24 = load ptr, ptr %23, align 8, !tbaa !12
  %.0.in55 = getelementptr inbounds i8, ptr %24, i64 8
  %.056 = load ptr, ptr %.0.in55, align 8, !tbaa !16
  %.not4457 = icmp eq ptr %.056, null
  br i1 %.not4457, label %.loopexit54, label %.lr.ph

.lr.ph:                                           ; preds = %20, %.lr.ph
  %.058 = phi ptr [ %.0, %.lr.ph ], [ %.056, %20 ]
  %25 = load i64, ptr %.058, align 8, !tbaa !17
  tail call void @uint64_t_ll_uniq_append(ptr noundef nonnull %14, i64 noundef %25)
  %.0.in = getelementptr inbounds i8, ptr %.058, i64 8
  %.0 = load ptr, ptr %.0.in, align 8, !tbaa !16
  %.not44 = icmp eq ptr %.0, null
  br i1 %.not44, label %.loopexit54, label %.lr.ph, !llvm.loop !20

.loopexit54:                                      ; preds = %.lr.ph, %20, %17
  %26 = load ptr, ptr %1, align 8, !tbaa !5
  %27 = getelementptr inbounds i8, ptr %26, i64 20
  %28 = load i32, ptr %27, align 4, !tbaa !10
  %.not71 = icmp eq i32 %28, 0
  br i1 %.not71, label %._crit_edge, label %.lr.ph70

.lr.ph70:                                         ; preds = %.loopexit54, %.loopexit
  %29 = phi ptr [ %45, %.loopexit ], [ %26, %.loopexit54 ]
  %.03969 = phi i64 [ %44, %.loopexit ], [ 0, %.loopexit54 ]
  %30 = load ptr, ptr getelementptr inbounds (i8, ptr @cache, i64 24), align 8, !tbaa !14
  %31 = load i32, ptr @ORDER, align 4, !tbaa !10
  %32 = add i32 %31, 8
  %33 = zext i32 %32 to i64
  %34 = getelementptr inbounds i32, ptr %29, i64 %33
  %35 = getelementptr inbounds i32, ptr %34, i64 %.03969
  %36 = load i32, ptr %35, align 4, !tbaa !10
  %37 = add i32 %36, -1
  %38 = tail call ptr %30(i32 noundef %0, i32 noundef %37, ptr noundef nonnull @uint64_t_ll_non_leading_cache_handler) #6
  %39 = load ptr, ptr %38, align 8, !tbaa !22
  %.not46 = icmp eq ptr %39, null
  br i1 %.not46, label %.loopexit53, label %.preheader52

.preheader52:                                     ; preds = %.lr.ph70
  %.038.in59 = getelementptr inbounds i8, ptr %39, i64 8
  %.03860 = load ptr, ptr %.038.in59, align 8, !tbaa !16
  %.not4761 = icmp eq ptr %.03860, null
  br i1 %.not4761, label %.loopexit53, label %.lr.ph63

.lr.ph63:                                         ; preds = %.preheader52, %.lr.ph63
  %.03862 = phi ptr [ %.038, %.lr.ph63 ], [ %.03860, %.preheader52 ]
  %40 = load i64, ptr %.03862, align 8, !tbaa !17
  tail call void @uint64_t_ll_uniq_append(ptr noundef nonnull %14, i64 noundef %40)
  %.038.in = getelementptr inbounds i8, ptr %.03862, i64 8
  %.038 = load ptr, ptr %.038.in, align 8, !tbaa !16
  %.not47 = icmp eq ptr %.038, null
  br i1 %.not47, label %.loopexit53, label %.lr.ph63, !llvm.loop !24

.loopexit53:                                      ; preds = %.lr.ph63, %.preheader52, %.lr.ph70
  %41 = getelementptr inbounds i8, ptr %38, i64 8
  %42 = load ptr, ptr %41, align 8, !tbaa !25
  %.not48 = icmp eq ptr %42, null
  br i1 %.not48, label %.loopexit, label %.preheader

.preheader:                                       ; preds = %.loopexit53
  %.037.in64 = getelementptr inbounds i8, ptr %42, i64 8
  %.03765 = load ptr, ptr %.037.in64, align 8, !tbaa !16
  %.not4966 = icmp eq ptr %.03765, null
  br i1 %.not4966, label %.loopexit, label %.lr.ph68

.lr.ph68:                                         ; preds = %.preheader, %.lr.ph68
  %.03767 = phi ptr [ %.037, %.lr.ph68 ], [ %.03765, %.preheader ]
  %43 = load i64, ptr %.03767, align 8, !tbaa !17
  tail call void @uint64_t_ll_remove(ptr noundef nonnull %14, i64 noundef %43)
  %.037.in = getelementptr inbounds i8, ptr %.03767, i64 8
  %.037 = load ptr, ptr %.037.in, align 8, !tbaa !16
  %.not49 = icmp eq ptr %.037, null
  br i1 %.not49, label %.loopexit, label %.lr.ph68, !llvm.loop !26

.loopexit:                                        ; preds = %.lr.ph68, %.preheader, %.loopexit53
  %44 = add nuw nsw i64 %.03969, 1
  %45 = load ptr, ptr %1, align 8, !tbaa !5
  %46 = getelementptr inbounds i8, ptr %45, i64 20
  %47 = load i32, ptr %46, align 4, !tbaa !10
  %48 = zext i32 %47 to i64
  %49 = icmp ult i64 %44, %48
  br i1 %49, label %.lr.ph70, label %._crit_edge, !llvm.loop !27

._crit_edge:                                      ; preds = %.loopexit, %.loopexit54
  %50 = load ptr, ptr %14, align 8, !tbaa !12
  %.not45 = icmp eq ptr %50, null
  br i1 %.not45, label %58, label %51

51:                                               ; preds = %._crit_edge
  %52 = load ptr, ptr getelementptr inbounds (i8, ptr @cache, i64 8), align 8, !tbaa !28
  %53 = tail call i32 %52(i32 noundef %0) #6
  %54 = add i32 %53, 1
  %55 = load ptr, ptr getelementptr inbounds (i8, ptr @cache, i64 16), align 8, !tbaa !29
  tail call void %55(i32 noundef %0, i32 noundef %53, ptr noundef nonnull %14, i64 noundef 8, ptr noundef nonnull @uint64_t_ll_leading_cache_handler) #6
  %56 = load ptr, ptr %2, align 8, !tbaa !5
  %57 = getelementptr inbounds i8, ptr %56, i64 12
  store i32 %54, ptr %57, align 4, !tbaa !10
  br label %59

58:                                               ; preds = %._crit_edge
  tail call void @free(ptr noundef nonnull %14) #6
  br label %59

59:                                               ; preds = %51, %58, %8, %3
  ret void
}

; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #3

; Function Attrs: nounwind uwtable
declare dso_local void @uint64_t_ll_uniq_append(ptr noundef, i64 noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
declare dso_local void @uint64_t_ll_remove(ptr noundef, i64 noundef) local_unnamed_addr #2

attributes #0 = { noreturn "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 nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite) "alloc-family"="malloc" "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 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 = { mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" "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 #4 = { nounwind allocsize(0) }
attributes #5 = { noreturn nounwind }
attributes #6 = { 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, !7, i64 0}
!6 = !{!"bpt_node", !7, i64 0}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!11, !11, i64 0}
!11 = !{!"int", !8, i64 0}
!12 = !{!13, !7, i64 0}
!13 = !{!"uint64_t_ll_bpt_leading_data", !7, i64 0}
!14 = !{!15, !7, i64 24}
!15 = !{!"cache_def", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !7, i64 32, !7, i64 40, !7, i64 48}
!16 = !{!7, !7, i64 0}
!17 = !{!18, !19, i64 0}
!18 = !{!"uint64_t_ll_node", !19, i64 0, !7, i64 8}
!19 = !{!"long", !8, i64 0}
!20 = distinct !{!20, !21}
!21 = !{!"llvm.loop.mustprogress"}
!22 = !{!23, !7, i64 0}
!23 = !{!"uint64_t_ll_bpt_non_leading_data", !7, i64 0, !7, i64 8}
!24 = distinct !{!24, !21}
!25 = !{!23, !7, i64 8}
!26 = distinct !{!26, !21}
!27 = distinct !{!27, !21}
!28 = !{!15, !7, i64 8}
!29 = !{!15, !7, i64 16}


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