; LLVM IR from recrsn/tinydb :: database (do_join_query)

; 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.table_info = type { [32 x i8], i32, [32 x %struct.field], i64 }
%struct.field = type { [32 x i8], i64, i32 }
%struct.query = type { i32, i32, i32, [32 x ptr], [32 x %struct.query_field], [32 x %struct.query_condition] }
%struct.query_field = type { [32 x i8], [32 x i8], i32 }
%struct.query_condition = type { %struct.literal, %struct.literal, i32, i32 }
%struct.literal = type { i32, [2048 x i8], ptr, i32 }
%struct.table = type { %struct.table_info, i8, ptr, ptr }
%struct.result_set = type { ptr, ptr }

@.str.14 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.17 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.18 = external hidden unnamed_addr constant [1 x i8], align 1
@.str.21 = external hidden unnamed_addr constant [2 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: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: nounwind uwtable
declare dso_local i32 @table_find_field(ptr noundef byval(%struct.table_info) align 8, ptr noundef) #1

; Function Attrs: nounwind uwtable
declare dso_local void @decode_temp_table_field(ptr noundef, ptr noundef, i64 noundef, i32 noundef) #1

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

; Function Attrs: nounwind uwtable
declare dso_local void @filter(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #1

; Function Attrs: nounwind uwtable
declare dso_local ptr @create_result_set(ptr noundef) #1

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

; Function Attrs: nounwind uwtable
declare dso_local ptr @table_to_temp_table(ptr noundef, ptr noundef) #1

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

; Function Attrs: nocallback nofree nosync nounwind willreturn
declare ptr @llvm.stacksave.p0() #3

; Function Attrs: nocallback nofree nosync nounwind willreturn
declare void @llvm.stackrestore.p0(ptr) #3

; Function Attrs: nounwind uwtable
define dso_local zeroext i1 @do_join_query(ptr noundef byval(%struct.query) align 8 %0) #1 {
  %2 = alloca i32, align 4
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca ptr, align 8
  %14 = alloca i64, align 8
  %15 = alloca i32, align 4
  %16 = alloca [2048 x i8], align 16
  %17 = alloca i64, align 8
  %18 = alloca i32, align 4
  %19 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #4
  store i32 1, ptr %2, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #4
  %20 = getelementptr inbounds %struct.query, ptr %0, i32 0, i32 0
  %21 = load i32, ptr %20, align 8, !tbaa !9
  %22 = sext i32 %21 to i64
  %23 = mul i64 8, %22
  %24 = alloca i8, i64 %23, align 16
  store ptr %24, ptr %3, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #4
  store i32 0, ptr %4, align 4, !tbaa !5
  br label %25

25:                                               ; preds = %54, %1
  %26 = load i32, ptr %4, align 4, !tbaa !5
  %27 = getelementptr inbounds %struct.query, ptr %0, i32 0, i32 0
  %28 = load i32, ptr %27, align 8, !tbaa !9
  %29 = icmp slt i32 %26, %28
  br i1 %29, label %31, label %30

30:                                               ; preds = %25
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #4
  br label %57

31:                                               ; preds = %25
  %32 = getelementptr inbounds %struct.query, ptr %0, i32 0, i32 3
  %33 = load i32, ptr %4, align 4, !tbaa !5
  %34 = sext i32 %33 to i64
  %35 = getelementptr inbounds [32 x ptr], ptr %32, i64 0, i64 %34
  %36 = load ptr, ptr %35, align 8, !tbaa !11
  %37 = getelementptr inbounds %struct.table, ptr %36, i32 0, i32 0
  %38 = getelementptr inbounds %struct.table_info, ptr %37, i32 0, i32 3
  %39 = load i64, ptr %38, align 8, !tbaa !13
  %40 = load i32, ptr %2, align 4, !tbaa !5
  %41 = sext i32 %40 to i64
  %42 = mul i64 %41, %39
  %43 = trunc i64 %42 to i32
  store i32 %43, ptr %2, align 4, !tbaa !5
  %44 = getelementptr inbounds %struct.query, ptr %0, i32 0, i32 3
  %45 = load i32, ptr %4, align 4, !tbaa !5
  %46 = sext i32 %45 to i64
  %47 = getelementptr inbounds [32 x ptr], ptr %44, i64 0, i64 %46
  %48 = load ptr, ptr %47, align 8, !tbaa !11
  %49 = call ptr @create_result_set(ptr noundef %48)
  %50 = load ptr, ptr %3, align 8, !tbaa !11
  %51 = load i32, ptr %4, align 4, !tbaa !5
  %52 = sext i32 %51 to i64
  %53 = getelementptr inbounds ptr, ptr %50, i64 %52
  store ptr %49, ptr %53, align 8, !tbaa !11
  br label %54

54:                                               ; preds = %31
  %55 = load i32, ptr %4, align 4, !tbaa !5
  %56 = add nsw i32 %55, 1
  store i32 %56, ptr %4, align 4, !tbaa !5
  br label %25, !llvm.loop !18

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

58:                                               ; preds = %111, %57
  %59 = load i32, ptr %6, align 4, !tbaa !5
  %60 = getelementptr inbounds %struct.query, ptr %0, i32 0, i32 2
  %61 = load i32, ptr %60, align 8, !tbaa !20
  %62 = icmp slt i32 %59, %61
  br i1 %62, label %64, label %63

63:                                               ; preds = %58
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  br label %114

64:                                               ; preds = %58
  %65 = getelementptr inbounds %struct.query, ptr %0, i32 0, i32 5
  %66 = load i32, ptr %6, align 4, !tbaa !5
  %67 = sext i32 %66 to i64
  %68 = getelementptr inbounds [32 x %struct.query_condition], ptr %65, i64 0, i64 %67
  %69 = getelementptr inbounds %struct.query_condition, ptr %68, i32 0, i32 1
  %70 = getelementptr inbounds %struct.literal, ptr %69, i32 0, i32 0
  %71 = load i32, ptr %70, align 8, !tbaa !21
  %72 = icmp ne i32 %71, 0
  br i1 %72, label %73, label %74

73:                                               ; preds = %64
  br label %111

74:                                               ; preds = %64
  %75 = load i32, ptr %5, align 4, !tbaa !5
  %76 = add nsw i32 %75, 1
  store i32 %76, ptr %5, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #4
  %77 = load ptr, ptr %3, align 8, !tbaa !11
  %78 = load i32, ptr %2, align 4, !tbaa !5
  %79 = getelementptr inbounds %struct.query, ptr %0, i32 0, i32 5
  %80 = load i32, ptr %6, align 4, !tbaa !5
  %81 = sext i32 %80 to i64
  %82 = getelementptr inbounds [32 x %struct.query_condition], ptr %79, i64 0, i64 %81
  %83 = getelementptr inbounds %struct.query_condition, ptr %82, i32 0, i32 0
  %84 = getelementptr inbounds %struct.literal, ptr %83, i32 0, i32 2
  %85 = load ptr, ptr %84, align 8, !tbaa !24
  %86 = call ptr @get_result_set(ptr noundef %77, i32 noundef %78, ptr noundef %85)
  store ptr %86, ptr %7, align 8, !tbaa !11
  %87 = load ptr, ptr %7, align 8, !tbaa !11
  %88 = getelementptr inbounds %struct.result_set, ptr %87, i32 0, i32 1
  %89 = load ptr, ptr %88, align 8, !tbaa !25
  %90 = getelementptr inbounds %struct.query, ptr %0, i32 0, i32 5
  %91 = load i32, ptr %6, align 4, !tbaa !5
  %92 = sext i32 %91 to i64
  %93 = getelementptr inbounds [32 x %struct.query_condition], ptr %90, i64 0, i64 %92
  %94 = getelementptr inbounds %struct.query_condition, ptr %93, i32 0, i32 0
  %95 = getelementptr inbounds %struct.literal, ptr %94, i32 0, i32 2
  %96 = load ptr, ptr %95, align 8, !tbaa !24
  %97 = getelementptr inbounds %struct.query, ptr %0, i32 0, i32 5
  %98 = load i32, ptr %6, align 4, !tbaa !5
  %99 = sext i32 %98 to i64
  %100 = getelementptr inbounds [32 x %struct.query_condition], ptr %97, i64 0, i64 %99
  %101 = getelementptr inbounds %struct.query_condition, ptr %100, i32 0, i32 0
  %102 = getelementptr inbounds %struct.literal, ptr %101, i32 0, i32 3
  %103 = load i32, ptr %102, align 8, !tbaa !27
  %104 = getelementptr inbounds %struct.query, ptr %0, i32 0, i32 5
  %105 = load i32, ptr %6, align 4, !tbaa !5
  %106 = sext i32 %105 to i64
  %107 = getelementptr inbounds [32 x %struct.query_condition], ptr %104, i64 0, i64 %106
  %108 = getelementptr inbounds %struct.query_condition, ptr %107, i32 0, i32 1
  %109 = getelementptr inbounds %struct.literal, ptr %108, i32 0, i32 1
  %110 = getelementptr inbounds [2048 x i8], ptr %109, i64 0, i64 0
  call void @filter(ptr noundef %89, ptr noundef %96, i32 noundef %103, ptr noundef %110)
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #4
  br label %111

111:                                              ; preds = %74, %73
  %112 = load i32, ptr %6, align 4, !tbaa !5
  %113 = add nsw i32 %112, 1
  store i32 %113, ptr %6, align 4, !tbaa !5
  br label %58, !llvm.loop !28

114:                                              ; preds = %63
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #4
  store ptr null, ptr %8, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #4
  store i32 0, ptr %9, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #4
  store i32 0, ptr %10, align 4, !tbaa !5
  br label %115

115:                                              ; preds = %198, %114
  %116 = load i32, ptr %10, align 4, !tbaa !5
  %117 = getelementptr inbounds %struct.query, ptr %0, i32 0, i32 2
  %118 = load i32, ptr %117, align 8, !tbaa !20
  %119 = icmp slt i32 %116, %118
  br i1 %119, label %121, label %120

120:                                              ; preds = %115
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #4
  br label %201

121:                                              ; preds = %115
  %122 = getelementptr inbounds %struct.query, ptr %0, i32 0, i32 5
  %123 = load i32, ptr %10, align 4, !tbaa !5
  %124 = sext i32 %123 to i64
  %125 = getelementptr inbounds [32 x %struct.query_condition], ptr %122, i64 0, i64 %124
  %126 = getelementptr inbounds %struct.query_condition, ptr %125, i32 0, i32 1
  %127 = getelementptr inbounds %struct.literal, ptr %126, i32 0, i32 0
  %128 = load i32, ptr %127, align 8, !tbaa !21
  %129 = icmp ne i32 %128, 0
  %130 = xor i1 %129, true
  %131 = zext i1 %130 to i32
  %132 = icmp ne i32 %131, 0
  br i1 %132, label %133, label %134

133:                                              ; preds = %121
  br label %198

134:                                              ; preds = %121
  %135 = load i32, ptr %9, align 4, !tbaa !5
  %136 = icmp eq i32 %135, 0
  br i1 %136, label %137, label %157

137:                                              ; preds = %134
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #4
  %138 = load ptr, ptr %3, align 8, !tbaa !11
  %139 = load i32, ptr %2, align 4, !tbaa !5
  %140 = getelementptr inbounds %struct.query, ptr %0, i32 0, i32 5
  %141 = getelementptr inbounds [32 x %struct.query_condition], ptr %140, i64 0, i64 0
  %142 = getelementptr inbounds %struct.query_condition, ptr %141, i32 0, i32 0
  %143 = getelementptr inbounds %struct.literal, ptr %142, i32 0, i32 2
  %144 = load ptr, ptr %143, align 8, !tbaa !24
  %145 = call ptr @get_result_set(ptr noundef %138, i32 noundef %139, ptr noundef %144)
  store ptr %145, ptr %11, align 8, !tbaa !11
  %146 = getelementptr inbounds %struct.query, ptr %0, i32 0, i32 5
  %147 = load i32, ptr %10, align 4, !tbaa !5
  %148 = sext i32 %147 to i64
  %149 = getelementptr inbounds [32 x %struct.query_condition], ptr %146, i64 0, i64 %148
  %150 = getelementptr inbounds %struct.query_condition, ptr %149, i32 0, i32 0
  %151 = getelementptr inbounds %struct.literal, ptr %150, i32 0, i32 2
  %152 = load ptr, ptr %151, align 8, !tbaa !24
  %153 = load ptr, ptr %11, align 8, !tbaa !11
  %154 = getelementptr inbounds %struct.result_set, ptr %153, i32 0, i32 1
  %155 = load ptr, ptr %154, align 8, !tbaa !25
  %156 = call ptr @table_to_temp_table(ptr noundef %152, ptr noundef %155)
  store ptr %156, ptr %8, align 8, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #4
  br label %157

157:                                              ; preds = %137, %134
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #4
  %158 = getelementptr inbounds %struct.query, ptr %0, i32 0, i32 5
  %159 = load i32, ptr %10, align 4, !tbaa !5
  %160 = sext i32 %159 to i64
  %161 = getelementptr inbounds [32 x %struct.query_condition], ptr %158, i64 0, i64 %160
  %162 = getelementptr inbounds %struct.query_condition, ptr %161, i32 0, i32 1
  %163 = getelementptr inbounds %struct.literal, ptr %162, i32 0, i32 2
  %164 = load ptr, ptr %163, align 8, !tbaa !29
  %165 = load ptr, ptr %3, align 8, !tbaa !11
  %166 = load i32, ptr %2, align 4, !tbaa !5
  %167 = getelementptr inbounds %struct.query, ptr %0, i32 0, i32 5
  %168 = getelementptr inbounds [32 x %struct.query_condition], ptr %167, i64 0, i64 0
  %169 = getelementptr inbounds %struct.query_condition, ptr %168, i32 0, i32 1
  %170 = getelementptr inbounds %struct.literal, ptr %169, i32 0, i32 2
  %171 = load ptr, ptr %170, align 8, !tbaa !29
  %172 = call ptr @get_result_set(ptr noundef %165, i32 noundef %166, ptr noundef %171)
  %173 = getelementptr inbounds %struct.result_set, ptr %172, i32 0, i32 1
  %174 = load ptr, ptr %173, align 8, !tbaa !25
  %175 = call ptr @table_to_temp_table(ptr noundef %164, ptr noundef %174)
  store ptr %175, ptr %12, align 8, !tbaa !11
  %176 = load ptr, ptr %8, align 8, !tbaa !11
  %177 = load ptr, ptr %8, align 8, !tbaa !11
  %178 = getelementptr inbounds %struct.table, ptr %177, i32 0, i32 0
  %179 = getelementptr inbounds %struct.query, ptr %0, i32 0, i32 5
  %180 = load i32, ptr %10, align 4, !tbaa !5
  %181 = sext i32 %180 to i64
  %182 = getelementptr inbounds [32 x %struct.query_condition], ptr %179, i64 0, i64 %181
  %183 = getelementptr inbounds %struct.query_condition, ptr %182, i32 0, i32 0
  %184 = getelementptr inbounds %struct.literal, ptr %183, i32 0, i32 1
  %185 = getelementptr inbounds [2048 x i8], ptr %184, i64 0, i64 0
  %186 = call i32 @table_find_field(ptr noundef byval(%struct.table_info) align 8 %178, ptr noundef %185)
  %187 = load ptr, ptr %12, align 8, !tbaa !11
  %188 = getelementptr inbounds %struct.query, ptr %0, i32 0, i32 5
  %189 = load i32, ptr %10, align 4, !tbaa !5
  %190 = sext i32 %189 to i64
  %191 = getelementptr inbounds [32 x %struct.query_condition], ptr %188, i64 0, i64 %190
  %192 = getelementptr inbounds %struct.query_condition, ptr %191, i32 0, i32 1
  %193 = getelementptr inbounds %struct.literal, ptr %192, i32 0, i32 3
  %194 = load i32, ptr %193, align 8, !tbaa !30
  %195 = call ptr @temp_table_inner_join(ptr noundef %176, i32 noundef %186, ptr noundef %187, i32 noundef %194)
  store ptr %195, ptr %8, align 8, !tbaa !11
  %196 = load i32, ptr %9, align 4, !tbaa !5
  %197 = add nsw i32 %196, 1
  store i32 %197, ptr %9, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #4
  br label %198

198:                                              ; preds = %157, %133
  %199 = load i32, ptr %10, align 4, !tbaa !5
  %200 = add nsw i32 %199, 1
  store i32 %200, ptr %10, align 4, !tbaa !5
  br label %115, !llvm.loop !31

201:                                              ; preds = %120
  %202 = getelementptr inbounds %struct.query, ptr %0, i32 0, i32 1
  %203 = load i32, ptr %202, align 4, !tbaa !32
  %204 = zext i32 %203 to i64
  %205 = call ptr @llvm.stacksave.p0()
  store ptr %205, ptr %13, align 8
  %206 = alloca i32, i64 %204, align 16
  store i64 %204, ptr %14, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #4
  store i32 0, ptr %15, align 4, !tbaa !5
  br label %207

207:                                              ; preds = %226, %201
  %208 = load i32, ptr %15, align 4, !tbaa !5
  %209 = getelementptr inbounds %struct.query, ptr %0, i32 0, i32 1
  %210 = load i32, ptr %209, align 4, !tbaa !32
  %211 = icmp slt i32 %208, %210
  br i1 %211, label %213, label %212

212:                                              ; preds = %207
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #4
  br label %229

213:                                              ; preds = %207
  %214 = load ptr, ptr %8, align 8, !tbaa !11
  %215 = getelementptr inbounds %struct.table, ptr %214, i32 0, i32 0
  %216 = getelementptr inbounds %struct.query, ptr %0, i32 0, i32 4
  %217 = load i32, ptr %15, align 4, !tbaa !5
  %218 = sext i32 %217 to i64
  %219 = getelementptr inbounds [32 x %struct.query_field], ptr %216, i64 0, i64 %218
  %220 = getelementptr inbounds %struct.query_field, ptr %219, i32 0, i32 1
  %221 = getelementptr inbounds [32 x i8], ptr %220, i64 0, i64 0
  %222 = call i32 @table_find_field(ptr noundef byval(%struct.table_info) align 8 %215, ptr noundef %221)
  %223 = load i32, ptr %15, align 4, !tbaa !5
  %224 = sext i32 %223 to i64
  %225 = getelementptr inbounds i32, ptr %206, i64 %224
  store i32 %222, ptr %225, align 4, !tbaa !5
  br label %226

226:                                              ; preds = %213
  %227 = load i32, ptr %15, align 4, !tbaa !5
  %228 = add nsw i32 %227, 1
  store i32 %228, ptr %15, align 4, !tbaa !5
  br label %207, !llvm.loop !33

229:                                              ; preds = %212
  call void @llvm.lifetime.start.p0(i64 2048, ptr %16) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #4
  store i64 0, ptr %17, align 8, !tbaa !34
  br label %230

230:                                              ; preds = %264, %229
  %231 = load i64, ptr %17, align 8, !tbaa !34
  %232 = load ptr, ptr %8, align 8, !tbaa !11
  %233 = getelementptr inbounds %struct.table, ptr %232, i32 0, i32 0
  %234 = getelementptr inbounds %struct.table_info, ptr %233, i32 0, i32 3
  %235 = load i64, ptr %234, align 8, !tbaa !13
  %236 = icmp ult i64 %231, %235
  br i1 %236, label %238, label %237

237:                                              ; preds = %230
  store i32 14, ptr %18, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #4
  br label %267

238:                                              ; preds = %230
  call void @llvm.lifetime.start.p0(i64 4, ptr %19) #4
  store i32 0, ptr %19, align 4, !tbaa !5
  br label %239

239:                                              ; preds = %259, %238
  %240 = load i32, ptr %19, align 4, !tbaa !5
  %241 = getelementptr inbounds %struct.query, ptr %0, i32 0, i32 1
  %242 = load i32, ptr %241, align 4, !tbaa !32
  %243 = icmp slt i32 %240, %242
  br i1 %243, label %245, label %244

244:                                              ; preds = %239
  store i32 17, ptr %18, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %19) #4
  br label %262

245:                                              ; preds = %239
  %246 = getelementptr inbounds [2048 x i8], ptr %16, i64 0, i64 0
  %247 = load ptr, ptr %8, align 8, !tbaa !11
  %248 = load i64, ptr %17, align 8, !tbaa !34
  %249 = load i32, ptr %19, align 4, !tbaa !5
  %250 = sext i32 %249 to i64
  %251 = getelementptr inbounds i32, ptr %206, i64 %250
  %252 = load i32, ptr %251, align 4, !tbaa !5
  call void @decode_temp_table_field(ptr noundef %246, ptr noundef %247, i64 noundef %248, i32 noundef %252)
  %253 = load i32, ptr %19, align 4, !tbaa !5
  %254 = icmp eq i32 %253, 0
  %255 = zext i1 %254 to i64
  %256 = select i1 %254, ptr @.str.18, ptr @.str.14
  %257 = getelementptr inbounds [2048 x i8], ptr %16, i64 0, i64 0
  %258 = call i32 (ptr, ...) @printf(ptr noundef @.str.17, ptr noundef %256, ptr noundef %257)
  br label %259

259:                                              ; preds = %245
  %260 = load i32, ptr %19, align 4, !tbaa !5
  %261 = add nsw i32 %260, 1
  store i32 %261, ptr %19, align 4, !tbaa !5
  br label %239, !llvm.loop !35

262:                                              ; preds = %244
  %263 = call i32 (ptr, ...) @printf(ptr noundef @.str.21)
  br label %264

264:                                              ; preds = %262
  %265 = load i64, ptr %17, align 8, !tbaa !34
  %266 = add i64 %265, 1
  store i64 %266, ptr %17, align 8, !tbaa !34
  br label %230, !llvm.loop !36

267:                                              ; preds = %237
  store i32 1, ptr %18, align 4
  call void @llvm.lifetime.end.p0(i64 2048, ptr %16) #4
  %268 = load ptr, ptr %13, align 8
  call void @llvm.stackrestore.p0(ptr %268)
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #4
  ret i1 true
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { "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 nosync nounwind willreturn }
attributes #4 = { 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, !6, i64 0}
!10 = !{!"", !6, i64 0, !6, i64 4, !6, i64 8, !7, i64 16, !7, i64 272, !7, i64 2448}
!11 = !{!12, !12, i64 0}
!12 = !{!"any pointer", !7, i64 0}
!13 = !{!14, !16, i64 1576}
!14 = !{!"", !15, i64 0, !17, i64 1584, !12, i64 1592, !12, i64 1600}
!15 = !{!"", !7, i64 0, !6, i64 32, !7, i64 40, !16, i64 1576}
!16 = !{!"long", !7, i64 0}
!17 = !{!"_Bool", !7, i64 0}
!18 = distinct !{!18, !19}
!19 = !{!"llvm.loop.mustprogress"}
!20 = !{!10, !6, i64 8}
!21 = !{!22, !6, i64 2072}
!22 = !{!"", !23, i64 0, !23, i64 2072, !6, i64 4144, !6, i64 4148}
!23 = !{!"", !6, i64 0, !7, i64 4, !12, i64 2056, !6, i64 2064}
!24 = !{!22, !12, i64 2056}
!25 = !{!26, !12, i64 8}
!26 = !{!"", !12, i64 0, !12, i64 8}
!27 = !{!22, !6, i64 2064}
!28 = distinct !{!28, !19}
!29 = !{!22, !12, i64 4128}
!30 = !{!22, !6, i64 4136}
!31 = distinct !{!31, !19}
!32 = !{!10, !6, i64 4}
!33 = distinct !{!33, !19}
!34 = !{!16, !16, i64 0}
!35 = distinct !{!35, !19}
!36 = distinct !{!36, !19}


; 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.table_info = type { [32 x i8], i32, [32 x %struct.field], i64 }
%struct.field = type { [32 x i8], i64, i32 }
%struct.query = type { i32, i32, i32, [32 x ptr], [32 x %struct.query_field], [32 x %struct.query_condition] }
%struct.query_field = type { [32 x i8], [32 x i8], i32 }
%struct.query_condition = type { %struct.literal, %struct.literal, i32, i32 }
%struct.literal = type { i32, [2048 x i8], ptr, i32 }

@.str.14 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.17 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.18 = external hidden unnamed_addr constant [1 x i8], align 1
@.str.21 = external hidden unnamed_addr constant [2 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 nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: nounwind uwtable
declare dso_local i32 @table_find_field(ptr noundef byval(%struct.table_info) align 8, ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare dso_local void @decode_temp_table_field(ptr noundef, ptr noundef, i64 noundef, i32 noundef) local_unnamed_addr #1

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

; Function Attrs: nounwind uwtable
declare dso_local void @filter(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare dso_local ptr @create_result_set(ptr noundef) local_unnamed_addr #1

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

; Function Attrs: nounwind uwtable
declare dso_local ptr @table_to_temp_table(ptr noundef, ptr noundef) local_unnamed_addr #1

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

; Function Attrs: nounwind uwtable
define dso_local noundef zeroext i1 @do_join_query(ptr noundef byval(%struct.query) align 8 %0) local_unnamed_addr #1 {
  %2 = alloca [2048 x i8], align 16
  %3 = load i32, ptr %0, align 8, !tbaa !5
  %4 = sext i32 %3 to i64
  %5 = shl nsw i64 %4, 3
  %6 = alloca i8, i64 %5, align 16
  %7 = icmp sgt i32 %3, 0
  br i1 %7, label %.lr.ph, label %.preheader62

.lr.ph:                                           ; preds = %1
  %8 = getelementptr inbounds i8, ptr %0, i64 16
  br label %13

.preheader62:                                     ; preds = %13, %1
  %.051.lcssa = phi i32 [ 1, %1 ], [ %19, %13 ]
  %9 = getelementptr inbounds i8, ptr %0, i64 8
  %10 = load i32, ptr %9, align 8, !tbaa !10
  %11 = icmp sgt i32 %10, 0
  br i1 %11, label %.lr.ph67, label %._crit_edge

.lr.ph67:                                         ; preds = %.preheader62
  %12 = getelementptr inbounds i8, ptr %0, i64 2448
  br label %27

13:                                               ; preds = %.lr.ph, %13
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %13 ]
  %.05164 = phi i32 [ 1, %.lr.ph ], [ %19, %13 ]
  %14 = getelementptr inbounds [32 x ptr], ptr %8, i64 0, i64 %indvars.iv
  %15 = load ptr, ptr %14, align 8, !tbaa !11
  %16 = getelementptr inbounds i8, ptr %15, i64 1576
  %17 = load i64, ptr %16, align 8, !tbaa !13
  %18 = trunc i64 %17 to i32
  %19 = mul i32 %.05164, %18
  %20 = tail call ptr @create_result_set(ptr noundef %15)
  %21 = getelementptr inbounds ptr, ptr %6, i64 %indvars.iv
  store ptr %20, ptr %21, align 8, !tbaa !11
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %22 = icmp slt i64 %indvars.iv.next, %4
  br i1 %22, label %13, label %.preheader62, !llvm.loop !18

.preheader61:                                     ; preds = %42
  %23 = icmp sgt i32 %43, 0
  br i1 %23, label %.lr.ph71, label %._crit_edge

.lr.ph71:                                         ; preds = %.preheader61
  %24 = getelementptr inbounds i8, ptr %0, i64 2448
  %25 = getelementptr inbounds i8, ptr %0, i64 4504
  %26 = getelementptr inbounds i8, ptr %0, i64 6576
  br label %52

27:                                               ; preds = %.lr.ph67, %42
  %28 = phi i32 [ %10, %.lr.ph67 ], [ %43, %42 ]
  %indvars.iv84 = phi i64 [ 0, %.lr.ph67 ], [ %indvars.iv.next85, %42 ]
  %29 = getelementptr inbounds [32 x %struct.query_condition], ptr %12, i64 0, i64 %indvars.iv84
  %30 = getelementptr inbounds i8, ptr %29, i64 2072
  %31 = load i32, ptr %30, align 8, !tbaa !20
  %.not60 = icmp eq i32 %31, 0
  br i1 %.not60, label %32, label %42

32:                                               ; preds = %27
  %33 = getelementptr inbounds i8, ptr %29, i64 2056
  %34 = load ptr, ptr %33, align 8, !tbaa !23
  %35 = call ptr @get_result_set(ptr noundef nonnull %6, i32 noundef %.051.lcssa, ptr noundef %34)
  %36 = getelementptr inbounds i8, ptr %35, i64 8
  %37 = load ptr, ptr %36, align 8, !tbaa !24
  %38 = load ptr, ptr %33, align 8, !tbaa !23
  %39 = getelementptr inbounds i8, ptr %29, i64 2064
  %40 = load i32, ptr %39, align 8, !tbaa !26
  %41 = getelementptr inbounds i8, ptr %29, i64 2076
  call void @filter(ptr noundef %37, ptr noundef %38, i32 noundef %40, ptr noundef nonnull %41)
  %.pre = load i32, ptr %9, align 8, !tbaa !10
  br label %42

42:                                               ; preds = %27, %32
  %43 = phi i32 [ %28, %27 ], [ %.pre, %32 ]
  %indvars.iv.next85 = add nuw nsw i64 %indvars.iv84, 1
  %44 = sext i32 %43 to i64
  %45 = icmp slt i64 %indvars.iv.next85, %44
  br i1 %45, label %27, label %.preheader61, !llvm.loop !27

._crit_edge:                                      ; preds = %81, %.preheader62, %.preheader61
  %.058.lcssa = phi ptr [ null, %.preheader61 ], [ null, %.preheader62 ], [ %.2, %81 ]
  %46 = getelementptr inbounds i8, ptr %0, i64 4
  %47 = load i32, ptr %46, align 4, !tbaa !28
  %48 = zext i32 %47 to i64
  %49 = alloca i32, i64 %48, align 16
  %50 = icmp sgt i32 %47, 0
  br i1 %50, label %.lr.ph75, label %._crit_edge76

.lr.ph75:                                         ; preds = %._crit_edge
  %51 = getelementptr inbounds i8, ptr %0, i64 272
  br label %87

52:                                               ; preds = %.lr.ph71, %81
  %53 = phi i32 [ %43, %.lr.ph71 ], [ %82, %81 ]
  %indvars.iv87 = phi i64 [ 0, %.lr.ph71 ], [ %indvars.iv.next88, %81 ]
  %.05669 = phi i32 [ 0, %.lr.ph71 ], [ %.157, %81 ]
  %.05868 = phi ptr [ null, %.lr.ph71 ], [ %.2, %81 ]
  %54 = getelementptr inbounds [32 x %struct.query_condition], ptr %24, i64 0, i64 %indvars.iv87
  %55 = getelementptr inbounds i8, ptr %54, i64 2072
  %56 = load i32, ptr %55, align 8, !tbaa !20
  %.not = icmp eq i32 %56, 0
  br i1 %.not, label %81, label %57

57:                                               ; preds = %52
  %58 = icmp eq i32 %.05669, 0
  br i1 %58, label %59, label %67

59:                                               ; preds = %57
  %60 = load ptr, ptr %25, align 8, !tbaa !23
  %61 = call ptr @get_result_set(ptr noundef nonnull %6, i32 noundef %.051.lcssa, ptr noundef %60)
  %62 = getelementptr inbounds i8, ptr %54, i64 2056
  %63 = load ptr, ptr %62, align 8, !tbaa !23
  %64 = getelementptr inbounds i8, ptr %61, i64 8
  %65 = load ptr, ptr %64, align 8, !tbaa !24
  %66 = call ptr @table_to_temp_table(ptr noundef %63, ptr noundef %65)
  br label %67

67:                                               ; preds = %59, %57
  %.159 = phi ptr [ %66, %59 ], [ %.05868, %57 ]
  %68 = getelementptr inbounds i8, ptr %54, i64 4128
  %69 = load ptr, ptr %68, align 8, !tbaa !29
  %70 = load ptr, ptr %26, align 8, !tbaa !29
  %71 = call ptr @get_result_set(ptr noundef nonnull %6, i32 noundef %.051.lcssa, ptr noundef %70)
  %72 = getelementptr inbounds i8, ptr %71, i64 8
  %73 = load ptr, ptr %72, align 8, !tbaa !24
  %74 = call ptr @table_to_temp_table(ptr noundef %69, ptr noundef %73)
  %75 = getelementptr inbounds i8, ptr %54, i64 4
  %76 = call i32 @table_find_field(ptr noundef byval(%struct.table_info) align 8 %.159, ptr noundef nonnull %75)
  %77 = getelementptr inbounds i8, ptr %54, i64 4136
  %78 = load i32, ptr %77, align 8, !tbaa !30
  %79 = call ptr @temp_table_inner_join(ptr noundef %.159, i32 noundef %76, ptr noundef %74, i32 noundef %78)
  %80 = add nsw i32 %.05669, 1
  %.pre97 = load i32, ptr %9, align 8, !tbaa !10
  br label %81

81:                                               ; preds = %52, %67
  %82 = phi i32 [ %53, %52 ], [ %.pre97, %67 ]
  %.2 = phi ptr [ %.05868, %52 ], [ %79, %67 ]
  %.157 = phi i32 [ %.05669, %52 ], [ %80, %67 ]
  %indvars.iv.next88 = add nuw nsw i64 %indvars.iv87, 1
  %83 = sext i32 %82 to i64
  %84 = icmp slt i64 %indvars.iv.next88, %83
  br i1 %84, label %52, label %._crit_edge, !llvm.loop !31

._crit_edge76:                                    ; preds = %87, %._crit_edge
  call void @llvm.lifetime.start.p0(i64 2048, ptr nonnull %2) #3
  %85 = getelementptr inbounds i8, ptr %.058.lcssa, i64 1576
  %86 = load i64, ptr %85, align 8, !tbaa !13
  %.not82 = icmp eq i64 %86, 0
  br i1 %.not82, label %._crit_edge81, label %.preheader

87:                                               ; preds = %.lr.ph75, %87
  %indvars.iv90 = phi i64 [ 0, %.lr.ph75 ], [ %indvars.iv.next91, %87 ]
  %88 = getelementptr inbounds [32 x %struct.query_field], ptr %51, i64 0, i64 %indvars.iv90, i32 1
  %89 = call i32 @table_find_field(ptr noundef byval(%struct.table_info) align 8 %.058.lcssa, ptr noundef nonnull %88)
  %90 = getelementptr inbounds i32, ptr %49, i64 %indvars.iv90
  store i32 %89, ptr %90, align 4, !tbaa !32
  %indvars.iv.next91 = add nuw nsw i64 %indvars.iv90, 1
  %91 = load i32, ptr %46, align 4, !tbaa !28
  %92 = sext i32 %91 to i64
  %93 = icmp slt i64 %indvars.iv.next91, %92
  br i1 %93, label %87, label %._crit_edge76, !llvm.loop !33

.preheader:                                       ; preds = %._crit_edge76, %._crit_edge79
  %.04980 = phi i64 [ %101, %._crit_edge79 ], [ 0, %._crit_edge76 ]
  %94 = load i32, ptr %46, align 4, !tbaa !28
  %95 = icmp sgt i32 %94, 0
  br i1 %95, label %.lr.ph78.preheader, label %._crit_edge79

.lr.ph78.preheader:                               ; preds = %.preheader
  %96 = load i32, ptr %49, align 16, !tbaa !32
  call void @decode_temp_table_field(ptr noundef nonnull %2, ptr noundef nonnull %.058.lcssa, i64 noundef %.04980, i32 noundef %96)
  %97 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.17, ptr noundef nonnull @.str.18, ptr noundef nonnull %2)
  %98 = load i32, ptr %46, align 4, !tbaa !28
  %99 = icmp sgt i32 %98, 1
  br i1 %99, label %.lr.ph78, label %._crit_edge79

._crit_edge81:                                    ; preds = %._crit_edge79, %._crit_edge76
  call void @llvm.lifetime.end.p0(i64 2048, ptr nonnull %2) #3
  ret i1 true

._crit_edge79:                                    ; preds = %.lr.ph78, %.lr.ph78.preheader, %.preheader
  %100 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.21)
  %101 = add nuw i64 %.04980, 1
  %102 = load i64, ptr %85, align 8, !tbaa !13
  %103 = icmp ult i64 %101, %102
  br i1 %103, label %.preheader, label %._crit_edge81, !llvm.loop !34

.lr.ph78:                                         ; preds = %.lr.ph78.preheader, %.lr.ph78
  %indvars.iv93 = phi i64 [ %indvars.iv.next94, %.lr.ph78 ], [ 1, %.lr.ph78.preheader ]
  %104 = getelementptr inbounds i32, ptr %49, i64 %indvars.iv93
  %105 = load i32, ptr %104, align 4, !tbaa !32
  call void @decode_temp_table_field(ptr noundef nonnull %2, ptr noundef %.058.lcssa, i64 noundef %.04980, i32 noundef %105)
  %106 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.17, ptr noundef nonnull @.str.14, ptr noundef nonnull %2)
  %indvars.iv.next94 = add nuw nsw i64 %indvars.iv93, 1
  %107 = load i32, ptr %46, align 4, !tbaa !28
  %108 = sext i32 %107 to i64
  %109 = icmp slt i64 %indvars.iv.next94, %108
  br i1 %109, label %.lr.ph78, label %._crit_edge79, !llvm.loop !35
}

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { nofree nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { nounwind }

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

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !7, i64 0}
!6 = !{!"", !7, i64 0, !7, i64 4, !7, i64 8, !8, i64 16, !8, i64 272, !8, i64 2448}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!6, !7, i64 8}
!11 = !{!12, !12, i64 0}
!12 = !{!"any pointer", !8, i64 0}
!13 = !{!14, !16, i64 1576}
!14 = !{!"", !15, i64 0, !17, i64 1584, !12, i64 1592, !12, i64 1600}
!15 = !{!"", !8, i64 0, !7, i64 32, !8, i64 40, !16, i64 1576}
!16 = !{!"long", !8, i64 0}
!17 = !{!"_Bool", !8, i64 0}
!18 = distinct !{!18, !19}
!19 = !{!"llvm.loop.mustprogress"}
!20 = !{!21, !7, i64 2072}
!21 = !{!"", !22, i64 0, !22, i64 2072, !7, i64 4144, !7, i64 4148}
!22 = !{!"", !7, i64 0, !8, i64 4, !12, i64 2056, !7, i64 2064}
!23 = !{!21, !12, i64 2056}
!24 = !{!25, !12, i64 8}
!25 = !{!"", !12, i64 0, !12, i64 8}
!26 = !{!21, !7, i64 2064}
!27 = distinct !{!27, !19}
!28 = !{!6, !7, i64 4}
!29 = !{!21, !12, i64 4128}
!30 = !{!21, !7, i64 4136}
!31 = distinct !{!31, !19}
!32 = !{!7, !7, i64 0}
!33 = distinct !{!33, !19}
!34 = distinct !{!34, !19}
!35 = distinct !{!35, !19, !36}
!36 = !{!"llvm.loop.peeled.count", i32 1}


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