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

; 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_def = type { ptr, ptr, ptr, ptr, ptr, ptr, ptr }
%struct.cache_handler = type { ptr, ptr, ptr }
%struct.bpt_node = type { ptr }
%struct.giggle_index = type { ptr, i32, i32, ptr, ptr, ptr, ptr, ptr, ptr }
%struct.simple_cache = type { ptr, ptr, ptr, ptr, ptr, i32, ptr, ptr, ptr, %union.pthread_mutex_t, ptr, ptr, i64, i64, i32 }
%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.uint_pair = type { i32, i32 }
%struct.ordered_set = type { ptr, i32, i32, ptr, ptr, ptr }

@cache = external dso_local global %struct.cache_def, align 8
@bpt_node_cache_handler = external dso_local global %struct.cache_handler, align 8
@ORDER = external dso_local global i32, align 4
@leaf_data_cache_handler = external dso_local global %struct.cache_handler, align 8
@_cache = external dso_local global [10 x ptr], align 16
@CACHE_NAME_SPACE = external dso_local global i32, align 4
@.str.44 = external hidden unnamed_addr constant [46 x i8], align 1
@.str.45 = external hidden unnamed_addr constant [55 x i8], align 1
@.str.46 = external hidden unnamed_addr constant [31 x i8], align 1
@.str.47 = external hidden unnamed_addr constant [32 x i8], align 1
@.str.48 = external hidden unnamed_addr constant [50 x i8], align 1
@.str.49 = external hidden unnamed_addr constant [25 x i8], align 1

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

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

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

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

; Function Attrs: nounwind allocsize(0,1)
declare noalias ptr @calloc(i64 noundef, i64 noundef) #3

; Function Attrs: noreturn
declare void @errx(i32 noundef, ptr noundef, ...) #2

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #5

; Function Attrs: nounwind uwtable
define dso_local void @giggle_write_tree_leaf_data(ptr noundef %0) #6 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca i32, align 4
  %14 = alloca ptr, align 8
  %15 = alloca ptr, align 8
  %16 = alloca ptr, align 8
  %17 = alloca ptr, align 8
  %18 = alloca i32, align 4
  %19 = alloca i32, align 4
  %20 = alloca i32, align 4
  %21 = alloca ptr, align 8
  %22 = alloca i64, align 8
  %23 = alloca i32, align 4
  %24 = alloca ptr, align 8
  %25 = alloca i32, align 4
  %26 = alloca i32, align 4
  %27 = alloca ptr, align 8
  %28 = alloca i64, align 8
  %29 = alloca i32, align 4
  %30 = alloca ptr, align 8
  %31 = alloca i32, align 4
  %32 = alloca ptr, align 8
  %33 = alloca ptr, align 8
  %34 = alloca i64, align 8
  %35 = alloca i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #8
  %36 = load ptr, ptr %2, align 8, !tbaa !5
  store ptr %36, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #8
  %37 = load i32, ptr @CACHE_NAME_SPACE, align 4, !tbaa !9
  %38 = zext i32 %37 to i64
  %39 = getelementptr inbounds [10 x ptr], ptr @_cache, i64 0, i64 %38
  %40 = load ptr, ptr %39, align 8, !tbaa !5
  store ptr %40, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #8
  %41 = call noalias ptr @malloc(i64 noundef 8) #9
  store ptr %41, ptr %5, align 8, !tbaa !5
  %42 = load ptr, ptr %5, align 8, !tbaa !5
  %43 = icmp eq ptr %42, null
  br i1 %43, label %44, label %45

44:                                               ; preds = %1
  call void (i32, ptr, ...) @err(i32 noundef 1, ptr noundef @.str.44) #10
  unreachable

45:                                               ; preds = %1
  %46 = load i32, ptr @ORDER, align 4, !tbaa !9
  %47 = mul i32 2, %46
  %48 = add i32 %47, 10
  %49 = zext i32 %48 to i64
  %50 = call noalias ptr @calloc(i64 noundef %49, i64 noundef 4) #11
  %51 = load ptr, ptr %5, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.bpt_node, ptr %51, i32 0, i32 0
  store ptr %50, ptr %52, align 8, !tbaa !11
  %53 = load ptr, ptr %5, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.bpt_node, ptr %53, i32 0, i32 0
  %55 = load ptr, ptr %54, align 8, !tbaa !11
  %56 = icmp eq ptr %55, null
  br i1 %56, label %57, label %58

57:                                               ; preds = %45
  call void (i32, ptr, ...) @err(i32 noundef 1, ptr noundef @.str.44) #10
  unreachable

58:                                               ; preds = %45
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #8
  store i32 0, ptr %6, align 4, !tbaa !9
  br label %59

59:                                               ; preds = %549, %58
  %60 = load i32, ptr %6, align 4, !tbaa !9
  %61 = load ptr, ptr %3, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct.giggle_index, ptr %61, i32 0, i32 2
  %63 = load i32, ptr %62, align 4, !tbaa !13
  %64 = icmp ult i32 %60, %63
  br i1 %64, label %65, label %552

65:                                               ; preds = %59
  %66 = load ptr, ptr %4, align 8, !tbaa !5
  %67 = getelementptr inbounds %struct.simple_cache, ptr %66, i32 0, i32 8
  %68 = load ptr, ptr %67, align 8, !tbaa !15
  %69 = load i32, ptr %6, align 4, !tbaa !9
  %70 = zext i32 %69 to i64
  %71 = getelementptr inbounds ptr, ptr %68, i64 %70
  %72 = load ptr, ptr %71, align 8, !tbaa !5
  %73 = icmp ne ptr %72, null
  br i1 %73, label %74, label %75

74:                                               ; preds = %65
  call void (i32, ptr, ...) @errx(i32 noundef 1, ptr noundef @.str.45) #10
  unreachable

75:                                               ; preds = %65
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #8
  %76 = load ptr, ptr getelementptr inbounds (%struct.cache_def, ptr @cache, i32 0, i32 1), align 8, !tbaa !18
  %77 = load i32, ptr %6, align 4, !tbaa !9
  %78 = call i32 %76(i32 noundef %77)
  %79 = udiv i32 %78, 2
  store i32 %79, ptr %7, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #8
  %80 = load ptr, ptr %4, align 8, !tbaa !5
  %81 = getelementptr inbounds %struct.simple_cache, ptr %80, i32 0, i32 4
  %82 = load ptr, ptr %81, align 8, !tbaa !20
  %83 = load i32, ptr %6, align 4, !tbaa !9
  %84 = zext i32 %83 to i64
  %85 = getelementptr inbounds i32, ptr %82, i64 %84
  %86 = load i32, ptr %85, align 4, !tbaa !9
  %87 = load ptr, ptr %4, align 8, !tbaa !5
  %88 = getelementptr inbounds %struct.simple_cache, ptr %87, i32 0, i32 6
  %89 = load ptr, ptr %88, align 8, !tbaa !21
  %90 = load i32, ptr %6, align 4, !tbaa !9
  %91 = zext i32 %90 to i64
  %92 = getelementptr inbounds ptr, ptr %89, i64 %91
  %93 = load ptr, ptr %92, align 8, !tbaa !5
  %94 = load ptr, ptr %4, align 8, !tbaa !5
  %95 = getelementptr inbounds %struct.simple_cache, ptr %94, i32 0, i32 7
  %96 = load ptr, ptr %95, align 8, !tbaa !22
  %97 = load i32, ptr %6, align 4, !tbaa !9
  %98 = zext i32 %97 to i64
  %99 = getelementptr inbounds ptr, ptr %96, i64 %98
  %100 = load ptr, ptr %99, align 8, !tbaa !5
  %101 = call ptr @disk_store_init(i32 noundef %86, ptr noundef null, ptr noundef %93, ptr noundef null, ptr noundef %100)
  store ptr %101, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #8
  %102 = load i32, ptr %7, align 4, !tbaa !9
  %103 = call ptr @ordered_set_init(i32 noundef %102, ptr noundef @uint_pair_sort_by_first_element_cmp, ptr noundef @uint_pair_search_by_first_element_cmp, ptr noundef @uint_pair_search_by_first_key_cmp)
  store ptr %103, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #8
  %104 = load ptr, ptr getelementptr inbounds (%struct.cache_def, ptr @cache, i32 0, i32 3), align 8, !tbaa !23
  %105 = load i32, ptr %6, align 4, !tbaa !9
  %106 = load ptr, ptr %3, align 8, !tbaa !5
  %107 = getelementptr inbounds %struct.giggle_index, ptr %106, i32 0, i32 0
  %108 = load ptr, ptr %107, align 8, !tbaa !24
  %109 = load i32, ptr %6, align 4, !tbaa !9
  %110 = zext i32 %109 to i64
  %111 = getelementptr inbounds i32, ptr %108, i64 %110
  %112 = load i32, ptr %111, align 4, !tbaa !9
  %113 = sub i32 %112, 1
  %114 = call ptr %104(i32 noundef %105, i32 noundef %113, ptr noundef @bpt_node_cache_handler)
  store ptr %114, ptr %10, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #8
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #8
  %115 = call noalias ptr @malloc(i64 noundef 8) #9
  store ptr %115, ptr %11, align 8, !tbaa !5
  %116 = load ptr, ptr %11, align 8, !tbaa !5
  %117 = icmp eq ptr %116, null
  br i1 %117, label %118, label %119

118:                                              ; preds = %75
  call void (i32, ptr, ...) @err(i32 noundef 1, ptr noundef @.str.44) #10
  unreachable

119:                                              ; preds = %75
  %120 = load ptr, ptr %10, align 8, !tbaa !5
  %121 = getelementptr inbounds %struct.bpt_node, ptr %120, i32 0, i32 0
  %122 = load ptr, ptr %121, align 8, !tbaa !11
  %123 = getelementptr inbounds i32, ptr %122, i64 0
  %124 = load i32, ptr %123, align 4, !tbaa !9
  %125 = load ptr, ptr %11, align 8, !tbaa !5
  %126 = getelementptr inbounds %struct.uint_pair, ptr %125, i32 0, i32 0
  store i32 %124, ptr %126, align 4, !tbaa !25
  %127 = load ptr, ptr %9, align 8, !tbaa !5
  %128 = getelementptr inbounds %struct.ordered_set, ptr %127, i32 0, i32 1
  %129 = load i32, ptr %128, align 8, !tbaa !27
  %130 = add i32 %129, 1
  %131 = load ptr, ptr %11, align 8, !tbaa !5
  %132 = getelementptr inbounds %struct.uint_pair, ptr %131, i32 0, i32 1
  store i32 %130, ptr %132, align 4, !tbaa !29
  %133 = load ptr, ptr %9, align 8, !tbaa !5
  %134 = load ptr, ptr %11, align 8, !tbaa !5
  %135 = call ptr @ordered_set_add(ptr noundef %133, ptr noundef %134)
  store ptr %135, ptr %12, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #8
  %136 = load ptr, ptr %11, align 8, !tbaa !5
  %137 = getelementptr inbounds %struct.uint_pair, ptr %136, i32 0, i32 1
  %138 = load i32, ptr %137, align 4, !tbaa !29
  store i32 %138, ptr %13, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #8
  store ptr null, ptr %14, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #8
  store ptr null, ptr %15, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #8
  %139 = call noalias ptr @malloc(i64 noundef 4) #9
  store ptr %139, ptr %16, align 8, !tbaa !5
  %140 = load ptr, ptr %16, align 8, !tbaa !5
  %141 = icmp eq ptr %140, null
  br i1 %141, label %142, label %143

142:                                              ; preds = %119
  call void (i32, ptr, ...) @err(i32 noundef 1, ptr noundef @.str.44) #10
  unreachable

143:                                              ; preds = %119
  %144 = load ptr, ptr %10, align 8, !tbaa !5
  %145 = getelementptr inbounds %struct.bpt_node, ptr %144, i32 0, i32 0
  %146 = load ptr, ptr %145, align 8, !tbaa !11
  %147 = getelementptr inbounds i32, ptr %146, i64 0
  %148 = load i32, ptr %147, align 4, !tbaa !9
  %149 = load ptr, ptr %16, align 8, !tbaa !5
  store i32 %148, ptr %149, align 4, !tbaa !9
  %150 = load ptr, ptr %16, align 8, !tbaa !5
  call void @fifo_q_push(ptr noundef %14, ptr noundef %150)
  br label %151

151:                                              ; preds = %511, %143
  %152 = load ptr, ptr %14, align 8, !tbaa !5
  %153 = call ptr @fifo_q_peek(ptr noundef %152)
  %154 = icmp ne ptr %153, null
  br i1 %154, label %155, label %512

155:                                              ; preds = %151
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #8
  %156 = call ptr @fifo_q_pop(ptr noundef %14)
  store ptr %156, ptr %17, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #8
  %157 = load ptr, ptr %17, align 8, !tbaa !5
  %158 = load i32, ptr %157, align 4, !tbaa !9
  store i32 %158, ptr %18, align 4, !tbaa !9
  %159 = load ptr, ptr %17, align 8, !tbaa !5
  call void @free(ptr noundef %159) #8
  %160 = load ptr, ptr getelementptr inbounds (%struct.cache_def, ptr @cache, i32 0, i32 3), align 8, !tbaa !23
  %161 = load i32, ptr %6, align 4, !tbaa !9
  %162 = load i32, ptr %18, align 4, !tbaa !9
  %163 = sub i32 %162, 1
  %164 = call ptr %160(i32 noundef %161, i32 noundef %163, ptr noundef @bpt_node_cache_handler)
  store ptr %164, ptr %10, align 8, !tbaa !5
  %165 = load ptr, ptr %5, align 8, !tbaa !5
  %166 = getelementptr inbounds %struct.bpt_node, ptr %165, i32 0, i32 0
  %167 = load ptr, ptr %166, align 8, !tbaa !11
  %168 = load i32, ptr @ORDER, align 4, !tbaa !9
  %169 = mul i32 2, %168
  %170 = add i32 %169, 10
  %171 = zext i32 %170 to i64
  %172 = mul i64 %171, 4
  call void @llvm.memset.p0.i64(ptr align 4 %167, i8 0, i64 %172, i1 false)
  call void @llvm.lifetime.start.p0(i64 4, ptr %19) #8
  %173 = load i32, ptr %18, align 4, !tbaa !9
  store i32 %173, ptr %19, align 4, !tbaa !9
  %174 = load ptr, ptr %9, align 8, !tbaa !5
  %175 = call ptr @ordered_set_get(ptr noundef %174, ptr noundef %19)
  store ptr %175, ptr %12, align 8, !tbaa !5
  %176 = load ptr, ptr %12, align 8, !tbaa !5
  %177 = icmp eq ptr %176, null
  br i1 %177, label %178, label %180

178:                                              ; preds = %155
  %179 = load i32, ptr %18, align 4, !tbaa !9
  call void (i32, ptr, ...) @errx(i32 noundef 1, ptr noundef @.str.46, i32 noundef %179) #10
  unreachable

180:                                              ; preds = %155
  %181 = load ptr, ptr %12, align 8, !tbaa !5
  %182 = getelementptr inbounds %struct.uint_pair, ptr %181, i32 0, i32 1
  %183 = load i32, ptr %182, align 4, !tbaa !29
  %184 = load ptr, ptr %5, align 8, !tbaa !5
  %185 = getelementptr inbounds %struct.bpt_node, ptr %184, i32 0, i32 0
  %186 = load ptr, ptr %185, align 8, !tbaa !11
  %187 = getelementptr inbounds i32, ptr %186, i64 0
  store i32 %183, ptr %187, align 4, !tbaa !9
  %188 = load ptr, ptr %10, align 8, !tbaa !5
  %189 = getelementptr inbounds %struct.bpt_node, ptr %188, i32 0, i32 0
  %190 = load ptr, ptr %189, align 8, !tbaa !11
  %191 = getelementptr inbounds i32, ptr %190, i64 1
  %192 = load i32, ptr %191, align 4, !tbaa !9
  %193 = load ptr, ptr %5, align 8, !tbaa !5
  %194 = getelementptr inbounds %struct.bpt_node, ptr %193, i32 0, i32 0
  %195 = load ptr, ptr %194, align 8, !tbaa !11
  %196 = getelementptr inbounds i32, ptr %195, i64 1
  store i32 %192, ptr %196, align 4, !tbaa !9
  %197 = load ptr, ptr %10, align 8, !tbaa !5
  %198 = getelementptr inbounds %struct.bpt_node, ptr %197, i32 0, i32 0
  %199 = load ptr, ptr %198, align 8, !tbaa !11
  %200 = getelementptr inbounds i32, ptr %199, i64 2
  %201 = load i32, ptr %200, align 4, !tbaa !9
  %202 = load ptr, ptr %5, align 8, !tbaa !5
  %203 = getelementptr inbounds %struct.bpt_node, ptr %202, i32 0, i32 0
  %204 = load ptr, ptr %203, align 8, !tbaa !11
  %205 = getelementptr inbounds i32, ptr %204, i64 2
  store i32 %201, ptr %205, align 4, !tbaa !9
  %206 = load ptr, ptr %10, align 8, !tbaa !5
  %207 = getelementptr inbounds %struct.bpt_node, ptr %206, i32 0, i32 0
  %208 = load ptr, ptr %207, align 8, !tbaa !11
  %209 = getelementptr inbounds i32, ptr %208, i64 3
  %210 = load i32, ptr %209, align 4, !tbaa !9
  %211 = load ptr, ptr %5, align 8, !tbaa !5
  %212 = getelementptr inbounds %struct.bpt_node, ptr %211, i32 0, i32 0
  %213 = load ptr, ptr %212, align 8, !tbaa !11
  %214 = getelementptr inbounds i32, ptr %213, i64 3
  store i32 %210, ptr %214, align 4, !tbaa !9
  %215 = load ptr, ptr %10, align 8, !tbaa !5
  %216 = getelementptr inbounds %struct.bpt_node, ptr %215, i32 0, i32 0
  %217 = load ptr, ptr %216, align 8, !tbaa !11
  %218 = getelementptr inbounds i32, ptr %217, i64 4
  %219 = load i32, ptr %218, align 4, !tbaa !9
  %220 = load ptr, ptr %5, align 8, !tbaa !5
  %221 = getelementptr inbounds %struct.bpt_node, ptr %220, i32 0, i32 0
  %222 = load ptr, ptr %221, align 8, !tbaa !11
  %223 = getelementptr inbounds i32, ptr %222, i64 4
  store i32 %219, ptr %223, align 4, !tbaa !9
  %224 = load ptr, ptr %10, align 8, !tbaa !5
  %225 = getelementptr inbounds %struct.bpt_node, ptr %224, i32 0, i32 0
  %226 = load ptr, ptr %225, align 8, !tbaa !11
  %227 = getelementptr inbounds i32, ptr %226, i64 5
  %228 = load i32, ptr %227, align 4, !tbaa !9
  %229 = load ptr, ptr %5, align 8, !tbaa !5
  %230 = getelementptr inbounds %struct.bpt_node, ptr %229, i32 0, i32 0
  %231 = load ptr, ptr %230, align 8, !tbaa !11
  %232 = getelementptr inbounds i32, ptr %231, i64 5
  store i32 %228, ptr %232, align 4, !tbaa !9
  %233 = load ptr, ptr %5, align 8, !tbaa !5
  %234 = getelementptr inbounds %struct.bpt_node, ptr %233, i32 0, i32 0
  %235 = load ptr, ptr %234, align 8, !tbaa !11
  %236 = load i32, ptr @ORDER, align 4, !tbaa !9
  %237 = add i32 6, %236
  %238 = add i32 %237, 1
  %239 = zext i32 %238 to i64
  %240 = getelementptr inbounds i32, ptr %235, i64 %239
  %241 = getelementptr inbounds i32, ptr %240, i64 0
  store i32 0, ptr %241, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %20) #8
  store i32 0, ptr %20, align 4, !tbaa !9
  br label %242

242:                                              ; preds = %266, %180
  %243 = load i32, ptr %20, align 4, !tbaa !9
  %244 = load ptr, ptr %10, align 8, !tbaa !5
  %245 = getelementptr inbounds %struct.bpt_node, ptr %244, i32 0, i32 0
  %246 = load ptr, ptr %245, align 8, !tbaa !11
  %247 = getelementptr inbounds i32, ptr %246, i64 5
  %248 = load i32, ptr %247, align 4, !tbaa !9
  %249 = icmp ule i32 %243, %248
  br i1 %249, label %250, label %269

250:                                              ; preds = %242
  %251 = load ptr, ptr %10, align 8, !tbaa !5
  %252 = getelementptr inbounds %struct.bpt_node, ptr %251, i32 0, i32 0
  %253 = load ptr, ptr %252, align 8, !tbaa !11
  %254 = getelementptr inbounds i32, ptr %253, i64 6
  %255 = load i32, ptr %20, align 4, !tbaa !9
  %256 = zext i32 %255 to i64
  %257 = getelementptr inbounds i32, ptr %254, i64 %256
  %258 = load i32, ptr %257, align 4, !tbaa !9
  %259 = load ptr, ptr %5, align 8, !tbaa !5
  %260 = getelementptr inbounds %struct.bpt_node, ptr %259, i32 0, i32 0
  %261 = load ptr, ptr %260, align 8, !tbaa !11
  %262 = getelementptr inbounds i32, ptr %261, i64 6
  %263 = load i32, ptr %20, align 4, !tbaa !9
  %264 = zext i32 %263 to i64
  %265 = getelementptr inbounds i32, ptr %262, i64 %264
  store i32 %258, ptr %265, align 4, !tbaa !9
  br label %266

266:                                              ; preds = %250
  %267 = load i32, ptr %20, align 4, !tbaa !9
  %268 = add i32 %267, 1
  store i32 %268, ptr %20, align 4, !tbaa !9
  br label %242, !llvm.loop !30

269:                                              ; preds = %242
  %270 = load ptr, ptr %10, align 8, !tbaa !5
  %271 = getelementptr inbounds %struct.bpt_node, ptr %270, i32 0, i32 0
  %272 = load ptr, ptr %271, align 8, !tbaa !11
  %273 = getelementptr inbounds i32, ptr %272, i64 2
  %274 = load i32, ptr %273, align 4, !tbaa !9
  %275 = icmp eq i32 %274, 0
  br i1 %275, label %276, label %405

276:                                              ; preds = %269
  store i32 0, ptr %20, align 4, !tbaa !9
  br label %277

277:                                              ; preds = %377, %276
  %278 = load i32, ptr %20, align 4, !tbaa !9
  %279 = load ptr, ptr %10, align 8, !tbaa !5
  %280 = getelementptr inbounds %struct.bpt_node, ptr %279, i32 0, i32 0
  %281 = load ptr, ptr %280, align 8, !tbaa !11
  %282 = getelementptr inbounds i32, ptr %281, i64 5
  %283 = load i32, ptr %282, align 4, !tbaa !9
  %284 = icmp ule i32 %278, %283
  br i1 %284, label %285, label %380

285:                                              ; preds = %277
  %286 = load ptr, ptr %10, align 8, !tbaa !5
  %287 = getelementptr inbounds %struct.bpt_node, ptr %286, i32 0, i32 0
  %288 = load ptr, ptr %287, align 8, !tbaa !11
  %289 = load i32, ptr @ORDER, align 4, !tbaa !9
  %290 = add i32 6, %289
  %291 = add i32 %290, 2
  %292 = zext i32 %291 to i64
  %293 = getelementptr inbounds i32, ptr %288, i64 %292
  %294 = load i32, ptr %20, align 4, !tbaa !9
  %295 = zext i32 %294 to i64
  %296 = getelementptr inbounds i32, ptr %293, i64 %295
  %297 = load i32, ptr %296, align 4, !tbaa !9
  %298 = icmp ne i32 %297, 0
  br i1 %298, label %299, label %376

299:                                              ; preds = %285
  %300 = call noalias ptr @malloc(i64 noundef 8) #9
  store ptr %300, ptr %11, align 8, !tbaa !5
  %301 = load ptr, ptr %11, align 8, !tbaa !5
  %302 = icmp eq ptr %301, null
  br i1 %302, label %303, label %304

303:                                              ; preds = %299
  call void (i32, ptr, ...) @err(i32 noundef 1, ptr noundef @.str.44) #10
  unreachable

304:                                              ; preds = %299
  %305 = load ptr, ptr %10, align 8, !tbaa !5
  %306 = getelementptr inbounds %struct.bpt_node, ptr %305, i32 0, i32 0
  %307 = load ptr, ptr %306, align 8, !tbaa !11
  %308 = load i32, ptr @ORDER, align 4, !tbaa !9
  %309 = add i32 6, %308
  %310 = add i32 %309, 2
  %311 = zext i32 %310 to i64
  %312 = getelementptr inbounds i32, ptr %307, i64 %311
  %313 = load i32, ptr %20, align 4, !tbaa !9
  %314 = zext i32 %313 to i64
  %315 = getelementptr inbounds i32, ptr %312, i64 %314
  %316 = load i32, ptr %315, align 4, !tbaa !9
  %317 = load ptr, ptr %11, align 8, !tbaa !5
  %318 = getelementptr inbounds %struct.uint_pair, ptr %317, i32 0, i32 0
  store i32 %316, ptr %318, align 4, !tbaa !25
  %319 = load ptr, ptr %9, align 8, !tbaa !5
  %320 = getelementptr inbounds %struct.ordered_set, ptr %319, i32 0, i32 1
  %321 = load i32, ptr %320, align 8, !tbaa !27
  %322 = add i32 %321, 1
  %323 = load ptr, ptr %11, align 8, !tbaa !5
  %324 = getelementptr inbounds %struct.uint_pair, ptr %323, i32 0, i32 1
  store i32 %322, ptr %324, align 4, !tbaa !29
  %325 = load ptr, ptr %9, align 8, !tbaa !5
  %326 = load ptr, ptr %11, align 8, !tbaa !5
  %327 = call ptr @ordered_set_add(ptr noundef %325, ptr noundef %326)
  store ptr %327, ptr %12, align 8, !tbaa !5
  %328 = load ptr, ptr %12, align 8, !tbaa !5
  %329 = getelementptr inbounds %struct.uint_pair, ptr %328, i32 0, i32 1
  %330 = load i32, ptr %329, align 4, !tbaa !29
  %331 = load ptr, ptr %11, align 8, !tbaa !5
  %332 = getelementptr inbounds %struct.uint_pair, ptr %331, i32 0, i32 1
  %333 = load i32, ptr %332, align 4, !tbaa !29
  %334 = icmp ne i32 %330, %333
  br i1 %334, label %335, label %342

335:                                              ; preds = %304
  %336 = load ptr, ptr %11, align 8, !tbaa !5
  %337 = getelementptr inbounds %struct.uint_pair, ptr %336, i32 0, i32 0
  %338 = load i32, ptr %337, align 4, !tbaa !25
  %339 = load ptr, ptr %12, align 8, !tbaa !5
  %340 = getelementptr inbounds %struct.uint_pair, ptr %339, i32 0, i32 0
  %341 = load i32, ptr %340, align 4, !tbaa !25
  call void (i32, ptr, ...) @errx(i32 noundef 1, ptr noundef @.str.47, i32 noundef %338, i32 noundef %341) #10
  unreachable

342:                                              ; preds = %304
  %343 = load ptr, ptr %11, align 8, !tbaa !5
  %344 = getelementptr inbounds %struct.uint_pair, ptr %343, i32 0, i32 1
  %345 = load i32, ptr %344, align 4, !tbaa !29
  %346 = load ptr, ptr %5, align 8, !tbaa !5
  %347 = getelementptr inbounds %struct.bpt_node, ptr %346, i32 0, i32 0
  %348 = load ptr, ptr %347, align 8, !tbaa !11
  %349 = load i32, ptr @ORDER, align 4, !tbaa !9
  %350 = add i32 6, %349
  %351 = add i32 %350, 2
  %352 = zext i32 %351 to i64
  %353 = getelementptr inbounds i32, ptr %348, i64 %352
  %354 = load i32, ptr %20, align 4, !tbaa !9
  %355 = zext i32 %354 to i64
  %356 = getelementptr inbounds i32, ptr %353, i64 %355
  store i32 %345, ptr %356, align 4, !tbaa !9
  %357 = call noalias ptr @malloc(i64 noundef 4) #9
  store ptr %357, ptr %16, align 8, !tbaa !5
  %358 = load ptr, ptr %16, align 8, !tbaa !5
  %359 = icmp eq ptr %358, null
  br i1 %359, label %360, label %361

360:                                              ; preds = %342
  call void (i32, ptr, ...) @err(i32 noundef 1, ptr noundef @.str.44) #10
  unreachable

361:                                              ; preds = %342
  %362 = load ptr, ptr %10, align 8, !tbaa !5
  %363 = getelementptr inbounds %struct.bpt_node, ptr %362, i32 0, i32 0
  %364 = load ptr, ptr %363, align 8, !tbaa !11
  %365 = load i32, ptr @ORDER, align 4, !tbaa !9
  %366 = add i32 6, %365
  %367 = add i32 %366, 2
  %368 = zext i32 %367 to i64
  %369 = getelementptr inbounds i32, ptr %364, i64 %368
  %370 = load i32, ptr %20, align 4, !tbaa !9
  %371 = zext i32 %370 to i64
  %372 = getelementptr inbounds i32, ptr %369, i64 %371
  %373 = load i32, ptr %372, align 4, !tbaa !9
  %374 = load ptr, ptr %16, align 8, !tbaa !5
  store i32 %373, ptr %374, align 4, !tbaa !9
  %375 = load ptr, ptr %16, align 8, !tbaa !5
  call void @fifo_q_push(ptr noundef %14, ptr noundef %375)
  br label %376

376:                                              ; preds = %361, %285
  br label %377

377:                                              ; preds = %376
  %378 = load i32, ptr %20, align 4, !tbaa !9
  %379 = add i32 %378, 1
  store i32 %379, ptr %20, align 4, !tbaa !9
  br label %277, !llvm.loop !32

380:                                              ; preds = %277
  call void @llvm.lifetime.start.p0(i64 8, ptr %21) #8
  call void @llvm.lifetime.start.p0(i64 8, ptr %22) #8
  %381 = load ptr, ptr %5, align 8, !tbaa !5
  %382 = call i64 @bpt_node_serialize(ptr noundef %381, ptr noundef %21)
  store i64 %382, ptr %22, align 8, !tbaa !33
  call void @llvm.lifetime.start.p0(i64 4, ptr %23) #8
  %383 = load ptr, ptr %8, align 8, !tbaa !5
  %384 = load ptr, ptr %21, align 8, !tbaa !5
  %385 = load i64, ptr %22, align 8, !tbaa !33
  %386 = call i32 @disk_store_append(ptr noundef %383, ptr noundef %384, i64 noundef %385)
  store i32 %386, ptr %23, align 4, !tbaa !9
  %387 = load i32, ptr %23, align 4, !tbaa !9
  %388 = add i32 %387, 1
  %389 = load ptr, ptr %5, align 8, !tbaa !5
  %390 = getelementptr inbounds %struct.bpt_node, ptr %389, i32 0, i32 0
  %391 = load ptr, ptr %390, align 8, !tbaa !11
  %392 = getelementptr inbounds i32, ptr %391, i64 0
  %393 = load i32, ptr %392, align 4, !tbaa !9
  %394 = icmp ne i32 %388, %393
  br i1 %394, label %395, label %403

395:                                              ; preds = %380
  %396 = load i32, ptr %23, align 4, !tbaa !9
  %397 = add i32 %396, 1
  %398 = load ptr, ptr %5, align 8, !tbaa !5
  %399 = getelementptr inbounds %struct.bpt_node, ptr %398, i32 0, i32 0
  %400 = load ptr, ptr %399, align 8, !tbaa !11
  %401 = getelementptr inbounds i32, ptr %400, i64 0
  %402 = load i32, ptr %401, align 4, !tbaa !9
  call void (i32, ptr, ...) @errx(i32 noundef 1, ptr noundef @.str.48, i32 noundef %397, i32 noundef %402) #10
  unreachable

403:                                              ; preds = %380
  %404 = load ptr, ptr %21, align 8, !tbaa !5
  call void @free(ptr noundef %404) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %23) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr %22) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr %21) #8
  br label %511

405:                                              ; preds = %269
  %406 = load ptr, ptr %10, align 8, !tbaa !5
  %407 = getelementptr inbounds %struct.bpt_node, ptr %406, i32 0, i32 0
  %408 = load ptr, ptr %407, align 8, !tbaa !11
  %409 = getelementptr inbounds i32, ptr %408, i64 4
  %410 = load i32, ptr %409, align 4, !tbaa !9
  %411 = icmp ne i32 %410, 0
  br i1 %411, label %412, label %432

412:                                              ; preds = %405
  %413 = load ptr, ptr %10, align 8, !tbaa !5
  %414 = getelementptr inbounds %struct.bpt_node, ptr %413, i32 0, i32 0
  %415 = load ptr, ptr %414, align 8, !tbaa !11
  %416 = getelementptr inbounds i32, ptr %415, i64 4
  %417 = load i32, ptr %416, align 4, !tbaa !9
  store i32 %417, ptr %19, align 4, !tbaa !9
  %418 = load ptr, ptr %9, align 8, !tbaa !5
  %419 = call ptr @ordered_set_get(ptr noundef %418, ptr noundef %19)
  store ptr %419, ptr %12, align 8, !tbaa !5
  %420 = load ptr, ptr %12, align 8, !tbaa !5
  %421 = icmp eq ptr %420, null
  br i1 %421, label %422, label %424

422:                                              ; preds = %412
  %423 = load i32, ptr %19, align 4, !tbaa !9
  call void (i32, ptr, ...) @errx(i32 noundef 1, ptr noundef @.str.46, i32 noundef %423) #10
  unreachable

424:                                              ; preds = %412
  %425 = load ptr, ptr %12, align 8, !tbaa !5
  %426 = getelementptr inbounds %struct.uint_pair, ptr %425, i32 0, i32 1
  %427 = load i32, ptr %426, align 4, !tbaa !29
  %428 = load ptr, ptr %5, align 8, !tbaa !5
  %429 = getelementptr inbounds %struct.bpt_node, ptr %428, i32 0, i32 0
  %430 = load ptr, ptr %429, align 8, !tbaa !11
  %431 = getelementptr inbounds i32, ptr %430, i64 4
  store i32 %427, ptr %431, align 4, !tbaa !9
  br label %432

432:                                              ; preds = %424, %405
  call void @llvm.lifetime.start.p0(i64 8, ptr %24) #8
  store ptr null, ptr %24, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %25) #8
  %433 = load ptr, ptr %3, align 8, !tbaa !5
  %434 = load i32, ptr %6, align 4, !tbaa !9
  %435 = load i32, ptr %18, align 4, !tbaa !9
  %436 = call i32 @giggle_get_leaf_data(ptr noundef %433, i32 noundef %434, i32 noundef %435, ptr noundef %24)
  store i32 %436, ptr %25, align 4, !tbaa !9
  %437 = load i32, ptr %25, align 4, !tbaa !9
  %438 = icmp eq i32 %437, 0
  br i1 %438, label %439, label %440

439:                                              ; preds = %432
  call void (i32, ptr, ...) @errx(i32 noundef 1, ptr noundef @.str.49) #10
  unreachable

440:                                              ; preds = %432
  call void @llvm.lifetime.start.p0(i64 4, ptr %26) #8
  %441 = load ptr, ptr getelementptr inbounds (%struct.cache_def, ptr @cache, i32 0, i32 1), align 8, !tbaa !18
  %442 = load i32, ptr %6, align 4, !tbaa !9
  %443 = call i32 %441(i32 noundef %442)
  %444 = add i32 %443, 1
  store i32 %444, ptr %26, align 4, !tbaa !9
  %445 = load ptr, ptr getelementptr inbounds (%struct.cache_def, ptr @cache, i32 0, i32 2), align 8, !tbaa !34
  %446 = load i32, ptr %6, align 4, !tbaa !9
  %447 = load i32, ptr %26, align 4, !tbaa !9
  %448 = sub i32 %447, 1
  %449 = load ptr, ptr %24, align 8, !tbaa !5
  call void %445(i32 noundef %446, i32 noundef %448, ptr noundef %449, i64 noundef 72, ptr noundef @leaf_data_cache_handler)
  %450 = call noalias ptr @malloc(i64 noundef 8) #9
  store ptr %450, ptr %11, align 8, !tbaa !5
  %451 = load ptr, ptr %11, align 8, !tbaa !5
  %452 = icmp eq ptr %451, null
  br i1 %452, label %453, label %454

453:                                              ; preds = %440
  call void (i32, ptr, ...) @err(i32 noundef 1, ptr noundef @.str.44) #10
  unreachable

454:                                              ; preds = %440
  %455 = load i32, ptr %26, align 4, !tbaa !9
  %456 = load ptr, ptr %11, align 8, !tbaa !5
  %457 = getelementptr inbounds %struct.uint_pair, ptr %456, i32 0, i32 0
  store i32 %455, ptr %457, align 4, !tbaa !25
  %458 = load ptr, ptr %9, align 8, !tbaa !5
  %459 = getelementptr inbounds %struct.ordered_set, ptr %458, i32 0, i32 1
  %460 = load i32, ptr %459, align 8, !tbaa !27
  %461 = add i32 %460, 1
  %462 = load ptr, ptr %11, align 8, !tbaa !5
  %463 = getelementptr inbounds %struct.uint_pair, ptr %462, i32 0, i32 1
  store i32 %461, ptr %463, align 4, !tbaa !29
  %464 = load ptr, ptr %9, align 8, !tbaa !5
  %465 = load ptr, ptr %11, align 8, !tbaa !5
  %466 = call ptr @ordered_set_add(ptr noundef %464, ptr noundef %465)
  store ptr %466, ptr %12, align 8, !tbaa !5
  %467 = call noalias ptr @malloc(i64 noundef 4) #9
  store ptr %467, ptr %16, align 8, !tbaa !5
  %468 = load ptr, ptr %16, align 8, !tbaa !5
  %469 = icmp eq ptr %468, null
  br i1 %469, label %470, label %471

470:                                              ; preds = %454
  call void (i32, ptr, ...) @err(i32 noundef 1, ptr noundef @.str.44) #10
  unreachable

471:                                              ; preds = %454
  %472 = load i32, ptr %26, align 4, !tbaa !9
  %473 = load ptr, ptr %16, align 8, !tbaa !5
  store i32 %472, ptr %473, align 4, !tbaa !9
  %474 = load ptr, ptr %16, align 8, !tbaa !5
  call void @fifo_q_push(ptr noundef %15, ptr noundef %474)
  %475 = load ptr, ptr %11, align 8, !tbaa !5
  %476 = getelementptr inbounds %struct.uint_pair, ptr %475, i32 0, i32 1
  %477 = load i32, ptr %476, align 4, !tbaa !29
  %478 = load ptr, ptr %5, align 8, !tbaa !5
  %479 = getelementptr inbounds %struct.bpt_node, ptr %478, i32 0, i32 0
  %480 = load ptr, ptr %479, align 8, !tbaa !11
  %481 = load i32, ptr @ORDER, align 4, !tbaa !9
  %482 = add i32 6, %481
  %483 = add i32 %482, 1
  %484 = zext i32 %483 to i64
  %485 = getelementptr inbounds i32, ptr %480, i64 %484
  %486 = getelementptr inbounds i32, ptr %485, i64 0
  store i32 %477, ptr %486, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %27) #8
  call void @llvm.lifetime.start.p0(i64 8, ptr %28) #8
  %487 = load ptr, ptr %5, align 8, !tbaa !5
  %488 = call i64 @bpt_node_serialize(ptr noundef %487, ptr noundef %27)
  store i64 %488, ptr %28, align 8, !tbaa !33
  call void @llvm.lifetime.start.p0(i64 4, ptr %29) #8
  %489 = load ptr, ptr %8, align 8, !tbaa !5
  %490 = load ptr, ptr %27, align 8, !tbaa !5
  %491 = load i64, ptr %28, align 8, !tbaa !33
  %492 = call i32 @disk_store_append(ptr noundef %489, ptr noundef %490, i64 noundef %491)
  store i32 %492, ptr %29, align 4, !tbaa !9
  %493 = load i32, ptr %29, align 4, !tbaa !9
  %494 = add i32 %493, 1
  %495 = load ptr, ptr %5, align 8, !tbaa !5
  %496 = getelementptr inbounds %struct.bpt_node, ptr %495, i32 0, i32 0
  %497 = load ptr, ptr %496, align 8, !tbaa !11
  %498 = getelementptr inbounds i32, ptr %497, i64 0
  %499 = load i32, ptr %498, align 4, !tbaa !9
  %500 = icmp ne i32 %494, %499
  br i1 %500, label %501, label %509

501:                                              ; preds = %471
  %502 = load i32, ptr %29, align 4, !tbaa !9
  %503 = add i32 %502, 1
  %504 = load ptr, ptr %5, align 8, !tbaa !5
  %505 = getelementptr inbounds %struct.bpt_node, ptr %504, i32 0, i32 0
  %506 = load ptr, ptr %505, align 8, !tbaa !11
  %507 = getelementptr inbounds i32, ptr %506, i64 0
  %508 = load i32, ptr %507, align 4, !tbaa !9
  call void (i32, ptr, ...) @errx(i32 noundef 1, ptr noundef @.str.48, i32 noundef %503, i32 noundef %508) #10
  unreachable

509:                                              ; preds = %471
  %510 = load ptr, ptr %27, align 8, !tbaa !5
  call void @free(ptr noundef %510) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %29) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr %28) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr %27) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %26) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %25) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr %24) #8
  br label %511

511:                                              ; preds = %509, %403
  call void @llvm.lifetime.end.p0(i64 4, ptr %20) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %19) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #8
  br label %151, !llvm.loop !35

512:                                              ; preds = %151
  br label %513

513:                                              ; preds = %517, %512
  %514 = load ptr, ptr %15, align 8, !tbaa !5
  %515 = call ptr @fifo_q_peek(ptr noundef %514)
  %516 = icmp ne ptr %515, null
  br i1 %516, label %517, label %534

517:                                              ; preds = %513
  call void @llvm.lifetime.start.p0(i64 8, ptr %30) #8
  %518 = call ptr @fifo_q_pop(ptr noundef %15)
  store ptr %518, ptr %30, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %31) #8
  %519 = load ptr, ptr %30, align 8, !tbaa !5
  %520 = load i32, ptr %519, align 4, !tbaa !9
  store i32 %520, ptr %31, align 4, !tbaa !9
  %521 = load ptr, ptr %30, align 8, !tbaa !5
  call void @free(ptr noundef %521) #8
  call void @llvm.lifetime.start.p0(i64 8, ptr %32) #8
  %522 = load ptr, ptr getelementptr inbounds (%struct.cache_def, ptr @cache, i32 0, i32 3), align 8, !tbaa !23
  %523 = load i32, ptr %6, align 4, !tbaa !9
  %524 = load i32, ptr %31, align 4, !tbaa !9
  %525 = sub i32 %524, 1
  %526 = call ptr %522(i32 noundef %523, i32 noundef %525, ptr noundef @leaf_data_cache_handler)
  store ptr %526, ptr %32, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %33) #8
  call void @llvm.lifetime.start.p0(i64 8, ptr %34) #8
  %527 = load ptr, ptr %32, align 8, !tbaa !5
  %528 = call i64 @leaf_data_serialize(ptr noundef %527, ptr noundef %33)
  store i64 %528, ptr %34, align 8, !tbaa !33
  call void @llvm.lifetime.start.p0(i64 4, ptr %35) #8
  %529 = load ptr, ptr %8, align 8, !tbaa !5
  %530 = load ptr, ptr %33, align 8, !tbaa !5
  %531 = load i64, ptr %34, align 8, !tbaa !33
  %532 = call i32 @disk_store_append(ptr noundef %529, ptr noundef %530, i64 noundef %531)
  store i32 %532, ptr %35, align 4, !tbaa !9
  %533 = load ptr, ptr %33, align 8, !tbaa !5
  call void @free(ptr noundef %533) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %35) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr %34) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr %33) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr %32) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %31) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr %30) #8
  br label %513, !llvm.loop !36

534:                                              ; preds = %513
  %535 = load ptr, ptr %8, align 8, !tbaa !5
  %536 = load ptr, ptr %4, align 8, !tbaa !5
  %537 = getelementptr inbounds %struct.simple_cache, ptr %536, i32 0, i32 8
  %538 = load ptr, ptr %537, align 8, !tbaa !15
  %539 = load i32, ptr %6, align 4, !tbaa !9
  %540 = zext i32 %539 to i64
  %541 = getelementptr inbounds ptr, ptr %538, i64 %540
  store ptr %535, ptr %541, align 8, !tbaa !5
  call void @ordered_set_destroy(ptr noundef %9, ptr noundef @free_wrapper)
  %542 = load i32, ptr %13, align 4, !tbaa !9
  %543 = load ptr, ptr %3, align 8, !tbaa !5
  %544 = getelementptr inbounds %struct.giggle_index, ptr %543, i32 0, i32 0
  %545 = load ptr, ptr %544, align 8, !tbaa !24
  %546 = load i32, ptr %6, align 4, !tbaa !9
  %547 = zext i32 %546 to i64
  %548 = getelementptr inbounds i32, ptr %545, i64 %547
  store i32 %542, ptr %548, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #8
  br label %549

549:                                              ; preds = %534
  %550 = load i32, ptr %6, align 4, !tbaa !9
  %551 = add i32 %550, 1
  store i32 %551, ptr %6, align 4, !tbaa !9
  br label %59, !llvm.loop !37

552:                                              ; preds = %59
  call void @bpt_node_free_mem(ptr noundef %5)
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #8
  ret void
}

declare ptr @disk_store_init(i32 noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef) #7

declare ptr @ordered_set_init(i32 noundef, ptr noundef, ptr noundef, ptr noundef) #7

declare i32 @uint_pair_sort_by_first_element_cmp(ptr noundef, ptr noundef) #7

declare i32 @uint_pair_search_by_first_element_cmp(ptr noundef, ptr noundef) #7

declare i32 @uint_pair_search_by_first_key_cmp(ptr noundef, ptr noundef) #7

declare ptr @ordered_set_add(ptr noundef, ptr noundef) #7

declare void @fifo_q_push(ptr noundef, ptr noundef) #7

declare ptr @fifo_q_peek(ptr noundef) #7

declare ptr @fifo_q_pop(ptr noundef) #7

declare ptr @ordered_set_get(ptr noundef, ptr noundef) #7

declare i64 @bpt_node_serialize(ptr noundef, ptr noundef) #7

declare i32 @disk_store_append(ptr noundef, ptr noundef, i64 noundef) #7

; Function Attrs: nounwind uwtable
declare dso_local i32 @giggle_get_leaf_data(ptr noundef, i32 noundef, i32 noundef, ptr noundef) #6

declare i64 @leaf_data_serialize(ptr noundef, ptr noundef) #7

declare void @ordered_set_destroy(ptr noundef, ptr noundef) #7

declare void @free_wrapper(ptr noundef) #7

declare void @bpt_node_free_mem(ptr noundef) #7

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

!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 = !{!"int", !7, i64 0}
!11 = !{!12, !6, i64 0}
!12 = !{!"bpt_node", !6, i64 0}
!13 = !{!14, !10, i64 12}
!14 = !{!"giggle_index", !6, i64 0, !10, i64 8, !10, i64 12, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !6, i64 56}
!15 = !{!16, !6, i64 64}
!16 = !{!"simple_cache", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !10, i64 40, !6, i64 48, !6, i64 56, !6, i64 64, !7, i64 72, !6, i64 112, !6, i64 120, !17, i64 128, !17, i64 136, !10, i64 144}
!17 = !{!"long", !7, i64 0}
!18 = !{!19, !6, i64 8}
!19 = !{!"cache_def", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48}
!20 = !{!16, !6, i64 32}
!21 = !{!16, !6, i64 48}
!22 = !{!16, !6, i64 56}
!23 = !{!19, !6, i64 24}
!24 = !{!14, !6, i64 0}
!25 = !{!26, !10, i64 0}
!26 = !{!"uint_pair", !10, i64 0, !10, i64 4}
!27 = !{!28, !10, i64 8}
!28 = !{!"ordered_set", !6, i64 0, !10, i64 8, !10, i64 12, !6, i64 16, !6, i64 24, !6, i64 32}
!29 = !{!26, !10, i64 4}
!30 = distinct !{!30, !31}
!31 = !{!"llvm.loop.mustprogress"}
!32 = distinct !{!32, !31}
!33 = !{!17, !17, i64 0}
!34 = !{!19, !6, i64 16}
!35 = distinct !{!35, !31}
!36 = distinct !{!36, !31}
!37 = distinct !{!37, !31}


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

@cache = external dso_local local_unnamed_addr global %struct.cache_def, align 8
@bpt_node_cache_handler = external dso_local global %struct.cache_handler, align 8
@ORDER = external dso_local local_unnamed_addr global i32, align 4
@leaf_data_cache_handler = external dso_local global %struct.cache_handler, align 8
@_cache = external dso_local local_unnamed_addr global [10 x ptr], align 16
@CACHE_NAME_SPACE = external dso_local local_unnamed_addr global i32, align 4
@.str.44 = external hidden unnamed_addr constant [46 x i8], align 1
@.str.45 = external hidden unnamed_addr constant [55 x i8], align 1
@.str.46 = external hidden unnamed_addr constant [31 x i8], align 1
@.str.47 = external hidden unnamed_addr constant [32 x i8], align 1
@.str.48 = external hidden unnamed_addr constant [50 x i8], align 1
@.str.49 = external hidden unnamed_addr constant [25 x i8], align 1

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

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

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

; 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 nofree nounwind willreturn allockind("alloc,zeroed") allocsize(0,1) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @calloc(i64 noundef, i64 noundef) local_unnamed_addr #3

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

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

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #5

; Function Attrs: nounwind uwtable
define dso_local void @giggle_write_tree_leaf_data(ptr noundef %0) local_unnamed_addr #6 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = load i32, ptr @CACHE_NAME_SPACE, align 4, !tbaa !5
  %12 = zext i32 %11 to i64
  %13 = getelementptr inbounds [10 x ptr], ptr @_cache, i64 0, i64 %12
  %14 = load ptr, ptr %13, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #8
  %15 = tail call noalias dereferenceable_or_null(8) ptr @malloc(i64 noundef 8) #9
  store ptr %15, ptr %2, align 8, !tbaa !9
  %16 = icmp eq ptr %15, null
  br i1 %16, label %17, label %18

17:                                               ; preds = %1
  tail call void (i32, ptr, ...) @err(i32 noundef 1, ptr noundef nonnull @.str.44) #10
  unreachable

18:                                               ; preds = %1
  %19 = load i32, ptr @ORDER, align 4, !tbaa !5
  %20 = shl i32 %19, 1
  %21 = add i32 %20, 10
  %22 = zext i32 %21 to i64
  %23 = tail call noalias ptr @calloc(i64 noundef %22, i64 noundef 4) #11
  store ptr %23, ptr %15, align 8, !tbaa !11
  %24 = icmp eq ptr %23, null
  br i1 %24, label %31, label %.preheader135

.preheader135:                                    ; preds = %18
  %25 = getelementptr inbounds i8, ptr %0, i64 12
  %26 = load i32, ptr %25, align 4, !tbaa !13
  %.not161 = icmp eq i32 %26, 0
  br i1 %.not161, label %._crit_edge160, label %.lr.ph159

.lr.ph159:                                        ; preds = %.preheader135
  %27 = getelementptr inbounds i8, ptr %14, i64 64
  %28 = getelementptr inbounds i8, ptr %14, i64 32
  %29 = getelementptr inbounds i8, ptr %14, i64 48
  %30 = getelementptr inbounds i8, ptr %14, i64 56
  br label %32

31:                                               ; preds = %18
  tail call void (i32, ptr, ...) @err(i32 noundef 1, ptr noundef nonnull @.str.44) #10
  unreachable

32:                                               ; preds = %.lr.ph159, %._crit_edge
  %33 = phi ptr [ %15, %.lr.ph159 ], [ %81, %._crit_edge ]
  %.0158 = phi i32 [ 0, %.lr.ph159 ], [ %269, %._crit_edge ]
  %34 = load ptr, ptr %27, align 8, !tbaa !15
  %35 = zext i32 %.0158 to i64
  %36 = getelementptr inbounds ptr, ptr %34, i64 %35
  %37 = load ptr, ptr %36, align 8, !tbaa !9
  %.not = icmp eq ptr %37, null
  br i1 %.not, label %39, label %38

38:                                               ; preds = %32
  call void (i32, ptr, ...) @errx(i32 noundef 1, ptr noundef nonnull @.str.45) #10
  unreachable

39:                                               ; preds = %32
  %40 = load ptr, ptr getelementptr inbounds (i8, ptr @cache, i64 8), align 8, !tbaa !18
  %41 = call i32 %40(i32 noundef %.0158) #8
  %42 = lshr i32 %41, 1
  %43 = load ptr, ptr %28, align 8, !tbaa !20
  %44 = getelementptr inbounds i32, ptr %43, i64 %35
  %45 = load i32, ptr %44, align 4, !tbaa !5
  %46 = load ptr, ptr %29, align 8, !tbaa !21
  %47 = getelementptr inbounds ptr, ptr %46, i64 %35
  %48 = load ptr, ptr %47, align 8, !tbaa !9
  %49 = load ptr, ptr %30, align 8, !tbaa !22
  %50 = getelementptr inbounds ptr, ptr %49, i64 %35
  %51 = load ptr, ptr %50, align 8, !tbaa !9
  %52 = call ptr @disk_store_init(i32 noundef %45, ptr noundef null, ptr noundef %48, ptr noundef null, ptr noundef %51) #8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #8
  %53 = call ptr @ordered_set_init(i32 noundef %42, ptr noundef nonnull @uint_pair_sort_by_first_element_cmp, ptr noundef nonnull @uint_pair_search_by_first_element_cmp, ptr noundef nonnull @uint_pair_search_by_first_key_cmp) #8
  store ptr %53, ptr %3, align 8, !tbaa !9
  %54 = load ptr, ptr getelementptr inbounds (i8, ptr @cache, i64 24), align 8, !tbaa !23
  %55 = load ptr, ptr %0, align 8, !tbaa !24
  %56 = getelementptr inbounds i32, ptr %55, i64 %35
  %57 = load i32, ptr %56, align 4, !tbaa !5
  %58 = add i32 %57, -1
  %59 = call ptr %54(i32 noundef %.0158, i32 noundef %58, ptr noundef nonnull @bpt_node_cache_handler) #8
  %60 = call noalias dereferenceable_or_null(8) ptr @malloc(i64 noundef 8) #9
  %61 = icmp eq ptr %60, null
  br i1 %61, label %62, label %63

62:                                               ; preds = %39
  call void (i32, ptr, ...) @err(i32 noundef 1, ptr noundef nonnull @.str.44) #10
  unreachable

63:                                               ; preds = %39
  %64 = load ptr, ptr %59, align 8, !tbaa !11
  %65 = load i32, ptr %64, align 4, !tbaa !5
  store i32 %65, ptr %60, align 4, !tbaa !25
  %66 = load ptr, ptr %3, align 8, !tbaa !9
  %67 = getelementptr inbounds i8, ptr %66, i64 8
  %68 = load i32, ptr %67, align 8, !tbaa !27
  %69 = add i32 %68, 1
  %70 = getelementptr inbounds i8, ptr %60, i64 4
  store i32 %69, ptr %70, align 4, !tbaa !29
  %71 = call ptr @ordered_set_add(ptr noundef %66, ptr noundef nonnull %60) #8
  %72 = load i32, ptr %70, align 4, !tbaa !29
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #8
  store ptr null, ptr %4, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #8
  store ptr null, ptr %5, align 8, !tbaa !9
  %73 = call noalias dereferenceable_or_null(4) ptr @malloc(i64 noundef 4) #9
  %74 = icmp eq ptr %73, null
  br i1 %74, label %75, label %76

75:                                               ; preds = %63
  call void (i32, ptr, ...) @err(i32 noundef 1, ptr noundef nonnull @.str.44) #10
  unreachable

76:                                               ; preds = %63
  %77 = load ptr, ptr %59, align 8, !tbaa !11
  %78 = load i32, ptr %77, align 4, !tbaa !5
  store i32 %78, ptr %73, align 4, !tbaa !5
  call void @fifo_q_push(ptr noundef nonnull %4, ptr noundef nonnull %73) #8
  %79 = load ptr, ptr %4, align 8, !tbaa !9
  %80 = call ptr @fifo_q_peek(ptr noundef %79) #8
  %.not125155 = icmp eq ptr %80, null
  br i1 %.not125155, label %.preheader134, label %.lr.ph

.preheader134:                                    ; preds = %250, %76
  %81 = phi ptr [ %33, %76 ], [ %251, %250 ]
  %82 = load ptr, ptr %5, align 8, !tbaa !9
  %83 = call ptr @fifo_q_peek(ptr noundef %82) #8
  %.not126156 = icmp eq ptr %83, null
  br i1 %.not126156, label %._crit_edge, label %.lr.ph157

.lr.ph:                                           ; preds = %76, %250
  %84 = phi ptr [ %251, %250 ], [ %33, %76 ]
  %85 = call ptr @fifo_q_pop(ptr noundef nonnull %4) #8
  %86 = load i32, ptr %85, align 4, !tbaa !5
  call void @free(ptr noundef %85) #8
  %87 = load ptr, ptr getelementptr inbounds (i8, ptr @cache, i64 24), align 8, !tbaa !23
  %88 = add i32 %86, -1
  %89 = call ptr %87(i32 noundef %.0158, i32 noundef %88, ptr noundef nonnull @bpt_node_cache_handler) #8
  %90 = load ptr, ptr %84, align 8, !tbaa !11
  %91 = load i32, ptr @ORDER, align 4, !tbaa !5
  %92 = shl i32 %91, 1
  %93 = add i32 %92, 10
  %94 = zext i32 %93 to i64
  %95 = shl nuw nsw i64 %94, 2
  call void @llvm.memset.p0.i64(ptr align 4 %90, i8 0, i64 %95, i1 false)
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %6) #8
  store i32 %86, ptr %6, align 4, !tbaa !5
  %96 = load ptr, ptr %3, align 8, !tbaa !9
  %97 = call ptr @ordered_set_get(ptr noundef %96, ptr noundef nonnull %6) #8
  %98 = icmp eq ptr %97, null
  br i1 %98, label %99, label %100

99:                                               ; preds = %.lr.ph
  call void (i32, ptr, ...) @errx(i32 noundef 1, ptr noundef nonnull @.str.46, i32 noundef %86) #10
  unreachable

100:                                              ; preds = %.lr.ph
  %101 = getelementptr inbounds i8, ptr %97, i64 4
  %102 = load i32, ptr %101, align 4, !tbaa !29
  %103 = load ptr, ptr %84, align 8, !tbaa !11
  store i32 %102, ptr %103, align 4, !tbaa !5
  %104 = load ptr, ptr %89, align 8, !tbaa !11
  %105 = getelementptr inbounds i8, ptr %104, i64 4
  %106 = load i32, ptr %105, align 4, !tbaa !5
  %107 = getelementptr inbounds i8, ptr %103, i64 4
  store i32 %106, ptr %107, align 4, !tbaa !5
  %108 = getelementptr inbounds i8, ptr %104, i64 8
  %109 = load i32, ptr %108, align 4, !tbaa !5
  %110 = getelementptr inbounds i8, ptr %103, i64 8
  store i32 %109, ptr %110, align 4, !tbaa !5
  %111 = getelementptr inbounds i8, ptr %104, i64 12
  %112 = load i32, ptr %111, align 4, !tbaa !5
  %113 = getelementptr inbounds i8, ptr %103, i64 12
  store i32 %112, ptr %113, align 4, !tbaa !5
  %114 = getelementptr inbounds i8, ptr %104, i64 16
  %115 = load i32, ptr %114, align 4, !tbaa !5
  %116 = getelementptr inbounds i8, ptr %103, i64 16
  store i32 %115, ptr %116, align 4, !tbaa !5
  %117 = getelementptr inbounds i8, ptr %104, i64 20
  %118 = load i32, ptr %117, align 4, !tbaa !5
  %119 = getelementptr inbounds i8, ptr %103, i64 20
  store i32 %118, ptr %119, align 4, !tbaa !5
  %120 = load i32, ptr @ORDER, align 4, !tbaa !5
  %121 = add i32 %120, 7
  %122 = zext i32 %121 to i64
  %123 = getelementptr inbounds i32, ptr %103, i64 %122
  store i32 0, ptr %123, align 4, !tbaa !5
  %124 = getelementptr inbounds i8, ptr %104, i64 24
  %125 = getelementptr inbounds i8, ptr %103, i64 24
  br label %126

126:                                              ; preds = %100, %126
  %.0110153 = phi i32 [ 0, %100 ], [ %131, %126 ]
  %127 = zext i32 %.0110153 to i64
  %128 = getelementptr inbounds i32, ptr %124, i64 %127
  %129 = load i32, ptr %128, align 4, !tbaa !5
  %130 = getelementptr inbounds i32, ptr %125, i64 %127
  store i32 %129, ptr %130, align 4, !tbaa !5
  %131 = add i32 %.0110153, 1
  %132 = load i32, ptr %117, align 4, !tbaa !5
  %.not127 = icmp ugt i32 %131, %132
  br i1 %.not127, label %133, label %126, !llvm.loop !30

133:                                              ; preds = %126
  %134 = load i32, ptr %108, align 4, !tbaa !5
  %135 = icmp eq i32 %134, 0
  br i1 %135, label %.preheader, label %197

.preheader:                                       ; preds = %133
  %.pre180 = load i32, ptr @ORDER, align 4, !tbaa !5
  br label %136

136:                                              ; preds = %.preheader, %180
  %137 = phi ptr [ %104, %.preheader ], [ %181, %180 ]
  %138 = phi i32 [ %.pre180, %.preheader ], [ %182, %180 ]
  %.1154 = phi i32 [ 0, %.preheader ], [ %183, %180 ]
  %139 = add i32 %138, 8
  %140 = zext i32 %139 to i64
  %141 = getelementptr inbounds i32, ptr %137, i64 %140
  %142 = zext i32 %.1154 to i64
  %143 = getelementptr inbounds i32, ptr %141, i64 %142
  %144 = load i32, ptr %143, align 4, !tbaa !5
  %.not132 = icmp eq i32 %144, 0
  br i1 %.not132, label %180, label %145

145:                                              ; preds = %136
  %146 = call noalias dereferenceable_or_null(8) ptr @malloc(i64 noundef 8) #9
  %147 = icmp eq ptr %146, null
  br i1 %147, label %148, label %149

148:                                              ; preds = %145
  call void (i32, ptr, ...) @err(i32 noundef 1, ptr noundef nonnull @.str.44) #10
  unreachable

149:                                              ; preds = %145
  store i32 %144, ptr %146, align 4, !tbaa !25
  %150 = load ptr, ptr %3, align 8, !tbaa !9
  %151 = getelementptr inbounds i8, ptr %150, i64 8
  %152 = load i32, ptr %151, align 8, !tbaa !27
  %153 = add i32 %152, 1
  %154 = getelementptr inbounds i8, ptr %146, i64 4
  store i32 %153, ptr %154, align 4, !tbaa !29
  %155 = call ptr @ordered_set_add(ptr noundef %150, ptr noundef nonnull %146) #8
  %156 = getelementptr inbounds i8, ptr %155, i64 4
  %157 = load i32, ptr %156, align 4, !tbaa !29
  %158 = load i32, ptr %154, align 4, !tbaa !29
  %.not133 = icmp eq i32 %157, %158
  br i1 %.not133, label %162, label %159

159:                                              ; preds = %149
  %160 = load i32, ptr %146, align 4, !tbaa !25
  %161 = load i32, ptr %155, align 4, !tbaa !25
  call void (i32, ptr, ...) @errx(i32 noundef 1, ptr noundef nonnull @.str.47, i32 noundef %160, i32 noundef %161) #10
  unreachable

162:                                              ; preds = %149
  %163 = load ptr, ptr %84, align 8, !tbaa !11
  %164 = load i32, ptr @ORDER, align 4, !tbaa !5
  %165 = add i32 %164, 8
  %166 = zext i32 %165 to i64
  %167 = getelementptr inbounds i32, ptr %163, i64 %166
  %168 = getelementptr inbounds i32, ptr %167, i64 %142
  store i32 %157, ptr %168, align 4, !tbaa !5
  %169 = call noalias dereferenceable_or_null(4) ptr @malloc(i64 noundef 4) #9
  %170 = icmp eq ptr %169, null
  br i1 %170, label %171, label %172

171:                                              ; preds = %162
  call void (i32, ptr, ...) @err(i32 noundef 1, ptr noundef nonnull @.str.44) #10
  unreachable

172:                                              ; preds = %162
  %173 = load ptr, ptr %89, align 8, !tbaa !11
  %174 = load i32, ptr @ORDER, align 4, !tbaa !5
  %175 = add i32 %174, 8
  %176 = zext i32 %175 to i64
  %177 = getelementptr inbounds i32, ptr %173, i64 %176
  %178 = getelementptr inbounds i32, ptr %177, i64 %142
  %179 = load i32, ptr %178, align 4, !tbaa !5
  store i32 %179, ptr %169, align 4, !tbaa !5
  call void @fifo_q_push(ptr noundef nonnull %4, ptr noundef nonnull %169) #8
  %.pre = load i32, ptr @ORDER, align 4, !tbaa !5
  %.pre181 = load ptr, ptr %89, align 8, !tbaa !11
  br label %180

180:                                              ; preds = %136, %172
  %181 = phi ptr [ %137, %136 ], [ %.pre181, %172 ]
  %182 = phi i32 [ %138, %136 ], [ %.pre, %172 ]
  %183 = add i32 %.1154, 1
  %184 = getelementptr inbounds i8, ptr %181, i64 20
  %185 = load i32, ptr %184, align 4, !tbaa !5
  %.not130 = icmp ugt i32 %183, %185
  br i1 %.not130, label %186, label %136, !llvm.loop !32

186:                                              ; preds = %180
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %7) #8
  %187 = call i64 @bpt_node_serialize(ptr noundef nonnull %84, ptr noundef nonnull %7) #8
  %188 = load ptr, ptr %7, align 8, !tbaa !9
  %189 = call i32 @disk_store_append(ptr noundef %52, ptr noundef %188, i64 noundef %187) #8
  %190 = add i32 %189, 1
  %191 = load ptr, ptr %2, align 8, !tbaa !9
  %192 = load ptr, ptr %191, align 8, !tbaa !11
  %193 = load i32, ptr %192, align 4, !tbaa !5
  %.not131 = icmp eq i32 %190, %193
  br i1 %.not131, label %195, label %194

194:                                              ; preds = %186
  call void (i32, ptr, ...) @errx(i32 noundef 1, ptr noundef nonnull @.str.48, i32 noundef %190, i32 noundef %193) #10
  unreachable

195:                                              ; preds = %186
  %196 = load ptr, ptr %7, align 8, !tbaa !9
  call void @free(ptr noundef %196) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %7) #8
  br label %250

197:                                              ; preds = %133
  %198 = load i32, ptr %114, align 4, !tbaa !5
  %.not128 = icmp eq i32 %198, 0
  br i1 %.not128, label %210, label %199

199:                                              ; preds = %197
  store i32 %198, ptr %6, align 4, !tbaa !5
  %200 = load ptr, ptr %3, align 8, !tbaa !9
  %201 = call ptr @ordered_set_get(ptr noundef %200, ptr noundef nonnull %6) #8
  %202 = icmp eq ptr %201, null
  br i1 %202, label %203, label %205

203:                                              ; preds = %199
  %204 = load i32, ptr %6, align 4, !tbaa !5
  call void (i32, ptr, ...) @errx(i32 noundef 1, ptr noundef nonnull @.str.46, i32 noundef %204) #10
  unreachable

205:                                              ; preds = %199
  %206 = getelementptr inbounds i8, ptr %201, i64 4
  %207 = load i32, ptr %206, align 4, !tbaa !29
  %208 = load ptr, ptr %84, align 8, !tbaa !11
  %209 = getelementptr inbounds i8, ptr %208, i64 16
  store i32 %207, ptr %209, align 4, !tbaa !5
  br label %210

210:                                              ; preds = %205, %197
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %8) #8
  store ptr null, ptr %8, align 8, !tbaa !9
  %211 = call i32 @giggle_get_leaf_data(ptr noundef nonnull %0, i32 noundef %.0158, i32 noundef %86, ptr noundef nonnull %8)
  %212 = icmp eq i32 %211, 0
  br i1 %212, label %213, label %214

213:                                              ; preds = %210
  call void (i32, ptr, ...) @errx(i32 noundef 1, ptr noundef nonnull @.str.49) #10
  unreachable

214:                                              ; preds = %210
  %215 = load ptr, ptr getelementptr inbounds (i8, ptr @cache, i64 8), align 8, !tbaa !18
  %216 = call i32 %215(i32 noundef %.0158) #8
  %217 = add i32 %216, 1
  %218 = load ptr, ptr getelementptr inbounds (i8, ptr @cache, i64 16), align 8, !tbaa !33
  %219 = load ptr, ptr %8, align 8, !tbaa !9
  call void %218(i32 noundef %.0158, i32 noundef %216, ptr noundef %219, i64 noundef 72, ptr noundef nonnull @leaf_data_cache_handler) #8
  %220 = call noalias dereferenceable_or_null(8) ptr @malloc(i64 noundef 8) #9
  %221 = icmp eq ptr %220, null
  br i1 %221, label %222, label %223

222:                                              ; preds = %214
  call void (i32, ptr, ...) @err(i32 noundef 1, ptr noundef nonnull @.str.44) #10
  unreachable

223:                                              ; preds = %214
  store i32 %217, ptr %220, align 4, !tbaa !25
  %224 = load ptr, ptr %3, align 8, !tbaa !9
  %225 = getelementptr inbounds i8, ptr %224, i64 8
  %226 = load i32, ptr %225, align 8, !tbaa !27
  %227 = add i32 %226, 1
  %228 = getelementptr inbounds i8, ptr %220, i64 4
  store i32 %227, ptr %228, align 4, !tbaa !29
  %229 = call ptr @ordered_set_add(ptr noundef %224, ptr noundef nonnull %220) #8
  %230 = call noalias dereferenceable_or_null(4) ptr @malloc(i64 noundef 4) #9
  %231 = icmp eq ptr %230, null
  br i1 %231, label %232, label %233

232:                                              ; preds = %223
  call void (i32, ptr, ...) @err(i32 noundef 1, ptr noundef nonnull @.str.44) #10
  unreachable

233:                                              ; preds = %223
  store i32 %217, ptr %230, align 4, !tbaa !5
  call void @fifo_q_push(ptr noundef nonnull %5, ptr noundef nonnull %230) #8
  %234 = load i32, ptr %228, align 4, !tbaa !29
  %235 = load ptr, ptr %84, align 8, !tbaa !11
  %236 = load i32, ptr @ORDER, align 4, !tbaa !5
  %237 = add i32 %236, 7
  %238 = zext i32 %237 to i64
  %239 = getelementptr inbounds i32, ptr %235, i64 %238
  store i32 %234, ptr %239, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %9) #8
  %240 = call i64 @bpt_node_serialize(ptr noundef nonnull %84, ptr noundef nonnull %9) #8
  %241 = load ptr, ptr %9, align 8, !tbaa !9
  %242 = call i32 @disk_store_append(ptr noundef %52, ptr noundef %241, i64 noundef %240) #8
  %243 = add i32 %242, 1
  %244 = load ptr, ptr %2, align 8, !tbaa !9
  %245 = load ptr, ptr %244, align 8, !tbaa !11
  %246 = load i32, ptr %245, align 4, !tbaa !5
  %.not129 = icmp eq i32 %243, %246
  br i1 %.not129, label %248, label %247

247:                                              ; preds = %233
  call void (i32, ptr, ...) @errx(i32 noundef 1, ptr noundef nonnull @.str.48, i32 noundef %243, i32 noundef %246) #10
  unreachable

248:                                              ; preds = %233
  %249 = load ptr, ptr %9, align 8, !tbaa !9
  call void @free(ptr noundef %249) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %9) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %8) #8
  br label %250

250:                                              ; preds = %248, %195
  %251 = phi ptr [ %244, %248 ], [ %191, %195 ]
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %6) #8
  %252 = load ptr, ptr %4, align 8, !tbaa !9
  %253 = call ptr @fifo_q_peek(ptr noundef %252) #8
  %.not125 = icmp eq ptr %253, null
  br i1 %.not125, label %.preheader134, label %.lr.ph, !llvm.loop !34

.lr.ph157:                                        ; preds = %.preheader134, %.lr.ph157
  %254 = call ptr @fifo_q_pop(ptr noundef nonnull %5) #8
  %255 = load i32, ptr %254, align 4, !tbaa !5
  call void @free(ptr noundef %254) #8
  %256 = load ptr, ptr getelementptr inbounds (i8, ptr @cache, i64 24), align 8, !tbaa !23
  %257 = add i32 %255, -1
  %258 = call ptr %256(i32 noundef %.0158, i32 noundef %257, ptr noundef nonnull @leaf_data_cache_handler) #8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %10) #8
  %259 = call i64 @leaf_data_serialize(ptr noundef %258, ptr noundef nonnull %10) #8
  %260 = load ptr, ptr %10, align 8, !tbaa !9
  %261 = call i32 @disk_store_append(ptr noundef %52, ptr noundef %260, i64 noundef %259) #8
  %262 = load ptr, ptr %10, align 8, !tbaa !9
  call void @free(ptr noundef %262) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %10) #8
  %263 = load ptr, ptr %5, align 8, !tbaa !9
  %264 = call ptr @fifo_q_peek(ptr noundef %263) #8
  %.not126 = icmp eq ptr %264, null
  br i1 %.not126, label %._crit_edge, label %.lr.ph157, !llvm.loop !35

._crit_edge:                                      ; preds = %.lr.ph157, %.preheader134
  %265 = load ptr, ptr %27, align 8, !tbaa !15
  %266 = getelementptr inbounds ptr, ptr %265, i64 %35
  store ptr %52, ptr %266, align 8, !tbaa !9
  call void @ordered_set_destroy(ptr noundef nonnull %3, ptr noundef nonnull @free_wrapper) #8
  %267 = load ptr, ptr %0, align 8, !tbaa !24
  %268 = getelementptr inbounds i32, ptr %267, i64 %35
  store i32 %72, ptr %268, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #8
  %269 = add nuw i32 %.0158, 1
  %270 = load i32, ptr %25, align 4, !tbaa !13
  %271 = icmp ult i32 %269, %270
  br i1 %271, label %32, label %._crit_edge160, !llvm.loop !36

._crit_edge160:                                   ; preds = %._crit_edge, %.preheader135
  call void @bpt_node_free_mem(ptr noundef nonnull %2) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #8
  ret void
}

declare ptr @disk_store_init(i32 noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #7

declare ptr @ordered_set_init(i32 noundef, ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #7

declare i32 @uint_pair_sort_by_first_element_cmp(ptr noundef, ptr noundef) #7

declare i32 @uint_pair_search_by_first_element_cmp(ptr noundef, ptr noundef) #7

declare i32 @uint_pair_search_by_first_key_cmp(ptr noundef, ptr noundef) #7

declare ptr @ordered_set_add(ptr noundef, ptr noundef) local_unnamed_addr #7

declare void @fifo_q_push(ptr noundef, ptr noundef) local_unnamed_addr #7

declare ptr @fifo_q_peek(ptr noundef) local_unnamed_addr #7

declare ptr @fifo_q_pop(ptr noundef) local_unnamed_addr #7

declare ptr @ordered_set_get(ptr noundef, ptr noundef) local_unnamed_addr #7

declare i64 @bpt_node_serialize(ptr noundef, ptr noundef) local_unnamed_addr #7

declare i32 @disk_store_append(ptr noundef, ptr noundef, i64 noundef) local_unnamed_addr #7

; Function Attrs: nounwind uwtable
declare dso_local i32 @giggle_get_leaf_data(ptr noundef, i32 noundef, i32 noundef, ptr noundef) local_unnamed_addr #6

declare i64 @leaf_data_serialize(ptr noundef, ptr noundef) local_unnamed_addr #7

declare void @ordered_set_destroy(ptr noundef, ptr noundef) local_unnamed_addr #7

declare void @free_wrapper(ptr noundef) #7

declare void @bpt_node_free_mem(ptr noundef) local_unnamed_addr #7

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { 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 #3 = { mustprogress nofree nounwind willreturn allockind("alloc,zeroed") allocsize(0,1) 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 = { 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 #5 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #6 = { 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 #7 = { "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 #8 = { nounwind }
attributes #9 = { nounwind allocsize(0) }
attributes #10 = { noreturn nounwind }
attributes #11 = { nounwind allocsize(0,1) }

!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, !6, i64 12}
!14 = !{!"giggle_index", !10, i64 0, !6, i64 8, !6, i64 12, !10, i64 16, !10, i64 24, !10, i64 32, !10, i64 40, !10, i64 48, !10, i64 56}
!15 = !{!16, !10, i64 64}
!16 = !{!"simple_cache", !10, i64 0, !10, i64 8, !10, i64 16, !10, i64 24, !10, i64 32, !6, i64 40, !10, i64 48, !10, i64 56, !10, i64 64, !7, i64 72, !10, i64 112, !10, i64 120, !17, i64 128, !17, i64 136, !6, i64 144}
!17 = !{!"long", !7, i64 0}
!18 = !{!19, !10, i64 8}
!19 = !{!"cache_def", !10, i64 0, !10, i64 8, !10, i64 16, !10, i64 24, !10, i64 32, !10, i64 40, !10, i64 48}
!20 = !{!16, !10, i64 32}
!21 = !{!16, !10, i64 48}
!22 = !{!16, !10, i64 56}
!23 = !{!19, !10, i64 24}
!24 = !{!14, !10, i64 0}
!25 = !{!26, !6, i64 0}
!26 = !{!"uint_pair", !6, i64 0, !6, i64 4}
!27 = !{!28, !6, i64 8}
!28 = !{!"ordered_set", !10, i64 0, !6, i64 8, !6, i64 12, !10, i64 16, !10, i64 24, !10, i64 32}
!29 = !{!26, !6, i64 4}
!30 = distinct !{!30, !31}
!31 = !{!"llvm.loop.mustprogress"}
!32 = distinct !{!32, !31}
!33 = !{!19, !10, i64 16}
!34 = distinct !{!34, !31}
!35 = distinct !{!35, !31}
!36 = distinct !{!36, !31}


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