; LLVM IR from seppo0010/rlite :: src (hyperloglog)

; 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.hllhdr = type { [4 x i8], i8, [3 x i8], [8 x i8], [0 x i8] }

@rl_hll_sparse_max_bytes = external dso_local global i64, align 8

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

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

; Function Attrs: nounwind uwtable
declare hidden i32 @hllAdd(ptr noundef, i64 noundef, ptr noundef, i64 noundef, ptr noundef, ptr noundef) #1

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

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

; Function Attrs: nounwind uwtable
declare hidden i64 @hllCount(ptr noundef, i64 noundef, ptr noundef) #1

; Function Attrs: nounwind uwtable
define dso_local i32 @rl_str_pfselftest() #1 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i64, align 8
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca [16384 x i8], align 16
  %11 = alloca i32, align 4
  %12 = alloca ptr, align 8
  %13 = alloca i64, align 8
  %14 = alloca i64, align 8
  %15 = alloca i64, align 8
  %16 = alloca i64, align 8
  %17 = alloca i32, align 4
  %18 = alloca ptr, align 8
  %19 = alloca i64, align 8
  %20 = alloca i64, align 8
  %21 = alloca i64, align 8
  %22 = alloca i64, align 8
  %23 = alloca i64, align 8
  %24 = alloca i32, align 4
  %25 = alloca double, align 8
  %26 = alloca i64, align 8
  %27 = alloca i64, align 8
  %28 = alloca i64, align 8
  %29 = alloca i64, align 8
  %30 = alloca i64, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #6
  %31 = call noalias ptr @calloc(i64 noundef 1, i64 noundef 12305) #7
  store ptr %31, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #6
  %32 = load ptr, ptr %6, align 8, !tbaa !5
  store ptr %32, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #6
  store ptr null, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 16384, ptr %10) #6
  store i32 0, ptr %4, align 4, !tbaa !9
  br label %33

33:                                               ; preds = %170, %0
  %34 = load i32, ptr %4, align 4, !tbaa !9
  %35 = icmp ult i32 %34, 1000
  br i1 %35, label %36, label %173

36:                                               ; preds = %33
  store i32 0, ptr %5, align 4, !tbaa !9
  br label %37

37:                                               ; preds = %110, %36
  %38 = load i32, ptr %5, align 4, !tbaa !9
  %39 = icmp ult i32 %38, 16384
  br i1 %39, label %40, label %113

40:                                               ; preds = %37
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #6
  %41 = call i32 @rand() #6
  %42 = and i32 %41, 63
  store i32 %42, ptr %11, align 4, !tbaa !9
  %43 = load i32, ptr %11, align 4, !tbaa !9
  %44 = trunc i32 %43 to i8
  %45 = load i32, ptr %5, align 4, !tbaa !9
  %46 = zext i32 %45 to i64
  %47 = getelementptr inbounds [16384 x i8], ptr %10, i64 0, i64 %46
  store i8 %44, ptr %47, align 1, !tbaa !11
  br label %48

48:                                               ; preds = %40
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #6
  %49 = load ptr, ptr %7, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.hllhdr, ptr %49, i32 0, i32 4
  %51 = getelementptr inbounds [0 x i8], ptr %50, i64 0, i64 0
  store ptr %51, ptr %12, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #6
  %52 = load i32, ptr %5, align 4, !tbaa !9
  %53 = mul i32 %52, 6
  %54 = udiv i32 %53, 8
  %55 = zext i32 %54 to i64
  store i64 %55, ptr %13, align 8, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #6
  %56 = load i32, ptr %5, align 4, !tbaa !9
  %57 = mul i32 %56, 6
  %58 = and i32 %57, 7
  %59 = zext i32 %58 to i64
  store i64 %59, ptr %14, align 8, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #6
  %60 = load i64, ptr %14, align 8, !tbaa !12
  %61 = sub i64 8, %60
  store i64 %61, ptr %15, align 8, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #6
  %62 = load i32, ptr %11, align 4, !tbaa !9
  %63 = zext i32 %62 to i64
  store i64 %63, ptr %16, align 8, !tbaa !12
  %64 = load i64, ptr %14, align 8, !tbaa !12
  %65 = trunc i64 %64 to i32
  %66 = shl i32 63, %65
  %67 = xor i32 %66, -1
  %68 = load ptr, ptr %12, align 8, !tbaa !5
  %69 = load i64, ptr %13, align 8, !tbaa !12
  %70 = getelementptr inbounds i8, ptr %68, i64 %69
  %71 = load i8, ptr %70, align 1, !tbaa !11
  %72 = zext i8 %71 to i32
  %73 = and i32 %72, %67
  %74 = trunc i32 %73 to i8
  store i8 %74, ptr %70, align 1, !tbaa !11
  %75 = load i64, ptr %16, align 8, !tbaa !12
  %76 = load i64, ptr %14, align 8, !tbaa !12
  %77 = shl i64 %75, %76
  %78 = load ptr, ptr %12, align 8, !tbaa !5
  %79 = load i64, ptr %13, align 8, !tbaa !12
  %80 = getelementptr inbounds i8, ptr %78, i64 %79
  %81 = load i8, ptr %80, align 1, !tbaa !11
  %82 = zext i8 %81 to i64
  %83 = or i64 %82, %77
  %84 = trunc i64 %83 to i8
  store i8 %84, ptr %80, align 1, !tbaa !11
  %85 = load i64, ptr %15, align 8, !tbaa !12
  %86 = trunc i64 %85 to i32
  %87 = ashr i32 63, %86
  %88 = xor i32 %87, -1
  %89 = load ptr, ptr %12, align 8, !tbaa !5
  %90 = load i64, ptr %13, align 8, !tbaa !12
  %91 = add i64 %90, 1
  %92 = getelementptr inbounds i8, ptr %89, i64 %91
  %93 = load i8, ptr %92, align 1, !tbaa !11
  %94 = zext i8 %93 to i32
  %95 = and i32 %94, %88
  %96 = trunc i32 %95 to i8
  store i8 %96, ptr %92, align 1, !tbaa !11
  %97 = load i64, ptr %16, align 8, !tbaa !12
  %98 = load i64, ptr %15, align 8, !tbaa !12
  %99 = lshr i64 %97, %98
  %100 = load ptr, ptr %12, align 8, !tbaa !5
  %101 = load i64, ptr %13, align 8, !tbaa !12
  %102 = add i64 %101, 1
  %103 = getelementptr inbounds i8, ptr %100, i64 %102
  %104 = load i8, ptr %103, align 1, !tbaa !11
  %105 = zext i8 %104 to i64
  %106 = or i64 %105, %99
  %107 = trunc i64 %106 to i8
  store i8 %107, ptr %103, align 1, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #6
  br label %108

108:                                              ; preds = %48
  br label %109

109:                                              ; preds = %108
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #6
  br label %110

110:                                              ; preds = %109
  %111 = load i32, ptr %5, align 4, !tbaa !9
  %112 = add i32 %111, 1
  store i32 %112, ptr %5, align 4, !tbaa !9
  br label %37, !llvm.loop !14

113:                                              ; preds = %37
  store i32 0, ptr %5, align 4, !tbaa !9
  br label %114

114:                                              ; preds = %166, %113
  %115 = load i32, ptr %5, align 4, !tbaa !9
  %116 = icmp ult i32 %115, 16384
  br i1 %116, label %117, label %169

117:                                              ; preds = %114
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #6
  br label %118

118:                                              ; preds = %117
  call void @llvm.lifetime.start.p0(i64 8, ptr %18) #6
  %119 = load ptr, ptr %7, align 8, !tbaa !5
  %120 = getelementptr inbounds %struct.hllhdr, ptr %119, i32 0, i32 4
  %121 = getelementptr inbounds [0 x i8], ptr %120, i64 0, i64 0
  store ptr %121, ptr %18, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %19) #6
  %122 = load i32, ptr %5, align 4, !tbaa !9
  %123 = mul i32 %122, 6
  %124 = udiv i32 %123, 8
  %125 = zext i32 %124 to i64
  store i64 %125, ptr %19, align 8, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 8, ptr %20) #6
  %126 = load i32, ptr %5, align 4, !tbaa !9
  %127 = mul i32 %126, 6
  %128 = and i32 %127, 7
  %129 = zext i32 %128 to i64
  store i64 %129, ptr %20, align 8, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 8, ptr %21) #6
  %130 = load i64, ptr %20, align 8, !tbaa !12
  %131 = sub i64 8, %130
  store i64 %131, ptr %21, align 8, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 8, ptr %22) #6
  %132 = load ptr, ptr %18, align 8, !tbaa !5
  %133 = load i64, ptr %19, align 8, !tbaa !12
  %134 = getelementptr inbounds i8, ptr %132, i64 %133
  %135 = load i8, ptr %134, align 1, !tbaa !11
  %136 = zext i8 %135 to i64
  store i64 %136, ptr %22, align 8, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 8, ptr %23) #6
  %137 = load ptr, ptr %18, align 8, !tbaa !5
  %138 = load i64, ptr %19, align 8, !tbaa !12
  %139 = add i64 %138, 1
  %140 = getelementptr inbounds i8, ptr %137, i64 %139
  %141 = load i8, ptr %140, align 1, !tbaa !11
  %142 = zext i8 %141 to i64
  store i64 %142, ptr %23, align 8, !tbaa !12
  %143 = load i64, ptr %22, align 8, !tbaa !12
  %144 = load i64, ptr %20, align 8, !tbaa !12
  %145 = lshr i64 %143, %144
  %146 = load i64, ptr %23, align 8, !tbaa !12
  %147 = load i64, ptr %21, align 8, !tbaa !12
  %148 = shl i64 %146, %147
  %149 = or i64 %145, %148
  %150 = and i64 %149, 63
  %151 = trunc i64 %150 to i32
  store i32 %151, ptr %17, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %23) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %22) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %21) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %20) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %19) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #6
  br label %152

152:                                              ; preds = %118
  br label %153

153:                                              ; preds = %152
  %154 = load i32, ptr %17, align 4, !tbaa !9
  %155 = load i32, ptr %5, align 4, !tbaa !9
  %156 = zext i32 %155 to i64
  %157 = getelementptr inbounds [16384 x i8], ptr %10, i64 0, i64 %156
  %158 = load i8, ptr %157, align 1, !tbaa !11
  %159 = zext i8 %158 to i32
  %160 = icmp ne i32 %154, %159
  br i1 %160, label %161, label %162

161:                                              ; preds = %153
  store i32 -1, ptr %2, align 4, !tbaa !9
  store i32 15, ptr %24, align 4
  br label %163

162:                                              ; preds = %153
  store i32 0, ptr %24, align 4
  br label %163

163:                                              ; preds = %162, %161
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #6
  %164 = load i32, ptr %24, align 4
  switch i32 %164, label %279 [
    i32 0, label %165
    i32 15, label %275
  ]

165:                                              ; preds = %163
  br label %166

166:                                              ; preds = %165
  %167 = load i32, ptr %5, align 4, !tbaa !9
  %168 = add i32 %167, 1
  store i32 %168, ptr %5, align 4, !tbaa !9
  br label %114, !llvm.loop !16

169:                                              ; preds = %114
  br label %170

170:                                              ; preds = %169
  %171 = load i32, ptr %4, align 4, !tbaa !9
  %172 = add i32 %171, 1
  store i32 %172, ptr %4, align 4, !tbaa !9
  br label %33, !llvm.loop !17

173:                                              ; preds = %33
  %174 = load ptr, ptr %7, align 8, !tbaa !5
  %175 = getelementptr inbounds %struct.hllhdr, ptr %174, i32 0, i32 4
  %176 = getelementptr inbounds [0 x i8], ptr %175, i64 0, i64 0
  call void @llvm.memset.p0.i64(ptr align 1 %176, i8 0, i64 12288, i1 false)
  %177 = call i32 @createHLLObject(ptr noundef %9, ptr noundef %3)
  %178 = call double @sqrt(double noundef 1.638400e+04) #6
  %179 = fdiv double 1.040000e+00, %178
  store double %179, ptr %25, align 8, !tbaa !18
  store i64 1, ptr %26, align 8, !tbaa !12
  %180 = call i32 @rand() #6
  %181 = sext i32 %180 to i64
  %182 = call i32 @rand() #6
  %183 = sext i32 %182 to i64
  %184 = shl i64 %183, 32
  %185 = or i64 %181, %184
  store i64 %185, ptr %27, align 8, !tbaa !12
  store i32 1, ptr %4, align 4, !tbaa !9
  br label %186

186:                                              ; preds = %271, %173
  %187 = load i32, ptr %4, align 4, !tbaa !9
  %188 = icmp ule i32 %187, 10000000
  br i1 %188, label %189, label %274

189:                                              ; preds = %186
  %190 = load i32, ptr %4, align 4, !tbaa !9
  %191 = zext i32 %190 to i64
  %192 = load i64, ptr %27, align 8, !tbaa !12
  %193 = xor i64 %191, %192
  store i64 %193, ptr %28, align 8, !tbaa !12
  %194 = load ptr, ptr %7, align 8, !tbaa !5
  %195 = getelementptr inbounds %struct.hllhdr, ptr %194, i32 0, i32 4
  %196 = getelementptr inbounds [0 x i8], ptr %195, i64 0, i64 0
  %197 = call i32 @hllDenseAdd(ptr noundef %196, ptr noundef %28, i64 noundef 8)
  %198 = load ptr, ptr %9, align 8, !tbaa !5
  %199 = load i64, ptr %3, align 8, !tbaa !12
  %200 = call i32 @hllAdd(ptr noundef %198, i64 noundef %199, ptr noundef %28, i64 noundef 8, ptr noundef %9, ptr noundef %3)
  %201 = load i32, ptr %4, align 4, !tbaa !9
  %202 = zext i32 %201 to i64
  %203 = load i64, ptr %26, align 8, !tbaa !12
  %204 = icmp eq i64 %202, %203
  br i1 %204, label %205, label %220

205:                                              ; preds = %189
  %206 = load i32, ptr %4, align 4, !tbaa !9
  %207 = zext i32 %206 to i64
  %208 = load i64, ptr @rl_hll_sparse_max_bytes, align 8, !tbaa !12
  %209 = udiv i64 %208, 2
  %210 = icmp ult i64 %207, %209
  br i1 %210, label %211, label %220

211:                                              ; preds = %205
  %212 = load ptr, ptr %9, align 8, !tbaa !5
  store ptr %212, ptr %8, align 8, !tbaa !5
  %213 = load ptr, ptr %8, align 8, !tbaa !5
  %214 = getelementptr inbounds %struct.hllhdr, ptr %213, i32 0, i32 1
  %215 = load i8, ptr %214, align 1, !tbaa !11
  %216 = zext i8 %215 to i32
  %217 = icmp ne i32 %216, 1
  br i1 %217, label %218, label %219

218:                                              ; preds = %211
  store i32 -2, ptr %2, align 4, !tbaa !9
  br label %275

219:                                              ; preds = %211
  br label %220

220:                                              ; preds = %219, %205, %189
  %221 = load i32, ptr %4, align 4, !tbaa !9
  %222 = zext i32 %221 to i64
  %223 = load i64, ptr %26, align 8, !tbaa !12
  %224 = icmp eq i64 %222, %223
  br i1 %224, label %225, label %233

225:                                              ; preds = %220
  %226 = load ptr, ptr %7, align 8, !tbaa !5
  %227 = call i64 @hllCount(ptr noundef %226, i64 noundef 12304, ptr noundef null)
  %228 = load ptr, ptr %9, align 8, !tbaa !5
  %229 = load i64, ptr %3, align 8, !tbaa !12
  %230 = call i64 @hllCount(ptr noundef %228, i64 noundef %229, ptr noundef null)
  %231 = icmp ne i64 %227, %230
  br i1 %231, label %232, label %233

232:                                              ; preds = %225
  store i32 -3, ptr %2, align 4, !tbaa !9
  br label %275

233:                                              ; preds = %225, %220
  %234 = load i32, ptr %4, align 4, !tbaa !9
  %235 = zext i32 %234 to i64
  %236 = load i64, ptr %26, align 8, !tbaa !12
  %237 = icmp eq i64 %235, %236
  br i1 %237, label %238, label %270

238:                                              ; preds = %233
  call void @llvm.lifetime.start.p0(i64 8, ptr %29) #6
  %239 = load i64, ptr %26, align 8, !tbaa !12
  %240 = load ptr, ptr %7, align 8, !tbaa !5
  %241 = call i64 @hllCount(ptr noundef %240, i64 noundef 12304, ptr noundef null)
  %242 = sub nsw i64 %239, %241
  store i64 %242, ptr %29, align 8, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 8, ptr %30) #6
  %243 = load double, ptr %25, align 8, !tbaa !18
  %244 = fmul double %243, 6.000000e+00
  %245 = load i64, ptr %26, align 8, !tbaa !12
  %246 = sitofp i64 %245 to double
  %247 = fmul double %244, %246
  %248 = call double @llvm.ceil.f64(double %247)
  %249 = fptoui double %248 to i64
  store i64 %249, ptr %30, align 8, !tbaa !12
  %250 = load i32, ptr %4, align 4, !tbaa !9
  %251 = icmp eq i32 %250, 10
  br i1 %251, label %252, label %253

252:                                              ; preds = %238
  store i64 1, ptr %30, align 8, !tbaa !12
  br label %253

253:                                              ; preds = %252, %238
  %254 = load i64, ptr %29, align 8, !tbaa !12
  %255 = icmp slt i64 %254, 0
  br i1 %255, label %256, label %259

256:                                              ; preds = %253
  %257 = load i64, ptr %29, align 8, !tbaa !12
  %258 = sub nsw i64 0, %257
  store i64 %258, ptr %29, align 8, !tbaa !12
  br label %259

259:                                              ; preds = %256, %253
  %260 = load i64, ptr %29, align 8, !tbaa !12
  %261 = load i64, ptr %30, align 8, !tbaa !12
  %262 = icmp sgt i64 %260, %261
  br i1 %262, label %263, label %264

263:                                              ; preds = %259
  store i32 -4, ptr %2, align 4, !tbaa !9
  store i32 15, ptr %24, align 4
  br label %267

264:                                              ; preds = %259
  %265 = load i64, ptr %26, align 8, !tbaa !12
  %266 = mul nsw i64 %265, 10
  store i64 %266, ptr %26, align 8, !tbaa !12
  store i32 0, ptr %24, align 4
  br label %267

267:                                              ; preds = %264, %263
  call void @llvm.lifetime.end.p0(i64 8, ptr %30) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %29) #6
  %268 = load i32, ptr %24, align 4
  switch i32 %268, label %279 [
    i32 0, label %269
    i32 15, label %275
  ]

269:                                              ; preds = %267
  br label %270

270:                                              ; preds = %269, %233
  br label %271

271:                                              ; preds = %270
  %272 = load i32, ptr %4, align 4, !tbaa !9
  %273 = add i32 %272, 1
  store i32 %273, ptr %4, align 4, !tbaa !9
  br label %186, !llvm.loop !20

274:                                              ; preds = %186
  store i32 0, ptr %2, align 4, !tbaa !9
  br label %275

275:                                              ; preds = %274, %267, %232, %218, %163
  %276 = load ptr, ptr %6, align 8, !tbaa !5
  call void @free(ptr noundef %276) #6
  %277 = load ptr, ptr %9, align 8, !tbaa !5
  call void @free(ptr noundef %277) #6
  %278 = load i32, ptr %2, align 4, !tbaa !9
  store i32 %278, ptr %1, align 4
  store i32 1, ptr %24, align 4
  br label %279

279:                                              ; preds = %275, %267, %163
  call void @llvm.lifetime.end.p0(i64 16384, ptr %10) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #6
  %280 = load i32, ptr %1, align 4
  ret i32 %280
}

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

; Function Attrs: nounwind
declare i32 @rand() #4

; Function Attrs: nounwind
declare double @sqrt(double noundef) #4

; Function Attrs: nounwind uwtable
declare hidden i32 @hllDenseAdd(ptr noundef, ptr noundef, i64 noundef) #1

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.ceil.f64(double) #5

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

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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
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 nosync nounwind speculatable willreturn memory(none) }
attributes #6 = { nounwind }
attributes #7 = { 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 = !{!7, !7, i64 0}
!12 = !{!13, !13, i64 0}
!13 = !{!"long", !7, i64 0}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}
!16 = distinct !{!16, !15}
!17 = distinct !{!17, !15}
!18 = !{!19, !19, i64 0}
!19 = !{!"double", !7, i64 0}
!20 = distinct !{!20, !15}


; 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"

@rl_hll_sparse_max_bytes = external dso_local local_unnamed_addr global i64, align 8

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

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

; Function Attrs: nounwind uwtable
declare hidden i32 @hllAdd(ptr noundef, i64 noundef, ptr noundef, i64 noundef, ptr noundef, ptr noundef) local_unnamed_addr #1

; 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 nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #2

; Function Attrs: nounwind uwtable
declare hidden i64 @hllCount(ptr noundef, i64 noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @rl_str_pfselftest() local_unnamed_addr #1 {
  %1 = alloca i64, align 8
  %2 = alloca ptr, align 8
  %3 = alloca [16384 x i8], align 16
  %4 = alloca i64, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %1) #8
  %5 = tail call noalias dereferenceable_or_null(12305) ptr @calloc(i64 noundef 1, i64 noundef 12305) #9
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #8
  store ptr null, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 16384, ptr nonnull %3) #8
  %6 = getelementptr inbounds i8, ptr %5, i64 16
  br label %.preheader89

.preheader89:                                     ; preds = %0, %58
  %.07892 = phi i32 [ 0, %0 ], [ %59, %58 ]
  br label %7

7:                                                ; preds = %.preheader89, %7
  %indvars.iv = phi i64 [ 0, %.preheader89 ], [ %indvars.iv.next, %7 ]
  %8 = tail call i32 @rand() #8
  %9 = and i32 %8, 63
  %10 = trunc nuw nsw i32 %9 to i8
  %11 = getelementptr inbounds [16384 x i8], ptr %3, i64 0, i64 %indvars.iv
  store i8 %10, ptr %11, align 1, !tbaa !9
  %12 = trunc i64 %indvars.iv to i32
  %13 = mul i32 %12, 6
  %14 = lshr i32 %13, 3
  %15 = zext nneg i32 %14 to i64
  %16 = and i32 %13, 6
  %17 = zext nneg i32 %16 to i64
  %18 = sub nuw nsw i64 8, %17
  %19 = zext nneg i32 %9 to i64
  %20 = shl nuw nsw i32 63, %16
  %21 = getelementptr inbounds i8, ptr %6, i64 %15
  %22 = load i8, ptr %21, align 1, !tbaa !9
  %23 = trunc i32 %20 to i8
  %24 = xor i8 %23, -1
  %25 = and i8 %22, %24
  %26 = shl nuw nsw i64 %19, %17
  %27 = trunc i64 %26 to i8
  %28 = or i8 %25, %27
  store i8 %28, ptr %21, align 1, !tbaa !9
  %29 = trunc nuw nsw i64 %18 to i16
  %30 = ashr i16 -64, %29
  %31 = getelementptr inbounds i8, ptr %21, i64 1
  %32 = load i8, ptr %31, align 1, !tbaa !9
  %33 = trunc nsw i16 %30 to i8
  %34 = and i8 %32, %33
  %35 = lshr i64 %19, %18
  %36 = trunc nuw nsw i64 %35 to i8
  %37 = or i8 %34, %36
  store i8 %37, ptr %31, align 1, !tbaa !9
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, 16384
  br i1 %exitcond.not, label %.preheader, label %7, !llvm.loop !10

38:                                               ; preds = %.preheader
  %indvars.iv.next98 = add nuw nsw i64 %indvars.iv97, 1
  %exitcond100.not = icmp eq i64 %indvars.iv.next98, 16384
  br i1 %exitcond100.not, label %58, label %.preheader, !llvm.loop !12

.preheader:                                       ; preds = %7, %38
  %indvars.iv97 = phi i64 [ %indvars.iv.next98, %38 ], [ 0, %7 ]
  %39 = trunc i64 %indvars.iv97 to i32
  %40 = mul i32 %39, 6
  %41 = lshr i32 %40, 3
  %42 = zext nneg i32 %41 to i64
  %43 = and i32 %40, 6
  %44 = sub nuw nsw i32 8, %43
  %45 = getelementptr inbounds i8, ptr %6, i64 %42
  %46 = load i8, ptr %45, align 1, !tbaa !9
  %47 = zext i8 %46 to i32
  %48 = getelementptr inbounds i8, ptr %45, i64 1
  %49 = load i8, ptr %48, align 1, !tbaa !9
  %50 = zext i8 %49 to i32
  %51 = lshr i32 %47, %43
  %52 = shl nuw nsw i32 %50, %44
  %53 = or i32 %52, %51
  %54 = and i32 %53, 63
  %55 = getelementptr inbounds [16384 x i8], ptr %3, i64 0, i64 %indvars.iv97
  %56 = load i8, ptr %55, align 1, !tbaa !9
  %57 = zext i8 %56 to i32
  %.not86 = icmp eq i32 %54, %57
  br i1 %.not86, label %38, label %.loopexit

58:                                               ; preds = %38
  %59 = add nuw nsw i32 %.07892, 1
  %exitcond101.not = icmp eq i32 %59, 1000
  br i1 %exitcond101.not, label %60, label %.preheader89, !llvm.loop !13

60:                                               ; preds = %58
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 1 dereferenceable(12288) %6, i8 0, i64 12288, i1 false)
  %61 = call i32 @createHLLObject(ptr noundef nonnull %2, ptr noundef nonnull %1)
  %62 = call i32 @rand() #8
  %63 = sext i32 %62 to i64
  %64 = call i32 @rand() #8
  %65 = sext i32 %64 to i64
  %66 = shl nsw i64 %65, 32
  %67 = or i64 %66, %63
  br label %68

68:                                               ; preds = %60, %.critedge87
  %indvars.iv102 = phi i64 [ 1, %60 ], [ %indvars.iv.next103, %.critedge87 ]
  %.07294 = phi i64 [ 1, %60 ], [ %.2, %.critedge87 ]
  %69 = xor i64 %67, %indvars.iv102
  store i64 %69, ptr %4, align 8, !tbaa !14
  %70 = call i32 @hllDenseAdd(ptr noundef nonnull %6, ptr noundef nonnull %4, i64 noundef 8)
  %71 = load ptr, ptr %2, align 8, !tbaa !5
  %72 = load i64, ptr %1, align 8, !tbaa !14
  %73 = call i32 @hllAdd(ptr noundef %71, i64 noundef %72, ptr noundef nonnull %4, i64 noundef 8, ptr noundef nonnull %2, ptr noundef nonnull %1)
  %74 = icmp eq i64 %.07294, %indvars.iv102
  br i1 %74, label %75, label %.critedge87

75:                                               ; preds = %68
  %76 = load i64, ptr @rl_hll_sparse_max_bytes, align 8, !tbaa !14
  %77 = lshr i64 %76, 1
  %78 = icmp ugt i64 %77, %indvars.iv102
  br i1 %78, label %79, label %83

79:                                               ; preds = %75
  %80 = load ptr, ptr %2, align 8, !tbaa !5
  %81 = getelementptr inbounds i8, ptr %80, i64 4
  %82 = load i8, ptr %81, align 1, !tbaa !9
  %.not = icmp eq i8 %82, 1
  br i1 %.not, label %83, label %.loopexit.loopexit

83:                                               ; preds = %75, %79
  %84 = call i64 @hllCount(ptr noundef %5, i64 noundef 12304, ptr noundef null)
  %85 = load ptr, ptr %2, align 8, !tbaa !5
  %86 = load i64, ptr %1, align 8, !tbaa !14
  %87 = call i64 @hllCount(ptr noundef %85, i64 noundef %86, ptr noundef null)
  %.not85 = icmp eq i64 %84, %87
  br i1 %.not85, label %.critedge, label %.loopexit.loopexit

.critedge:                                        ; preds = %83
  %88 = call i64 @hllCount(ptr noundef %5, i64 noundef 12304, ptr noundef null)
  %89 = sub nsw i64 %indvars.iv102, %88
  %90 = uitofp nneg i64 %indvars.iv102 to double
  %91 = fmul double %90, 4.875000e-02
  %92 = call double @llvm.ceil.f64(double %91)
  %93 = fptoui double %92 to i64
  %94 = icmp eq i64 %indvars.iv102, 10
  %spec.store.select = select i1 %94, i64 1, i64 %93
  %spec.select = call i64 @llvm.abs.i64(i64 %89, i1 true)
  %95 = icmp sgt i64 %spec.select, %spec.store.select
  %96 = mul nuw nsw i64 %indvars.iv102, 10
  br i1 %95, label %.loopexit.loopexit, label %.critedge87

.critedge87:                                      ; preds = %.critedge, %68
  %.2 = phi i64 [ %96, %.critedge ], [ %.07294, %68 ]
  %indvars.iv.next103 = add nuw nsw i64 %indvars.iv102, 1
  %exitcond105.not = icmp eq i64 %indvars.iv.next103, 10000001
  br i1 %exitcond105.not, label %.loopexit.loopexit, label %68, !llvm.loop !16

.loopexit.loopexit:                               ; preds = %79, %83, %.critedge87, %.critedge
  %.6.ph = phi i32 [ -4, %.critedge ], [ -2, %79 ], [ -3, %83 ], [ 0, %.critedge87 ]
  %.pre = load ptr, ptr %2, align 8, !tbaa !5
  br label %.loopexit

.loopexit:                                        ; preds = %.preheader, %.loopexit.loopexit
  %97 = phi ptr [ %.pre, %.loopexit.loopexit ], [ null, %.preheader ]
  %.6 = phi i32 [ %.6.ph, %.loopexit.loopexit ], [ -1, %.preheader ]
  call void @free(ptr noundef %5) #8
  call void @free(ptr noundef %97) #8
  call void @llvm.lifetime.end.p0(i64 16384, ptr nonnull %3) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %1) #8
  ret i32 %.6
}

; 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: nounwind
declare i32 @rand() local_unnamed_addr #4

; Function Attrs: nounwind uwtable
declare hidden i32 @hllDenseAdd(ptr noundef, ptr noundef, i64 noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.ceil.f64(double) #5

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

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i64 @llvm.abs.i64(i64, i1 immarg) #7

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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
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 = { 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 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #6 = { 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 #7 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #8 = { nounwind }
attributes #9 = { 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 = !{!7, !7, i64 0}
!10 = distinct !{!10, !11}
!11 = !{!"llvm.loop.mustprogress"}
!12 = distinct !{!12, !11}
!13 = distinct !{!13, !11}
!14 = !{!15, !15, i64 0}
!15 = !{!"long", !7, i64 0}
!16 = distinct !{!16, !11}


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