; LLVM IR from clausecker/24puzzle :: catalogue (catalogue_load)

; 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.pdb_catalogue = type { [64 x %struct.heuristic], [64 x i32], [64 x i64], i64, i64 }
%struct.heuristic = type { ptr, ptr, ptr, ptr, i32, i32, i32 }

@.str = external hidden unnamed_addr constant [31 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [8 x i8], align 1
@stderr = external global ptr, align 8
@.str.4 = external hidden unnamed_addr constant [52 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [56 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [45 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [40 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [44 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local ptr @catalogue_load(ptr noundef %0, ptr noundef %1, i32 noundef %2, ptr noundef %3) #0 {
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca i64, align 8
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  %16 = alloca [512 x i8], align 16
  %17 = alloca ptr, align 8
  %18 = alloca i32, align 4
  store ptr %0, ptr %6, align 8, !tbaa !5
  store ptr %1, ptr %7, align 8, !tbaa !5
  store i32 %2, ptr %8, align 4, !tbaa !9
  store ptr %3, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #9
  %19 = call noalias ptr @malloc(i64 noundef 3856) #10
  store ptr %19, ptr %10, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #9
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #9
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #9
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #9
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #9
  store i32 0, ptr %15, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 512, ptr %16) #9
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #9
  %20 = load ptr, ptr %10, align 8, !tbaa !5
  %21 = icmp eq ptr %20, null
  br i1 %21, label %22, label %23

22:                                               ; preds = %4
  store ptr null, ptr %5, align 8
  store i32 1, ptr %18, align 4
  br label %251

23:                                               ; preds = %4
  %24 = load ptr, ptr %10, align 8, !tbaa !5
  call void @llvm.memset.p0.i64(ptr align 8 %24, i8 0, i64 3856, i1 false)
  %25 = load ptr, ptr %9, align 8, !tbaa !5
  %26 = icmp ne ptr %25, null
  br i1 %26, label %27, label %31

27:                                               ; preds = %23
  %28 = load ptr, ptr %9, align 8, !tbaa !5
  %29 = load ptr, ptr %6, align 8, !tbaa !5
  %30 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %28, ptr noundef @.str, ptr noundef %29) #9
  br label %31

31:                                               ; preds = %27, %23
  %32 = load ptr, ptr %7, align 8, !tbaa !5
  %33 = icmp eq ptr %32, null
  br i1 %33, label %34, label %36

34:                                               ; preds = %31
  %35 = call ptr @getenv(ptr noundef @.str.1) #9
  store ptr %35, ptr %7, align 8, !tbaa !5
  br label %36

36:                                               ; preds = %34, %31
  %37 = load ptr, ptr %6, align 8, !tbaa !5
  %38 = call noalias ptr @fopen(ptr noundef %37, ptr noundef @.str.2)
  store ptr %38, ptr %11, align 8, !tbaa !5
  %39 = load ptr, ptr %11, align 8, !tbaa !5
  %40 = icmp eq ptr %39, null
  br i1 %40, label %41, label %54

41:                                               ; preds = %36
  %42 = call ptr @__errno_location() #11
  %43 = load i32, ptr %42, align 4, !tbaa !9
  store i32 %43, ptr %13, align 4, !tbaa !9
  %44 = load ptr, ptr %9, align 8, !tbaa !5
  %45 = icmp ne ptr %44, null
  br i1 %45, label %46, label %53

46:                                               ; preds = %41
  %47 = load ptr, ptr %9, align 8, !tbaa !5
  %48 = load ptr, ptr %6, align 8, !tbaa !5
  %49 = call ptr @__errno_location() #11
  %50 = load i32, ptr %49, align 4, !tbaa !9
  %51 = call ptr @strerror(i32 noundef %50) #9
  %52 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %47, ptr noundef @.str.3, ptr noundef %48, ptr noundef %51) #9
  br label %53

53:                                               ; preds = %46, %41
  br label %247

54:                                               ; preds = %36
  br label %55

55:                                               ; preds = %153, %107, %79, %54
  %56 = getelementptr inbounds [512 x i8], ptr %16, i64 0, i64 0
  %57 = load ptr, ptr %11, align 8, !tbaa !5
  %58 = call ptr @fgets(ptr noundef %56, i32 noundef 512, ptr noundef %57)
  %59 = icmp ne ptr %58, null
  br i1 %59, label %60, label %173

60:                                               ; preds = %55
  %61 = getelementptr inbounds [512 x i8], ptr %16, i64 0, i64 0
  %62 = call ptr @strchr(ptr noundef %61, i32 noundef 10) #12
  store ptr %62, ptr %17, align 8, !tbaa !5
  %63 = load ptr, ptr %17, align 8, !tbaa !5
  %64 = icmp eq ptr %63, null
  br i1 %64, label %65, label %73

65:                                               ; preds = %60
  %66 = load ptr, ptr %9, align 8, !tbaa !5
  %67 = icmp ne ptr %66, null
  br i1 %67, label %68, label %72

68:                                               ; preds = %65
  %69 = load ptr, ptr @stderr, align 8, !tbaa !5
  %70 = load ptr, ptr %6, align 8, !tbaa !5
  %71 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %69, ptr noundef @.str.4, ptr noundef %70) #9
  br label %72

72:                                               ; preds = %68, %65
  store i32 34, ptr %13, align 4, !tbaa !9
  br label %228

73:                                               ; preds = %60
  %74 = load ptr, ptr %17, align 8, !tbaa !5
  store i8 0, ptr %74, align 1, !tbaa !11
  %75 = getelementptr inbounds [512 x i8], ptr %16, i64 0, i64 0
  %76 = load i8, ptr %75, align 16, !tbaa !11
  %77 = sext i8 %76 to i32
  %78 = icmp eq i32 %77, 35
  br i1 %78, label %79, label %80

79:                                               ; preds = %73
  br label %55, !llvm.loop !12

80:                                               ; preds = %73
  %81 = getelementptr inbounds [512 x i8], ptr %16, i64 0, i64 0
  %82 = load i8, ptr %81, align 16, !tbaa !11
  %83 = sext i8 %82 to i32
  %84 = icmp eq i32 %83, 0
  br i1 %84, label %85, label %108

85:                                               ; preds = %80
  %86 = load i32, ptr %15, align 4, !tbaa !9
  %87 = call i32 @tileset_empty(i32 noundef %86)
  %88 = icmp ne i32 %87, 0
  br i1 %88, label %107, label %89

89:                                               ; preds = %85
  %90 = load i32, ptr %15, align 4, !tbaa !9
  %91 = call i32 @tileset_add(i32 noundef %90, i32 noundef 0)
  %92 = icmp ne i32 %91, 33554431
  br i1 %92, label %93, label %102

93:                                               ; preds = %89
  %94 = load ptr, ptr %9, align 8, !tbaa !5
  %95 = icmp ne ptr %94, null
  br i1 %95, label %96, label %102

96:                                               ; preds = %93
  %97 = load ptr, ptr %9, align 8, !tbaa !5
  %98 = load ptr, ptr %10, align 8, !tbaa !5
  %99 = getelementptr inbounds %struct.pdb_catalogue, ptr %98, i32 0, i32 4
  %100 = load i64, ptr %99, align 8, !tbaa !14
  %101 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %97, ptr noundef @.str.5, i64 noundef %100) #9
  br label %102

102:                                              ; preds = %96, %93, %89
  %103 = load ptr, ptr %10, align 8, !tbaa !5
  %104 = getelementptr inbounds %struct.pdb_catalogue, ptr %103, i32 0, i32 4
  %105 = load i64, ptr %104, align 8, !tbaa !14
  %106 = add i64 %105, 1
  store i64 %106, ptr %104, align 8, !tbaa !14
  br label %107

107:                                              ; preds = %102, %85
  store i32 0, ptr %15, align 4, !tbaa !9
  br label %55, !llvm.loop !12

108:                                              ; preds = %80
  %109 = load ptr, ptr %10, align 8, !tbaa !5
  %110 = getelementptr inbounds %struct.pdb_catalogue, ptr %109, i32 0, i32 4
  %111 = load i64, ptr %110, align 8, !tbaa !14
  %112 = icmp uge i64 %111, 64
  br i1 %112, label %113, label %120

113:                                              ; preds = %108
  %114 = load ptr, ptr %9, align 8, !tbaa !5
  %115 = icmp ne ptr %114, null
  br i1 %115, label %116, label %119

116:                                              ; preds = %113
  %117 = load ptr, ptr %9, align 8, !tbaa !5
  %118 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %117, ptr noundef @.str.6, i32 noundef 64) #9
  br label %119

119:                                              ; preds = %116, %113
  store i32 34, ptr %13, align 4, !tbaa !9
  br label %228

120:                                              ; preds = %108
  %121 = load ptr, ptr %10, align 8, !tbaa !5
  %122 = getelementptr inbounds [512 x i8], ptr %16, i64 0, i64 0
  %123 = load ptr, ptr %7, align 8, !tbaa !5
  %124 = load i32, ptr %8, align 4, !tbaa !9
  %125 = load ptr, ptr %9, align 8, !tbaa !5
  %126 = call i32 @add_pdb(ptr noundef %121, ptr noundef %122, ptr noundef %123, i32 noundef %124, i32 noundef 3, ptr noundef %125)
  store i32 %126, ptr %14, align 4, !tbaa !9
  %127 = load i32, ptr %14, align 4, !tbaa !9
  %128 = icmp eq i32 %127, -1
  br i1 %128, label %129, label %132

129:                                              ; preds = %120
  %130 = call ptr @__errno_location() #11
  %131 = load i32, ptr %130, align 4, !tbaa !9
  store i32 %131, ptr %13, align 4, !tbaa !9
  br label %228

132:                                              ; preds = %120
  %133 = load i32, ptr %15, align 4, !tbaa !9
  %134 = load ptr, ptr %10, align 8, !tbaa !5
  %135 = getelementptr inbounds %struct.pdb_catalogue, ptr %134, i32 0, i32 1
  %136 = load i32, ptr %14, align 4, !tbaa !9
  %137 = sext i32 %136 to i64
  %138 = getelementptr inbounds [64 x i32], ptr %135, i64 0, i64 %137
  %139 = load i32, ptr %138, align 4, !tbaa !9
  %140 = call i32 @tileset_intersect(i32 noundef %133, i32 noundef %139)
  %141 = call i32 @tileset_remove(i32 noundef %140, i32 noundef 0)
  %142 = call i32 @tileset_empty(i32 noundef %141)
  %143 = icmp ne i32 %142, 0
  br i1 %143, label %153, label %144

144:                                              ; preds = %132
  %145 = load ptr, ptr %9, align 8, !tbaa !5
  %146 = icmp ne ptr %145, null
  br i1 %146, label %147, label %153

147:                                              ; preds = %144
  %148 = load ptr, ptr %9, align 8, !tbaa !5
  %149 = load ptr, ptr %10, align 8, !tbaa !5
  %150 = getelementptr inbounds %struct.pdb_catalogue, ptr %149, i32 0, i32 4
  %151 = load i64, ptr %150, align 8, !tbaa !14
  %152 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %148, ptr noundef @.str.7, i64 noundef %151) #9
  br label %153

153:                                              ; preds = %147, %144, %132
  %154 = load i32, ptr %15, align 4, !tbaa !9
  %155 = load ptr, ptr %10, align 8, !tbaa !5
  %156 = getelementptr inbounds %struct.pdb_catalogue, ptr %155, i32 0, i32 1
  %157 = load i32, ptr %14, align 4, !tbaa !9
  %158 = sext i32 %157 to i64
  %159 = getelementptr inbounds [64 x i32], ptr %156, i64 0, i64 %158
  %160 = load i32, ptr %159, align 4, !tbaa !9
  %161 = call i32 @tileset_union(i32 noundef %154, i32 noundef %160)
  store i32 %161, ptr %15, align 4, !tbaa !9
  %162 = load i32, ptr %14, align 4, !tbaa !9
  %163 = shl i32 1, %162
  %164 = sext i32 %163 to i64
  %165 = load ptr, ptr %10, align 8, !tbaa !5
  %166 = getelementptr inbounds %struct.pdb_catalogue, ptr %165, i32 0, i32 2
  %167 = load ptr, ptr %10, align 8, !tbaa !5
  %168 = getelementptr inbounds %struct.pdb_catalogue, ptr %167, i32 0, i32 4
  %169 = load i64, ptr %168, align 8, !tbaa !14
  %170 = getelementptr inbounds [64 x i64], ptr %166, i64 0, i64 %169
  %171 = load i64, ptr %170, align 8, !tbaa !17
  %172 = or i64 %171, %164
  store i64 %172, ptr %170, align 8, !tbaa !17
  br label %55, !llvm.loop !12

173:                                              ; preds = %55
  %174 = load ptr, ptr %11, align 8, !tbaa !5
  %175 = call i32 @ferror(ptr noundef %174) #9
  %176 = icmp ne i32 %175, 0
  br i1 %176, label %177, label %190

177:                                              ; preds = %173
  %178 = call ptr @__errno_location() #11
  %179 = load i32, ptr %178, align 4, !tbaa !9
  store i32 %179, ptr %13, align 4, !tbaa !9
  %180 = load ptr, ptr %9, align 8, !tbaa !5
  %181 = icmp ne ptr %180, null
  br i1 %181, label %182, label %189

182:                                              ; preds = %177
  %183 = load ptr, ptr %9, align 8, !tbaa !5
  %184 = load ptr, ptr %6, align 8, !tbaa !5
  %185 = call ptr @__errno_location() #11
  %186 = load i32, ptr %185, align 4, !tbaa !9
  %187 = call ptr @strerror(i32 noundef %186) #9
  %188 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %183, ptr noundef @.str.3, ptr noundef %184, ptr noundef %187) #9
  br label %189

189:                                              ; preds = %182, %177
  br label %228

190:                                              ; preds = %173
  %191 = load i32, ptr %15, align 4, !tbaa !9
  %192 = icmp ne i32 %191, 0
  br i1 %192, label %193, label %211

193:                                              ; preds = %190
  %194 = load i32, ptr %15, align 4, !tbaa !9
  %195 = call i32 @tileset_add(i32 noundef %194, i32 noundef 0)
  %196 = icmp ne i32 %195, 33554431
  br i1 %196, label %197, label %206

197:                                              ; preds = %193
  %198 = load ptr, ptr %9, align 8, !tbaa !5
  %199 = icmp ne ptr %198, null
  br i1 %199, label %200, label %206

200:                                              ; preds = %197
  %201 = load ptr, ptr %9, align 8, !tbaa !5
  %202 = load ptr, ptr %10, align 8, !tbaa !5
  %203 = getelementptr inbounds %struct.pdb_catalogue, ptr %202, i32 0, i32 4
  %204 = load i64, ptr %203, align 8, !tbaa !14
  %205 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %201, ptr noundef @.str.5, i64 noundef %204) #9
  br label %206

206:                                              ; preds = %200, %197, %193
  %207 = load ptr, ptr %10, align 8, !tbaa !5
  %208 = getelementptr inbounds %struct.pdb_catalogue, ptr %207, i32 0, i32 4
  %209 = load i64, ptr %208, align 8, !tbaa !14
  %210 = add i64 %209, 1
  store i64 %210, ptr %208, align 8, !tbaa !14
  br label %211

211:                                              ; preds = %206, %190
  %212 = load ptr, ptr %9, align 8, !tbaa !5
  %213 = icmp ne ptr %212, null
  br i1 %213, label %214, label %224

214:                                              ; preds = %211
  %215 = load ptr, ptr %9, align 8, !tbaa !5
  %216 = load ptr, ptr %10, align 8, !tbaa !5
  %217 = getelementptr inbounds %struct.pdb_catalogue, ptr %216, i32 0, i32 3
  %218 = load i64, ptr %217, align 8, !tbaa !19
  %219 = load ptr, ptr %10, align 8, !tbaa !5
  %220 = getelementptr inbounds %struct.pdb_catalogue, ptr %219, i32 0, i32 4
  %221 = load i64, ptr %220, align 8, !tbaa !14
  %222 = load ptr, ptr %6, align 8, !tbaa !5
  %223 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %215, ptr noundef @.str.8, i64 noundef %218, i64 noundef %221, ptr noundef %222) #9
  br label %224

224:                                              ; preds = %214, %211
  %225 = load ptr, ptr %11, align 8, !tbaa !5
  %226 = call i32 @fclose(ptr noundef %225)
  %227 = load ptr, ptr %10, align 8, !tbaa !5
  store ptr %227, ptr %5, align 8
  store i32 1, ptr %18, align 4
  br label %251

228:                                              ; preds = %189, %129, %119, %72
  %229 = load ptr, ptr %11, align 8, !tbaa !5
  %230 = call i32 @fclose(ptr noundef %229)
  store i64 0, ptr %12, align 8, !tbaa !20
  br label %231

231:                                              ; preds = %243, %228
  %232 = load i64, ptr %12, align 8, !tbaa !20
  %233 = load ptr, ptr %10, align 8, !tbaa !5
  %234 = getelementptr inbounds %struct.pdb_catalogue, ptr %233, i32 0, i32 3
  %235 = load i64, ptr %234, align 8, !tbaa !19
  %236 = icmp ult i64 %232, %235
  br i1 %236, label %237, label %246

237:                                              ; preds = %231
  %238 = load ptr, ptr %10, align 8, !tbaa !5
  %239 = getelementptr inbounds %struct.pdb_catalogue, ptr %238, i32 0, i32 0
  %240 = getelementptr inbounds [64 x %struct.heuristic], ptr %239, i64 0, i64 0
  %241 = load i64, ptr %12, align 8, !tbaa !20
  %242 = getelementptr inbounds %struct.heuristic, ptr %240, i64 %241
  call void @heu_free(ptr noundef %242)
  br label %243

243:                                              ; preds = %237
  %244 = load i64, ptr %12, align 8, !tbaa !20
  %245 = add i64 %244, 1
  store i64 %245, ptr %12, align 8, !tbaa !20
  br label %231, !llvm.loop !21

246:                                              ; preds = %231
  br label %247

247:                                              ; preds = %246, %53
  %248 = load ptr, ptr %10, align 8, !tbaa !5
  call void @free(ptr noundef %248) #9
  %249 = load i32, ptr %13, align 4, !tbaa !9
  %250 = call ptr @__errno_location() #11
  store i32 %249, ptr %250, align 4, !tbaa !9
  store ptr null, ptr %5, align 8
  store i32 1, ptr %18, align 4
  br label %251

251:                                              ; preds = %247, %224, %22
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #9
  call void @llvm.lifetime.end.p0(i64 512, ptr %16) #9
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #9
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #9
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #9
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #9
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #9
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #9
  %252 = load ptr, ptr %5, align 8
  ret ptr %252
}

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

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

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

; Function Attrs: nounwind
declare i32 @fprintf(ptr noundef, ptr noundef, ...) #4

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

declare noalias ptr @fopen(ptr noundef, ptr noundef) #5

; Function Attrs: nounwind willreturn memory(none)
declare ptr @__errno_location() #6

; Function Attrs: nounwind
declare ptr @strerror(i32 noundef) #4

declare ptr @fgets(ptr noundef, i32 noundef, ptr noundef) #5

; Function Attrs: nounwind willreturn memory(read)
declare ptr @strchr(ptr noundef, i32 noundef) #7

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @tileset_empty(i32 noundef) #8

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @tileset_add(i32 noundef, i32 noundef) #8

; Function Attrs: nounwind uwtable
declare hidden i32 @add_pdb(ptr noundef, ptr noundef, ptr noundef, i32 noundef, i32 noundef, ptr noundef) #0

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @tileset_remove(i32 noundef, i32 noundef) #8

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @tileset_intersect(i32 noundef, i32 noundef) #8

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @tileset_union(i32 noundef, i32 noundef) #8

; Function Attrs: nounwind
declare i32 @ferror(ptr noundef) #4

declare i32 @fclose(ptr noundef) #5

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @heu_free(ptr noundef) #8

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

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

attributes #0 = { nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #3 = { nocallback nofree nounwind willreturn memory(argmem: write) }
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 = { "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 #6 = { nounwind willreturn memory(none) "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 = { nounwind willreturn memory(read) "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 = { inlinehint 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 #9 = { nounwind }
attributes #10 = { nounwind allocsize(0) }
attributes #11 = { nounwind willreturn memory(none) }
attributes #12 = { nounwind willreturn memory(read) }

!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 = !{!7, !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}
!14 = !{!15, !16, i64 3848}
!15 = !{!"pdb_catalogue", !7, i64 0, !7, i64 3072, !7, i64 3328, !16, i64 3840, !16, i64 3848}
!16 = !{!"long", !7, i64 0}
!17 = !{!18, !18, i64 0}
!18 = !{!"long long", !7, i64 0}
!19 = !{!15, !16, i64 3840}
!20 = !{!16, !16, i64 0}
!21 = distinct !{!21, !13}


; 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.heuristic = type { ptr, ptr, ptr, ptr, i32, i32, i32 }

@.str = external hidden unnamed_addr constant [31 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [8 x i8], align 1
@stderr = external local_unnamed_addr global ptr, align 8
@.str.4 = external hidden unnamed_addr constant [52 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [56 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [45 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [40 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [44 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local noundef ptr @catalogue_load(ptr noundef %0, ptr noundef %1, i32 noundef %2, ptr noundef %3) local_unnamed_addr #0 {
  %5 = alloca [512 x i8], align 16
  %calloc = tail call dereferenceable_or_null(3856) ptr @calloc(i64 1, i64 3856)
  call void @llvm.lifetime.start.p0(i64 512, ptr nonnull %5) #10
  %6 = icmp eq ptr %calloc, null
  br i1 %6, label %116, label %7

7:                                                ; preds = %4
  %8 = icmp ne ptr %3, null
  br i1 %8, label %9, label %11

9:                                                ; preds = %7
  %10 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef nonnull %3, ptr noundef nonnull @.str, ptr noundef %0) #10
  br label %11

11:                                               ; preds = %9, %7
  %12 = icmp eq ptr %1, null
  br i1 %12, label %13, label %15

13:                                               ; preds = %11
  %14 = tail call ptr @getenv(ptr noundef nonnull @.str.1) #10
  br label %15

15:                                               ; preds = %13, %11
  %.073 = phi ptr [ %14, %13 ], [ %1, %11 ]
  %16 = tail call noalias ptr @fopen(ptr noundef %0, ptr noundef nonnull @.str.2)
  %17 = icmp eq ptr %16, null
  br i1 %17, label %21, label %.preheader

.preheader:                                       ; preds = %15
  %18 = getelementptr inbounds i8, ptr %calloc, i64 3848
  %19 = getelementptr inbounds i8, ptr %calloc, i64 3072
  %20 = getelementptr inbounds i8, ptr %calloc, i64 3328
  br label %.outer

21:                                               ; preds = %15
  %22 = tail call ptr @__errno_location() #11
  %23 = load i32, ptr %22, align 4, !tbaa !5
  br i1 %8, label %24, label %.loopexit

24:                                               ; preds = %21
  %25 = tail call ptr @strerror(i32 noundef %23) #10
  %26 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef nonnull %3, ptr noundef nonnull @.str.3, ptr noundef %0, ptr noundef %25) #10
  br label %.loopexit

27:                                               ; preds = %.outer, %36
  %28 = call ptr @fgets(ptr noundef nonnull %5, i32 noundef 512, ptr noundef nonnull %16)
  %.not = icmp eq ptr %28, null
  br i1 %.not, label %81, label %29

29:                                               ; preds = %27
  %30 = call ptr @strchr(ptr noundef nonnull dereferenceable(1) %5, i32 noundef 10) #12
  %31 = icmp eq ptr %30, null
  br i1 %31, label %32, label %36

32:                                               ; preds = %29
  br i1 %8, label %33, label %107

33:                                               ; preds = %32
  %34 = load ptr, ptr @stderr, align 8, !tbaa !9
  %35 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %34, ptr noundef nonnull @.str.4, ptr noundef %0) #13
  br label %107

36:                                               ; preds = %29
  store i8 0, ptr %30, align 1, !tbaa !11
  %37 = load i8, ptr %5, align 16, !tbaa !11
  switch i8 %37, label %49 [
    i8 35, label %27
    i8 0, label %38
  ]

38:                                               ; preds = %36
  %39 = call i32 @tileset_empty(i32 noundef %.072.ph)
  %.not85 = icmp eq i32 %39, 0
  br i1 %.not85, label %40, label %.outer.backedge

.outer.backedge:                                  ; preds = %38, %46, %72
  %.072.ph.be = phi i32 [ %74, %72 ], [ 0, %46 ], [ 0, %38 ]
  br label %.outer, !llvm.loop !12

40:                                               ; preds = %38
  %41 = call i32 @tileset_add(i32 noundef %.072.ph, i32 noundef 0)
  %42 = icmp ne i32 %41, 33554431
  %or.cond = and i1 %8, %42
  br i1 %or.cond, label %43, label %46

43:                                               ; preds = %40
  %44 = load i64, ptr %18, align 8, !tbaa !14
  %45 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef nonnull %3, ptr noundef nonnull @.str.5, i64 noundef %44) #10
  br label %46

46:                                               ; preds = %43, %40
  %47 = load i64, ptr %18, align 8, !tbaa !14
  %48 = add i64 %47, 1
  store i64 %48, ptr %18, align 8, !tbaa !14
  br label %.outer.backedge

.outer:                                           ; preds = %.outer.backedge, %.preheader
  %.072.ph = phi i32 [ 0, %.preheader ], [ %.072.ph.be, %.outer.backedge ]
  br label %27

49:                                               ; preds = %36
  %50 = load i64, ptr %18, align 8, !tbaa !14
  %51 = icmp ugt i64 %50, 63
  br i1 %51, label %52, label %55

52:                                               ; preds = %49
  br i1 %8, label %53, label %107

53:                                               ; preds = %52
  %54 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef nonnull %3, ptr noundef nonnull @.str.6, i32 noundef 64) #10
  br label %107

55:                                               ; preds = %49
  %56 = call i32 @add_pdb(ptr noundef nonnull %calloc, ptr noundef nonnull %5, ptr noundef %.073, i32 noundef %2, i32 noundef 3, ptr noundef %3)
  %57 = icmp eq i32 %56, -1
  br i1 %57, label %58, label %61

58:                                               ; preds = %55
  %59 = tail call ptr @__errno_location() #11
  %60 = load i32, ptr %59, align 4, !tbaa !5
  br label %107

61:                                               ; preds = %55
  %62 = sext i32 %56 to i64
  %63 = getelementptr inbounds [64 x i32], ptr %19, i64 0, i64 %62
  %64 = load i32, ptr %63, align 4, !tbaa !5
  %65 = call i32 @tileset_intersect(i32 noundef %.072.ph, i32 noundef %64)
  %66 = call i32 @tileset_remove(i32 noundef %65, i32 noundef 0)
  %67 = call i32 @tileset_empty(i32 noundef %66)
  %68 = icmp eq i32 %67, 0
  %or.cond3 = and i1 %8, %68
  br i1 %or.cond3, label %69, label %72

69:                                               ; preds = %61
  %70 = load i64, ptr %18, align 8, !tbaa !14
  %71 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef nonnull %3, ptr noundef nonnull @.str.7, i64 noundef %70) #10
  br label %72

72:                                               ; preds = %69, %61
  %73 = load i32, ptr %63, align 4, !tbaa !5
  %74 = call i32 @tileset_union(i32 noundef %.072.ph, i32 noundef %73)
  %75 = shl nuw i32 1, %56
  %76 = sext i32 %75 to i64
  %77 = load i64, ptr %18, align 8, !tbaa !14
  %78 = getelementptr inbounds [64 x i64], ptr %20, i64 0, i64 %77
  %79 = load i64, ptr %78, align 8, !tbaa !17
  %80 = or i64 %79, %76
  store i64 %80, ptr %78, align 8, !tbaa !17
  br label %.outer.backedge

81:                                               ; preds = %27
  %82 = call i32 @ferror(ptr noundef nonnull %16) #10
  %.not83 = icmp eq i32 %82, 0
  br i1 %.not83, label %89, label %83

83:                                               ; preds = %81
  %84 = tail call ptr @__errno_location() #11
  %85 = load i32, ptr %84, align 4, !tbaa !5
  br i1 %8, label %86, label %107

86:                                               ; preds = %83
  %87 = call ptr @strerror(i32 noundef %85) #10
  %88 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef nonnull %3, ptr noundef nonnull @.str.3, ptr noundef %0, ptr noundef %87) #10
  br label %107

89:                                               ; preds = %81
  %.not84 = icmp eq i32 %.072.ph, 0
  br i1 %.not84, label %99, label %90

90:                                               ; preds = %89
  %91 = call i32 @tileset_add(i32 noundef %.072.ph, i32 noundef 0)
  %92 = icmp ne i32 %91, 33554431
  %or.cond5 = and i1 %8, %92
  br i1 %or.cond5, label %93, label %96

93:                                               ; preds = %90
  %94 = load i64, ptr %18, align 8, !tbaa !14
  %95 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef nonnull %3, ptr noundef nonnull @.str.5, i64 noundef %94) #10
  br label %96

96:                                               ; preds = %93, %90
  %97 = load i64, ptr %18, align 8, !tbaa !14
  %98 = add i64 %97, 1
  store i64 %98, ptr %18, align 8, !tbaa !14
  br label %99

99:                                               ; preds = %96, %89
  br i1 %8, label %100, label %105

100:                                              ; preds = %99
  %101 = getelementptr inbounds i8, ptr %calloc, i64 3840
  %102 = load i64, ptr %101, align 8, !tbaa !19
  %103 = load i64, ptr %18, align 8, !tbaa !14
  %104 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef nonnull %3, ptr noundef nonnull @.str.8, i64 noundef %102, i64 noundef %103, ptr noundef %0) #10
  br label %105

105:                                              ; preds = %100, %99
  %106 = call i32 @fclose(ptr noundef nonnull %16)
  br label %116

107:                                              ; preds = %52, %53, %32, %33, %83, %86, %58
  %.074 = phi i32 [ %60, %58 ], [ %85, %86 ], [ %85, %83 ], [ 34, %33 ], [ 34, %32 ], [ 34, %53 ], [ 34, %52 ]
  %108 = call i32 @fclose(ptr noundef nonnull %16)
  %109 = getelementptr inbounds i8, ptr %calloc, i64 3840
  %110 = load i64, ptr %109, align 8, !tbaa !19
  %.not90 = icmp eq i64 %110, 0
  br i1 %.not90, label %.loopexit, label %.lr.ph

.lr.ph:                                           ; preds = %107, %.lr.ph
  %.07589 = phi i64 [ %112, %.lr.ph ], [ 0, %107 ]
  %111 = getelementptr inbounds %struct.heuristic, ptr %calloc, i64 %.07589
  call void @heu_free(ptr noundef nonnull %111)
  %112 = add nuw i64 %.07589, 1
  %113 = load i64, ptr %109, align 8, !tbaa !19
  %114 = icmp ult i64 %112, %113
  br i1 %114, label %.lr.ph, label %.loopexit, !llvm.loop !20

.loopexit:                                        ; preds = %.lr.ph, %107, %21, %24
  %.1 = phi i32 [ %23, %24 ], [ %23, %21 ], [ %.074, %107 ], [ %.074, %.lr.ph ]
  call void @free(ptr noundef nonnull %calloc) #10
  %115 = tail call ptr @__errno_location() #11
  store i32 %.1, ptr %115, align 4, !tbaa !5
  br label %116

116:                                              ; preds = %4, %.loopexit, %105
  %.0 = phi ptr [ null, %.loopexit ], [ %calloc, %105 ], [ null, %4 ]
  call void @llvm.lifetime.end.p0(i64 512, ptr nonnull %5) #10
  ret ptr %.0
}

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

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

; Function Attrs: nofree nounwind memory(read)
declare noundef ptr @getenv(ptr nocapture noundef) local_unnamed_addr #3

; Function Attrs: nofree nounwind
declare noalias noundef ptr @fopen(ptr nocapture noundef readonly, ptr nocapture noundef readonly) local_unnamed_addr #2

; Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none)
declare ptr @__errno_location() local_unnamed_addr #4

; Function Attrs: nounwind
declare ptr @strerror(i32 noundef) local_unnamed_addr #5

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

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read)
declare ptr @strchr(ptr noundef, i32 noundef) local_unnamed_addr #6

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @tileset_empty(i32 noundef) local_unnamed_addr #7

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @tileset_add(i32 noundef, i32 noundef) local_unnamed_addr #7

; Function Attrs: nounwind uwtable
declare hidden i32 @add_pdb(ptr noundef, ptr noundef, ptr noundef, i32 noundef, i32 noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @tileset_remove(i32 noundef, i32 noundef) local_unnamed_addr #7

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @tileset_intersect(i32 noundef, i32 noundef) local_unnamed_addr #7

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @tileset_union(i32 noundef, i32 noundef) local_unnamed_addr #7

; Function Attrs: nofree nounwind memory(read)
declare noundef i32 @ferror(ptr nocapture noundef) local_unnamed_addr #3

; Function Attrs: nofree nounwind
declare noundef i32 @fclose(ptr nocapture noundef) local_unnamed_addr #2

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @heu_free(ptr noundef) local_unnamed_addr #7

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

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

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

attributes #0 = { nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nofree nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { nofree nounwind memory(read) "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 nofree nosync nounwind willreturn memory(none) "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 "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 #6 = { mustprogress nofree nounwind willreturn memory(argmem: read) "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 = { inlinehint 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 #8 = { 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 #9 = { nofree nounwind willreturn allockind("alloc,zeroed") allocsize(0,1) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" }
attributes #10 = { nounwind }
attributes #11 = { nounwind willreturn memory(none) }
attributes #12 = { nounwind willreturn memory(read) }
attributes #13 = { cold nounwind }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"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 = !{!7, !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}
!14 = !{!15, !16, i64 3848}
!15 = !{!"pdb_catalogue", !7, i64 0, !7, i64 3072, !7, i64 3328, !16, i64 3840, !16, i64 3848}
!16 = !{!"long", !7, i64 0}
!17 = !{!18, !18, i64 0}
!18 = !{!"long long", !7, i64 0}
!19 = !{!15, !16, i64 3840}
!20 = distinct !{!20, !13}


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